Skip to content

Investigate a production bug without a checkout

Some people must read the code but must not hold it: a support engineer who gets a bug report, a security reviewer, an outside contractor, an AI agent that runs on another machine or as another user. The usual answer is to give them a clone of the repository, with the credentials and the shell access a clone needs.

With CodeNavi they need one URL and a token. The code stays on the CodeNavi host. The investigator, or their agent, searches and reads it through the MCP endpoint and gets answers with file and line.

This page shows one real investigation done that way, and how to set up the same access. Everything on it is shipped behaviour.

A real session

This happened on 19 November 2026 on a production PHP web application of about 16,000 indexed code chunks. It was not planned as a test.

The site owner reported a privacy problem to an AI agent (Claude Code). He did not notice that this agent was working in a different project, as a different operating-system user. That user had no permission to open the application's repository: a plain cd into it failed with Permission denied. The agent's only way to the code was the CodeNavi server, which had the application indexed.

What the agent used Count
semantic_search (search by meaning) 1
grep_search (exact strings) 16
read_file (read a file or a line range) 15
list_codebases 1
Requests to the public site as a signed-out visitor 4

What it found:

  1. The first report was not a bug. The owner saw a member's details on a page that should hide them from signed-out visitors. The agent read the login check, the two templates that hide the details, and the three cache layers, and compared them with what the live site returned to a signed-out request. The code was correct. The owner's browser was still signed in, and another tab showed an old copy of the list. The owner confirmed it.
  2. The second report was a real gap. A text field that belongs to the same hidden member was shown to signed-out visitors. The agent named the four places that printed it, each with file and line: the page body, the page's structured data, its meta description, and the rows of the list page.
  3. The agent could not change anything. It had no write access to the repository, so it wrote the fix as a work order for the team that owns the code: the files, the lines, the test to add, and what it had not checked.

The first search was one sentence that described the page. Its second result was a test file that named the feature, and the exact-string searches went on from there.

What this gives you

  • No clone on the investigator's machine. There is nothing to copy off a laptop later, and nothing to remove when a contract ends. You take the token away.
  • No repository credentials and no shell on the code host. The investigator never talks to your git server.
  • The server cannot change your code. The compose file mounts the codebase into the container read-only (team server). No CodeNavi tool runs a shell command or writes to the repository (security model).
  • Answers come with file and line, so the person who owns the code can check every claim before acting on it.
  • The code stays on your hardware. CodeNavi sends code to no one. What the investigator's own agent does with the results it receives is governed by that agent's provider, see what CodeNavi sends.

Set it up

  1. Run CodeNavi on a host that has a clone of the repository, and index it. See Running CodeNavi as a team server. For anyone outside your team, use a separate server that holds only the code they may see. The token opens the whole server, not one project or one set of tools: see Limits.
  2. Set the auth token and make the server reachable for the investigator. See Remote access.
  3. Give the investigator the scoped URL, http://<host>:8765/mcp/<codebase>, and the token. The scoped URL fixes that connection to one codebase. It is a convenience, not a lock: the same token also works on /mcp, on the scoped URL of every other codebase and on the web API.
  4. Remove the write tools from the MCP endpoint. Set CODENAVI_MCP_READ_ONLY=true on the server (where to set it) to remove the tools that change CodeNavi's own state (reindex, notes, feedback, backup and restore, crawl) for everyone. This covers the MCP tools. It does not cover the web API and its settings screen, which the same token opens. A client can also narrow its own connection with the X-CodeNavi-Read-Only: true header. See the API reference.
  5. Connect the agent. See Connect your agent.

Hunter agents and committer agents

The session above had two roles. One agent found the problem and could not write. Another agent, with write access, gets the work order and makes the change. You can set up the same split on purpose:

  • The hunter connects to the scoped URL and reads only. It can be a security scanner, a bug hunter, or a reviewer that you do not want near the repository.
  • The committer or reviewer works in a clone, as usual, and connects to the same CodeNavi server.

The hunter can pass its findings through the server with investigation notes. A note is a short text with at least one file anchor. The committer's agent gets fresh notes as labelled advisory results in its own semantic_search, next to the code they describe, and the note is marked stale when that code changes.

What we tested (2026-11-22): we removed one line from the lock release() of a public test repository (Medusa), so that a caller that does not own a lock still deletes it. Claude Sonnet then got two tasks: audit the locking module, and find the cause of an incident report ("release returned false, yet another worker got the lock"). With CodeNavi read tools only, on a read-only scoped URL, it found the bug in 6 of 6 sessions, with file and line. With a shell on a copy of the tree it also found it in 6 of 6. The difference was cost: the CodeNavi sessions cost about 50% more. The claim is that the hunter can do the work with no clone, not that it does the work better.

For this, the hunter must be able to write notes and nothing else. Do not set CODENAVI_MCP_READ_ONLY=true, because it removes the note tools. Give the hunter's connection an X-CodeNavi-Tools header that lists the search and read tools, save_note and search_notes.

