Back to MCP directory
publicPublicdnsLocal runtime

mcp-remote-server

一个可配置的MCP远程服务器,通过动态加载远程配置来提供工具、资源和提示功能,作为MCP客户端与远程API之间的桥梁。

article

README

🚀 mcp-远程服务器

mcp-远程服务器是一个可配置的模型上下文协议(MCP)服务器,其能力可通过远程配置动态加载。它借助模型上下文协议创建本地服务器,实现与本地MCP客户端的通信,为用户提供灵活、高效的服务。

🚀 快速开始

mcp-远程服务器充当MCP客户端和远程API之间的桥梁。它会解析一个远程托管的配置(通过MCP_CONTROL_PLANE_URL指定),该配置包含工具、资源和提示的列表,每个都指向远程API端点。

✨ 主要特性

  • 动态配置:服务器的功能由远程JSON配置定义。
  • 自动刷新:配置每60秒自动刷新一次。
  • 支持所有MCP原语
    • 工具:通过远程API调用执行操作。
    • 资源:将远程数据作为可读资源暴露。
    • 提示:定义可重用的提示模板。

📦 安装指南

bun install

💻 使用示例

基础用法

  1. 设置您的控制平面URL:
export MCP_CONTROL_PLANE_URL="https://your-config-endpoint"
  1. 运行服务器:
bun run index.ts

📚 详细文档

配置格式

{
  "tools": [{
    "name": "tool-name",
    "description": "工具描述",
    "inputSchema": {
      "type": "object",
      "properties": {
        // JSON Schema用于工具输入
      }
    },
    "handler": "https://api.example.com/tool-endpoint"
  }],
  "resources": [{
    "uri": "resource://identifier",
    "name": "资源名称",
    "description": "资源描述",
    "mimeType": "application/json",
    "handler": "https://api.example.com/resource-endpoint"
  }],
  "prompts": [{
    "name": "prompt-name",
    "description": "提示描述",
    "arguments": [{
      "name": "arg-name",
      "description": "参数描述",
      "required": true
    }],
    "handler": "https://api.example.com/prompt-endpoint"
  }]
}

处理程序API要求

远程处理程序必须返回适当格式的响应:

  • 工具处理程序:返回JSON,该JSON将被字符串化并包装在MCP工具响应中。
  • 资源处理程序:返回与指定 mimeType匹配的内容。
  • 提示处理程序:返回字符串(自动包装在消息中)或MCP格式的消息数组。

局限性

  • 只支持HTTP/HTTPS处理程序端点。
  • 配置必须可通过HTTP GET请求访问。
  • 处理程序响应必须是JSON兼容的。
  • 仅在本地运行(标准MCP限制)。

项目相关信息

此项目使用bun init创建,版本为bun v1.1.32。Bun是一个快速的一站式JavaScript运行时。选择Bun是因为它速度快,而且想尝试一些不同的东西。

该项目还使用Biome进行类型检查和代码格式化。选择Biome的原因与选择Bun相同,希望能为JS有一个类似gofmt的工具,这是一个很好的开始。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client