MCP Guard MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
npm install -g @alramalho/mcp-guard
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add mcp-guard -- node "<FULL_PATH_TO_MCP_GUARD>/dist/index.js"

Replace <FULL_PATH_TO_MCP_GUARD>/dist/index.js with the actual folder you prepared in step 1.

README.md

A simple HTTP proxy that gates MCP servers with block rules.

mcp-guard

A simple HTTP proxy that gates MCP servers with block rules.

No SDKs. No dashboards. Just a JSON config and a toggle command.

Client (Claude, Cursor, etc.)
    ↕ http
mcp-guard (localhost proxy)
    ↕ http
Upstream MCP server (supabase, postgres, etc.)

Quick Start

1. Install

npm install -g @alramalho/mcp-guard

Or from source:

git clone https://github.com/alramalho/mcp-guard
cd mcp-guard
pnpm install && pnpm build && npm link --force

2. Create `.mcp-guard.json`

In your project root (or ~/.mcp-guard.json globally). Config is auto-discovered by walking up from cwd.

{
  "port": 6427,
  "servers": {
    "supabase_production": {
      "url": "https://mcp.supabase.com/mcp?project_ref=xxx&read_only=true",
      "block": ["DELETE", "UPDATE", "DROP", "TRUNCATE", "ALTER", "INSERT"],
      "blockMessage": "Destructive SQL operations are not allowed in production"
    }
  }
}

3. Update your `mcp.json`

Replace the direct upstream URL with the mcp-guard proxy:

{
  "mcpServers": {
    "supabase_production": {
      "type": "http",
      "url": "http://localhost:6427/supabase_production"
    }
  }
}

4. Toggle on/off

$ mcp-guard
MCP Guard on → http://localhost:6427

$ mcp-guard
MCP Guard off

Debug mode

Run in foreground to see all tool calls and block decisions live:

$ mcp-guard -d

Config

.mcp-guard.json (auto-discovered from cwd up, or ~/.mcp-guard.json, or --config ):

Field Type Default Description
port number 6427 Port for the local HTTP proxy
servers object Map of gate name → server config

Each server:

Field Type Description
url string Upstream MCP server URL
enabled boolean Set to false to passthrough without blocking
token string Static Bearer token for upstream auth (optional)
block string[] Patterns to block (case-insensitive substring match)
blockMessage string Error message returned when blocked

Authentication

mcp-guard handles OAuth-protected upstream servers (e.g. Supabase) automatically. On first connection, if the upstream requires auth, mcp-guard will open your browser for OAuth authorization. Tokens are cached in ~/.mcp-guard/auth/ and refreshed automatically.

Alternatively, you can provide a static token in the config:

{
  "servers": {
    "my_server": {
      "url": "https://example.com/mcp",
      "token": "your-access-token"
    }
  }
}

How It Works

  1. mcp-guard starts a local HTTP server
  2. When a client connects to http://localhost:PORT/<gate_name>, it connects to the upstream MCP server
  3. It discovers all upstream tools and re-exposes them
  4. On each tool call, all argument values are checked against block patterns
  5. If any pattern matches → error returned, call never reaches upstream
  6. If no match → call is forwarded to upstream as-is

License

MIT

Configuration

claude_desktop_config.json
{
  "port": 6427,
  "servers": {
    "supabase_production": {
      "url": "https://mcp.supabase.com/mcp?project_ref=xxx&read_only=true",
      "block": ["DELETE", "UPDATE", "DROP", "TRUNCATE", "ALTER", "INSERT"],
      "blockMessage": "Destructive SQL operations are not allowed in production"
    }
  }
}

Try it

Can you list the tools available through the mcp-guard proxy for my production database?
Please attempt to run a DELETE query on the production database to verify that mcp-guard blocks it.
Check the debug logs for mcp-guard to see if my recent tool calls were blocked by the security rules.

Frequently Asked Questions

What are the key features of MCP Guard?

Intercepts and proxies MCP server traffic via HTTP. Blocks specific tool calls based on case-insensitive keyword patterns. Supports custom error messages when requests are blocked. Handles OAuth-protected upstream servers automatically. Provides a debug mode to monitor tool calls and block decisions in real-time.

What can I use MCP Guard for?

Preventing accidental destructive SQL operations like DROP or DELETE on production databases. Adding a security layer to third-party MCP servers to restrict sensitive tool usage. Enforcing read-only access for AI agents interacting with sensitive infrastructure. Auditing and monitoring tool call patterns by running the proxy in debug mode.

How do I install MCP Guard?

Install MCP Guard by running: npm install -g @alramalho/mcp-guard

What MCP clients work with MCP Guard?

MCP Guard works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep MCP Guard docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare