VOOZH about

URL: https://glama.ai/mcp/servers/ssut/Remote-MCP?locale=zh-CN

⇱ 远程 MCP 服务器 by ssut | Glama


Remote-MCP:远程模型上下文协议

一种类型安全、双向且简单的 远程 MCP 通信解决方案,允许远程访问和集中管理模型上下文。

👁 预览

建筑学

%%{init: {"flowchart": {"htmlLabels": false}} }%%
graph TD
 %% Modern, Bright Color Styling with white text
 classDef client fill:#22c55e,stroke:#059669,stroke-width:2px,color:#ffffff
 classDef gateway fill:#06b6d4,stroke:#0891b2,stroke-width:2px,color:#ffffff
 classDef backend fill:#f97316,stroke:#ea580c,stroke-width:2px,color:#ffffff
 classDef resource fill:#8b5cf6,stroke:#7c3aed,stroke-width:2px,color:#ffffff
 classDef server fill:#06b6d4,stroke:#0891b2,stroke-width:2px,color:#ffffff

 linkStyle default stroke:#64748b,stroke-width:1.5px,stroke-dasharray: 5 5

 %% Current MCP Setup (Multiple Local Servers)
 subgraph Current["Current Setup (Local)"]
 direction LR
 subgraph ClientGroup["Client"]
 A[Client]:::client
 end

 subgraph Servers["Local MCP Servers"]
 direction TB
 B1["Local MCP Server (DB)"]:::server -->|"DB Access"| C1[DB]:::resource
 B2["Local MCP Server (API 1)"]:::server -->|"API Access"| C2["Web API 1"]:::resource
 B3["Local MCP Server (API 2)"]:::server -->|"API Access"| C3["Web API 2"]:::resource
 end

 A -->|"MCP Protocol"| B1
 A -->|"MCP Protocol"| B2
 A -->|"MCP Protocol"| B3
 end

 %% Vertical separator
 Current --> Proposed

 %% Proposed MCP Architecture (Decoupled)
 subgraph Proposed["Proposed Architecture (Remote)"]
 direction LR
 D[Client/Host]:::client -->|"MCP Protocol"| E["Local MCP Server (@remote-mcp/client)"]:::server
 E <-->|"tRPC(HTTP)"| F["Remote MCP Server (@remote-mcp/server)"]:::backend

 %% Separated Resources
 F -->|"DB Access"| G1[DB]:::resource
 F -->|"API Access"| G2["Web API 1"]:::resource
 F -->|"API Access"| G3["Web API 2"]:::resource
 end

Related MCP server: MCP Python Server

我为什么现在做这个

是的,我知道官方的 MCP 路线图包含 2025 年第一季度的远程 MCP 支持。但是,我和其他许多人一样,迫切需要远程访问。这个库就是为了弥补这一差距而创建的,它提供了一种从本地 MCP 客户端立即连接到远程 MCP 服务器的方法,而无需等待未来的官方实现。

注意:我不希望这件事变得太复杂或太过复杂。这种方法目前就有效

入门

注意:该项目目前处于积极开发阶段,且处于实验阶段。预计会发生重大变更并可能出现问题。

客户端使用情况

使用公开发布的包

只需将以下代码放入您的 MCP 客户端设置中,这里我以 Claude 为例:

{
 "mcpServers": {
 "remote-mcp": {
 "command": "npx",
 "args": ["-y", "@remote-mcp/client"],
 "env": {
 "REMOTE_MCP_URL": "http://localhost:9512",
 "HTTP_HEADER_Authorization": "Bearer <token>"
 }
 }
 }
}

编写您自己的本地 MCP 服务器

安装要求:

$ npm install @remote-mcp/client @trpc/client@next zod

然后编写自己的代码,如下所示:

import { RemoteMCPClient } from "@remote-mcp/client";

const client = new RemoteMCPClient({
 remoteUrl: "http://localhost:9512",

 onError: (method, error) => console.error(`Error in ${method}:`, error)
});

void client.start();

服务器使用情况(远程 MCP 实施)

您可以在examples目录中看到一些示例。

编写您自己的远程 MCP 服务器

npm install @remote-mcp/server之后,你可以像下面这样建立自己的远程 MCP 服务器:

import { MCPRouter, LogLevel } from "@remote-mcp/server";
import { createHTTPServer } from '@trpc/server/adapters/standalone';

import { z } from "zod";

// Create router instance
const mcpRouter = new MCPRouter({
 logLevel: LogLevel.DEBUG,
 name: "example-server",
 version: "1.0.0",
 capabilities: {
 logging: {},
 },
});

// Add example tool
mcpRouter.addTool(
 "calculator",
 {
 description:
 "Perform basic calculations. Add, subtract, multiply, divide. Invoke this every time you need to perform a calculation.",
 schema: z.object({
 operation: z.enum(["add", "subtract", "multiply", "divide"]),
 a: z.string(),
 b: z.string(),
 }),
 },
 async (args) => {
 const a = Number(args.a);
 const b = Number(args.b);

 let result: number;
 switch (args.operation) {
 case "add":
 result = Number(a) + b;
 break;
 case "subtract":
 result = a - b;
 break;
 case "multiply":
 result = a * b;
 break;
 case "divide":
 if (b === 0) throw new Error("Division by zero");
 result = a / b;
 break;
 }

 return {
 content: [{ type: "text", text: `${result}` }],
 };
 },
);

const appRouter = mcpRouter.createTRPCRouter();

void createHTTPServer({
 router: appRouter,
 createContext: () => ({}),
}).listen(Number(process.env.PORT || 9512));

然后您可以在 MCP 客户端中看到以下内容:

套餐

该存储库包含:

  • @remote-mcp/client :客户端库充当本地 MCP 服务器,连接到远程实现。

  • @remote-mcp/server :用于创建可远程访问的 MCP 服务(用作远程实现)的服务器库。

路线图

核心功能

  • [x] 基本类型安全的客户端/服务器通信

    • [x] 基本 MCP 命令支持

    • [x] 基本 MCP 工具支持

    • [x] 基本 MCP 提示支持

    • [ ] 碰撞安全处理(WIP,优先)

  • [ ] 完整的事件订阅系统

    • [ ] 资源变更通知

    • [ ] 工具/提示列表变更通知

  • [ ] HTTP 标头支持

    • [x] 自定义标题

    • [ ] 身份验证中间件

  • [ ] 基本错误处理改进

  • [ ] 基本中间件支持

框架支持

  • [ ] Nest.js 集成( @remote-mcp/nestjs

高级功能

  • [ ] 双向通信

    • [ ] 服务器到客户端的请求

    • [ ] 服务器/客户端之间的资源共享

  • [ ] 基本监控和日志记录

贡献

欢迎贡献。详情请参阅CONTRIBUTING.md

免责声明

该库是一个补充扩展,不是官方 MCP 规范的一部分,它建立在现有的 MCP 概念之上。

执照

本项目遵循 MIT 许可证。详情请参阅LICENSE文件。

参考

A
license - permissive license
-
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ssut/Remote-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server