#Connection to MCP is not stable.

1 messages · Page 1 of 1 (latest)

mild void
#

Hi,
We are using the mcp(https://mcp.copilotkit.ai/sse) from github copilot configured in vscode. It kind of gets disconnected often. Then we try to restart it, some time it works and discovering the 2tools. Many a times, we see the following error . Any Pointers on why this is happenig?

2025-10-20 06:10:00.110 [info] Connection state: Error Error sending message to https://mcp.copilotkit.ai/sse: TypeError: fetch failed
2025-10-20 06:10:03.214 [info] Starting server my-mcp-server-9447f3f9
2025-10-20 06:10:03.215 [info] Connection state: Starting
2025-10-20 06:10:03.227 [info] Starting server from LocalProcess extension host
2025-10-20 06:10:03.231 [info] Connection state: Running
2025-10-20 06:10:03.573 [info] 404 status sending message to https://mcp.copilotkit.ai/sse, will attempt to fall back to legacy SSE
2025-10-20 06:10:14.783 [info] Connection state: Error Error sending message to https://mcp.copilotkit.ai/sse: TypeError: fetch failed

woven jayBOT
#

To save your precious dev time, this solution has been AI generated

Your connection issues with the MCP service are likely due to deprecated transport methods and server compatibility problems.

Troubleshooting MCP Connection Issues

1. SSE Transport Deprecation

  • Root Cause: SSE (Server-Sent Events) is deprecated for MCP; many servers no longer support it.
  • Solution: Switch to HTTP Stream Transport:
const mcpClient = createMCPClient({
  transport: 'http-stream',
  endpoint: 'your-mcp-endpoint-url'
});

2. Configure Retries

  • Use built-in retry logic for unstable connections:
const retryConfig = {
  maxRetries: 3,
  baseDelayMs: 1000,
  maxDelayMs: 5000,
  retryableStatusCodes: [502, 503, 504, 408, 429],
  retryableErrors: ["fetch failed", "network error", "connection timeout"]
};

3. Check Endpoint and Compatibility

  • Test endpoint with curl -I https://your-mcp-server.com
  • Ensure server supports HTTP Stream and is not SSE-only
  • Confirm API key/authentication if required

4. Enable Debug Logging

  • Review logs for repeated fetch failures or 404 errors
  • Errors like fetch failed and fallback to legacy SSE indicate transport mismatch

References:

Switching to HTTP Stream transport and verifying server compatibility should resolve most disconnection issues.

Was this helpful?

If this solution worked for you, please click on the appropriate option below to help us improve:

woven jayBOT
#

Hey @mild void, just checking in - did the solution work for you, or are you still running into issues?

mild void