Skip to content

Add configurable AI role/system prompt support for MCP server #1320

Description

@sanju234-san

Summary

When CodeGraphContext is used as an MCP server, the AI assistant receives raw graph query results with no guidance on how to reason about them. This issue proposes adding a configurable AI role — a system-level prompt that shapes how the AI interprets and responds to code graph data.

Problem

Currently, the MCP server returns structured graph data (callers, callees, complexity scores, etc.) but provides no context to the AI about:

  • What role it should take (e.g. "code reviewer", "architecture explainer", "dead code auditor")
  • How to format or prioritize its responses
  • What the graph data semantically means

This means the quality of AI responses depends entirely on the user's prompt engineering, and varies across AI clients (Claude, Cursor, Copilot, etc.).

Proposed Solution

Add a --role or --ai-role option to codegraphcontext mcp start (and optionally to mcp setup) that injects a system prompt prefix when the MCP server responds.

Example built-in roles:

  • reviewer — frame responses as a senior code reviewer
  • architect — explain structural relationships and suggest improvements
  • auditor — focus on dead code, complexity, and risk areas
  • explainer — describe code for onboarding/documentation purposes
  • custom — read from a ~/.codegraphcontext/role.md file
codegraphcontext mcp start --role reviewer
codegraphcontext mcp start --role custom

Why This Is Implementable

  • The MCP server already constructs response payloads; this is an additive wrapper
  • Role definitions can be stored as simple .md or .txt files under ~/.codegraphcontext/roles/
  • No changes to graph DB or parsers needed
  • A default "neutral" role maintains backward compatibility

Expected Outcome

Users get more consistent, context-aware AI responses when querying their codebase through any MCP-compatible client, without needing to manually craft system prompts.

Interested in contributing?

Happy to work on this if the maintainer is open to it. Can start with a draft PR for the CLI flag + one built-in role.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Backlog tasks
    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions