on main help sign in
fix(mcp): set logger on all mcp clients (#554)
d72bac2Carlos Alexandro Becker
go.mod+1−1
@@ -27,7 +27,7 @@ require (
27 github.com/google/uuid v1.6.0
27 github.com/google/uuid v1.6.0
28 github.com/invopop/jsonschema v0.13.0
28 github.com/invopop/jsonschema v0.13.0
29 github.com/joho/godotenv v1.5.1
29 github.com/joho/godotenv v1.5.1
30− github.com/mark3labs/mcp-go v0.36.0
30+ github.com/mark3labs/mcp-go v0.37.0
31 github.com/muesli/termenv v0.16.0
31 github.com/muesli/termenv v0.16.0
32 github.com/ncruces/go-sqlite3 v0.25.0
32 github.com/ncruces/go-sqlite3 v0.25.0
33 github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
33 github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
go.sum+2−2
@@ -180,8 +180,8 @@ github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69
180github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
180github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
181github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
181github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
182github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
182github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
183−github.com/mark3labs/mcp-go v0.36.0 h1:rIZaijrRYPeSbJG8/qNDe0hWlGrCJ7FWHNMz2SQpTis=
183+github.com/mark3labs/mcp-go v0.37.0 h1:BywvZLPRT6Zx6mMG/MJfxLSZQkTGIcJSEGKsvr4DsoQ=
184−github.com/mark3labs/mcp-go v0.36.0/go.mod h1:T7tUa2jO6MavG+3P25Oy/jR7iCeJPHImCZHRymCn39g=
184+github.com/mark3labs/mcp-go v0.37.0/go.mod h1:T7tUa2jO6MavG+3P25Oy/jR7iCeJPHImCZHRymCn39g=
185github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
185github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
186github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
186github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
187github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
187github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
internal/llm/agent/mcp-tools.go+9−7
@@ -308,29 +308,31 @@ func doGetMCPTools(ctx context.Context, permissions permission.Service, cfg *con
308func createMcpClient(m config.MCPConfig) (*client.Client, error) {
308func createMcpClient(m config.MCPConfig) (*client.Client, error) {
309 switch m.Type {
309 switch m.Type {
310 case config.MCPStdio:
310 case config.MCPStdio:
311− return client.NewStdioMCPClient(
311+ return client.NewStdioMCPClientWithOptions(
312 m.Command,
312 m.Command,
313 m.ResolvedEnv(),
313 m.ResolvedEnv(),
314− m.Args...,
314+ m.Args,
315+ transport.WithCommandLogger(mcpLogger{}),
315 )
316 )
316 case config.MCPHttp:
317 case config.MCPHttp:
317 return client.NewStreamableHttpClient(
318 return client.NewStreamableHttpClient(
318 m.URL,
319 m.URL,
319 transport.WithHTTPHeaders(m.ResolvedHeaders()),
320 transport.WithHTTPHeaders(m.ResolvedHeaders()),
320− transport.WithLogger(mcpHTTPLogger{}),
321+ transport.WithHTTPLogger(mcpLogger{}),
321 )
322 )
322 case config.MCPSse:
323 case config.MCPSse:
323 return client.NewSSEMCPClient(
324 return client.NewSSEMCPClient(
324 m.URL,
325 m.URL,
325 client.WithHeaders(m.ResolvedHeaders()),
326 client.WithHeaders(m.ResolvedHeaders()),
327+ transport.WithSSELogger(mcpLogger{}),
326 )
328 )
327 default:
329 default:
328 return nil, fmt.Errorf("unsupported mcp type: %s", m.Type)
330 return nil, fmt.Errorf("unsupported mcp type: %s", m.Type)
329 }
331 }
330}
332}
331
333
332−// for MCP's HTTP client.
334+// for MCP's clients.
333−type mcpHTTPLogger struct{}
335+type mcpLogger struct{}
334
336
335−func (l mcpHTTPLogger) Errorf(format string, v ...any) { slog.Error(fmt.Sprintf(format, v...)) }
337+func (l mcpLogger) Errorf(format string, v ...any) { slog.Error(fmt.Sprintf(format, v...)) }
336−func (l mcpHTTPLogger) Infof(format string, v ...any) { slog.Info(fmt.Sprintf(format, v...)) }
338+func (l mcpLogger) Infof(format string, v ...any) { slog.Info(fmt.Sprintf(format, v...)) }