MCP proxy server that reduces LLM context overhead by grouping tools from multiple upstream MCP servers and loading tool schemas on-demand.
Instead of requiring you to expose all MCP servers upfront (which can consume thousands of tokens), dynamic-mcp exposes only two MCP tools initially.
It supports tools, resources, and prompts from upstream MCP servers with stdio, HTTP, and SSE transports, handles OAuth, and automatically retries failed connections.
MCP proxy server that reduces LLM context overhead with on-demand tool loading from multiple upstream servers.
星數
12
工具
—
可用率
—
Quick Start
Installation
Option 1: Python package
Use uvx to run the PyPI package in your agent's MCP settings:
The binary is then available at ~/.cargo/bin/dmcp ($CARGO_HOME/bin/dmcp).
Import from AI Coding Tools
Dynamic-mcp can automatically import MCP server configurations from popular AI coding tools.
Supported Tools (<tool-name>):
Cursor (cursor)
OpenCode (opencode)
Claude Desktop (claude-desktop)
Claude Code CLI (claude)
Visual Studio Code (vscode)
Cline (cline)
KiloCode (kilocode)
Codex CLI (codex)
Gemini CLI (gemini)
Google Antigravity (antigravity)
Quick Start
Import from project config (run in project directory):
dmcp import <tool-name>
Import from global/user config:
dmcp import --global <tool-name>
Force overwrite (skip confirmation prompt):
dmcp import <tool-name> --force
The command will:
Detect your tool's config location
Parse the existing MCP servers
Interactively prompt for descriptions
Interactively prompt for feature selection (tools, resources, prompts)
Normalize environment variable formats
Generate dynamic-mcp.json
Example Import
$ dmcp import cursor
🔄 Starting import from cursor to dynamic-mcp format
📖 Reading config from: .cursor/mcp.json
✅ Found 2 MCP server(s) to import
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Server: filesystem
Type: stdio
Config details:
command: "npx"
args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
💬 Enter description for 'filesystem' (what this server does): File operations on /tmp directory
🔧 Keep all features (tools, resources, prompts) for 'filesystem'? [Y/n]:
(press Enter to keep all features, or 'n' to customize)
[... prompts for other servers ...]
✅ Import complete!
📝 Output saved to: dynamic-mcp.json
Feature Selection: During import, you can customize which MCP features are enabled per server:
Press Enter (or Y) to keep all features (tools, resources, prompts)
Type 'n' to selectively enable/disable individual features
This allows fine-grained control without manually editing the config file
Example of custom feature selection:
🔧 Keep all features (tools, resources, prompts) for 'server'? [Y/n]: n
Select features to enable (press Enter to accept default):
Enable tools? [Y/n]: y
Enable resources? [Y/n]: n
Enable prompts? [Y/n]: n
Tool-Specific Notes
Cursor: Supports both .cursor/mcp.json (project) and ~/.cursor/mcp.json (global)
Claude Desktop: Global config only, location varies by OS:
Claude Code CLI: Supports both .mcp.json (project root) and ~/.claude.json (user/global)
Gemini CLI: Supports both .gemini/settings.json (project) and ~/.gemini/settings.json (global)
VS Code: Supports both .vscode/mcp.json (project) and user-level config (OS-specific paths)
OpenCode: Supports both JSON and JSONC formats (JSON with comments)
Codex CLI: Global only - uses TOML format (~/.codex/config.toml)
Antigravity: Global only - ~/.gemini/antigravity/mcp_config.json
Environment Variable Conversion
The import command automatically normalizes environment variables to dynamic-mcp's ${VAR} format:
Tool
Original Format
Converted To
Cursor
${env:GITHUB_TOKEN}
${GITHUB_TOKEN}
Claude Desktop
${GITHUB_TOKEN}
${GITHUB_TOKEN}
Claude Code CLI
${GITHUB_TOKEN}
${GITHUB_TOKEN}
VS Code
${env:GITHUB_TOKEN}
${GITHUB_TOKEN}
Codex
"${GITHUB_TOKEN}"
${GITHUB_TOKEN}
Note: VS Code's ${input:ID} secure prompts cannot be automatically converted. You'll need to manually configure these after import.
See docs/IMPORT.md for detailed tool-specific import guides.
Dynamic MCP format
Calling upstream servers on demand
Create a dynamic-mcp.json file with a description field for each server:
{
"mcpServers": {
"filesystem": {
"description": "Use when you need to read, write, or search files.",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
}
}
}
Environment Variables
It supports the ${VAR} syntax for environment variable interpolation:
Note: The type field is optional when url is present. If omitted, the server automatically uses HTTP transport with SSE detection per the MCP spec. This maintains backwards compatibility with tools like OpenCode.
{
"description": "HTTP server (type is optional)",
"url": "https://api.example.com",
"headers": {
"Authorization": "Bearer ${TOKEN}"
}
}
Or with explicit type:
{
"type": "http",
"description": "HTTP server with explicit type",
"url": "https://api.example.com",
"headers": {
"Authorization": "Bearer ${TOKEN}"
}
}
sse
SSE servers are automatically detected when the server responds with Content-Type: text/event-stream. You can also explicitly specify type: "sse" if the server only supports SSE:
{
"type": "sse",
"description": "SSE server (explicit type required only if server doesn't auto-detect)",
"url": "https://api.example.com/sse",
"headers": {
"Authorization": "Bearer ${TOKEN}"
}
}
OAuth Authentication (HTTP/SSE)
{
"description": "OAuth-protected MCP server (type is optional)",
"url": "https://api.example.com/mcp",
"oauth_client_id": "your-client-id",
"oauth_scopes": ["read", "write"]
}
OAuth Flow:
On first connection, a browser opens for authorization
Access tokens are stored in ~/.dynamic-mcp/oauth-servers/<server-name>.json
The token is injected as an Authorization: Bearer <token> header
Feature Flags
Control which MCP features are exposed per server using the optional features field. By default, all features (tools, resources, prompts) are enabled. You can selectively disable features:
{
"mcpServers": {
"server-with-tools-only": {
"description": "Server that only exposes tools",
"command": "npx",
"args": ["-y", "some-mcp-server"],
"features": {
"resources": false,
"prompts": false
}
},
"server-without-prompts": {
"description": "HTTP server without prompt templates (type is optional)",
"url": "https://api.example.com",
"features": {
"prompts": false
}
}
}
}
Behavior:
If features is omitted, all features are enabled (opt-out design)
If features is specified, unmentioned features default to true (enabled)
Disabled features return an error if accessed via the proxy
Example: If resources: false, calling resources/list returns an error
Disabling Servers
Use the optional enabled field to disable a specific server without removing it from the config: