Connecting CodeNavi to Pi¶
Pi is a minimal terminal coding harness. Pi 0.99 and newer has a
built-in MCP client (npm package @earendil-works/pi-coding-agent; the older
@mariozechner/pi-coding-agent package is deprecated). Older Pi has none and needs the
pi-mcp-adapter package, see Older Pi. Once connected,
CodeNavi's default tools show up as Pi tools: semantic search, the call graph
(find_callers, impact_analysis, diff_impact), the overview and the index tools. The rest
run via reveal_tools(call="read_file", args=…).
Fast path¶
On a machine that is not the server (a Mac or a laptop that reaches CodeNavi through a
tunnel or the LAN), there is no install directory: go to step 1, the
pi mcp add command works anywhere. On the server itself, from your install directory:
./codenavi connect pi # --host <addr> if the server is on another machine
It checks the server and the token, then writes the entry from step 1 into
~/.pi/agent/mcp.json ($PI_CODING_AGENT_DIR if set), with "exposure": "direct".
It also writes the CodeNavi usage rules (search with CodeNavi before grep) into
~/.pi/agent/AGENTS.md, which Pi loads in every session; --no-rules skips it.
A backup is saved next to each file. It prints the export line. The entry has no
directTools list, so on Pi older than 0.99 add it by hand (see below).
1. Add the server¶
export CODENAVI_AUTH_TOKEN=$(grep '^CODENAVI_AUTH_TOKEN=' /path/to/install/.env | cut -d= -f2-)
pi mcp add codenavi --url http://localhost:8765/mcp \
--bearer-token-env-var CODENAVI_AUTH_TOKEN --exposure direct
pi mcp list # codenavi: connected, 12 tools (direct, global)
That writes ~/.pi/agent/mcp.json (the user-global file; a trusted project can add
.pi/mcp.json). Written by hand, the same entry, the /connect page generates it with
your address filled in:
{
"mcpServers": {
"codenavi": {
"url": "http://localhost:8765/mcp",
"headers": { "Authorization": "Bearer ${CODENAVI_AUTH_TOKEN}" },
"exposure": "direct",
"directTools": [
"reveal_tools", "semantic_search", "file_search", "symbol_search", "grep_search",
"find_references", "find_callers", "impact_analysis", "diff_impact",
"graph_neighborhood", "codebase_overview", "read_file", "list_directory",
"list_codebases", "wiki_pages", "wiki_page", "doc_sources", "index_stats",
"search_analytics", "submit_feedback", "feedback_stats", "generate_claude_md",
"reindex", "reindex_incremental", "reindex_full", "reindex_docs",
"reindex_status", "cancel_reindex",
"save_note", "search_notes", "list_notes", "delete_note"
]
}
}
}
Keep "exposure": "direct". Pi's default exposure, codemode, does not declare MCP
tools to the model, it reaches them only through a script tool, which smaller local
models rarely manage. direct declares them like built-in tools. directTools is read
only by the adapter on older Pi; Pi 0.99+ ignores it, so one file serves both.
Under the server's default focused profile only semantic search, the call graph, the overview,
the index tools and reveal_tools are advertised (protected lists the older 11-tool core); the rest run through reveal_tools(call=…), and
reveal_tools(group="relations") shows their arguments. To list some of them as Pi tools,
send X-CodeNavi-Tools with the names you want (config.md). Want every tool from the start? Set CODENAVI_TOOL_PROFILE=full on the server
(config.md).
If your server runs with auth off, drop the header, just url.
Verify¶
pi mcp list should show codenavi: connected. In a running session, /reload picks
up a changed mcp.json and /mcp shows the server. Then try:
"Use semantic_search to find where payment processing happens."
Older Pi: the adapter¶
Before 0.99 Pi has no MCP client. Upgrade (npm install -g @earendil-works/pi-coding-agent),
or install the adapter and restart Pi:
pi install npm:pi-mcp-adapter
The adapter reads the same mcpServers entry from ~/.pi/agent/mcp.json (also
~/.config/mcp/mcp.json, .mcp.json, .pi/mcp.json) and needs the directTools list:
without it the tools stay behind the adapter's mcp() gateway. Its other knobs are on
the pi-mcp-adapter package page.
The things that bite people¶
- Default exposure hides the tools. Without
"exposure": "direct"(or--exposure direct), a small model never calls them. - It's
mcp.json, not Pi'ssettings.json. And~/.pi/mcp.json(noagent/) is read by nothing. - Get the token interpolation right.
${CODENAVI_AUTH_TOKEN}in the header needs the variable exported in the shell that starts Pi; otherwise the placeholder text is sent and the server rejects it. - Unscoped vs scoped
/mcp. Use unscoped/mcpunless you know the codebase name./mcp/<name>returnsUnknown codebase(404) for any<name>that isn't configured; a single-codebase install is usually nameddefault. Check withlist_codebases.
Privacy¶
Pi talks to whichever model provider you've configured. Your prompts, and the code chunks CodeNavi returns, go to that provider. Point Pi at a local provider (e.g. Ollama) for fully on-box search + chat, or scope CodeNavi to codebases you're comfortable sharing. The CodeNavi server itself never phones home.