Skip to content

0.5.3: MCP initialize fails with "name 'LLM_SYSTEM_PROMPT' is not defined" — stdio server unusable #1451

Closed

Description

@Ajay-Chandrasekaran

Summary

codegraphcontext 0.5.3 cannot complete the MCP initialize handshake over stdio. Every initialize request returns a JSON-RPC internal error, so no stdio MCP client can connect (Claude Code, Cursor, etc.). 0.5.2 is unaffected — this is a regression introduced and released on the same day.

{"jsonrpc": "2.0", "id": 1, "error": {"code": -32603, "message": "Internal error: name 'LLM_SYSTEM_PROMPT' is not defined"}}

Reproduction

pip install codegraphcontext==0.5.3
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"t","version":"1"}}}' \
  | cgc mcp start

Observed:

Starting CodeGraphContext Server...
MCP Server is running. Waiting for requests...
{"jsonrpc": "2.0", "id": 1, "error": {"code": -32603, "message": "Internal error: name 'LLM_SYSTEM_PROMPT' is not defined"}}

Expected: an initialize result containing serverInfo and instructions.

Root cause

src/codegraphcontext/server.py references the module-level LLM_SYSTEM_PROMPT when building the initialize response, but no longer imports it:

  • L19: from .prompts import build_system_prompt
  • L808: "instructions": LLM_SYSTEM_PROMPT,

Introduced by c9a9f7e ("feat: Add cgc prompt command for custom LLM prompts (#583)", #613), which changed the import from LLM_SYSTEM_PROMPT to build_system_prompt and left the L808 reference in place.

Both names are needed — build_system_prompt() is called at L795, and LLM_SYSTEM_PROMPT is still used at L808.

Scope

  • The initialize handler at L793 is the only one and is unconditional, so the failure is total for stdio — not intermittent or config-dependent. The server starts and logs normally, which makes it look healthy.
  • The SSE transport (api/mcp_sse.py) does not reference either symbol and is unaffected. That is plausibly why this got through.
  • No test covers the initialize handshake — tests/integration/mcp/test_mcp_server.py exercises tool routing only.

Affected versions

Verified by grepping server.py in each published wheel:

Version Released server.py L19 Status
0.4.9 2026-05-13 import LLM_SYSTEM_PROMPT works
0.5.1 2026-06-12 import LLM_SYSTEM_PROMPT works
0.5.2 2026-07-25 import LLM_SYSTEM_PROMPT works
0.5.3 2026-07-26 import build_system_prompt broken

main currently carries the bug as well.

Fix

One line:

from .prompts import LLM_SYSTEM_PROMPT, build_system_prompt

PR follows, with a regression test that drives _run_loop with a real initialize request (fails before the fix with the exact error above, passes after).

Workaround meanwhile: pin codegraphcontext==0.5.2.

Environment

  • codegraphcontext 0.5.3 (pip)
  • Python 3.13, macOS 15 (arm64)
  • Client: Claude Code (stdio transport)

Activity

  1. github-actions commented on Jul 27, 2026

    @github-actions
    Contributor

    Hi! 👋 Join our CodeGraphContext Discord channel to collaborate: https://discord.gg/dR4QY32uYQ

  2. moved this from Backlog tasks to In progress in CGC Progress Boardon Jul 27, 2026
  3. moved this from In progress to Done in CGC Progress Boardon Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions