Back to Browse

Codenav MCP Server

Developer ToolsLow Risk10.0MCP RegistryLocal
Free

Server data from the Official MCP Registry

Python code navigation and type-checked refactoring through MCP, powered by ty.

About

Python code navigation and type-checked refactoring through MCP, powered by ty.

Security Report

10.0
Low Risk10.0Low Risk

Valid MCP server (2 strong, 1 medium validity signals). No known CVEs in dependencies. Package registry verified. Imported from the Official MCP Registry.

3 files analyzed · 1 issue found

Security scores are indicators to help you make informed decisions, not guarantees. Always review permissions before connecting any MCP server.

Permissions Required

This plugin requests these system permissions. Most are normal for its category.

file_system

Check that this permission is expected for this type of plugin.

HTTP Network Access

Connects to external APIs or services over the internet.

env_vars

Check that this permission is expected for this type of plugin.

What You'll Need

Set these up before or after installing:

Project root the server serves (never overridden); default follows the client's MCP roots, CLAUDE_PROJECT_DIR or the working directoryOptional

Environment variable: CODENAV_MCP_WORKSPACE

Directory scanned for lookup implementations candidates and used to derive dotted import paths (e.g. src); default is the whole workspaceOptional

Environment variable: CODENAV_MCP_SOURCE_ROOT

Set to 1/true/yes/on to make write tools refuse to write (previews and checks still work)Optional

Environment variable: CODENAV_MCP_READ_ONLY

Comma-separated extra directories for Protocol implementation lookup. Unset scans top-level test/ and tests/ outside the source root. Set to none to scan only the source root.Optional

Environment variable: CODENAV_MCP_EXTRA_SOURCE_ROOTS

Maximum characters of one tool result (default 30000); longer results end with an omission noteOptional

Environment variable: CODENAV_MCP_MAX_OUTPUT_CHARS

Set to 1/true/yes/on to let write tools overwrite read-only (0444) Python files and keep their modeOptional

Environment variable: CODENAV_MCP_ALLOW_READONLY_FILES

Comma-separated directory names added to the built-in list of directories that are never scanned or writtenOptional

Environment variable: CODENAV_MCP_EXCLUDE_DIRS

Comma-separated directory names removed from that list, for example build to treat a first-party build/ package as sourceOptional

Environment variable: CODENAV_MCP_INCLUDE_DIRS

Maximum number of Python files (.py/.pyi) a workspace may hold (default 250000); a larger tree is refused before the language server startsOptional

Environment variable: CODENAV_MCP_MAX_FILES

Directory where previews and the applied-edit history are kept across restarts, one subdirectory per workspace (default $XDG_STATE_HOME/codenav-mcp or ~/.local/state/codenav-mcp)Optional

Environment variable: CODENAV_MCP_STATE_DIR

How to Install

Add this to your MCP configuration file:

{
  "mcpServers": {
    "codenav-mcp": {
      "command": "uvx",
      "args": [
        "codenav-mcp==2.0.1"
      ],
      "env": {
        "CODENAV_MCP_MAX_FILES": "your-codenav-mcp-max-files-here",
        "CODENAV_MCP_READ_ONLY": "your-codenav-mcp-read-only-here",
        "CODENAV_MCP_STATE_DIR": "your-codenav-mcp-state-dir-here",
        "CODENAV_MCP_WORKSPACE": "your-codenav-mcp-workspace-here",
        "CODENAV_MCP_SOURCE_ROOT": "your-codenav-mcp-source-root-here",
        "CODENAV_MCP_EXCLUDE_DIRS": "your-codenav-mcp-exclude-dirs-here",
        "CODENAV_MCP_INCLUDE_DIRS": "your-codenav-mcp-include-dirs-here",
        "CODENAV_MCP_MAX_OUTPUT_CHARS": "your-codenav-mcp-max-output-chars-here",
        "CODENAV_MCP_EXTRA_SOURCE_ROOTS": "your-codenav-mcp-extra-source-roots-here",
        "CODENAV_MCP_ALLOW_READONLY_FILES": "your-codenav-mcp-allow-readonly-files-here"
      }
    }
  }
}

Some servers take additional arguments. See the repository for details.

Documentation

View on GitHub

From the project's GitHub README.

codenav-mcp

PyPI Python CI License: MIT

