Claude Desktop uses MCP servers to interact with your filesystem, databases, APIs, and other tools. Every tool call from Claude flows through these servers — and without protection, a prompt injection attack can turn any of them into an attack vector.
Rampart sits between Claude Desktop and your MCP servers, evaluating every tool call against your security policy before it executes.
AI assistants process content from many sources: emails, documents, calendar invites, web pages, shared files. Any of these can contain hidden instructions that hijack the assistant’s behavior (prompt injection).
Example attack chain:
With Rampart:
go install github.com/peg/rampart/cmd/rampart@latest)Claude Desktop stores MCP server configuration at:
~/Library/Application Support/Claude/claude_desktop_config.json~/.config/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.jsonA typical config looks like:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/you/Documents"]
},
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "ghp_..."
}
}
}
}
# Create a policy file (start with standard profile)
rampart init --profile standard
# Start the policy server
rampart serve --background
# `rampart serve stop` stops it.
Replace each MCP server command with rampart mcp --:
{
"mcpServers": {
"filesystem": {
"command": "rampart",
"args": ["mcp", "--", "npx", "-y", "@modelcontextprotocol/server-filesystem", "/Users/you/Documents"],
"env": {
"RAMPART_TOKEN": "your-token-here"
}
},
"github": {
"command": "rampart",
"args": ["mcp", "--", "npx", "-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "ghp_...",
"RAMPART_TOKEN": "your-token-here"
}
}
}
}
Quit and reopen Claude Desktop. Your MCP servers now route through Rampart.
# Watch tool calls in real time
rampart watch
# View audit log
rampart audit tail --follow
With the standard policy profile, Rampart blocks:
| Attack | Tool Call | Result |
|---|---|---|
| Credential theft | read_file("~/.ssh/id_rsa") |
Denied |
| Credential theft | read_file("~/.aws/credentials") |
Denied |
| Env file access | read_file(".env") |
Denied |
| Destructive command | execute("rm -rf /") |
Denied |
| Data exfiltration | execute("curl webhook.site") |
Denied |
| Shell history | read_file("~/.bash_history") |
Denied |
| Normal file read | read_file("report.pdf") |
Allowed |
| Normal command | execute("git status") |
Allowed |
| Normal search | search_files("TODO") |
Allowed |
The standard profile covers common attacks. For tighter control, customize your policy:
version: "1"
default_action: allow
policies:
- name: block-sensitive-reads
match:
tool: ["read"]
rules:
- action: deny
when:
path_matches:
- "**/.ssh/*"
- "**/.aws/*"
- "**/.env"
- "**/.gnupg/*"
- "**/keychain*"
message: "Blocked: sensitive file access"
- name: block-exfil
match:
tool: ["exec", "fetch"]
rules:
- action: deny
when:
command_matches:
- "*curl*webhook.site*"
- "*curl*ngrok.io*"
- "*curl*requestbin*"
message: "Blocked: potential data exfiltration"
- name: require-approval-for-writes
match:
tool: ["write"]
rules:
- action: ask
when:
path_matches: ["**/.*"] # Hidden files
message: "Writing to hidden file — approve?"
Not sure what to block? Start in monitor mode — everything gets logged, nothing gets blocked:
{
"mcpServers": {
"filesystem": {
"command": "rampart",
"args": ["mcp", "--mode", "monitor", "--", "npx", "-y", "@modelcontextprotocol/server-filesystem", "."]
}
}
}
Run for a few days, review the audit log, then write policies based on actual usage patterns:
# See what tools are being called
rampart audit stats
# Generate a report
rampart report
Claude Desktop
└─ MCP tool call (JSON-RPC)
└─ rampart mcp (proxy)
├─ Policy engine evaluates the call
├─ Audit log records it (hash-chained)
├─ Allowed → forwards to MCP server
└─ Denied → returns JSON-RPC error to Claude
(MCP server never sees it)
Rampart speaks the MCP protocol natively. It’s invisible to both Claude Desktop and the MCP server — they don’t know it’s there. Denied tool calls return a standard JSON-RPC error, so Claude handles them gracefully (typically saying “I wasn’t able to access that file”).
MCP servers can run locally on your machine or remotely in the cloud. Rampart’s protection works differently depending on where the server lives:
Most MCP servers today run locally — Claude Desktop launches them as child processes on your machine.
┌──────────────────────────────────────────────────────────┐
│ YOUR MACHINE │
│ │
│ Claude Desktop │
│ └─ MCP tool call ──► Rampart ──► MCP Server (local) │
│ │ │ │ │
│ DENY? LOG executes │
│ │ │ │
│ never reaches touches YOUR │
│ the server filesystem, │
│ YOUR network, │
│ YOUR credentials │
└──────────────────────────────────────────────────────────┘
Rampart blocks the request before it reaches the server. The MCP server never sees denied tool calls. Since the server runs on your machine, a blocked call means the action never happens — your files stay untouched, no network requests fire, no commands execute.
This is full protection. You control both the policy layer and the execution environment.
Some MCP servers run remotely — on Cloudflare, AWS, a company API, etc. Claude Desktop connects to them over the network (typically via SSE or WebSocket transport).
┌────────────────────────────────┐ ┌─────────────────────┐
│ YOUR MACHINE │ │ CLOUD SERVER │
│ │ │ │
│ Claude Desktop │ │ MCP Server │
│ └─ MCP tool call ──► Rampart ─ ✕ ─►│ (executes on │
│ │ │ │ remote infra) │
│ DENY? │ │ │
│ │ │ │ You don't control │
│ request │ │ this environment │
│ never │ │ │
│ leaves │ └─────────────────────┘
│ your │
│ machine │
└────────────────────────────────┘
Rampart blocks the request before it leaves your machine. The cloud server never receives the denied tool call. This is important:
delete_database, terminate_instance, etc. get blocked before the request reaches the cloud.What Rampart can’t do for cloud servers:
| Scenario | What Rampart blocks | Where |
|---|---|---|
| Local MCP server | Request + execution | Everything happens on your machine — full protection |
| Cloud MCP server | Request only | Blocked calls never leave your machine. Allowed calls execute remotely. |
| Direct cloud connection | Nothing (without proxy) | If Claude connects to a remote URL directly, Rampart isn’t in the path |
For maximum protection with cloud MCP servers, the policy should be more restrictive — deny by default, explicitly allow only the tool calls you expect.
This same approach works with any MCP-compatible app:
Note: This technique only protects MCP server tools. Editors like Cursor and Windsurf have built-in native tools (file read/write, terminal) that don’t go through MCP and cannot be intercepted by Rampart. For full protection, use Claude Code with native hooks (
rampart setup claude-code).
RAMPART_TOKEN is stored in the config file. Protect that file’s permissions.rampart watch for real-time monitoring