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:
Gemini AI
2025-12-26 11:05:11 +04:00
Unverified
parent c6152cb3ea
commit 4aa4795d4b
3 changed files with 53 additions and 5 deletions

View File

@@ -163,12 +163,24 @@ const McpManager: Component<McpManagerProps> = (props) => {
setConnecting(true)
setError(null)
try {
log.info("Connecting to all MCP servers...")
const result = await serverApi.connectWorkspaceMcps(props.instanceId)
log.info("MCP connection result:", result)
setConnectionStatus(result.servers ?? {})
setToolCount(result.toolCount ?? 0)
// Check for any connection errors
const connectionDetails = (result as any).connectionDetails ?? {}
const failedServers = Object.entries(connectionDetails)
.filter(([_, details]: [string, any]) => !details.connected)
.map(([name, details]: [string, any]) => `${name}: ${details.error || 'Unknown error'}`)
if (failedServers.length > 0) {
setError(`Some servers failed to connect: ${failedServers.join(', ')}`)
}
} catch (err) {
log.error("Failed to connect MCPs", err)
setError("Failed to connect MCP servers.")
setError("Failed to connect MCP servers. Check console for details.")
} finally {
setConnecting(false)
}