Built for AI agents tackling sprawling C++ refactors that blow past context windows. Parses repos with tree-sitter AST, builds a NetworkX dependency graph, then exposes MCP tools like get_callers, detect_cycles, and get_orphan_functions so your agent queries relationships instead of reading raw files. Ships with analyze_codebase for GitHub ingestion and generate_mermaid_graph for token-safe visual exports. Runs stdio locally or HTTP over Docker on Hugging Face Spaces. The author benchmarked it against LLVM's 67k files and reports 30x speedup over sequential parsing. Reach for this when you need accurate upstream/downstream tracing before touching legacy code that regex parsers can't handle.
Legacy C++ codebases are too large for LLM context windows, leading to:
LegacyGraph‑MCP is a Model Context Protocol (MCP) server that exposes a C++ codebase as a knowledge graph. Agents query the graph instead of raw text:
"Agent: Which functions call
calculate_risk()?" "MCP:process_loan()andassess_credit()"
tree‑sitter – 100 % C++ syntax coverage.LegacyGraph‑MCP now uses JSON for cache files (.legacygraph.json) instead of unsafe pickle, and supports a constrained‑resource benchmark profile.
| Metric | Sequential (v0.1) | Distributed (v0.3) | ⚡ Improvement |
|---|---|---|---|
| CPU Utilisation | ~6 % (1 core) | ~80 % dynamic cores | Adaptive |
| AST Build Time | 5 h | 10 min | ≈30× |
| Throughput | 3.8 files/s | 113 files/s | ≈30× |
| Incremental Updates | N/A | < 1 s | Instant |
src/
├── __init__.py # package root
├── __main__.py # CLI entry point (python -m src)
├── server.py # MCP registration & server card
│
├── core/ # business logic
│ ├── graph.py # NetworkX dependency graph model
│ └── parser.py # tree‑sitter C++ parser
│
├── tools/ # MCP tool functions
│ ├── analysis.py # analyze_codebase (ingestion)
│ ├── queries.py # get_callers, get_callees, detect_cycles …
│ └── export.py # Mermaid graph generation & export
│
└── utils/ # cross‑cutting infrastructure
├── config.py # MCP_MODE, CPP_EXTENSIONS
├── logger.py # centralized logging
├── services.py # singletons (graph, parser)
└── helpers.py # git clone, directory scanning, Mermaid builder
graph LR
A[AI Agent] -->|JSON‑RPC| B[MCP Server]
B -->|Parse| C[tree‑sitter]
B -->|Query| D[NetworkX Graph]
C -->|AST| D
D -->|Cycles/Deps| B
E{MCP_MODE} -->|local| F[stdio + Disk]
E -->|cloud| G[HTTP + /tmp/ Clone]
📖 See
ARCHITECTURE.mdfor detailed component diagrams.
This section helps developers run the code directly, develop the server, and test it locally.
Ensure you have Python 3.11+ and poetry installed.
git clone https://github.com/RohitYadav34980/LegacyGraph-MCP.git
cd LegacyGraph-MCP
# Install dependencies using Poetry
pip install poetry
poetry install
To develop or verify the MCP server running natively:
python -m src --mode local
Test the cloud endpoints locally without Docker:
python -m src --mode cloud --transport http --path /mcp --host 127.0.0.1 --port 7860
(--transport streamable-http is accepted as an alias for http; sse remains available for legacy clients.)
This forces the server to bind to localhost:7860, mimicking the Hugging Face Spaces environment.
Test if your local setup works perfectly:
# Run the internal validation script
python tools/verifier.py
Expected output: 100 % accuracy on dependency detection.
This project is optimized for Hugging Face Spaces using the Docker SDK.
Create a new Space on huggingface.co and select Docker as the SDK.
The easiest way is to push your existing local repository to the Space:
# Add the Hugging Face Space as a remote
git remote add hf https://huggingface.co/spaces/Rohitadav/GraphPulse
# Push your code (requires an HF Access Token)
git push hf main --force
Once pushed, the Space will automatically build the Dockerfile and start the server on port 7860. You can then consume this server via SSE in any MCP-compatible client.
Connect your AI agent to the Graph engine using these configurations.
If you've deployed to Hugging Face or another remote hosting, or just want to use the published Remote MCP setup, use Smithery. You can view the server directly on Smithery.
npx -y @smithery/cli@latest mcp add labsofuniverse/legacy-mcp-analyzer --client claude-code
If you want to plug your local development environment directly into Claude Desktop, update your configuration file.
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.jsonAdd the following configuration, ensuring you replace the cwd paths with the absolute path where you cloned this repository.
{
"mcpServers": {
"legacy-mcp-analyzer": {
"command": "python",
"args": [
"-m",
"src",
"--mode",
"local"
],
"cwd": "C:\\path\\to\\your\\LegacyGraph-MCP"
}
}
}
Note: Make sure to escape backslashes on Windows (e.g. C:\\Users\\...), or use forward slashes on macOS/Linux.
| Tool | Description | Mode |
|---|---|---|
analyze_codebase | Unified ingestion (repo URL, patch, raw files, or local dir) | Both |
get_file_functions | List functions defined in a specific source file | Both |
get_file_coupling | Cross‑file coupling report (file A → file B) | Both |
get_callers | Find upstream dependencies | Both |
get_callees | Find downstream dependencies | Both |
detect_cycles | Identify circular dependencies | Both |
get_orphan_functions | Find unused code | Both |
generate_mermaid_graph | Return Mermaid diagram inline (token‑safe) | Both |
export_ide_graph | Save Mermaid .md file to local disk | Local only |
# Unit + integration tests (≈30 cases)
python -m pytest tests/ -v
# End‑to‑end verifier against sample legacy project
python tools/verifier.py
Current Accuracy: 100 % (all dependencies, cycles, and orphan detection verified).
Review the complete documentation suite for deep-dives into the architecture and usage:
| Document | Description |
|---|---|
PROJECT_MANUAL.md | In‑depth guide, API reference, deployment modes |
ARCHITECTURE.md | Detailed architecture, data flows, component diagrams |
CONTRIBUTING.md | Development standards, commit protocol, PR process |
CHANGELOG.md | Version history and release notes |
git checkout -b feature/your-feature.mypy typing, Google‑style docstrings, conventional commits.pytest – ensure all tests pass.Built with:
Made with ❤️
Thanks for visiting!
ray0907/git-mcp-server
cyanheads/git-mcp-server
io.github.b1ff/atlassian-dc-mcp-bitbucket
io.github.b1ff/atlassian-dc-mcp-jira
com.mcparmory/atlassian-jira
sirlordt/vscode-terminal-mcp