mcp-intelligence-context
Click on "Deploy 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., "@mcp-intelligence-context What imports and dependencies does the auth module have?"
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.
MCP Intelligence Context
A Repository Intelligence MCP server that indexes a codebase's files, symbols, imports and dependency graph, and hands Copilot/agents a small, focused context package instead of making them scan the entire repository.
Why
When an agent gets an ambiguous question about a large repo, it often has to repeatedly list directories, open unrelated files, and re-derive structure before finding the relevant code — burning tokens and time. This project builds a persistent, incrementally-updated index of the repo (files, symbols, imports, reverse dependencies) and exposes MCP tools that return only the context relevant to a query, with an approximate token budget.
Related MCP server: lens
How it works
index_repositorywalks the repo (honoring.gitignore), parses Python (viaast) and JS/TS (via lightweight regex heuristics) files for functions/classes/methods/imports/exports, and builds a reverse dependency graph. The index is cached at.mcp_intel_cache/index.jsonand refreshed incrementally (only changed files are re-parsed, based on mtime/size).search_code/get_relevant_contextrank files by symbol-name, filename, docstring/summary, and import matches (lexical/symbol search — no embeddings in this MVP) and return a token-budgeted context package: symbol tables + small code excerpts, not whole files.get_relevant_contextalso reports atoken_savingscomparison against a naive full-repo-scan baseline, so the savings are visible in the tool's own response.get_file_summary/get_dependencieslet an agent drill into a specific file's symbols or blast radius (importers/imports) without reading the whole file.Tools report a staleness warning if the cached index is older than 5 minutes and no live watcher is active. In practice, the first tool call for a repo starts a background file watcher (via
watchdog) that applies create/modify/delete events to the in-memory index immediately, so the index stays continuously up to date as the code changes — no manual reindex needed during a session. The on-disk cache is flushed on a debounce (~2s) so rapid saves don't cause a write per keystroke.
Repository layout
src/mcp_intelligence_context/ Python MCP server package
walker.py gitignore-aware file walker
parsers/ Python (ast) and JS/TS (regex) symbol extraction
indexer.py builds/caches the RepoIndex, resolves imports
watcher.py background file watcher that keeps the index live
search.py lexical/symbol search + reverse-dep lookups
context_builder.py token-budgeted context package assembly
server.py MCP tool definitions (stdio server)
vscode-extension/ VS Code extension wrapper (setup/reindex/status commands)
scripts/ one-command bootstrap for new usersQuick Start (New Users)
If you are new to MCP and just want this working in VS Code quickly:
git clone https://github.com/LeoChimal09/MCP-INTELLIGENCE-CONTEXT.git
cd MCP-INTELLIGENCE-CONTEXT
bash scripts/setup_mcp_workspace.shWhat this script does:
Installs (or updates)
mcp-intelligence-contextwithpipx.Writes
.vscode/mcp.jsonfor this workspace.Restricts indexing to the current workspace folder by setting
MCP_INTEL_ALLOWED_ROOTS=${workspaceFolder}.
Then in VS Code:
Command Palette ->
MCP: List Servers.Start/Restart
mcp-intelligence-context.In Copilot Chat tool picker, enable
mcp-intelligence-context.
If the script says pipx is missing, install it once:
brew install pipx
pipx ensurepathRunning the MCP server standalone
python3 -m venv .venv
.venv/bin/pip install -e .
.venv/bin/mcp-intelligence-context # or: python -m mcp_intelligence_context.serverPoint the repo to index by setting MCP_INTEL_REPO_ROOT, or pass repo_root
explicitly to any tool call (defaults to the server's current working
directory).
Installing without cloning this repo
Other users don't need a local checkout — install directly from the git repository (or from PyPI, once published there):
python3 -m venv .venv
.venv/bin/pip install "git+https://github.com/LeoChimal09/MCP-INTELLIGENCE-CONTEXT.git"
# once published: .venv/bin/pip install mcp-intelligence-contextThe mcp-intelligence-context console script and MCP_INTEL_REPO_ROOT env
var work exactly the same either way — only the pip install source differs.
Register with an MCP client (e.g. VS Code)
Add to .vscode/mcp.json in the target workspace:
{
"servers": {
"mcp-intelligence-context": {
"type": "stdio",
"command": "/absolute/path/to/.venv/bin/python",
"args": ["-m", "mcp_intelligence_context.server"],
"env": { "MCP_INTEL_REPO_ROOT": "${workspaceFolder}" }
}
}
}VS Code extension
vscode-extension/ bundles a thin wrapper with three commands:
MCP Intelligence: Setup Server — creates a venv and installs the Python package, then writes the
.vscode/mcp.jsonentry above.MCP Intelligence: Reindex Repository — forces a re-index of the open workspace.
MCP Intelligence: Show Status — prints the cached index's file count, git commit, and age.
By default, "Setup Server" installs the package from this project's git repository into a venv under the extension's private storage — no local clone required. Two settings control this:
mcpIntelligenceContext.serverPath— point at a local editable checkout (used for development on this monorepo); leave empty otherwise.mcpIntelligenceContext.pythonPackageSource— override the pip install target (e.g. a PyPI package name) whenserverPathis empty.
To build it:
cd vscode-extension
npm install
npm run compileThen press F5 in VS Code (with vscode-extension/ open) to launch an
Extension Development Host.
Available MCP tools
Tool | Purpose |
| Build/refresh the index for a repo root |
| Top-level directories, language breakdown, core modules |
| Ranked file/symbol hits for a query |
| Symbol table, imports, exports for one file |
| What a file imports and who imports it |
| Token-budgeted context package for a query, plus a |
Evaluating whether this actually helps
eval/ contains a small, honest benchmark against this repo's own code
(no LLM calls, no fabricated numbers): 10 hand-written queries with known
ground-truth files, comparing our indexed tool against a naive baseline
(list the tree, grep, read whole matching files).
.venv/bin/python eval/run_eval.pyIt reports hit@1/hit@3 (does the top result point at the right file), average token reduction, and latency. This only measures retrieval/token mechanics — it does not measure whether a real Copilot answer is actually better, since that requires live model calls.
Current limitations (MVP)
JS/TS parsing is regex-based (not a full AST), so unusual syntax may be missed. Python parsing uses the standard
astmodule and is exact.Search is lexical/symbol-based only (with stopword filtering and accumulated multi-signal scoring); no embeddings/semantic search yet.
The file watcher applies per-file changes but does not re-walk
.gitignorechanges themselves at runtime — if.gitignoreis edited, runindex_repositorywithrefresh=trueonce to pick up the new rules.
Security considerations before broader/production use
Already fixed:
Shell injection — the VS Code extension previously interpolated workspace settings into shell command strings; it now uses
execFilewith argument arrays (no shell), and refuses to run "Setup Server" in untrusted workspaces.Symlink escape — the walker skips symlinks that resolve outside the repo root (blocks a planted symlink from exposing files like
/etc/passwd).Secret leakage — filenames matching common credential patterns (
.env,*.pem,id_rsa,credentials.json, etc., seeSENSITIVE_FILENAME_PATTERNSinconfig.py) are skipped even if not gitignored, so their contents can't end up in tool output.Corrupted-cache crash — a malformed/tampered
.mcp_intel_cache/index.jsonnow triggers a clean rebuild instead of crashing the server on launch.ReDoS — the JS/TS regex parser skips pathologically long single lines (minified files) to avoid catastrophic-backtracking DoS.
Unrestricted
repo_root— setMCP_INTEL_ALLOWED_ROOTS(a:-separated list of absolute paths) to restrict which directories the server will index; unset by default to preserve today's flexible single-user behavior.
Still architectural, not fully solved — read before deploying beyond a single local user:
Not safe as a shared/multi-tenant network service. This is designed as a local, one-process-per-user stdio server. The in-memory index/watcher caches have no per-user isolation or authentication. Do not expose this as a shared HTTP/SSE endpoint without adding per-caller sandboxing and auth.
Dependencies are unpinned (
>=only) — pin exact versions or use a lock file for reproducible, vetted production installs (this already bit us once with anmcp1.x → 2.0 breaking API change).No automated regression tests for this codebase itself yet — changes are currently verified via the manual
eval/harness and ad hoc runs, not a CI-gated test suite.
Available Tools
6 toolsget_dependenciesA
Return what a file imports and which files import it (reverse deps), to understand blast radius before changing a file.
Inputs: path (required), repo_root.
get_file_summaryB
Return the symbol table (functions/classes/methods with signatures and docstrings), imports, and exports for a single indexed file — without returning the entire file body.
Inputs: path (required), repo_root.
get_relevant_contextA
Build a focused, token-budgeted context package (symbol tables + small code excerpts) for the files most relevant to a query. This is the main entry point for "help me find/fix X" style requests — use it instead of reading whole files or globbing the repo.
Inputs: query (required), repo_root, token_budget.
get_repo_overviewA
Return a high-level architecture summary: top-level directories, language breakdown, and the files with the most symbols (likely core modules). Use this to orient before drilling into specific files.
Inputs: repo_root.
index_repositoryA
Index (or re-index) a repository: extracts files, symbols, imports and a reverse dependency graph. Call this first, and again with refresh=true after significant file changes. Uses an on-disk cache for fast re-runs.
Inputs: refresh, repo_root.
search_codeA
Search the indexed repository for files/symbols relevant to a natural language or keyword query (e.g. "authentication middleware", "parseConfig"). Returns ranked file hits with the matching symbol/reason — much cheaper than scanning the whole repo.
Inputs: query (required), top_k, repo_root.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool has a largely distinct purpose (index, overview, search, file details, dependencies, context), and the descriptive text flags get_relevant_context as the main entry point. However, search_code and get_relevant_context could both serve as the starting point for a 'find X' request, creating minor selection ambiguity.
All tools follow a consistent verb_noun snake_case pattern (index_, get_, search_), making the API predictable and scannable. The only minor nitpick is abbreviating 'repository' as 'repo' in get_repo_overview, but this does not affect the overall pattern.
Six tools sit at the sweet spot for a code-intelligence server, each earning its place in the index-query workflow. The set covers setup, orientation, discovery, drill-down, and impact analysis without bloat.
The core indexing-to-context pipeline is well covered, including re-indexing via refresh and reverse-dependency analysis for safe edits. Minor gaps exist (no full-file body reader, no way to list indexed repositories or explicitly purge the cache), but these seem like intentional scope decisions for a token-budget-focused tool.
Maintenance
Related MCP Connectors
Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.
Code intelligence for LLMs. Analyze, search, and retrieve code from any public git repository.
Codebase intelligence for AI agents — dead code, blast radius, ownership.
Code intelligence platform for AI agents. 20 tools for architecture, security & impact analysis.
Related MCP Servers
AlicenseNot gradedqualityDmaintenanceProvides AI coding agents with structured access to indexed codebases via semantic search, symbol analysis, and file reading tools.13Server Side Public , v 1- AlicenseNot gradedqualityCmaintenanceProvides token-efficient code retrieval for coding agents by indexing repositories and enabling ranked snippet search, symbol outlines, and surgical line reads.3 npmMIT
- AlicenseNot gradedqualityDmaintenanceEnables LLM agents to efficiently understand and navigate a codebase by providing semantic search over symbols and a reference graph, replacing expensive grep/glob calls with structured tools like definition lookup, caller/callee queries, and change-impact analysis.4MIT
- FlicenseNot gradedqualityBmaintenanceProvides efficient code navigation and graph-based analysis for AI agents, enabling symbol resolution, callers, implementations, and type schemas with minimal token usage.-