<!-- https://avertgate.com/docs/mcp-proxy · Integration -->

# MCP proxy

The MCP proxy sits between the agent client and the real MCP server. The client connects to AvertGate; AvertGate inspects every `tools/call` and forwards it upstream.

## Single upstream

<!-- terminal -->
```
UPSTREAM_COMMAND="npx" \
UPSTREAM_ARGS="-y @modelcontextprotocol/server-filesystem /data" \
npx @avertgate/cli start
```

## Multiple upstreams

`UPSTREAM_SERVERS` accepts a JSON array, a standard `mcpServers` dictionary, or a path to a JSON file:

<!-- .env -->
```
UPSTREAM_SERVERS='{
  "filesystem": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/data"] },
  "github":     { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-github"] }
}'
```

If tool names collide, the second is namespaced as `server__tool` and referred to by that name in the policy.

## Client configuration

In your MCP client define AvertGate as the command instead of the real server:

<!-- mcp.json -->
```json
{
  "mcpServers": {
    "governed": {
      "command": "npx",
      "args": ["@avertgate/cli", "start"],
      "env": { "UPSTREAM_COMMAND": "npx", "UPSTREAM_ARGS": "-y @modelcontextprotocol/server-filesystem /data" }
    }
  }
}
```

## What is inspected?

- `tools/call`: the full request/response loop.
- `resources`: the policy's `resources` rules (`uri_pattern`).
