Skip to content

igrigorik/MCProxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCP Proxy

Rust-based MCP (Model-Context-Protocol) proxy that aggregates tools from multiple upstream servers and exposes them through a single streamable HTTP interface.

  • Tool aggregation: Connects to multiple upstream MCP servers (via stdio or http) and exposes an aggregated list of all their tools.
  • Dynamic tool updates: Listens for toolListChanged notifications from upstream servers and dynamically updates its aggregated tool list.
  • Tool search: When a large number of tools are available, proxy can automatically limit initial list and provide search functionality to search/update exposed tools on demand.
  • Middleware system: Flexible middleware system for intercepting and modifying requests/responses:
    • ClientMiddleware: Operates on individual server calls (logging, tool filtering, payload inspection for security, etc)
    • ProxyMiddleware: Operates on aggregated tool/prompt/resources from servers (description enrichment, tool search, etc)

Built-in middleware (see docs/MIDDLEWARE.md):

  • Logging: Logs all operations with timing information per server
  • Tool filtering: Filters tools based on configurable regex patterns (allow/disallow)
  • Tool security: Inspects tool call inputs and blocks calls that match security rules
  • Tool enrichment: Augments tool/prompt/resource descriptions (demo)
  • Tool search: Provides intelligent tool management with selective exposure and search functionality (see docs/SEARCH.md).
    • Disclaimer: cursor does not currently support dynamic tool refresh (1, 2), you have to manually toggle the tool.

Usage

  1. Build the project:

    cargo build --release
  2. Create a configuration file (e.g., mcp_servers.json) as described above.

  3. Run the proxy:

    ./target/release/mcproxy mcp_servers.json

    The proxy will start, connect to the configured servers, and listen for MCP messages on its stdio.

Configuration

The proxy is configured using a JSON file passed as a command-line argument. The file should contain the mcpServers key (MCP configuration you use for VSCode/Cursor/Claude/etc), plus httpServer key to configure the MCP proxy:

{
  "mcpServers": {
    "stdio-mcp-service": {
      "type": "stdio",
      "command": "node",
      "args": ["script.js"],
      "env": {
        "ENV_FOO_VAR": "BAR"
      }
    },
    "http-mcp-github": {
      "url": "https://api.githubcopilot.com/mcp/",
      "authorizationToken": "Bearer GitHUB_PAT_TOKEN"
    }
  },
  "httpServer": {
    "host": "127.0.0.1",
    "port": 8081,
    "corsEnabled": true,
    "corsOrigins": [
      "*"
    ]
  }
}

In example above, we are aggregating tools from a local (stdio) MCP server and remote (HTTP) MCP server and exposing it on http://127.0.0.1:8081/mcp endpoint. To access these tools, we can configure the MCP client with:

{
  "mcpServers": {
    "tool-proxy": {
      "type": "http",
      "url": "http://127.0.0.1:8081/mcp"
    }
  }
}

See example-config.json for a complete example with custom middleware and search configuration.

License

This project is licensed under the MIT License - see LICENSE.md.

About

MCP proxy: tool aggregation, search, filtering, security

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages