Skip to main content

codenav-mcp

An MCP server that gives AI agents type-resolved Python navigation, backed by ty's language server. Definitions, references and call sites go through real type inference (imports, dependency-injected parameters, dataclass fields), not text grep.

Quick start

ty is installed with the package, so all you need is uv (or pipx):

uvx codenav-mcp

Register it with your MCP host. For Claude Code, from the project root:

claude mcp add codenav -- uvx codenav-mcp

Or add it to a project .mcp.json (Claude Code) or .cursor/mcp.json (Cursor):

{
	"mcpServers": {
		"codenav": {
			"command": "uvx",
			"args": ["codenav-mcp"],
			"env": {
				"CODENAV_MCP_SOURCE_ROOT": "src"
			}
		}
	}
}

In Cursor, also set "CODENAV_MCP_WORKSPACE": "${workspaceFolder}", because Cursor may start MCP servers with your home directory as the working directory.

Tools

Start with the name-based tools:

Tool Answers
symbol_info What is this? Header, hover, definition and references in one call
outline What's in this file? (classes, methods, functions)
callers Who actually calls this function? (call hierarchy, not imports)
implementations Which classes structurally implement this Protocol? (type-checked)
search_symbol Workspace symbol search by name (ranked, capped; optional kind= / path= filters; production code before tests; fuzzy-only hits summarised unless fuzzy=true)
workspace Which directory is being navigated, and why

Then use the position tools once you have a path:line:col:

Tool Answers
hover Type and docs at a position
definition Go to definition (resolves through injected parameters)
references All usages across the workspace
diagnostics ty type-check diagnostics for one file

name and query are accepted as aliases on the name-based tools (port_name / name / query on implementations). A missing or wrong parameter gets a short hint back instead of a validation error. Dotted names may nest (Outer.Inner.method). implementations also takes file_path to pick one port when the name exists in several files, and counts inherited members and dataclass/self.x fields toward a port's required names.

Positions are 1-indexed. column is a UTF-16 character offset (a leading tab counts as one character).

Python only (.py / .pyi).

Which ty runs

  1. The project's own .venv/bin/ty (.venv\Scripts\ty.exe on Windows), so the ty version matches the project's pin and config.
  2. The ty installed alongside codenav-mcp.
  3. ty on PATH.
  4. uvx ty server as a last resort.

Environment

Variable Default Purpose
CODENAV_MCP_WORKSPACE unset: follows the client's MCP roots when they name a worktree of the same git repository, else CLAUDE_PROJECT_DIR, else the working directory Pins the project root (never overridden). See the workspace tool
CODENAV_MCP_SOURCE_ROOT whole workspace Directory scanned for implementations candidates and used to derive dotted import paths (e.g. src)
CODENAV_MCP_EXTRA_SOURCE_ROOTS none Comma-separated directories (e.g. tests) that implementations also scans; matches (test doubles) are listed under a separate heading

Requirements

  • webnav-mcp: the same kind of navigation for JS/TS/HTML/CSS.
  • Design notes (Protocol conformance probe, positioning, output formats): docs/agent-tooling.md.

Development

Developed in the SpaceMaker repository as a uv workspace member (mcp-servers/codenav_mcp). From a checkout: uv sync --group dev, then uv run codenav-mcp.

License

MIT. See LICENSE.

Release files for codenav-mcp 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for codenav-mcp 0.1.0
File Size Uploaded
codenav_mcp-0.1.0.tar.gz 15.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for codenav-mcp 0.1.0
File Interpreter ABI Platform
codenav_mcp-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 33.2 kB

Release files / codenav_mcp-0.1.0.tar.gz

Download URL codenav_mcp-0.1.0.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e083ad6cc764fbba55fbbaf3a1d0551a14e99ad026ed02873ff30552a2b6b73f
BLAKE2b-256 checksum
How to use checksums
445681e91b00d2beb87fea730e889aebc55be45e70edaf719ba6ed5ded280e56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / codenav_mcp-0.1.0-py3-none-any.whl

Download URL codenav_mcp-0.1.0-py3-none-any.whl
Size 17.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
34af0c77687f71160c9a3865d2a10b2b5530a9f2b48a568409239b9a780f0411
BLAKE2b-256 checksum
How to use checksums
b7c6cac0f92d3df58266ed0c85bc922ebb654239d64e69be6ed0e58f5ee54215
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release history Release notifications | RSS feed

0.1.1

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page