codebase-cartographer
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., "@codebase-cartographerPlan renaming the function compute to calculate across the codebase"
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.
Codebase Cartographer
An MCP server that maps a local Python repository into an AST-backed symbol graph and performs verified multi-file refactors on it.
Most coding agents refactor by grepping for a string and rewriting what they find. That
approach cannot tell a call to compute() apart from a local variable that happens to be
named compute, and it has no idea which twelve files break when you rename it. This server
gives the model a real index instead: scope-resolved references, an import graph, and a
two-phase edit protocol that refuses to write anything it cannot verify.
What it does
Maps. Walks the repository (honouring .gitignore), parses every module, and builds a
symbol table of functions, classes, methods, and module-level variables, plus the import
graph between modules.
Resolves. Finds references using real scope analysis — the LEGB chain, global and
nonlocal declarations, comprehension scopes, walrus bindings, and the rule that class
bodies are invisible to nested functions. A local variable that shadows a module-level
symbol is not a reference to it, and the tool knows the difference.
Refactors. Renames, moves, and deletes symbols across every file that touches them —
rewriting from x import y, import x + x.y attribute access, as aliases, and __all__
entries. Nothing is written until you apply a plan you have seen the diff for.
Related MCP server: MCP Python Code Navigation Server
Safety model
Refactoring is two-phase, and the first phase never touches disk.
plan_rename_symbol/plan_move_symbol/plan_delete_symbolreturn a plan id, a unified diff, and a list of warnings. Every touched file's content hash is recorded.apply_planre-checks those hashes (aborting if anything changed on disk since planning), builds the new content for every file, re-parses each one, and refuses to write if any file would end up unparseable. Originals are copied to.cartographer-backups/<plan_id>/. A failure mid-write rolls every file back.
Further guardrails: paths outside the mapped root are rejected; renaming a method requires
an explicit allow_heuristic=true because attribute matching cannot be resolved without type
inference; deleting a symbol that still has references is refused unless forced.
What it cannot see
Static analysis has a hard edge, and the tool is built to say where that edge is rather than to pretend it isn't there.
find_dynamic_references reports string literals matching a symbol name — getattr(mod, "compute"),
plugin registries, dotted settings strings, entry-point tables — and detects imports of
underscore-prefixed native modules. Those warnings are attached to every refactor plan.
This matters concretely. Renaming JSONDecodeError in a copy of the stdlib json package
rewrites all 19 Python references correctly and still breaks the package, because the _json
C accelerator resolves that name at runtime through the C API. No pure-Python analysis can
follow that. The tool flags the native accelerator import and tells you to check by hand.
Also invisible: from x import * re-exports (reported as a warning), runtime monkey-patching,
and references from other languages or config files.
Tools
Tool | Purpose |
| Scan a directory and build the index. Call this first, and again after applying. |
| Stats, packages, import cycles, most-depended-on modules. |
| Indexed modules, filterable by dotted prefix. |
| One file's imports and definitions. |
| Find definitions by substring, kind, or module prefix. |
| Full source of one definition, with docstring and decorators. |
| Every scope-resolved use of a symbol. |
| String literals and native imports that static analysis can't follow. |
| Internal import edges, whole-graph or one module's neighbourhood. |
| Transitive dependents — the blast radius of editing a module. |
| Module-level definitions with no discoverable references. |
| Plan a repository-wide rename. Writes nothing. |
| Plan moving a definition to another module. Writes nothing. |
| Plan removing a definition and its |
| Re-render a pending plan's diff. |
| Inspect or drop pending plans. |
| Commit a plan, with hash checks, syntax validation, and backups. |
Install
pip install -e .Register it with an MCP client:
{
"mcpServers": {
"codebase-cartographer": {
"command": "python",
"args": ["-m", "cartographer"],
"env": { "CARTOGRAPHER_ROOT": "/path/to/your/repo" }
}
}
}CARTOGRAPHER_ROOT is only the default for map_repository; the tool takes an explicit
root argument too.
A typical session
map_repository(root="~/work/service")
-> 412 files, 1 import cycle, 38k LOC
impact_of_change(module="service.auth.tokens")
-> 23 transitive dependents
find_references(qualname="service.auth.tokens.decode_jwt")
-> 31 references across 12 files
find_dynamic_references(name="decode_jwt")
-> 1 string literal in service/registry.py:44 <- read this before proceeding
plan_rename_symbol(qualname="service.auth.tokens.decode_jwt", new_name="decode_access_token")
-> plan 9f2a1c: 31 edits across 12 files, with diff
apply_plan(plan_id="9f2a1c")
-> written, backed up to .cartographer-backups/9f2a1c/Development
pip install -e ".[dev]"
pytest65 tests cover scope resolution (shadowing, global, comprehensions, class-body visibility),
reference finding across every import style, rename/move/delete correctness, generated-import
style, and the apply-phase guarantees: stale-file detection, syntax validation, and rollback.
The suite's strongest check is that the tool refactors its own source — renaming a function across the implementation and the tests, and moving one between modules — after which the full suite still passes against the rewritten copy.
Requirements
Python 3.10+ (uses ast.alias position attributes). Python source only.
License
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables querying and analyzing code relationships by building a lightweight graph of TypeScript and Python symbols. Supports symbol lookup, reference tracking, impact analysis from diffs, and code snippet retrieval through natural language.
- AlicenseNot gradedqualityDmaintenanceProvides tools for Python code navigation, analysis, and refactoring, including finding definitions, references, and symbol lists. It enables automated tasks such as renaming symbols and organizing imports to enhance AI-driven development.Apache 2.0
- AlicenseAqualityDmaintenanceProvides Python refactoring capabilities via the Rope library, enabling AI agents to perform safe, project-wide code transformations such as renaming symbols, moving modules, and extracting methods.101MIT
- AlicenseAqualityBmaintenanceEnables coding agents to perform safe, project-wide Python refactoring (rename, move, extract, inline, change signature, organize imports, etc.) with a dry-run safety contract and LSP-coordinate addressing.15MIT
Related MCP Connectors
Deterministic context layer for your codebase: change impact, blast radius, answers with receipts.
Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.
Give your AI agent a persistent map of your project's structure, dependencies, and bugs.
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/sdg5-hub/MCP-Cartographer'
If you have feedback or need assistance with the MCP directory API, please join our Discord server