MCP Tools and Prompts Exposed by the Code-Review-Graph Server: Complete Reference

The Code-Review-Graph server exposes 14+ MCP tool endpoints and 5 prompt templates for code review workflows, all registered via FastMCP decorators in main.py.

The Code-Review-Graph repository (tirth8205/code-review-graph) provides an MCP (Model-Centric Programming) service built on FastMCP. When you run code-review-graph serve, the server registers a comprehensive set of tool and prompt endpoints that LLM clients can invoke for intelligent code review. This article catalogs every MCP tool and prompt template exposed by the server, with source file references and usage examples.


Graph Lifecycle and Change Detection Tools

build_or_update_graph_tool

(Re)builds the knowledge graph for a repository. Supports incremental updates or full rebuilds via the force parameter.

Source: [code_review_graph/main.py, lines 99-119](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py#L99-L119)


# Example: Incremental update

client.call("build_or_update_graph_tool", repo_root="/path/to/repo", force=False)

# Example: Force full rebuild

client.call("build_or_update_graph_tool", repo_root="/path/to/repo", force=True)

detect_changes_tool

Detects git changes, scores risk, and produces a prioritized review guide. This is the entry point for automated PR review workflows.

Source: [code_review_graph/main.py, lines 632-667](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py#L632-L667)


Impact Analysis and Query Tools

get_impact_radius_tool

Traverses the graph to show which nodes and files are affected by a set of changed files. Essential for understanding blast radius of modifications.

Source: [code_review_graph/main.py, lines 219-241](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py#L219-L241)

resp = client.call(
    "get_impact_radius_tool",
    changed_files=["src/auth.py", "src/models/user.py"],
    max_depth=2,
    detail_level="minimal"  # or "full"

)
print(resp["affected_files"])
print(resp["risk_score"])

query_graph_tool

Executes predefined query patterns: callers_of, callees_of, tests_for, implements, depends_on, and more.

Source: [code_review_graph/main.py, lines 246-285](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py#L246-L285)


Search and Statistics Tools

semantic_search_nodes_tool

Performs hybrid keyword + embedding search over graph nodes. Combines SQLite FTS with vector similarity for accurate code discovery.

Source: [code_review_graph/main.py, lines 307-354](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py#L307-L354)

results = client.call(
    "semantic_search_nodes_tool",
    query="user authentication middleware",
    kind="Function",  # or "Class", "Module", "File"

    limit=10,
    hybrid_weight=0.7  # 0=keyword only, 1=embedding only

)

list_graph_stats_tool

Returns repository-wide statistics: total nodes, edges, languages detected, last update timestamp, and storage size.

Source: [code_review_graph/main.py, lines 408-420](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py#L408-L420)


Community, Flow, and Traversal Tools

Tool Purpose Source
list_communities_tool Enumerate code communities (clusters of related modules) [main.py, lines 546-560](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py#L546-L560)
list_flows_tool List execution flows extracted from call graphs [main.py, lines 561-575](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py#L561-L575)
get_flow_tool Retrieve detailed steps for a specific flow [main.py, lines 576-590](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py#L576-L590)
get_affected_flows_tool Find flows impacted by file changes [main.py, lines 591-605](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py#L591-L605)
traverse_graph_tool Free-form BFS/DFS traversal with custom filters [main.py, lines 546-605](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py#L546-L605)

Architectural Insight Tools

These tools analyze structural properties of the codebase to identify hotspots and technical debt:

  • get_architecture_overview_tool — High-level module dependency map
  • get_hub_nodes_tool — Nodes with highest centrality (critical files)
  • get_bridge_nodes_tool — Chokepoints between communities
  • get_knowledge_gaps_tool — Areas with low test coverage or documentation
  • get_surprising_connections_tool — Unexpected cross-module dependencies

Source: [code_review_graph/main.py, lines 609-686](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py#L609-L686)


# Find the most critical files in the codebase

hubs = client.call("get_hub_nodes_tool", top_n=20, metric="betweenness")
for node in hubs["nodes"]:
    print(f"{node['name']}: {node['risk_score']}")

Refactoring and Wiki Generation Tools

refactor_tool and apply_refactor_tool

Graph-driven refactoring support:

  • Rename preview — Simulate renames and detect broken references
  • Dead code detection — Find unreachable functions and classes
  • Apply edits — Execute safe refactoring operations

Source: [code_review_graph/main.py, lines 698-746](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py#L698-L746)

generate_wiki_tool and get_wiki_page_tool

Auto-generate markdown documentation per community and serve individual pages for developer wikis.

Source: [code_review_graph/main.py, lines 717-763](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py#L717-L763)


Repository Registry and Multi-Repo Tools

Tool Purpose Source
list_repos_tool Enumerate registered repositories in the global registry [main.py, lines 738-750](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py#L738-L750)
cross_repo_search_tool Semantic search across multiple repositories [main.py, lines 751-767](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py#L751-L767)

Embedding Management

embed_graph_tool

Generates vector embeddings for every node in the graph. Supports local inference and cloud providers (OpenAI, Cohere, etc.).

Source: [code_review_graph/main.py, lines 362-401](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py#L362-L401)


# Local embedding with sentence-transformers

client.call("embed_graph_tool", provider="local", model="all-MiniLM-L6-v2")

# Cloud embedding

client.call("embed_graph_tool", provider="openai", model="text-embedding-3-small")

MCP Prompt Templates Exposed

The server registers 5 prompt templates via @mcp.prompt() decorators. These return token-efficient message sequences that guide LLM workflows.

Prompt Template Use Case Source
review_changes Automated PR review with risk scoring [main.py, lines 968-985](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py#L968-L985)
architecture_map Generate visual/textual architecture overviews [main.py, lines 986-994](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py#L986-L994)
debug_issue Root-cause analysis for bugs using graph traversal [main.py, lines 995-1003](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py#L995-L1003)
onboard_developer Interactive codebase exploration for new team members [main.py, lines 1004-1012](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py#L1004-L1012)
pre_merge_check Final validation before merging to main [main.py, lines 1013-1020](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py#L1013-L1020)

The prompt implementations delegate to code_review_graph/prompts.py, which contains the actual message templates (e.g., review_changes_prompt(), architecture_map_prompt()).


# Use a prompt template

messages = client.call_prompt("review_changes", base="main", head="feature-branch")
for msg in messages:
    print(f"[{msg.role}] {msg.content[:100]}...")

Server Startup and Tool Filtering

The MCP tool set can be filtered at startup via CLI flag or environment variable.


# Only expose core review tools

code-review-graph serve --tools detect_changes_tool,get_impact_radius_tool,semantic_search_nodes_tool

# Or via environment

export CRG_TOOLS="detect_changes_tool,get_impact_radius_tool"
code-review-graph serve

The filtering logic is implemented in _apply_tool_filter at [main.py, lines 1022-1055](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py#L1022-L1055).


HTTP Transport and Security

When started with --http, the server exposes a JSON-RPC endpoint with origin validation:

code-review-graph serve --http --host 127.0.0.1 --port 5555 --allowed-origins "https://my-ide.example.com"

The http_origin_guard middleware ([http_origin_guard.py](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/http_origin_guard.py)) protects against DNS-rebinding attacks by validating Host and Origin headers.


Complete Tool Reference Table

Category Tool Name Line Range in main.py
Graph lifecycle build_or_update_graph_tool 99-119
Change detection detect_changes_tool 632-667
Impact analysis get_impact_radius_tool 219-241
Query query_graph_tool 246-285
Search semantic_search_nodes_tool 307-354
Statistics list_graph_stats_tool 408-420
Communities list_communities_tool 546-560
Flows list_flows_tool, get_flow_tool, get_affected_flows_tool 561-605
Traversal traverse_graph_tool 546-605
Architecture get_architecture_overview_tool, get_hub_nodes_tool, get_bridge_nodes_tool, get_knowledge_gaps_tool, get_surprising_connections_tool 609-686
Refactoring refactor_tool, apply_refactor_tool 698-746
Wiki generate_wiki_tool, get_wiki_page_tool 717-763
Registry list_repos_tool, cross_repo_search_tool 738-767
Embedding embed_graph_tool 362-401

Summary

  • 14 MCP tools are exposed via @mcp.tool() decorators in main.py, covering graph building, change detection, impact analysis, semantic search, architectural insights, and refactoring.
  • 5 prompt templates (review_changes, architecture_map, debug_issue, onboard_developer, pre_merge_check) provide token-efficient LLM workflows.
  • All tools honor the global --repo flag or per-call repo_root parameter via _resolve_repo_helper.
  • Tool exposure can be filtered with --tools or CRG_TOOLS for security and performance.
  • The actual implementations live in code_review_graph/tools/*.py, with analysis_tools.py, query.py, and _common.py containing the core logic.

Frequently Asked Questions

What transport protocols does the Code-Review-Graph MCP server support?

The server supports stdio (default for CLI integration) and HTTP (--http flag) transports. The HTTP transport includes http_origin_guard middleware for request validation against DNS-rebinding attacks, configured via --allowed-origins.

How do I call MCP tools programmatically from Python?

Use fastmcp.FastMCPClient to connect via stdio or HTTP, then call client.call(tool_name, **kwargs). For prompt templates, use client.call_prompt(prompt_name, **kwargs) to receive a list of Message objects ready for LLM consumption.

Where are the actual tool implementations located?

While main.py contains the MCP wrapper decorators, the concrete implementations reside in code_review_graph/tools/: analysis_tools.py for architectural insights, query.py for graph traversal and search, and _common.py for shared helpers like store access and builtin call lists.

Can I restrict which tools are exposed to clients?

Yes. Pass --tools comma,tool,names at startup or set the CRG_TOOLS environment variable. The _apply_tool_filter function (lines 1022-1055) selectively registers only the specified tools with the FastMCP server instance.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →