microsoft/autogen · error · Error
HTTP ${response.status}: ${errorText || "Failed to create We
Error message
HTTP ${response.status}: ${errorText || "Failed to create WebSocket connection"} What it means
Thrown by useMcpWebSocket when the HTTP POST that initiates an MCP session (sending server_params) returns a non-OK status. The message interpolates the HTTP status code plus the raw response body text, defaulting to 'Failed to create WebSocket connection' when the body is empty. It means the backend rejected or failed the MCP connection setup before a WebSocket was opened.
Source
Thrown at python/packages/autogen-studio/frontend/src/components/views/teambuilder/builder/component-editor/fields/workbench/useMcpWebSocket.ts:141
try {
// First, get the WebSocket connection URL
console.log("Connecting to MCP server with params:", serverParams);
const serverUrl = getServerUrl();
const response = await fetch(`${serverUrl}/mcp/ws/connect`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ server_params: serverParams }),
});
console.log("Response status:", response.status, response.statusText);
if (!response.ok) {
const errorText = await response.text();
console.error("HTTP error response:", errorText);
throw new Error(
`HTTP ${response.status}: ${
errorText || "Failed to create WebSocket connection"
}`
);
}
let connectionData;
try {
const responseText = await response.text();
console.log("Raw response:", responseText);
connectionData = JSON.parse(responseText);
} catch (jsonError) {
console.error("JSON parse error:", jsonError);
throw new Error(
`Invalid JSON response from server. Check if the MCP route is properly configured.`
);
}
View on GitHub (pinned to 027ecf0a37)
Solutions
- Read the interpolated status: 404 means the MCP route is absent (update backend or fix URL); 4xx/5xx bodies usually contain the backend's reason.
- Verify the MCP server params (command, args, env) work by launching the MCP server manually.
- Ensure the AutoGen Studio backend version matches the frontend and includes MCP support enabled in settings.
- Check backend logs for the exception raised during session creation.
Defensive patterns
Strategy: try-catch
Validate before calling
const mcpEndpoint = `${getServerUrl()}/mcp`;
// Preflight: does the route exist at all?
const probe = await fetch(mcpEndpoint, { method: 'OPTIONS' });
if (probe.status === 404) throw new Error('MCP route not found on backend'); Try / catch
try {
await connectMcp(serverParams);
} catch (e) {
if (e instanceof Error && /^HTTP (401|403)/.test(e.message)) {
promptReauthentication();
} else if (e instanceof Error && /^HTTP 404/.test(e.message)) {
showDeployError('Backend does not expose MCP routes; update the server.');
} else {
showError(e.message); // includes status + server body
}
} Prevention
- Verify MCP support is enabled in AutoGen Studio settings before offering MCP fields in the UI.
- Smoke-test the MCP route after each backend upgrade.
- Log the response body on failure — it's already embedded in this error's message.
When it happens
Trigger: POSTing server_params for an MCP server that the backend cannot reach (404 route missing), invalid/unsupported server_params payload (400/422), auth failure (401/403), or backend exception while spawning the MCP session (500). The URL and status in the message identify which.
Common situations: MCP server command/path configured incorrectly in the component (backend can't launch it, returns 4xx/5xx); frontend and backend versions mismatched so /mcp route doesn't exist; gateway timeout because the MCP server takes too long to start.
Related errors
- Invalid server URL configuration
- Failed to list MCP tools
- HTTP ${response.status}: ${errorText || "Failed to create We
- Failed to delete team
- Failed to validate component
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/00c155414c3b80ab.
Report an issue: GitHub.