feat: support legacy SSE MCP servers (#117)

This commit is contained in:
RuoJi6 authored and GitHub committed 2026-09-15 00:56:16 +08:00
1 parent 71fa919599
commit 1a388e3e9e
8 files changed
+386 -21

No files matched your search

+9 -3
View File
@@ -6,13 +6,14 @@ import (
"log"
"time"
"github.com/Autumn-27/norma/mcp"
actool "github.com/Autumn-27/norma/tool"
"github.com/Autumn-27/artex/db"
"github.com/Autumn-27/artex/mcphttp"
"github.com/Autumn-27/norma/mcp"
actool "github.com/Autumn-27/norma/tool"
)
// mcpClient is the shared surface of a connected MCP server (stdio or remote http),
// mcpClient is the shared surface of a connected MCP server (stdio, Streamable HTTP,
// or legacy SSE),
// so tools/list and cleanup are handled uniformly regardless of transport.
type mcpClient interface {
Tools(context.Context) ([]actool.CoreTool, error)
@@ -33,6 +34,11 @@ func connectMCP(ctx context.Context, m *db.MCPServer) (mcpClient, error) {
}
// env map doubles as HTTP headers (e.g. Authorization).
return mcphttp.New(ctx, m.Name, m.URL, jsonStrMap(m.Env), m.Insecure)
case "sse":
if m.URL == "" {
return nil, fmt.Errorf("sse 传输缺少 URL")
}
return mcphttp.NewSSE(ctx, m.Name, m.URL, jsonStrMap(m.Env), m.Insecure)
default:
return nil, fmt.Errorf("未知传输方式 %q", m.Transport)
}
+1 -1
View File
@@ -292,7 +292,7 @@ func (a mcpToolInput) toDB() *db.MCPServer {
}
func (s *Server) toolCreateMCP() actool.CoreTool {
return wrTool("create_mcp", "创建一个 MCP 服务器(stdio/http)。创建后其工具需按 agent 可见性授权。",
return wrTool("create_mcp", "创建一个 MCP 服务器(stdio/http/sse)。创建后其工具需按 agent 可见性授权。",
mcpSchema(false),
func(_ context.Context, in json.RawMessage) (actool.Result, error) {
var a mcpToolInput