sketch/mcp: increase connection and tool timeouts
diff --git a/loop/agent.go b/loop/agent.go
index 4ad1341..d1ff360 100644
--- a/loop/agent.go
+++ b/loop/agent.go
@@ -1406,7 +1406,7 @@
}
}
}
- mcpConnections, mcpErrors := a.mcpManager.ConnectToServerConfigs(ctx, serverConfigs, 10*time.Second, parseErrors)
+ mcpConnections, mcpErrors := a.mcpManager.ConnectToServerConfigs(ctx, serverConfigs, mcp.DefaultMCPConnectionTimeout, parseErrors)
if len(mcpErrors) > 0 {
for _, err := range mcpErrors {
diff --git a/mcp/client.go b/mcp/client.go
index d15ae84..8f65614 100644
--- a/mcp/client.go
+++ b/mcp/client.go
@@ -15,6 +15,14 @@
"sketch.dev/llm"
)
+const (
+ // DefaultMCPConnectionTimeout is the default timeout for connecting to MCP servers
+ DefaultMCPConnectionTimeout = 120 * time.Second
+
+ // DefaultMCPToolTimeout is the default timeout for executing MCP tool calls
+ DefaultMCPToolTimeout = 120 * time.Second
+)
+
// ServerConfig represents the configuration for an MCP server
type ServerConfig struct {
Name string `json:"name,omitempty"`
@@ -297,7 +305,7 @@
func (m *MCPManager) executeMCPTool(ctx context.Context, mcpClient *client.Client, toolName string, input json.RawMessage) (any, error) {
// Add timeout for tool execution
// TODO: Expose the timeout as a tool call argument.
- ctxWithTimeout, cancel := context.WithTimeout(ctx, 120*time.Second)
+ ctxWithTimeout, cancel := context.WithTimeout(ctx, DefaultMCPToolTimeout)
defer cancel()
// Parse input arguments