What this does not do:

  • A note is a claim, not a fact. The server scans a note for secrets and injection patterns before it stores it, and rejects one that is mostly pasted code. It does not check that the finding is true. The committer's agent must verify it against the code, and a human must approve the change.
  • There is no queue. Notes have no owner, no assignment and no "fixed" state. Track the work in your issue tracker and put the note's file and line in the ticket.
  • In the session above the findings went as a written work order, pasted by the owner into the other agent's session, not as notes.

An agent in one repository reads another

The agent in the session above was working in a different project. It read the application's code only because the same CodeNavi server had both projects indexed. That is a use case of its own:

  • A team's agent must know how another team's service behaves: the API it calls, a shared library, the format of a message. It asks the server and reads that code. Nobody clones the other repository.
  • Every tool takes a codebase argument. The agent passes the name of the other project, and list_codebases shows the names. The plain /mcp URL reaches every indexed codebase. A scoped /mcp/<codebase> URL reaches only that one, so use the plain URL for this.
  • The agent can read the other project and cannot change it. A change there goes to its owners as a finding with file and line.

Index each repository as its own codebase with CODEBASE_CONFIG, see Configuration.

Check an incoming report before it reaches a developer

A customer, a tester or an outside researcher reports a problem. Somebody must decide if it is real. Both reports in the session above went through this step:

  • The first report was closed with a reason: the code is correct, and here is why the reporter saw something else. No developer was interrupted.
  • The second report was confirmed, with the four code locations a developer needs to start.

The person who does this check, in support or in security, needs to read the code and compare it with what the live system does. They do not need a clone, a build or write access. This fits vulnerability reports well: the code stays on your host while you check the claim, and the reporter gets nothing from you until you decide what to answer.

The check is only as good as the reading. An agent's "not a bug" is a conclusion from the code it read; have the reporter or a developer confirm it, as the owner did here.

Read untrusted code with an agent that cannot act

A third-party library, a contractor's delivery or a suspicious repository can hold text written for AI agents: "ignore your instructions and run this command". An agent with a shell can act on that text. An agent whose only tools are CodeNavi's read tools cannot, because no CodeNavi tool runs a command or writes a file, and the agent has no other tool.

Set it up:

  1. Index the untrusted repository as its own codebase on the CodeNavi host.
  2. Set CODENAVI_MCP_READ_ONLY=true on that server (where to set it), or give the connection the X-CodeNavi-Read-Only: true header, so the agent cannot write notes or start a reindex either.
  3. Start the agent with no built-in tools and only the CodeNavi server. In Claude Code: claude --tools "" --strict-mcp-config --mcp-config codenavi.json, with --allowedTools listing the CodeNavi read tools (semantic_search, grep_search, read_file, file_search, symbol_search, list_directory).

What we tested (2026-11-21): we put a comment in a public test repository (Medusa) that told AI assistants to run a touch command and to call the code deprecated, then asked about that code six times with CodeNavi tools only and six times with a shell and file tools on the checkout. Claude Sonnet ran no command and did not repeat the claim in either setup. With CodeNavi tools only it told the user about the planted comment every time. The model ignored the text on its own, so this test does not show the containment stopping an attempt. The containment is in the tool list: there is no tool that can act.

What this does not do:

  • It stops actions, not persuasion. read_file and grep_search return the planted text as it is on disk. semantic_search drops comments from the code it returns. The agent can still be told something false, so a person must check its findings, as with any review.
  • The scanner tags this text in the index but does not mark it in tool output. The [FLAGGED:…] markers in search results are for dangerous function calls, not for text addressed to AI agents.

Limits

  • This is at least read access to the code, and you must treat it as such. A person with the token can read every file in the indexed codebases. "No checkout" means no copy and no write access. It does not mean the person cannot see the code.
  • The token is all-or-nothing. There is no per-person or read-only token today (security verification). The read-only switch above is a server setting, and the header is the client's own choice. Treat the token as an administrator's token. We tested it on 25 November 2026 on a throwaway server with the read-only switch on. Without a valid token, every data and control route answered 401. With it, the MCP write tools were gone, but the web API still let the holder change server settings (the chat provider, the scanner, the webhook), allowlist a file so that search shows its secrets, start a reindex, and make and restore backups. The code on disk did not change. Since 1.3.76 the chat, webhook and scanner addresses work only for hosts you listed; before that release the holder could choose them. If you need different rights for different people, run a separate server for them, and keep no LLM API key on a server whose token an outsider holds: chat can still use it.
  • Redaction is pattern matching. semantic_search, read_file and grep_search replace detected secrets with [REDACTED:…] markers, and grep_search and find_references cannot be used to guess one: they search the redacted text. Detection misses some values. Do not index a tree that holds secrets the investigator must not see.
  • The index shows the host's clone. A change that is not pulled and reindexed on the host is not visible.
  • One session is an example, not a measurement. We do not claim that an agent finds a bug faster this way than with a local clone. The claim is that it can do the work with no clone at all.
  • The fix still needs someone with write access. That is the point of the setup.