continuedev/continue · error · Error

MCP Connection ${serverId} not found

Error message

MCP Connection ${serverId} not found

What it means

Identical guard to the non-streaming path, applied in chatCompletionStream: Vertex AI express (apiKey) auth only works for Gemini models, and streaming requests for anthropic/mistral models are rejected before any network call.

Source

Thrown at core/context/mcp/MCPManagerSingleton.ts:147

  private compareEnv(
    aEnv: Record<string, string> | undefined,
    bEnv: Record<string, string> | undefined,
  ): boolean {
    const a = aEnv ?? {};
    const b = bEnv ?? {};
    const aKeys = Object.keys(a);
    const bKeys = Object.keys(b);

    return (
      aKeys.length === bKeys.length && aKeys.every((key) => a[key] === b[key])
    );
  }

  async refreshConnection(serverId: string) {
    const connection = this.connections.get(serverId);
    if (!connection) {
      throw new Error(`MCP Connection ${serverId} not found`);
    }
    await connection.connectClient(true, this.abortController.signal);
    if (this.onConnectionsRefreshed) {
      this.onConnectionsRefreshed();
    }
  }

  async refreshConnections(force: boolean) {
    this.abortController.abort();
    this.abortController = new AbortController();
    await Promise.race([
      new Promise((resolve) => {
        this.abortController.signal.addEventListener("abort", () => {
          resolve(undefined);
        });
      }),
      (async () => {
        await Promise.all(

View on GitHub (pinned to 5522c6f44c)

Solutions

  1. Use service-account auth (keyJson/keyFile/ADC) for non-gemini streaming models
  2. Or stream a gemini-* model in express mode
  3. Keep separate adapter instances per auth mode/model family

Example fix

// before
const api = new VertexAIApi({ apiKey: KEY });
for await (const c of api.chatCompletionStream({ model: 'claude-3-5-sonnet@...', ... }, signal)) {}

// after
const api = new VertexAIApi({ keyJson: SA_JSON });
for await (const c of api.chatCompletionStream({ model: 'claude-3-5-sonnet@...', ... }, signal)) {}
Defensive patterns

Strategy: validation

Validate before calling

if (hasApiKey && !/gemini/i.test(body.model)) throw new Error('configure service-account auth for non-gemini streaming');

Type guard

const isGeminiModel = (m: string): boolean => /gemini/i.test(m);

Try / catch

try { for await (const c of api.chatCompletionStream(body, signal)) {} } catch (e) { if ((e as Error).message.includes('express (apiKey) mode')) { /* reauth with keyJson or switch model */ } throw e; }

Prevention

When it happens

Trigger: config.apiKey set and a streaming completion requested with a claude-* or mistral/codestral model via completionStream.

Common situations: Streaming pipelines configured with a Vertex API key, then the model is switched to Claude or Codestral on Vertex without changing auth.

Related errors


AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27). Data as JSON: /api/errors/cc4a1abb7ef9a1d3. Report an issue: GitHub.