fix: MCP connection - Added explicit connectAll() method with timeout - Updated mcp-connect endpoint to use connectAll - Enhanced UI feedback for connection errors
This commit is contained in:
@@ -313,17 +313,26 @@ export function registerWorkspaceRoutes(app: FastifyInstance, deps: RouteDeps) {
|
||||
const { getMcpManager } = await import("../../mcp/client")
|
||||
const mcpManager = getMcpManager()
|
||||
|
||||
// Load and connect to all configured MCPs
|
||||
// Load config first
|
||||
await mcpManager.loadConfig(workspace.path)
|
||||
|
||||
// Get the tools to trigger connections
|
||||
// Explicitly connect all servers
|
||||
const connectionResults = await mcpManager.connectAll()
|
||||
|
||||
// Get tools from connected servers
|
||||
const tools = await mcpManager.getAllTools()
|
||||
const status = mcpManager.getStatus()
|
||||
|
||||
// Transform connection results to status format
|
||||
const status: Record<string, { connected: boolean }> = {}
|
||||
for (const [name, result] of Object.entries(connectionResults)) {
|
||||
status[name] = { connected: result.connected }
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
servers: status,
|
||||
toolCount: tools.length
|
||||
toolCount: tools.length,
|
||||
connectionDetails: connectionResults
|
||||
}
|
||||
} catch (error) {
|
||||
request.log.error({ err: error }, "Failed to connect MCPs")
|
||||
|
||||
Reference in New Issue
Block a user