From 0f5dfbe41918835d178e5e79cdb9c47843562746 Mon Sep 17 00:00:00 2001 From: samanhappy Date: Fri, 9 May 2025 21:25:44 +0800 Subject: [PATCH] feat: support server-specified endpoint (#58) --- README.md | 14 ++++++++++++++ README.zh.md | 19 ++++++++++++++++++- src/services/mcpService.ts | 1 + 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 76d7cfe..8bdd448 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,15 @@ Where `{group}` is the ID or name of the group you created in the dashboard. Thi - Isolate different AI tools to access only relevant servers - Implement more granular access control for different environments or teams +**Server-Specific Endpoints**: +For direct access to individual servers, use the server-specific HTTP endpoint: +``` +http://localhost:3000/mcp/{server} +``` +Where `{server}` is the name of the server you want to connect to. This allows you to access a specific MCP server directly. + +> **Note**: If the server name and group name are the same, the group name will take precedence. + ### SSE Endpoint (Deprecated in Future) Connect AI clients (e.g., Claude Desktop, Cursor, DeepChat, etc.) via: @@ -127,6 +136,11 @@ For targeted access to specific server groups, use the group-based SSE endpoint: http://localhost:3000/sse/{group} ``` +For direct access to individual servers, use the server-specific SSE endpoint: +``` +http://localhost:3000/sse/{server} +``` + ## 🧑‍💻 Local Development ```bash diff --git a/README.zh.md b/README.zh.md index a5cf9cc..628cdb3 100644 --- a/README.zh.md +++ b/README.zh.md @@ -125,7 +125,18 @@ http://localhost:3000/mcp/{group} - 通过分组名称轻松识别和管理服务器 - 允许不同的 AI 客户端使用相同的端点,简化集成过程 -### SSE 端点集成 (即将废弃) +**针对特定服务器的 HTTP 端点**: +要针对特定服务器进行访问,请使用以下格式: + +``` +http://localhost:3000/mcp/{server} +``` + +其中 `{server}` 是您要连接的服务器名称。这样做可以直接访问特定的 MCP 服务器。 + +> **提示**:如果服务器名称和分组名称相同,则分组名称优先。 + +### SSE 端点集成 (未来可能废弃) 通过以下地址连接 AI 客户端(如 Claude Desktop、Cursor、DeepChat 等): @@ -139,6 +150,12 @@ http://localhost:3000/sse http://localhost:3000/sse/{group} ``` +要针对特定服务器进行访问,请使用以下格式: + +``` +http://localhost:3000/sse/{server} +``` + ## 🧑‍💻 本地开发 ```bash diff --git a/src/services/mcpService.ts b/src/services/mcpService.ts index 109fda2..695293b 100644 --- a/src/services/mcpService.ts +++ b/src/services/mcpService.ts @@ -347,6 +347,7 @@ export const createMcpServer = (name: string, version: string): Server => { if (serverInfo.enabled === false) return false; if (!group) return true; const serversInGroup = getServersInGroup(group); + if (!serversInGroup || serversInGroup.length === 0) return serverInfo.name === group; return serversInGroup.includes(serverInfo.name); });