JSON适配器服务

MCP Python适配器是一个轻量级的服务,用于将规范的JSON请求转换为MCP Orchestrator的简单请求格式,并将响应包装回规范的信封格式。

  • by wbernardo-star
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 wbernardo-star/mcp_adapter

使用说明

MCP Python适配器(规范JSON)

此服务充当MCP Orchestrator前面的精简适配器。

它

  • 接受 规范JSON 来自任何客户 POST /canonical/voice
  • 将其转换为简单的MCP /orchestrate 请求格式
  • 呼叫MCP编排器
  • 将响应包装回规范响应信封中

端点

  • GET /health –基本健康检查
  • POST /canonical/voice –规范消息的主要入口点

预期规范请求(示例)

{
  "version": "1.0",
  "timestamp": "2025-11-21T12:44:05.112Z",
  "context": {
    "channel": "web",
    "device": "browser",
    "locale": "en-US",
    "tenant": "blinksbuy",
    "client_app": "food-order-widget"
  },
  "session": {
    "session_id": "postman-user-B:web",
    "conversation_id": "conv-23f98c83-9928-4e41-b9f4-01d4998689f2",
    "user_id": "postman-user-B",
    "turn": 7
  },
  "request": {
    "type": "text",
    "text": "Can you please get the menu?",
    "intent_override": null
  },
  "observability": {
    "trace_id": "trace-319bf86a-6688-40d5-9833-437b7e2345b2",
    "span_id": "span-adapter-in-0021"
  }
}

MCP请求(内部)

适配器将此规范信封转换为对MCP Orchestrator的调用:

{
  "text": "Can you please get the menu?",
  "user_id": "postman-user-B",
  "channel": "web",
  "session_id": "postman-user-B:web"
}

铁路部署

  1. 从此仓库创建新服务。

  2. 设置环境变量 MCP_URL 发送给您的MCP编排器 /orchestrate URL。

  3. 铁路将安装 requirements.txt 并运行 Procfile:

    web: uvicorn app:app --host 0.0.0.0 --port $PORT
    

部署后,您可以使用进行测试 POST /canonical/voice.