Network & authentication¶
CodeNavi serves one port, 8765: the MCP endpoint (/mcp), the web UI (/ui), the connect wizard (/connect) and /health share it. Prometheus metrics are on 9091, on the host's loopback only. Who can reach port 8765 depends on the install:
| Install | Listens on | From another machine |
|---|---|---|
Linux with a GPU, set up by setup.sh (NVIDIA or AMD) |
0.0.0.0:8765 (every interface) |
Reachable, unless a firewall blocks it. Plain HTTP. The code, the index and the settings need the token; open without it are only /health (minimal), the web UI and connect page files, the plugin downloads and product information |
| Linux without a GPU, and Windows | 127.0.0.1:8765 |
Not reachable until you set CODENAVI_HOST=0.0.0.0 |
A Linux GPU install shares the host's network, so there is no published port to limit, and setup.sh writes CODENAVI_BIND=0.0.0.0 to .env together with a generated token. To keep it on this machine only, set CODENAVI_BIND=127.0.0.1 in .env and run docker compose up -d. On a network you do not control, do that or put HTTPS in front: over plain HTTP anyone on the path can read the code and the token. ss -tlnp | grep 8765 shows what yours does.
| Variable | Default | Notes | |
|---|---|---|---|
| Port | CODENAVI_PORT |
8765 |
MCP + web UI |
| Metrics port | CODENAVI_METRICS_PORT |
9091 |
Prometheus text format; also bearer-gated at GET /metrics on the API port |
| Host interface | CODENAVI_HOST |
127.0.0.1 |
The host-side interface the port is published on. 0.0.0.0 for LAN access. Ignored on a Linux GPU install (nothing is published there). |
| Server bind | CODENAVI_BIND |
0.0.0.0 |
What the server itself listens on.1 On a Linux GPU install this is the host's interface: 127.0.0.1 keeps it local. On every other install it is inside the container; leave it. |
| Auth token | CODENAVI_AUTH_TOKEN |
generated by setup.sh |
Bearer token. Empty = no auth, allowed only on a loopback bind: otherwise the server refuses to start. |
| Public URL | CODENAVI_PUBLIC_URL |
http://localhost:<port> |
The origin clients reach the server at from outside (scheme + host + optional port, no path). Set it when a reverse proxy or tunnel fronts CodeNavi, see HTTPS in front of CodeNavi. |
Authentication (bearer token)¶
setup.sh generates CODENAVI_AUTH_TOKEN. Without a token the server accepts all requests, and starts only when it is bound to 127.0.0.1.
To enable authentication:
- Generate a token:
python3 -c "import secrets; print(secrets.token_urlsafe(32))"
- Set it in
.env:
CODENAVI_AUTH_TOKEN=your-generated-token-here
- Restart the container:
docker compose down && docker compose up -d
- Configure your MCP client to send the token. In Claude Code's
.mcp.json:
{
"mcpServers": {
"codenavi": {
"type": "http",
"url": "http://localhost:8765/mcp",
"headers": {
"Authorization": "Bearer your-generated-token-here"
}
}
}
}
The /health endpoint is always unauthenticated, so monitoring tools work without tokens.
The server implements RFC 9728 OAuth Protected Resource metadata. MCP clients that support OAuth discovery will automatically detect whether auth is required by querying /.well-known/oauth-protected-resource.
Packaged and trial installs always issue a token, the installer prints it, and the connect wizard fills it into the client config for you.
Rotate the token¶
Rotate the token when it may have leaked. For example, if it was pasted into a chat or a ticket, stored on a machine you no longer control, or held by a person who left. The server reads one token when it starts. When you recreate the container, the old token stops working at once. There is no overlap period, so connected clients get 401 until you give them the new token.
- Put a new token in your install's
.env(run this in the install folder):
NEW=$(python3 -c "import secrets; print(secrets.token_urlsafe(32))")
sed -i "s|^CODENAVI_AUTH_TOKEN=.*|CODENAVI_AUTH_TOKEN=$NEW|" .env
chmod 600 .env
On Windows (PowerShell, in the install folder):
$b = New-Object byte[] 32; [Security.Cryptography.RandomNumberGenerator]::Create().GetBytes($b)
$new = [Convert]::ToBase64String($b).TrimEnd('=').Replace('+','-').Replace('/','_')
$lines = (Get-Content .env) -replace '^CODENAVI_AUTH_TOKEN=.*', "CODENAVI_AUTH_TOKEN=$new"
[IO.File]::WriteAllLines("$PWD\.env", $lines) # UTF-8 without a BOM
- Recreate the container, from a shell that does not hold the old token:
env -u CODENAVI_AUTH_TOKEN docker compose up -d --force-recreate
On Windows: Remove-Item Env:CODENAVI_AUTH_TOKEN -ErrorAction SilentlyContinue; docker compose up -d --force-recreate. On a podman install, use podman compose.
Two traps make the server keep the old token without an error:
- docker compose restart does not read .env again.
- Compose takes CODENAVI_AUTH_TOKEN from your shell before it reads .env. Some client guides tell you to export the token, so your shell can still hold the old value.
- Check that the old token no longer works. Send the same request with each token. Expect
200for the new token and401for the old one:
probe() { curl -s -o /dev/null -w '%{http_code}\n' -X POST http://localhost:8765/mcp \
-H "Authorization: Bearer $1" -H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"probe","version":"0"}}}'; }
probe "$NEW" # 200
probe "<old token>" # 401
Do not use /health for this check. It never returns 401.
- Give the new token to every client. Put it in each place where you stored the old one: an MCP config
Authorizationheader, anenvblock (for example in Claude Code's~/.claude/settings.json), a shell profile, or a CI secret. Then restart those clients, because most read the token only when they start. If you used the connect wizard, open it again and copy the new config. To find the stored copies on a machine, search for the old token. Print only the file names, never the matching lines:
printf '%s\n' "<old token>" > /tmp/old.tok
grep -rlF -f /tmp/old.tok ~ 2>/dev/null; rm /tmp/old.tok
Backups and agent history files can keep the old value. After the rotation that value has no access, so you can delete these copies when you want.
Beyond localhost¶
Every recipe starts with the token above. Then, by shape:
| You want | Recipe |
|---|---|
| A second machine on the same LAN (another dev box, a Windows IDE talking to a Linux server) | Remote access → Same LAN, CODENAVI_HOST=0.0.0.0 (a Linux GPU install is reachable already) + token, plain HTTP |
| HTTPS from anywhere: phones, Claude Desktop Connectors, off-site | Remote access → Tailscale Funnel / Cloudflare Tunnel / your own proxy |
| One shared server for the whole team, index following the repo | Team server |
| Windows IDE ↔ CodeNavi in Docker Desktop or WSL2 on the same PC | Windows, no proxy on the Docker Desktop path; netsh port proxy only for a self-managed WSL2 install |
| A CI runner calling the server | CI review bots |
Health and monitoring endpoints¶
GET /health is always unauthenticated but minimal without a token (status, version, auth_required, no codebase names, counts or models), so monitors work and an unauthenticated caller cannot inventory the deployment. The full diagnostic body needs the bearer token, see Setup guide → Health check. Metrics: Observability.
Outbound connections¶
Apart from the update check below, the server by default makes no outbound connection after install: the embedder is in the image, the reranker is cached on first run (TRANSFORMERS_OFFLINE=1 afterwards), and search runs entirely on the box. The only outbound paths, each visible: a cloud LLM provider for chat (Providers), the web crawler when you enable it (with an SSRF guard that refuses private and cloud-metadata addresses, Configuration), event hooks you configure (Webhooks), and the update check, which the one-line installer turns on and CODENAVI_UPDATE_CHECK=off turns off (Updating). An air-gapped install has none of them. Your coding agent's connection to its model provider is separate from the server and carries what the agent reads.
-
Vendor change reference CN-84. ↩