Skip to main content
Glama
sirmews

MCP Remote Server

by sirmews

这是增强的自述文件,其中包含基于代码库的更多技术细节:

mcp-远程服务器

可配置的模型上下文协议 (MCP) 服务器,可从远程配置动态加载其功能。它利用ModelContextProtocol创建一个可与本地 MCP 客户端通信的本地服务器。

概述

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

主要特点

  • 动态配置:服务器功能通过远程 JSON 配置定义

  • 自动刷新:配置每 60 秒自动刷新一次

  • 支持所有 MCP 原语

    • 工具:通过远程 API 调用执行操作

    • 资源:将远程数据公开为可读资源

    • 提示:定义可重复使用的提示模板

配置格式

{
  "tools": [{
    "name": "tool-name",
    "description": "Tool description",
    "inputSchema": {
      "type": "object",
      "properties": {
        // JSON Schema for tool inputs
      }
    },
    "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"
  }]
}

处理程序 API 要求

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

  • 工具处理程序:返回将被字符串化并包装在 MCP 工具响应中的 JSON

  • 资源处理程序:返回与指定 mimeType 匹配的内容

  • 提示处理程序:返回字符串(自动包装在消息中)或 MCP 格式的消息数组

Related MCP server: MCP-YNU FastMCP Server

安装

bun install

用法

  1. 设置您的控制平面 URL:

export MCP_CONTROL_PLANE_URL="https://your-config-endpoint"
  1. 运行服务器:

bun run index.ts

限制

  • 仅支持 HTTP/HTTPS 处理程序端点

  • 必须可以通过 HTTP GET 请求访问配置

  • 处理程序响应必须兼容 JSON

  • 仅在本地运行(标准 MCP 限制)

该项目是在 bun v1.1.32 版本中使用bun init创建的。Bun 是一个快速的一体化 JavaScript 运行时。我选择Bun是因为它速度快,而且我想尝试一些与众不同的东西。

这个项目也使用Biome进行类型检查和 linting。我选择 Biome 的原因和 Bun 一样。我想要一些不同的东西,并且希望 JS 能有一个类似gofmt的工具。这是一个很好的开始。

Related MCP Connectors

Related MCP Servers

  • F
    license
    C
    quality
    D
    maintenance
    This is an MCP server that facilitates building tools for interacting with various APIs and workflows, supporting Python-based development with potential for customizable prompts and user configurations.
    1
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    A dynamic MCP server implementation that automatically loads tools, resources, and prompts from their respective directories, allowing for easy extension and configuration.
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    A generic MCP server that dynamically exposes any OpenAPI-documented REST API to LLMs by auto-discovering endpoints. It provides tools for exploring API capabilities and making authenticated requests directly through natural language interfaces.
    2
    7 npm
    MIT