Skip to content

[MCP T10] Code-specific GraphRAG prompt overrides #658

@DvirDukhan

Description

@DvirDukhan

Phase 1 ticket T10. Depends on #657 (T9 GraphRAG init).

Context

The ask tool's NL→Cypher quality depends heavily on the system prompts. Today the prompts live in api/prompts.py (CYPHER_GEN_SYSTEM, CYPHER_GEN_PROMPT, GRAPH_QA_SYSTEM, GRAPH_QA_PROMPT — lines 1-113) and are tuned for the existing FastAPI chat endpoint. The MCP ask tool may want slightly different framing in the future (e.g. "the user is an AI agent inspecting code, not a human asking conceptual questions"), so this ticket creates a dedicated prompt module that re-exports the existing prompts and provides a clean hook for future divergence.

For v1, the module is mostly a re-export. The value is the seam — once T11 ships, prompt iteration happens in api/mcp/code_prompts.py without touching api/prompts.py.

Scope

In:

  • New api/mcp/code_prompts.py:
    from api.prompts import (
        CYPHER_GEN_SYSTEM,
        CYPHER_GEN_PROMPT,
        GRAPH_QA_SYSTEM,
        GRAPH_QA_PROMPT,
    )
    
    __all__ = ["CYPHER_GEN_SYSTEM", "CYPHER_GEN_PROMPT", "GRAPH_QA_SYSTEM", "GRAPH_QA_PROMPT"]
    Plus a docstring explaining the seam and a # TODO marker for where to start diverging.
  • Update api/mcp/graphrag_init.py (from T9) to import from api.mcp.code_prompts instead of api.prompts directly. This should be a one-line change since T9 left a TODO(T10) marker.
  • New tests/mcp/test_code_prompts.py:
    • Snapshot test: pin the text of all four prompt constants. If api/prompts.py is edited unexpectedly, this test fails — catches accidental drift.
    • Re-export test: assert all four constants are importable from api.mcp.code_prompts and equal the originals from api.prompts.

Out:

  • Actually changing prompts (Phase 1.5 prompt iteration).
  • The ask tool itself (T11).

Files to create / modify

  • new api/mcp/code_prompts.py
  • modified api/mcp/graphrag_init.py (one-line import swap)
  • new tests/mcp/test_code_prompts.py

Acceptance criteria

  • api/mcp/code_prompts.py exists and re-exports the four constants.
  • api/mcp/graphrag_init.py imports prompts from api.mcp.code_prompts (no longer from api.prompts directly).
  • Snapshot test pins the prompt text. Updating api/prompts.py requires either updating the snapshot (intentional) or seeing this test fail (catches accidental edits).
  • Re-export test verifies all four constants are present and equal the originals.
  • All T9 tests still pass.
  • CI workflow [MCP T2] CI workflow with FalkorDB service for MCP tests #649 green.

Dependencies

Out of scope (do NOT do in this PR)

  • Actual prompt content changes — that's Phase 1.5 prompt iteration with real-LLM E2E.
  • The ask tool (T11).
  • A separate prompt-config file format / hot-reload (overengineering).

Notes for the implementer

  • This ticket is intentionally tiny (a re-export module + a snapshot test). It exists to create a stable seam, not to do work.
  • The snapshot test should compare against an inline string constant rather than a separate snapshot file. Keeps the "what is pinned" obvious.
  • Document in the module docstring why this layer exists ("seam for future MCP-specific prompt divergence — see Phase 1.5 prompt iteration").

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestmcpMCP server (model context protocol) work

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions