一个灵活的模型上下文协议(MCP)代理,支持在多个MCP服务器和JavaScript函数之间发现和执行工具。如果你有数百个工具,可以减少上下文事件。此MCP作为其他MCP(或库)的封装器,进行一种本地RAG(检索增强生成),以减少提供给LLM的上下文大小,并通过两种方法(发现和执行)来请求LLM简洁地描述发现过程。执行方法是一个简单的代理。
我们强烈建议添加配置项discoverDescriptionExtras,以便详细说明工具的目的以及LLM应如何使用它。
编辑你的文件 ~/Library/Application Support/Claude/claude_desktop_config.json
并添加以下内容
{
"mcpServers": {
"mcp-openapi-proxy": {
"command": "npx",
"args": ["@nullplatform/meta-mcp-proxy","-f","config.json"]
}
}
}
你的 config.json 应该遵循以下结构:
{
"discoverDescriptionExtras": "用于发现的附加描述",
"discoverLimit": 10,
"mcpServers": {
"server-name": {
"command": "要执行的命令",
"args": ["arg1", "arg2"],
"env": {
"ENV_VAR1": "value1",
"ENV_VAR2": "value2"
},
"transport": "stdio"
}
}
}
例如
{
"discoverDescriptionExtras": "用于管理宠物商店的API,具有访问宠物、宠物类型、用户、订单和商店的功能",
"mcpServers": {
"mcp-petstore": {
"command": "uvx",
"args": ["mcp-openapi-proxy"],
"env": {
"OPENAPI_SPEC_URL": "https://petstore.swagger.io/v2/swagger.json",
"API_KEY": "xxxxx"
}
}
}
}
此示例使用带有宠物商店的演示配置,几乎没有任何关于API的描述。

你也可以在自己的JavaScript应用程序中使用Meta MCP Proxy作为库:
import { MCPProxy } from '@nullplatform/meta-mcp-proxy';
// 创建一个新的代理实例
const mcpProxy = new MCPProxy({
mcpServers: {
"my-server": {
"command": "path/to/server",
"args": [],
"env": {}
}
},
discoverLimit: 10
});
// 注册一个自定义JavaScript函数
mcpProxy.registerJsFunction(
"myFunction",
"我的函数描述",
{
properties: {
param1: {
type: "string",
description: "第一个参数"
},
param2: {
type: "number",
description: "第二个参数"
}
},
required: ["param1"]
},
async ({ param1, param2 }) => {
// 实现代码放在这里
return {
content: [
{
type: "text",
text: JSON.stringify({ result: `处理了 ${param1}` })
}
]
};
}
);
// 启动MCP服务器
await mcpProxy.startMCP();
MIT