以下是基于代码库的增强版README,包含更多技术细节:
一个可配置的模型上下文协议(MCP)服务器,能够从远程配置动态加载其功能。该服务器利用ModelContextProtocol创建一个本地服务器,可以与您的本地MCP客户端进行通信。
mcp-remote-server充当MCP客户端与远程API之间的桥梁。它解析一个由MCP_CONTROL_PLANE_URL指定的远程托管配置文件,该配置文件包含工具、资源和提示列表,每个条目都指向远程API端点。
{
"tools": [{
"name": "tool-name",
"description": "Tool description",
"inputSchema": {
"type": "object",
"properties": {
// 工具输入的JSON模式
}
},
"handler": "https://api.example.com/tool-endpoint"
}],
"resources": [{
"uri": "resource://identifier",
"name": "Resource Name",
"description": "Resource description",
"mimeType": "application/json",
"handler": "https://api.example.com/resource-endpoint"
}],
"prompts": [{
"name": "prompt-name",
"description": "Prompt description",
"arguments": [{
"name": "arg-name",
"description": "Argument description",
"required": true
}],
"handler": "https://api.example.com/prompt-endpoint"
}]
}
远程处理程序必须返回适当格式化的响应:
bun install
export MCP_CONTROL_PLANE_URL="https://your-config-endpoint"
bun run index.ts
此项目使用bun init在bun v1.1.32版本下创建。Bun是一个快速的一体化JavaScript运行时。我选择Bun是因为它速度快,并且我想尝试一些不同的东西。
此项目还使用Biome进行类型检查和代码格式化。我选择Biome的原因与Bun相同。我希望JavaScript有一个类似gofmt的工具。这是一个好的开始。