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")

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)

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)

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)

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.3

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.3
File Size Uploaded Provenance Actions
codenav_mcp-1.0.3.tar.gz 111.3 kB With provenance Details for codenav_mcp-1.0.3.tar.gz

Built distribution (wheel)

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

Total release size: 234.5 kB

Release files / codenav_mcp-1.0.3.tar.gz

Download URL codenav_mcp-1.0.3.tar.gz
Size 111.3 kB
Tags Source
SHA-256 checksum
How to use checksums
404f38b696a8283332ff89b180fb42aeeec0f4d9913f3693f8ebc5e758b54ed6
BLAKE2b-256 checksum
How to use checksums
3db208151db13857ae351cc2abc13f5e227e90245ca82d831d80bbdc06e793e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

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

Download URL codenav_mcp-1.0.3-py3-none-any.whl
Size 123.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9410b98d7e17e3fb7ce6e596845cdc1792ecb5a9506c683989fe8eee0ee51195
BLAKE2b-256 checksum
How to use checksums
68e6eccd8c94df3f3b64bdec1f62f7876b4cd7b82a168a0228a41f90d39ba518
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Security for codenav-mcp 1.0.3

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for codenav_mcp-1.0.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

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