mcpblox
一个可编程的MCP代理,可以使用任何现有的MCP服务器和自然语言 转换提示,并生成一个新的MCP服务器,其工具由该提示重塑。
- 重命名 工具, 重新格式化 输出, 更改架构
- 隐藏 你不需要的工具
- 编排 将多种上游工具整合到新的 合成工具
- 链 通过Unix管道将实例转换为多级转换管道
所有这些都不需要修改原始服务器。
安装
# Run directly with npx
npx mcpblox --upstream "your-mcp-server" --prompt "your transform"
# Or install globally
npm install -g mcpblox快速开始
# 1. Proxy an MCP server unchanged (transparent pass-through)
mcpblox --upstream "npx @modelcontextprotocol/server-filesystem /tmp" --api-key $ANTHROPIC_API_KEY
# 2. Preview what transforms the LLM would apply (no server started)
mcpblox \
--upstream "npx @modelcontextprotocol/server-filesystem /tmp" \
--prompt "Rename read_file to cat and hide write_file" \
--api-key $ANTHROPIC_API_KEY \
--dry-run
# 3. Run with transforms applied
mcpblox \
--upstream "npx @modelcontextprotocol/server-filesystem /tmp" \
--prompt "Rename read_file to cat and hide write_file" \
--api-key $ANTHROPIC_API_KEY
# 4. Point any MCP host at http://localhost:8000/mcp
curl http://localhost:8000/health
# 5. Chain transforms via Unix pipes
mcpblox --upstream "npx @modelcontextprotocol/server-filesystem /tmp" --prompt "Hide write_file" \
| mcpblox --prompt "Rename read_file to cat" \
| mcpblox --prompt "Format outputs as markdown"运作原理
┌──────────┐ ┌──────────────────────────────────────────┐ ┌───────────┐
│ │ │ mcpblox │ │ │
│ MCP │◄────►│ ┌────────┐ ┌───────────┐ ┌─────────┐ │◄────►│ Upstream │
│ Host │ HTTP │ │Exposed │ │ Transform │ │Upstream │ │stdio/│ MCP │
│ │ │ │Server │──│ Engine │──│Client │ │ HTTP │ Server │
└──────────┘ │ └────────┘ └─────┬─────┘ └─────────┘ │ └───────────┘
│ │ │
│ ┌─────▼─────┐ │
│ │ LLM │ │
│ │ (startup │ │
│ │ codegen) │ │
│ └───────────┘ │
└──────────────────────────────────────────┘在启动时,mcpblox:
- 连接到上游MCP服务器并发现其工具
- 将转换提示+工具定义发送到LLM
- LLM产生 改造计划 (哪些工具可以修改、隐藏、传递或组合成新的
synthetic工具) - 对于每个修改过的工具,LLM都会生成JavaScript转换函数
- 生成的代码在沙盒中运行
vm上下文(无文件系统/网络访问) - 结果被缓存——后续具有相同提示的启动程序将完全跳过LLM
在运行时,工具调用流经转换管道:输入参数被转换,上游工具被调用,输出在返回主机之前被转换。直通工具直接代理,没有开销。
CLI参考
mcpblox [options]
Upstream (required unless stdin is a pipe):
--upstream Upstream MCP server as stdio command
e.g., "npx @modelcontextprotocol/server-filesystem /tmp"
--upstream-url Upstream MCP server as HTTP/SSE URL
--upstream-token Bearer token for HTTP upstream (env: MCP_UPSTREAM_TOKEN)
Transform:
--prompt Transform prompt (inline)
--prompt-file
Transform prompt from file
LLM:
--provider LLM provider: anthropic | openai (default: anthropic)
--model LLM model ID (default: claude-sonnet-4-20250514 / gpt-4o)
--api-key LLM API key (env: ANTHROPIC_API_KEY | OPENAI_API_KEY)
Server:
--port HTTP server port (default: 8000, or 0 for OS-assigned when piped)
Cache:
--cache-dir
Cache directory (default: .mcpblox-cache)
--no-cache Disable caching, regenerate on every startup
Other:
--dry-run Show the transform plan as JSON without starting the server
--verbose Verbose logging (generated code, cache keys, tool call details)没有 --prompt,mcpblox作为透明代理运行——所有工具都会原封不动地通过。
例子
重命名和重构工具:
mcpblox \
--upstream "npx @mcp/server-github" \
--prompt "Rename search_repositories to find_repos. For list_issues, add a max_results parameter (default 10) that truncates the output."格式化输出:
mcpblox \
--upstream "uvx mcp-server-yfinance" \
--prompt "Format all numeric values in tool outputs with thousand separators and 2 decimal places. Prefix currency values with $."隐藏不需要的工具:
mcpblox \
--upstream "npx @modelcontextprotocol/server-filesystem /tmp" \
--prompt "Hide write_file, create_directory, and move_file. Only expose read-only tools."合成工具(将上游工具组合成新工具):
mcpblox \
--upstream "uvx yfinance-mcp" \
--prompt-file period-returns.txt \
--port 18500提示创建了一个 get_period_returns 调用工具 yfinance_get_price_history 四次(1个月、3个月、6个月和12个月),解析结果,并返回给定股票代码的计算回报——所有这些都是在一次工具调用中编排的。
连接到HTTP/SSE上游而不是stdio:
# Proxy an already-running MCP server over HTTP
mcpblox --upstream-url http://localhost:3000/mcp --api-key $ANTHROPIC_API_KEY
# With bearer token authentication
mcpblox --upstream-url http://localhost:3000/mcp \
--upstream-token $MCP_TOKEN \
--prompt "Hide admin tools" \
--api-key $ANTHROPIC_API_KEY从文件加载复杂提示:
mcpblox \
--upstream "uvx yfinance-mcp" \
--prompt-file transforms.txt \
--api-key $ANTHROPIC_API_KEY通过Unix管道链实例:
# Each instance reads its upstream URL from stdin and writes its own URL to stdout.
# Only the first instance needs --upstream.
mcpblox --upstream "node stock-server.js" --prompt "Add a max_results param to search" \
| mcpblox --prompt "Format prices as USD with commas" \
| mcpblox --prompt "Add caching hints to descriptions"
# Or feed an upstream URL via echo:
echo "http://localhost:3000/mcp" \
| mcpblox --prompt "Hide admin tools" \
| mcpblox --prompt "Format outputs as markdown"当stdout是一个管道时,mcpblox绑定到操作系统分配的端口并写入其URL(例如。 http://localhost:57403/mcp)到stdout。下一个实例从stdin读取该URL。使用 --port 以覆盖自动分配的端口。
使用显式端口手动链接:
# First instance: modify tool schemas
mcpblox --upstream "node stock-server.js" --prompt "Add a max_results param to search" --port 8001 &
# Second instance: format the output of the first
mcpblox --upstream-url http://localhost:8001/mcp --prompt "Format prices as USD with commas" --port 8002端点
| 端点 | 方法 | 描述 |
|---|---|---|
/mcp | POST | MCP协议(流式HTTP) |
/health | GET | 健康检查--返回 {"status":"ok","tools":} |
缓存
转换已缓存到磁盘中 .mcpblox-cache/ (可配置为 --cache-dir).缓存键是转换提示的哈希值与上游工具模式的哈希值的组合。如果任一更改,缓存将自动失效。
使用 --no-cache 以强制再生。使用 --dry-run 在不启动服务器的情况下预览计划。
安全
LLM生成的转换代码在受限的Node.js中运行 vm 无法访问文件系统、网络、进程环境或模块系统的上下文。沙盒仅提供数据操作原语(JSON、Math、String、Array等),输入/输出转换的执行超时为5秒,合成工具编排的执行超时则为30秒。
合成工具编排代码接收 callTool 桥接函数将调用限制为仅限于工具计划中声明的上游工具——它不能调用任意工具或访问沙盒之外的任何东西。
注:Node.js vm 不是一个完整的安全边界——对于受信任的用户上下文中的LLM生成的代码来说,这已经足够了,而不是对于任意不受信任的输入。
