元MCP代理
一个灵活的模型上下文协议(MCP)代理,能够跨多个MCP服务器和JavaScript函数发现和执行工具。如果你有大量的工具,可以减少上下文事件。 这个mcp充当其他mcp(或库)的包装器,执行一种本地RAG(检索增强生成)来减少上下文大小,为llm提供2种方法(发现和执行),并要求llm对发现保持简洁。execute方法是一个简单的代理
我们强烈建议添加配置 discoverDescriptionExtras 详细介绍工具的用途以及llm应该将其用于什么类型的主题。
特性
- 🌉 统一工具发现:跨多个MCP服务器搜索工具
- 🔌 代理执行:将工具调用路由到相应的服务器
- 🔍 智能搜索:通过模糊匹配找到最适合工作的工具
- 🧩 JavaScript集成:将自定义JavaScript函数作为MCP工具公开
- 📝 可配置的:从文件或命令行参数加载配置
用法
🧱 安装
编辑您的文件 ~/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": "Additional description for discovery",
"discoverLimit": 10,
"mcpServers": {
"server-name": {
"command": "command-to-execute",
"args": ["arg1", "arg2"],
"env": {
"ENV_VAR1": "value1",
"ENV_VAR2": "value2"
},
"transport": "stdio"
}
}
}作为示例
{
"discoverDescriptionExtras": "Api used to manage a pet store with access to pets, pet types, users, orders and store",
"mcpServers": {
"mcp-petstore": {
"command": "uvx",
"args": ["mcp-openapi-proxy"],
"env": {
"OPENAPI_SPEC_URL": "https://petstore.swagger.io/v2/swagger.json",
"API_KEY": "xxxxx"
}
}
}
}示例0-Shot与Claude的对话
这个例子是在宠物商店中使用演示配置,几乎没有描述api是什么
作为图书馆
您还可以在自己的JavaScript应用程序中将Meta MCP Proxy用作库:
import { MCPProxy } from '@nullplatform/meta-mcp-proxy';
// Create a new proxy instance
const mcpProxy = new MCPProxy({
mcpServers: {
"my-server": {
"command": "path/to/server",
"args": [],
"env": {}
}
},
discoverLimit: 10
});
// Register a custom JavaScript function
mcpProxy.registerJsFunction(
"myFunction",
"Description of my function",
{
properties: {
param1: {
type: "string",
description: "First parameter"
},
param2: {
type: "number",
description: "Second parameter"
}
},
required: ["param1"]
},
async ({ param1, param2 }) => {
// Implementation goes here
return {
content: [
{
type: "text",
text: JSON.stringify({ result: `Processed ${param1}` })
}
]
};
}
);
// Start the MCP server
await mcpProxy.startMCP();许可证
麻省理工学院
