change: upgrade mcp-go to v0.27.0

This commit is contained in:
lilong.129
2025-05-12 22:46:21 +08:00
parent 3b3807770d
commit 6f428ce5cd
4 changed files with 16 additions and 14 deletions

2
go.mod
View File

@@ -27,7 +27,7 @@ require (
github.com/joho/godotenv v1.5.1
github.com/json-iterator/go v1.1.12
github.com/maja42/goval v1.2.1
github.com/mark3labs/mcp-go v0.22.0
github.com/mark3labs/mcp-go v0.27.0
github.com/mitchellh/mapstructure v1.5.0
github.com/pkg/errors v0.9.1
github.com/rs/zerolog v1.33.0

4
go.sum
View File

@@ -177,8 +177,8 @@ github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4
github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
github.com/maja42/goval v1.2.1 h1:fyEgzddqPgCZsKcFLk4C6SdCHyEaAHYvtZG4mGzQOHU=
github.com/maja42/goval v1.2.1/go.mod h1:42LU+BQXL/veE9jnTTUOSj38GRmOTSThYSXRVodI5J4=
github.com/mark3labs/mcp-go v0.22.0 h1:cCEBWi4Yy9Kio+OW1hWIyi4WLsSr+RBBK6FI5tj+b7I=
github.com/mark3labs/mcp-go v0.22.0/go.mod h1:rXqOudj/djTORU/ThxYx8fqEVj/5pvTuuebQ2RC7uk4=
github.com/mark3labs/mcp-go v0.27.0 h1:iok9kU4DUIU2/XVLgFS2Q9biIDqstC0jY4EQTK2Erzc=
github.com/mark3labs/mcp-go v0.27.0/go.mod h1:rXqOudj/djTORU/ThxYx8fqEVj/5pvTuuebQ2RC7uk4=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=

View File

@@ -101,6 +101,7 @@ func (h *MCPHub) connectToServer(ctx context.Context, serverName string, config
switch config.TransportType {
case "sse":
mcpClient, err = client.NewSSEMCPClient(config.URL)
case "stdio", "": // default to stdio
var env []string
for k, v := range config.Env {
@@ -108,6 +109,17 @@ func (h *MCPHub) connectToServer(ctx context.Context, serverName string, config
}
mcpClient, err = client.NewStdioMCPClient(config.Command,
env, config.Args...)
// print MCP Server logs for stdio transport
stderr, _ := client.GetStderr(mcpClient)
go func() {
scanner := bufio.NewScanner(stderr)
for scanner.Scan() {
fmt.Fprintf(os.Stderr, "MCP Server %s: %s\n",
serverName, scanner.Text())
}
}()
default:
return fmt.Errorf("unsupported transport type: %s", config.TransportType)
}
@@ -115,16 +127,6 @@ func (h *MCPHub) connectToServer(ctx context.Context, serverName string, config
return fmt.Errorf("failed to create client: %w", err)
}
// print MCP Server logs
stderr := client.GetStderr(mcpClient)
go func() {
scanner := bufio.NewScanner(stderr)
for scanner.Scan() {
fmt.Fprintf(os.Stderr, "MCP Server %s: %s\n",
serverName, scanner.Text())
}
}()
// prepare client init request
initRequest := mcp.InitializeRequest{}
initRequest.Params.ProtocolVersion = mcp.LATEST_PROTOCOL_VERSION

View File

@@ -1 +1 @@
v5.0.0-beta-2505122135
v5.0.0-beta-2505122246