Intelligent code knowledge graph for AI coding agents β 71% cheaper, 72% faster
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste the JSON block into your client's configuration file under mcpServers, then restart the application.
Intelligent code knowledge graph for AI coding agents
71% cheaper, 72% faster, 82% fewer tool calls vs baseline Grep+Read
on 6 real-world repos (Sonnet 4.6) β from a single codemesh index.
Benchmarks Β· Quick Start Β· Integrations Β· Write-Back Β· How It Works Β· API Reference Β· Full Results
AI coding agents waste 40-80% of their tokens on discovery β grepping through files, reading irrelevant code, and rebuilding context they've already seen in previous sessions.
On a 600-file codebase, a typical exploration task involves 10+ file reads before the agent even knows what's relevant.
Codemesh is an MCP server that gives agents a persistent, queryable knowledge graph. The graph gets smarter over time: agents write back what they learn, so the next session starts informed.
Benchmarked on 6 real-world codebases (Alamofire, Excalidraw, VS Code, Swift Compiler, pydantic-validators, pydantic-basemodel) with Claude Sonnet 4.6, compared alongside baseline and graph-based approaches for context.
Full methodology, per-repo breakdowns, and pairwise comparisons: docs/benchmark-results.md | Early pydantic evals
| Mode | Alamofire | Excalidraw | VS Code | Swift Compiler1 | pydantic-validators | pydantic-basemodel | Avg |
|---|---|---|---|---|---|---|---|
| Baseline | $0.54 | $0.89 | $0.21 | $0.83 | $1.32 | $0.78 | $0.76 |
| Codemesh MCP | $0.25 | $0.21 | $0.16 | $0.23 | $0.33 | $0.13 | $0.22 |
| Codemesh CLI | $0.67 | $0.51 | $0.16 | $0.83 | $1.00 | $0.18 | $0.56 |
| Codegraph | $0.37 | $0.56 | $0.57 | $0.74 | $0.29 | $0.19 | $0.45 |
| Mode | Alamofire | Excalidraw | VS Code | Swift1 | pydantic-v | pydantic-b | Avg |
|---|---|---|---|---|---|---|---|
| Baseline | 180s | 191s | 87s | 199s | 352s | 232s | 207s |
| Codemesh MCP | 78s | 45s | 35s | 87s | 72s | 32s | 58s |
| Codemesh CLI | 226s | 177s | 62s | 227s | 235s | 51s | 163s |
| Codegraph | 134s | 180s | 192s | 199s | 75s | 60s | 140s |
| Mode | Alamofire | Excalidraw | VS Code | Swift1 | pydantic-v | pydantic-b | Avg |
|---|---|---|---|---|---|---|---|
| Baseline | 31 | 48 | 12 | 29 | 84 | 65 | 45 |
| Codemesh MCP | 9 | 5 | 3 | 14 | 14 | 3 | 8 |
| Codemesh CLI | 30 | 32 | 12 | 56 | 64 | 9 | 34 |
| Codegraph | 31 | 35 | 44 | 44 | 20 | 12 | 31 |
| Mode | Alamofire2 | Excalidraw | VS Code | Swift Compiler | pydantic-validators | pydantic-basemodel | Avg |
|---|---|---|---|---|---|---|---|
| Baseline | n/a | 9 | 8 | 7 | 2 | 9 | 7.0 |
| Codemesh MCP | 9 | 9 | 7 | 8 | 7 | 7.8 | 7.9 |
| Codemesh CLI | 9 | 7 | 7 | 9 | 1 | 8.4 | 6.9 |
| Codegraph | 8 | 9 | 8.7 | 8 | 8 | 9 | 8.4 |
| Repo | Baseline | Codemesh MCP | Cost saved | Time saved |
|---|---|---|---|---|
| Alamofire | $0.54 | $0.25 | β54% | β57% (180s β 78s) |
| Excalidraw | $0.89 | $0.21 | β76% | β76% (191s β 45s) |
| VS Code | $0.21 | $0.16 | β24% | β60% (87s β 35s) |
| Swift Compiler1 | $0.83 | $0.23 | β72% | β56% (199s β 87s) |
| pydantic-validators | $1.32 | $0.33 | β75% | β79% (352s β 72s) |
| pydantic-basemodel | $0.78 | $0.13 | β83% | β86% (232s β 32s) |
| Average | $0.76 | $0.22 | β71% | β72% |
[!NOTE] Codemesh MCP achieves the lowest cost and fastest time of any mode tested β 71% cheaper and 72% faster than baseline on average across 6 repos, using 82% fewer tool calls (8 vs 45). Quality is comparable to baseline (7.9 vs 7.0); Codegraph edges Codemesh on quality (8.4) but at roughly double the cost ($0.45 vs $0.22). Every repo shows cost and time savings β including the comprehension-heavy queries (Excalidraw, pydantic-basemodel) that regressed in prior builds of codemesh.
Or run directly without installing:
Verify the install:
codemesh --versionshould print the package version.
Codemesh offers two ways to integrate with AI agents:
Add to your Claude Code MCP config (~/.claude/mcp-servers.json or project .mcp.json):
The agent gets native MCP tools:
codemesh_answer β one-call question answering (PRIMARY)codemesh_explore β search, context (multi-target), impactcodemesh_trace β follow call chainscodemesh_enrich / codemesh_workflow β write backcodemesh_status β health checkBest for: Opus, structured workflows, enrichment/write-back
No MCP config needed. The agent calls codemesh directly via Bash:
All commands return JSON to stdout. No MCP server process, no protocol overhead.
Best for: Sonnet/Haiku, speed-sensitive workflows, simpler setup
| MCP Server | CLI Mode | |
|---|---|---|
| Setup | MCP config file | Just export CODEMESH_PROJECT_ROOT |
| Overhead | MCP protocol per call | Zero β direct subprocess |
| Enrichment | Native codemesh_enrich tool | Via Bash("codemesh enrich ...") |
| Best model | Opus (follows MCP well) | Sonnet (55% cheaper, 61% faster than baseline) |
| Recommended | Complex codebases | Default choice |
The agent now has 6 new tools. Query the graph before reading code:
Codemesh speaks the Model Context Protocol, so any MCP-compatible client can use it. Paste one of the snippets below, restart the client, and the six codemesh_* tools show up in the agent's toolbox.
Add to ~/.claude/mcp-servers.json (user-wide) or .mcp.json (project-local):
Edit claude_desktop_config.json:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.jsonRestart Claude Desktop. Codemesh's tools will appear in the tool picker (hammer icon).
Swift Compiler's codemesh index failed to complete (indexer regression on 30k+ file codebases β see known issues). The codemesh numbers above reflect agent behavior with an empty retrieval graph, falling back to Read + LSP β still ahead of baseline, but unrepresentative of codemesh's capability on a properly-indexed Swift repo. β© β©2 β©3 β©4
Baseline for Alamofire hit a judge error (score recorded as 0 but not meaningful); excluded from the Baseline average. β©
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/codemesh)<a href="https://allmcps.com/mcp/codemesh"><img src="https://allmcps.com/api/badge/codemesh?style=directory" alt="Codemesh on AllMCPs" /></a>