Skip to content

Connecting CodeNavi to GitHub Copilot CLI

GitHub Copilot CLI (copilot, npm package @github/copilot, Node 22+) is GitHub's terminal coding agent. It speaks MCP over HTTP, installs CodeNavi's Claude Code plugin from your server, and can run on a local model with no GitHub login. Verified on Copilot CLI 1.0.97 with a local llama3.1 8B.

Fast path

From your install directory:

./codenavi connect copilot           # --host <addr> if the server is on another machine

It checks the server and the token, then writes the entry from step 1 into ~/.copilot/mcp-config.json ($COPILOT_HOME if set). A backup is saved next to the file. It also writes the CodeNavi usage rules (search with CodeNavi before grep) into ~/.copilot/copilot-instructions.md, which Copilot loads in every session; --no-rules skips it. It prints the export line and the plugin commands from step 2.

1. Add the server

export CODENAVI_AUTH_TOKEN=$(grep '^CODENAVI_AUTH_TOKEN=' /path/to/install/.env | cut -d= -f2-)
copilot mcp add --transport http \
  --header 'Authorization: Bearer ${CODENAVI_AUTH_TOKEN}' \
  codenavi http://localhost:8765/mcp
copilot mcp list      # User servers: codenavi (http)

That writes ~/.copilot/mcp-config.json. Copilot expands ${CODENAVI_AUTH_TOKEN} when it connects, so the file holds the placeholder, not the token. Keep the single quotes, so your shell does not expand it first. Written by hand, the same entry:

{
  "mcpServers": {
    "codenavi": {
      "type": "http",
      "url": "http://localhost:8765/mcp",
      "headers": { "Authorization": "Bearer ${CODENAVI_AUTH_TOKEN}" },
      "tools": ["*"]
    }
  }
}

If your server runs with auth off, drop the --header.

2. Optional: the plugin (skills + session hook)

Copilot CLI installs Claude Code-format plugins, and your CodeNavi server serves its plugin over git:

copilot plugin marketplace add http://localhost:8765/plugins/claude.git
copilot plugin install codenavi@codenavi     # Installed 2 skills.

This adds the using-codenavi and compliance-check skills. It also adds the SessionStart hook, which tells the model to search with CodeNavi before grep. The plugin does not connect the server: Copilot skips the plugin's MCP entry because its URL is a template for Claude Code. Step 1 is still required.

The plugin's commands load as skills too (copilot skill list shows all 15). In the interactive prompt, type them with the prefix: /codenavi:status, /codenavi:feedback. Copilot has its own /feedback, /search and /review, which are different commands. With copilot -p, a slash command is not expanded: name the skill in the prompt instead, for example copilot --allow-tool codenavi -p "Invoke the skill named feedback, then follow its instructions. Rating 3.". A full /codenavi:feedback report needs a capable model: a local Qwen 27B wrote it, and llama3.1 8B did not.

The grep hook works in Copilot too. It sees both the shell tool and Copilot's own grep tool, and with CODENAVI_HOOK_GREP=block it denies a search of the indexed tree and points the model at grep_search instead (checked on Copilot CLI 1.0.97).

Run it on a local model

Copilot CLI takes any OpenAI-compatible endpoint (BYOK). With COPILOT_OFFLINE=true it also turns off GitHub sign-in, telemetry, web tools and auto-update, so no code leaves the machine:

export COPILOT_OFFLINE=true \
       COPILOT_PROVIDER_BASE_URL=http://127.0.0.1:11434/v1 \
       COPILOT_MODEL=llama3.1:latest
copilot

Without these variables Copilot uses GitHub's hosted models, which need a Copilot subscription and /login.

Verify

copilot mcp list shows codenavi (http) but no connection status. To check the token, run one prompt:

copilot --allow-tool codenavi -p "Use the codenavi MCP tools only. Call list_codebases and tell me the codebase names."

The output shows ● list_codebases (MCP: codenavi) and then the names. To the model the tools are named codenavi-semantic_search, codenavi-read_file, and so on. --allow-tool codenavi allows that one server and nothing else.

Under the server's default focused profile, the model sees semantic search, the call graph, the overview, the index tools and reveal_tools (the protected profile lists the older 11-tool core). Run the rest with reveal_tools(call=…); reveal_tools(group="relations") shows their arguments.

The things that bite people

  1. The plugin alone gives no tools. Copilot does not expand ${VAR} in an MCP URL, and it drops the plugin's entry, whose URL is a ${CODENAVI_HOST:-localhost} template. Its debug log blames the shape instead (Invalid MCP config … mcpServers: Required). Add the server with copilot mcp add.
  2. Quote the placeholder. With double quotes the shell writes the real token (or an empty string) into mcp-config.json. With the placeholder kept, export CODENAVI_AUTH_TOKEN in the shell that starts copilot, or the server answers 401. With the plugin installed, its session hook sees the missing or wrong token and tells the model to give you these steps.
  3. Headless needs a permission flag. copilot -p has no one to approve tool calls. Pass --allow-tool codenavi, plus whatever else the task needs (or --allow-all-tools).
  4. Unscoped vs scoped /mcp. Use unscoped /mcp unless you know the codebase name. /mcp/<name> returns Unknown codebase (404) for any <name> that isn't configured; a single-codebase install is usually named default. Check with list_codebases.

Privacy

On GitHub's hosted models, your prompts and the code chunks CodeNavi returns go to GitHub. With COPILOT_OFFLINE=true and a local provider, everything stays on the machine. The CodeNavi server itself never phones home.