MCP Codebase Inspector
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
MCP Codebase Inspector
A tiny read-only MCP server that gives an LLM safe, on-demand access to a local codebase. The model discovers the tools itself, picks the right ones, and answers from real files instead of guesses.
Built to demonstrate the Model Context Protocol end to end: stdio transport, tool and prompt discovery, runtime path confinement, and a real model driving the loop (Big Pickle via OpenCode). No API key is needed.
Why this exists
Most MCP tutorials call hardcoded functions and call it an agent. This one doesn't:
The server registers capabilities; the client discovers them at runtime.
The model chooses tools and arguments — no keyword matching.
Every tool routes through one shared path guard, so "read-only" is enforced, not promised.
The whole thing is ~150 lines of server code and uses only the
mcpSDK plus the standard library.
Related MCP server: Local Code MCP Server
What it exposes
Four tools:
Tool | Purpose |
| File/line counts, languages, largest files |
| One directory level, with sizes |
| Numbered lines from any offset, capped |
| Regex search → |
One prompt: codebase_report(path) tells the model how to chain the tools into a short report.
Vendor directories and files over 2 MB are skipped. Paths are confined to MCP_ROOT (default: launch directory); traversal and symlinks pointing outside are rejected.
Quickstart
git clone https://github.com/crizmo/mcp-codebase-inspector.git
cd mcp-codebase-inspector
python3 -m pip install -e .
opencode mcp add codebase -- "$(python3 -c 'import sys;print(sys.executable)')" mcp_server.py
opencode run --model opencode/big-pickle --auto \
"Use the codebase MCP tools to analyze this project. What does it do, main components, and two improvements?"Requires Python 3.10+ and opencode. opencode mcp add writes a local opencode.json with this machine's Python path (the file is gitignored, so the repo stays portable).
To inspect a different directory, set MCP_ROOT in opencode.json:
"environment": { "MCP_ROOT": "/path/to/project" }Example output
> build · big-pickle
⚙ execute {"code":"const [summary, root] = await Promise.all([
tools.codebase.project_summary({ path: \".\" }),
tools.codebase.list_directory({ path: \".\" })]); return { summary, root };"}
## What it does
mcp-codebase-inspector is a tiny read-only MCP server that gives an LLM safe, on-demand
access to a local codebase...
## Two concrete improvements
1. Cap read_file inputs.
2. Return a readable error on path escape.Those two suggestions were real bugs. Both were fixed — this is the loop actually working.
Other commands
python3 mcp_inspect.py # raw MCP protocol
python3 -m unittest discover -s tests -t . -v # 4 trust-boundary testsmcp_inspect.py is the fastest way to learn MCP: it prints the exact requests and responses the model sees.
VS Code: open the folder → Terminal → Run Task → Big Pickle: analyze this repo, MCP protocol inspector, or Run tests.
Layout
mcp_server.py server: tools, prompt, path guard
mcp_inspect.py tiny stdio client that prints the protocol flow
tests/ unittest checks for traversal, symlinks, line and result caps
pyproject.toml package metadata and console entry points
opencode.json generated by `opencode mcp add` (gitignored)
.github/workflows/ CI: install + unit tests on Python 3.10 and 3.13Design decisions
Read-only by construction. No write, delete, or execute tools.
One guard, all callers.
_path()and_files()are the only places that resolve paths.Stdlib first. Only the MCP SDK is a dependency.
No framework.
unittestis enough.
MIT licensed.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Safe folder access for ChatGPT and Claude: read, write and search files, risky tools opt-in.
Code intelligence for LLMs. Analyze, search, and retrieve code from any public git repository.
Run verified read-only code tools: quant diagnostics + agent-ops preflight, no source exposure.
Code-map tools for AI agents: see a repo's structure first, then edit only what matters.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides secure and efficient tools for codebase analysis, including file management, metadata retrieval, and dependency tree traversal. It allows LLMs to explore project structures and search for configuration files within a restricted root directory.21 npm3MIT
- FlicenseBqualityDmaintenanceProvides LLMs with safe, read-only access to local codebases for searching, reading files, and finding function definitions. All source code remains local, ensuring privacy while enabling AI assistants to explore project structures and functionality.4-
- AlicenseNot gradedqualityBmaintenanceEnables language models to explore and analyze source code repositories through read-only tools for listing directories, reading files, searching code, finding symbols, and inspecting git history, with strict sandboxing and security controls.MIT
- FlicenseNot gradedqualityCmaintenanceEnables AI assistants to safely read and search project files within a configured root directory, supporting regex search, file listing, line-range reading, and symbol usage lookup.-