Skip to main content

version

codenav-mcp

Give AI agents Python code navigation and refactoring through the Model Context Protocol. codenav-mcp uses ty's language server to resolve definitions, references and call sites, and checks proposed edits for type diagnostics before writing them.

Infographic showing an MCP client requesting navigation or an edit, ty resolving code, and edits being checked before preview or application.

An MCP client sends a request to codenav-mcp. Navigation uses ty to resolve code; edits are simulated and checked before they are previewed or applied. Applied edits can be undone while the server retains its edit journal, if the files have not changed since.

Examples

Real tool calls on a small sample project (app/user_service.py defines UserService with create and save; app/main.py and tests/test_user_service.py use it):

symbol_info(name: "UserService.create")

create  [Method]  (app/user_service.py:14:6)

def create(
    self,
    name: str
) -> User
---------------------------------------------
Create a user and save it.

Definition:
app/user_service.py:14:6
   12 | 		self._next_id = 1
   13 |
   14 | 	def create(self, name: str) -> User:
   15 | 		"""Create a user and save it."""
   16 | 		user = User(id=self._next_id, name=name)

References:
3 reference(s) in 3 file(s):
app/main.py: L4
app/user_service.py: L14
tests/test_user_service.py: L5

references(file_path: "app/user_service.py", line: 14, column: 6)

3 reference(s) in 3 file(s):
app/main.py:4:16
    2 |
    3 | service = UserService()
    4 | user = service.create("Ada")
    5 | print(user.name)

app/user_service.py:14:6
   12 | 		self._next_id = 1
   13 |
   14 | 	def create(self, name: str) -> User:
   15 | 		"""Create a user and save it."""
   16 | 		user = User(id=self._next_id, name=name)

tests/test_user_service.py:5:23
    3 |
    4 | def test_create_returns_user() -> None:
    5 | 	user = UserService().create("Grace")
    6 | 	assert user.name == "Grace"

edit(file_path: "app/user_service.py", old_string: "...", new_string: "...", apply: false) — an edit that would introduce a bug is caught before anything is written:

Edit app/user_service.py
Replaced 1 occurrence(s).

Preview only, nothing written. apply=true would be refused: 1 new error (allowed: 0). Review the diagnostics below; adjust and rerun, or write the plan anyway with apply_edit.
The plan is kept: apply_edit(id="a59fa0ec") writes it anyway.

Files:
  app/user_service.py: +1 -1

Diagnostics: 1 new error(s), 0 fixed (3 file(s) checked, 0 unchanged)
New:
  + app/user_service.py:16:15 error [unknown-argument]: Argument `active` does not match any known parameter

--- a/app/user_service.py
+++ b/app/user_service.py
@@ -14,5 +14,5 @@
 	def create(self, name: str) -> User:
 		"""Create a user and save it."""
-		user = User(id=self._next_id, name=name)
+		user = User(active=True, id=self._next_id, name=name)
 		self._next_id += 1
 		self.save(user)

rename_symbol(name: "UserService.save", new_name: "persist", apply: false) — a type-checked rename, with call sites found through the language server:

Rename save -> persist (UserService.save): 2 edit(s) in 1 file(s)

Preview only, nothing written.
Write it with apply_edit(id="9fd895aa") or rerun with apply=true.

Files:
  app/user_service.py: +2 -2

Notes:
  - `save` appears in strings (getattr/patch targets, __all__, messages): 1
    app/user_service.py:15: """Create a user and save it."""

Diagnostics: 0 new error(s), 0 fixed (3 file(s) checked, 0 unchanged)

--- a/app/user_service.py
+++ b/app/user_service.py
@@ -16,8 +16,8 @@
 		user = User(id=self._next_id, name=name)
 		self._next_id += 1
-		self.save(user)
+		self.persist(user)
 		return user

-	def save(self, user: User) -> None:
+	def persist(self, user: User) -> None:
 		self._users = getattr(self, "_users", {})
 		self._users[user.id] = user

All tools answer plain text like this; the full catalogue with parameters and safety rules is in the tool reference.

Quick start

Install uv, then register the server with your MCP host from the project root. The host starts it when needed.

Claude Code:

claude mcp add codenav -- uvx codenav-mcp

Codex (user configuration):

codex mcp add codenav -- uvx codenav-mcp

OpenCode (project configuration):

opencode mcp add codenav -- uvx codenav-mcp

See configuration for Claude Code and Cursor configuration, workspace selection and environment variables.

Requirements and limits

  • Python 3.11 or later; the package installs ty and its other dependencies.
  • Navigation and edits target Python (.py and .pyi). Positions are 1-indexed; columns use UTF-16 offsets.
  • Edit tools normally check type diagnostics and allow no new errors by default. Use apply=false to preview; apply_edit can explicitly apply a preview despite its diagnostic limit. Read-only mode disables writes. Checks are not a substitute for tests.
  • Batch calls run in order and are not atomic. Tool results are capped at 30,000 characters by default (CODENAV_MCP_MAX_OUTPUT_CHARS). See the tool reference for safety rules, output limits and known limits.

Environment

See configuration for environment variables.

Tests

From a checkout, run uv sync --group dev and uv run pytest. See development for lint and package smoke-test commands. No evaluation score is reported here.

Documentation

Related: webnav-ts-mcp provides navigation for JS/TS/HTML/CSS. Design notes cover Protocol conformance, positioning and output formats.

License

MIT.

Metadata

Release files for codenav-mcp 1.0.2

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 1.0.2
File Size Uploaded Provenance Actions
codenav_mcp-1.0.2.tar.gz 111.1 kB Without provenance Details for codenav_mcp-1.0.2.tar.gz

Built distribution (wheel)

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

Total release size: 234.1 kB

Release files / codenav_mcp-1.0.2.tar.gz

Download URL codenav_mcp-1.0.2.tar.gz
Size 111.1 kB
Tags Source
SHA-256 checksum
How to use checksums
11b2873966f00ce8c904116a08f38556529ac11265b347eb317a8c8362e9b0f0
BLAKE2b-256 checksum
How to use checksums
ef8082e390af6610a1ed664e2c000ff2add27ac1308b953fdcb7a852897977f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

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

Download URL codenav_mcp-1.0.2-py3-none-any.whl
Size 123.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b9f02ec8f2d325a590d9fe6478b062c310246aae27e6e85528aff7287d0f31c8
BLAKE2b-256 checksum
How to use checksums
f443d6990c71c85cc0f8d5c7e7bc9edd6e08971b31d67f0f891f7e90baded220
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for codenav-mcp 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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