Python code navigation and type-checked refactoring over MCP, powered by Astral's ty. Use it to follow typed calls through imports and dependency injection, find structural Protocol implementations, and preview refactors that touch several files. Use grep for exact-name text lookups and Read for a known file or excerpt.

An agent asks codenav for a symbol by name; ty resolves definitions, references, callers and implementations. For edits, codenav builds the change in memory, offers text mentions as optional sites, checks types with ty, and shows a preview that can be applied and undone.

An agent asks by name, and ty follows the types to answer. For an edit, codenav builds the change in memory, offers names it found in strings, docs and shell heredocs as optional sites, and writes only if ty reports no new type errors. Every change has a preview ID to apply and an undo ID.

What it can do

  • Follow typed code: find callers and Protocol implementations across imports and dependency injection.
  • Preview refactors: rename symbols, change signatures and move definitions with their linked usages.
  • Catch overlooked sites: surface mentions in strings, docs and shell heredocs for review.
  • Review and undo: inspect type-checked previews before applying them, then undo stored changes.

For agent workflows, exact calls and parameters, see the agent tool guide.

Quick start

Install uv and Node.js 22+, then run this from your project folder. mcps prompts you to choose agents and registers CodeNav locally:

npx @danielxir96/mcps add illescasDaniel/codenav-mcp

When installing for OpenCode, CodeNav requests codemode: false so its tools appear directly to the agent. See the OpenCode setup for older installers and manual registration.

claude mcp add codenav -- uvx codenav-mcp
codex mcp add codenav -- uvx codenav-mcp

For OpenCode, use the configuration entry with codemode: false.

Some models need a prompt to pick up new tools (see What has been measured). Add this to the project's AGENTS.md or CLAUDE.md.

For Python symbol navigation and refactors, start with Codenav’s `lookup` or `search`.
If those tools aren’t visible, use your harness’s MCP tool catalog or discovery mechanism to find and invoke them before falling back to grep, sed, or hand edits.
If Codenav is unavailable, briefly explain why and proceed.

Requirements and limits

  • Python 3.11 or later. ty installs with codenav, and a workspace's own ty takes priority when present.
  • Python navigation and writes cover .py and .pyi files. Positions use 1-based lines and UTF-16 columns.
  • The write gate checks types only. Run the relevant tests and documentation checks after applying a change.
  • Static analysis can't resolve every dynamic reference, mock, framework registration or library extension; review the optional sites a rename offers. Known limits

What has been measured

Small models (Claude Haiku 5.5, GPT-6 Luna) did real tasks on one project with and without codenav, and every run was graded against a hand-checked key. These are pilots with a few runs per task: read them as direction, not effect sizes.

  • Completeness on a big rename: a 35-file rename where the tests can't see 4 of the files (an example, a doc page, two shell scripts). Luna with codenav updated all 4 in 4 of 5 runs, without it in 0 of 4.
  • Effort: Haiku was usually complete either way, but with codenav it used 161k-359k input tokens against 368k-519k.
  • Adoption: Haiku used codenav unprompted in 17 of 18 runs. Luna used it in 0 of 12 runs without the hint line above, and 12 of 13 with it.
  • Where it didn't help: on tasks where names are distinct and the tests thorough, careful grep was just as correct, and codenav sometimes cost more tokens.

Findings, data and the harness to repeat the runs: Research.

How it is tested

A refactoring tool must not break code quietly, so codenav is tested in several ways:

  • About 1,300 tests: unit tests, plus about 350 integration tests that run the tools against a real ty server.
  • Property tests: about 190, with Hypothesis and generated Python (hypothesmith), including a state machine for preview, apply and undo, and CrossHair symbolic checks.
  • A refactor fuzzer: random renames, moves and signature changes on real projects (srxy, click, tomlkit), each checked against the project's own tests and ty. 187 refactors so far, none silently broke code.
  • Differential checks: references agree with jedi on 40 of 40 symbols, and renames with rope on 38 of 40; the 2 differences are call sites rope misses.
  • Mutation testing (mutmut) of the modules where a wrong edit would go unnoticed, to find tests that don't check enough. The suite catches about 84% of the mutants there; the gaps that mattered got tests.
  • Agent pilots: the small-model runs above, graded by hand.

The results and their data are in Research; how to run each check is in Hardening checks.

Documentation

License

MIT

Reviews

No reviews yet

Be the first to review this server!