RepoGraph-Honest MCP Server
{ "answer": "This is an MCP server called HonestCode that deterministically verifies AI-generated code against your actual project structure and installed dependencies to catch hallucinations like undefined symbols, wrong API calls, and dead code — 100% locally.
Core capability: scan_file performs AST-based scanning of Python files to detect undefined symbols, missing imports, and incorrect API calls, returning structured JSON results with issue type, name, and line number.
Additional capabilities (opt-in via HONESTCODE_TOOLS env variable):
Project indexing (
index_project): Build a module-qualified symbol index with content-hash caching; supportsforce_rebuildand a backgroundwatchmode for auto re-indexing.Dependency loading (
load_project_deps,load_package_apis): Parserequirements.txt/pyproject.tomland load public API signatures of installed packages.Symbol & API verification (
check_symbol,check_api): Verify identifiers are defined in the indexed project and check library API calls exist, with fuzzy typo suggestions (e.g.,math.sqrtt→math.sqrt).Type/structural checks (
validate_types): Detect iterating overNone, wrong argument counts for builtins, calling constants, and string methods on non-string constants.Sandboxed execution (
execute_code): Run code in an isolated subprocess with timeout, memory limits, and restrictedPYTHONPATH.Call graph exploration (
explore_call_graph,explore_impact): Return definitions, callers, and callees of a symbol; compute transitive blast radius up to configurable depth.Affected-files tracing (
affected_files): Trace a git diff through the call graph to identify impacted files and tests — CI-friendly.Dead-code detection (
find_dead_code): Find unused symbols with entrypoint support andignore_patterns.Code-clone detection (
find_similar_code): Find function-level clones via sequence similarity with a length-ratio pre-filter.Regex code search (
search_code): FTS5-accelerated regex search across project source files.Project stats (
get_project_stats): Return symbol count and dependency API statistics.File watcher management (
stop_watching): Stop background watcher started byindex_project(watch=true).Tool routing (
choose_tool): Map natural-language queries to the best tool.
Multi-language support: Optional symbol extraction for JavaScript, TypeScript, Go, Rust, and Java via tree-sitter extras.
Integration flexibility: Every tool has a 1:1 CLI subcommand (honestcode scan, honestcode index, etc.) for CI usage, is importable as a Python function from honestcode.mcp.tools, and supports both stdio and SSE transports with auto-configuration for Claude Code, Cursor, VS Code, and Windsurf."
}
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@RepoGraph-Honest MCP ServerScan src/utils.py for undefined symbols"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
HonestCode MCP Server
Catch AI code hallucinations before they reach your editor.
A lightweight Model Context Protocol (MCP) server that verifies AI-generated code against your actual project structure and installed dependencies — detecting undefined symbols, wrong API calls, dead code, and type mismatches in real time.
100% local. No data leaves your machine.
Contents
Related MCP server: javalens-mcp
Why HonestCode?
AI coding assistants hallucinate. They invent function names, fabricate library APIs, and produce dead code. HonestCode acts as a deterministic verification layer between the model and your editor — pure AST analysis, no LLM calls, no network requests.
graph LR
A["AI Model generates code"] -->|sends code| B["HonestCode verifies against project"]
B -->|clean code| C["Editor receives verified code"]One tool by default: scan_file
By default the server exposes one primary tool — scan_file. Give it a Python file and it
returns every undefined symbol, incorrect API call, and structural issue in a single trip.
Exposing a single tool is deliberate. Measured agent behavior shows that one well-aimed tool
steers agents to a direct answer better than a menu of narrower ones — fewer mis-picks, fewer
round-trips. 16 additional tools exist for power users; opt in via the HONESTCODE_TOOLS
environment variable (see Environment Variables).
Key differentiators
HonestCode | grep / Read | RAG over code | |
Deterministic | AST-based, reproducible | Exact string match | Embedding variance |
Cross-file | Module-qualified symbols | Single-file only | Chunk-level |
Type-aware | Argument counts, None iteration | No | No |
Zero latency | Pre-indexed, cached | Per-query scan | Per-query embed |
100% local | No network calls | No | Often requires API |
Performance
Numbers below are measured, not estimated. Re-run them yourself:
# Local project
python scripts/benchmark.py --target /path/to/project --repeat 5
# External real-world repos (clones them into a temp dir)
python scripts/benchmark.py --repos psf/requests pallets/flask --format markdownMeasured on this repository (43 Python modules, ~7400 LOC, Python 3.14, median of 3 runs on a developer laptop, Windows):
Operation | Measured | Note |
| ~143 ms | Content-hash cached; skips unchanged files |
| < 1 ms | In-memory cache hit |
| ~35 ms | AST parse + symbol lookup |
| < 1 ms | Dictionary lookup on cached API index |
| ~1 ms | SQLite graph cache hit; cold rebuild ~278 ms |
| ~1.4 ms | Reads the persisted reference graph |
| ~3750 ms | O(n²) |
| ~16 ms | FTS5 candidate narrowing + regex on hits |
The call graph (definitions + references) is persisted to SQLite next to the
symbol index, keyed by content hashes of every source file. Graph queries
(explore_call_graph, find_dead_code, explore_impact, affected_files)
read from disk instead of re-parsing the project on each call — the first call
after a change pays the cold rebuild, every later call is a cache hit.
find_similar_code uses a length-ratio pre-filter but is still quadratic in
the number of functions; this is fine for small/medium projects but will need
a token-hash scheme for large codebases.
Note: the "hot" graph numbers above are in-process cache hits. A fresh process pays one full-tree SHA-256 pass (to validate the SQLite cache's freshness) on its first graph query after startup, then every later call is a cache hit. On this repo that validation adds roughly the cost of a cold
index_project(~143 ms).
Token savings vs. grep + Read exploration: ~60% fewer tool calls, ~45% fewer tokens on architecture questions spanning multiple files.
Quick Start
1. Install
pip install honestcodeOr from source:
git clone https://github.com/Fengrru/honestcode.git
cd honestcode-mcp
pip install -e .Requires Python >= 3.10
2. Configure your MCP client
Claude Code
claude mcp add honestcode -- honestcode-mcpOr manually add to ~/.claude.json:
{
"mcpServers": {
"honestcode": {
"command": "honestcode-mcp"
}
}
}Cursor
Add to .cursor/mcp.json (project) or ~/.cursor/mcp.json (global):
{
"mcpServers": {
"honestcode": {
"command": "honestcode-mcp"
}
}
}VS Code
Add to .vscode/mcp.json:
{
"servers": {
"honestcode": {
"command": "honestcode-mcp"
}
}
}Windsurf
Add to ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"honestcode": {
"command": "honestcode-mcp"
}
}
}Python (direct invocation)
{
"mcpServers": {
"honestcode": {
"command": "python",
"args": ["-m", "honestcode.mcp.server"]
}
}
}3. Verify setup
Restart your MCP client. The agent should be able to call scan_file. If not, see
Troubleshooting.
4. Use it
1. Index your project → index_project("/path/to/project")
2. Load dependency APIs → load_project_deps("/path/to/project")
3. Verify generated code → scan_file("/path/to/project/generated.py")Typical agent workflow — one call answers the question:
Agent: "Does this code have any hallucinated APIs?"
Tool: scan_file("src/services/auth.py")
Result: 2 issues found — undefined_call: validate_token (line 12),
undefined_call: db.fetch_all (line 27)Environment Variables
Variable | Default | Description |
|
| Comma-separated tool names to expose (or |
|
| Directory for cached symbol indices |
|
| Directory for SQLite graph caches (override for CI/tests) |
|
| Seconds before |
|
| MB memory limit for sandboxed execution (POSIX) |
|
| Logging verbosity ( |
HONESTCODE_TOOLS
Controls which tools the MCP server exposes. By default only scan_file is
registered; set this to a comma-separated list to expose more, or to all to
expose every tool:
export HONESTCODE_TOOLS=index,check_symbol,check_api,validate_types
export HONESTCODE_TOOLS=allscan_file is always included even if not listed. Unknown names are ignored
with a warning. Available tool names: scan_file, index, deps,
check_symbol, check_api, execute_code, validate_types,
find_dead_code, find_similar_code, explore_call_graph,
explore_impact, affected_files, stop_watching, search_code,
load_package_apis, get_project_stats, choose_tool.
A
honestcode.tomlconfig file for per-project rules and ignore patterns is planned — tracked on the Roadmap.
Multi-language support (optional)
Python is the fully supported language (stdlib ast). For JavaScript,
TypeScript, Go, Rust and Java, symbol extraction is available via the
optional tree-sitter extras:
pip install -e "honestcode[multi-language]"Once installed, scan_file accepts .js/.ts/.go/.rs/.java files and
reports undefined call sites using tree-sitter's grammar. Without the extras,
scan_file returns a clear message pointing at the install command instead of
failing. This keeps the default install dependency-free.
Supported Platforms and Agents
Runs anywhere Python 3.10+ does — no native build step, no node_modules,
no external services.
Platform | Support |
Windows | First-class (stdio + SSE, sandboxed execution) |
macOS | First-class (stdio + SSE, sandboxed execution) |
Linux | First-class (stdio + SSE, sandboxed execution, RLIMIT limits) |
Agent / Client | Config file | Auto-install |
Claude Code |
|
|
Cursor |
|
|
VS Code |
|
|
Windsurf |
| Manual (see Quick Start) |
Any stdio MCP client |
| — |
Any SSE MCP client |
| — |
See Quick Start for the manual JSON snippets and the
CLI Usage section for install/init/root project binding.
Tool Reference
Primary tool (always exposed)
scan_file(file_path)
AST-based scan for undefined calls, missing imports, and incorrect API usage in a Python file.
scan_file("/path/to/project/src/auth.py")
# {
# "success": true,
# "file": "/path/to/project/src/auth.py",
# "issues": [
# {"type": "undefined_call", "name": "validate_token", "line": 12},
# {"type": "undefined_call", "name": "db.fetch_all", "line": 27}
# ],
# "defined_symbols": 342
# }Issue types: undefined_call — function/method not defined in project or loaded dependencies.
Additional tools (opt-in)
Enable via the HONESTCODE_TOOLS environment variable (see
Environment Variables):
export HONESTCODE_TOOLS=index,check_symbol,check_api,execute_code,validate_typesTool | Purpose | Speed |
| Build module-qualified symbol index with content-hash caching | < 1s |
| Parse | < 5s |
| Verify an identifier is defined in the project | < 5ms |
| Verify a library API call exists (with fuzzy typo suggestions) | < 10ms |
| Structural checks: None iteration, wrong arg counts, calling constants | < 20ms |
| Run code in sandboxed subprocess with timeout and memory limits | varies |
| Return callers, callees, and blast-radius summary of a symbol | < 5ms (hot) |
| Blast radius of a symbol: transitively impacted symbols/files | < 10ms (hot) |
| Files/tests affected by a git diff, via reverse call-graph trace | < 50ms |
| Find unused symbols with entrypoint support | < 10ms (hot) |
| Detect function-level code clones via sequence similarity | < 2s |
| Regex search across project source files (FTS5-accelerated) | < 100ms |
| Load API signatures for a single installed package | < 3s |
| Return index statistics (symbol count, dependency APIs) | < 5ms |
| Stop the background file watcher started by | < 5ms |
| Map a natural-language query to the best tool (debugging) | < 5ms |
index_project(root_path, force_rebuild=False, watch=False)
Build or reuse the project symbol index. Returns indexed symbol count, root path, and cache status.
Set watch=True to start a background file watcher that re-indexes (and invalidates the graph
cache) whenever a source file changes, keeping the index fresh for long-running sessions.
explore_impact(symbol_name, max_depth=3)
Compute the blast radius of a symbol: which other symbols and files would be affected if it
changed, following callers and callees up to max_depth hops.
affected_files(base="HEAD", head=None, max_depth=4)
Trace a git diff through the call graph to find which files — especially tests — may be affected
by uncommitted changes (base vs the working tree) or a range of commits (base..head).
CI-friendly: run it after each commit to know exactly which tests to run.
load_project_deps(root_path)
Parse requirements.txt or pyproject.toml and load public API signatures of installed packages.
check_symbol(symbol_name, file_path=None)
Verify a symbol is defined in the indexed project. Symbols use module-qualified names (pkg.core.main).
check_api(api_name)
Check if a library API exists. Returns fuzzy suggestions for typos.
check_api("math.sqrt") # valid
check_api("math.sqrtt") # invalid → suggests "math.sqrt"validate_types(code)
Lightweight structural checks on code snippets:
Iterating over
None(includingdict.get()without default)Wrong argument counts for common builtins (
len,sum, etc.)Calling constant values
String methods on non-string constants
execute_code(code, prelude="", known_names=None)
Run code in a sandboxed subprocess with timeout and temp working directory.
explore_call_graph(symbol_name)
Return definitions, callers, and callees of a symbol.
find_dead_code(entrypoints=None, ignore_patterns=None, include_tests=True)
Find unused symbols. Provide entrypoints to keep known roots alive.
find_similar_code(threshold=0.85)
Find function-level code clones across the project. Uses length-ratio pre-filter for performance.
search_code(pattern, glob="*.py")
Regex search across project source files.
load_package_apis(package_name)
Load and cache API signatures for a specific installed package.
get_project_stats()
Return statistics about the currently indexed project.
CLI Usage
Every MCP tool has a CLI equivalent under the honestcode command, for
scripts and non-MCP harnesses. Output is JSON; exit code is non-zero when
issues are found (so it drops into CI pipelines cleanly).
# Index a project
honestcode index /path/to/project
honestcode index /path/to/project --force
# Load dependency APIs
honestcode deps /path/to/project
# Check a symbol
honestcode check-symbol pkg.core.helper
# Check an API
honestcode check-api pandas.read_csv
# Scan a file (exit 1 if issues found)
honestcode scan src/main.py
# Validate a code snippet (exit 1 if issues found)
honestcode validate "for x in None: pass"
# Execute code in a sandbox
honestcode execute "print(1+1)"
# Find dead code (exit 1 if any dead symbols found)
honestcode dead-code --entrypoints pkg.cli.main --no-tests
# Find similar code (exit 1 if any clones found)
honestcode similar --threshold 0.85
# Explore callers/callees of a symbol (includes blast-radius summary)
honestcode call-graph pkg.core.helper
# Blast radius of a symbol
honestcode impact pkg.core.helper --depth 3
# Files/tests affected by uncommitted changes (CI killer)
honestcode affected --base HEAD
honestcode affected --base main --head feature-branch
# Search code (exit 1 if matches found)
honestcode search "def \w+_helper"
# Load a single package's APIs
honestcode load-package numpy
# Show index statistics
honestcode stats
# Show which tool a query maps to
honestcode choose-tool "is my_symbol defined"
# Bind a directory as a project (creates .honestcode/) and discover the root
honestcode init /path/to/project
honestcode root
# Register the MCP server with Cursor / VS Code / Claude Code
honestcode install --dry-run
honestcode install --client cursor
# Keep an index fresh during long work sessions (Ctrl+C to stop)
honestcode watch /path/to/projectYou can also invoke it as a module:
python -m honestcode.cli scan src/main.pyThe
honestcode-mcpcommand starts the MCP server (stdio by default); usehonestcode-mcp --transport sse --port 8000for SSE.
Library Usage
Every MCP tool is also a plain function in honestcode.mcp.tools, so the
same verification logic can run inside your own Python code — no MCP client
required:
from honestcode.mcp.tools import check_symbol, index_project, scan_file
index_project("/path/to/project") # build/reuse the symbol index
print(scan_file("/path/to/project/src/auth.py")) # hallucination scan
print(check_symbol("pkg.core.main")) # symbol lookupRunnable examples live in examples/ — index & check,
API typo detection, scan & validate, and dead-code discovery:
pip install -e .
python examples/01_index_and_check.py /path/to/projectArchitecture
Data flow
graph TD
Client["MCP Client"] -->|tool call| Tools["tools.py (17 tools)"]
Tools -->|parse file| Extractor["StructureExtractor (Python ast)"]
Tools -->|lookup symbol| Index["Symbol Index (cache)"]
Tools -->|graph queries| Graph["Graph Store (SQLite + FTS5)"]
Tools -->|check API| KB["Knowledge Base (dep APIs)"]
Index -->|persists| GraphModule layout
honestcode/
├── mcp/ # MCP server layer
│ ├── server.py # FastMCP entry point (stdio + SSE), tool whitelist
│ ├── tools.py # 17 tool implementations
│ └── knowledge_base.py # Dependency API signature cache
├── honest/ # Core hallucination detection
│ ├── router.py # NL query → tool routing
│ ├── symbol_index.py # Project-wide symbol index + caching
│ └── project_binding.py # .honestcode/ binding + MCP client auto-config
├── graph/ # Persistent graph layer
│ ├── graph_store.py # SQLite call graph (definitions/refs) + FTS5 index
│ └── watcher.py # Zero-dependency polling file watcher
├── structure/ # Code structure extraction
│ ├── extractor.py # AST-based parser (Python ast)
│ ├── multi_lang.py # Optional tree-sitter extraction (JS/TS/Go/Rust/Java)
│ ├── relations.py # Edge/relation data structures
│ └── utils.py # Shared AST utilities
├── sandbox/ # Sandboxed execution
│ └── __init__.py # Subprocess executor with timeout + resource limits
└── cli.py # Command-line interface (every tool as a subcommand)Class responsibilities
Module | Class/Function | Responsibility |
|
| MCP protocol handling, stdio + SSE transport, tool whitelist |
| Tool functions | 17 hallucination-detection tools |
|
| Load/cache dependency API signatures via |
|
| Module-qualified symbol index with content-hash caching |
|
|
|
|
| Map natural-language queries to tool intents |
|
| SQLite call graph (definitions/refs) + FTS5 full-text index |
|
| Polling file watcher with debounce for auto-re-indexing |
|
| Parse Python AST, extract defs/imports/edges |
|
| Optional tree-sitter extraction (JS/TS/Go/Rust/Java) |
|
| Extract dotted names from AST call nodes |
|
| Isolated subprocess with timeout + resource limits |
|
| Argparse-based CLI mirroring every MCP tool |
Design decisions
Decision | Rationale |
Standard-library | Call graphs and file scans use Python's |
Module-qualified symbols | Index stores |
Persistent graph (SQLite + FTS5) | The call graph is stored on disk keyed by content hashes, so graph queries skip re-parsing; FTS5 narrows regex searches to candidate files |
Lazy loading + caching | Dependency APIs and project indices are cached with content-hash invalidation |
Zero-dependency watcher | File watching uses stdlib polling + debounce instead of a native watcher, keeping the install footprint small |
Thread-safe global state | Tool state protected by |
Subprocess sandbox |
|
Primary tool pattern | One well-aimed tool ( |
CLI parity | Every MCP tool has a 1:1 CLI subcommand so the same checks run in CI without an MCP client |
Output safety
All tools enforce output limits to prevent context window bloat:
Tool | Max output | Strategy |
| 50 issues | Truncated with |
| 3 suggestions | Fuzzy match capped at top-3 |
| 200 symbols | Filtered by |
| 50 pairs | Length-ratio pre-filter |
| 100 matches | Regex |
| Full | No limit (bounded by project size) |
When NOT to use HonestCode
Scenario | Why it doesn't fit | Alternative |
Runtime behavior questions | AST is static; can't trace execution |
|
Non-Python projects | Python is first-class; other languages need | CodeGraph (20+ languages) |
Type inference across packages | Structural checks only, not full type solver |
|
Tiny repos (< 20 files) | Index overhead exceeds benefit | Direct |
Highly active monorepos | Index may lag behind rapid changes |
|
Troubleshooting
Symptom | Likely cause | Fix |
No tools visible in agent | Server not started | Restart MCP client; check MCP config JSON |
|
| Call |
All symbols report | Dependencies not loaded | Call |
| Code contains infinite loop | Increase timeout or fix the code |
| File has invalid Python | Fix syntax before scanning |
Slow | Large project, first run | Subsequent runs use cache; use |
Windows: no memory limit | OS limitation | Use Docker/WSL2 for untrusted code |
Verify setup
# Check the server is importable
python -c "from honestcode.mcp.server import main; print('OK')"
# Check the CLI works
python -m honestcode.cli --help
# Run tests
python -m pytest tests/ -qDevelopment
# Clone and install
git clone https://github.com/Fengrru/honestcode.git
cd honestcode-mcp
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
# Run tests
pytest
# Lint & format
ruff check honestcode tests scripts
ruff format honestcode tests scripts
# Pre-commit hooks
pre-commit install
pre-commit run --all-filesSee CONTRIBUTING.md for pull request guidelines.
Security
execute_code runs in a subprocess with:
Timeout protection (default 10s, configurable)
Memory limits (256 MB on POSIX via
RLIMIT_AS)CPU time limits (POSIX via
RLIMIT_CPU)Restricted
PYTHONPATH(empty, no inherited modules)Temporary working directory (cleaned up after execution)
No console window on Windows (
CREATE_NO_WINDOW)
This catches accidental mistakes but is not a hardened security boundary. For untrusted code, use a container or dedicated VM.
See SECURITY.md for vulnerability reporting.
Telemetry
HonestCode collects no telemetry. There are no analytics libraries, no background services, and no phone-home endpoints:
All parsing, indexing, and verification run 100% locally — source code never leaves your machine.
The server makes no outbound network requests of its own. The only network traffic in your stack comes from the LLM provider your MCP client is configured to use.
Every tool returns deterministic JSON you can diff, so verification results are auditable in CI.
This is a design invariant, not a toggle.
Roadmap
Persistent call graph (SQLite) + FTS5 full-text search
explore_impactblast-radius analysisaffected_filesgit-diff → affected tests (CI killer)File watcher for automatic re-indexing
Project binding (
.honestcode/) +installfor MCP clientsMulti-language symbol extraction via optional tree-sitter extras
VS Code extension with inline diagnostics
GitHub Action for PR-level hallucination checks
Remote dependency API caching (PyPI index)
Configurable rules and ignore patterns
Adaptive output budgeting based on project size
Changelog
See CHANGELOG.md for release history.
Contributing
Contributions are welcome! Please read CONTRIBUTING.md first.
License
MIT - Copyright (c) 2026 HonestCode Team
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Tools
Related MCP Servers
- Flicense-qualityDmaintenanceA modular MCP server that provides tools for file operations, regex-based code searching, and structural analysis of functions and classes across multiple programming languages. It also includes AI-powered features for intelligently updating files according to architectural changes.
- AlicenseAqualityAmaintenanceAn MCP server providing 63 semantic analysis tools for Java, built directly on Eclipse JDT for compiler-accurate code understanding.7536MIT
- AlicenseBqualityBmaintenanceA high-performance MCP server for intelligent documentation search, proactive bug detection, and semantic analysis of codebases.2515MIT
- AlicenseAqualityAmaintenanceAn MCP server that empowers AI coding agents to work effectively with Minecraft mod development, providing static analysis of decompiled source code and runtime interaction with a running Minecraft instance.313912MIT
Related MCP Connectors
A MCP server built for developers enabling Git based project management with project and personal…
MCP server for doc2mcp documentation, generated by doc2mcp.
An MCP server that gives your AI access to the source code and docs of all public github repos
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Fengrru/honestcode'
If you have feedback or need assistance with the MCP directory API, please join our Discord server