Skip to content

fix: SDK server client constructor mismatch — MCP init crash on GCE #52

Description

@Number531

Summary

The GCE-deployed server (claude-sdk-server.js) failed to initialize the Agent SDK MCP server, rejecting all research workloads with:

⚠️ Failed to build Agent SDK MCP server: Cannot read properties of undefined (reading 'courtListener')
Agent SDK stream error: Error: Agent SDK MCP server not initialized

Root Cause

Two client constructor mismatches in getClients() (lines 390-391):

Client Expected Signature Received Impact
ComprehensiveAnalysisClient ({ courtListener, secEdgar, federalRegister, uspto }) (exaKey, rateLimiter) Constructor crash → MCP server null → all workloads blocked
ExaClient (rateLimiter) (exaKey, rateLimiter) exaKey string consumed as rateLimiter; real rateLimiter discarded

Why This Only Affected GCE (Not Local)

Two architecturally different servers exist:

Environment Entry Point Client Init
Local (npm start) index.jsEnhancedLegalMcpServer.js Constructs ComprehensiveAnalysisClient correctly (lines 220-225)
GCE (Dockerfile) src/server/claude-sdk-server.js directly Had broken constructor calls (lines 390-391)

The Dockerfile runs claude-sdk-server.js directly, bypassing index.js. The local MCP stdio server (EnhancedLegalMcpServer) never calls getClients() in the SDK server — they share API client classes but initialize them independently.

Fix

  • ExaClient: (exaKey, rateLimiter)(rateLimiter)
  • ComprehensiveAnalysisClient: Moved construction after clients object, passing { courtListener: clients.courtListenerWeb, secEdgar: clients.secWeb, federalRegister: clients.federalRegisterWeb, uspto: clients.usptoWeb } — matching EnhancedLegalMcpServer.js pattern

Commit: d28f483
Version: v4.12.3
Files: src/server/claude-sdk-server.js, CHANGELOG.md

Verification

  • Local server unaffected (different entry point)
  • GCE rebuild + redeploy
  • E2E research workload through frontend

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions