> ## Documentation Index
> Fetch the complete documentation index at: https://agent-memory.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# GitHub Copilot CLI

> MCP wiring plus an 11-event plugin, the one adapter that also runs on Windows

## Setup

<Steps>
  <Step title="Start agentmemory">
    ```bash theme={"dark"}
    npx @agentmemory/agentmemory
    ```
  </Step>

  <Step title="Wire MCP">
    ```bash theme={"dark"}
    npx @agentmemory/agentmemory connect copilot-cli
    ```

    The adapter detects `~/.copilot/` (or `$COPILOT_HOME` when set), backs up `mcp-config.json`, merges the entry, and verifies it after writing. This is the only connect adapter that runs on Windows; every other adapter requires manual setup there.
  </Step>

  <Step title="Install the plugin for hooks and skills">
    ```bash theme={"dark"}
    copilot plugin install rohitg00/agentmemory:plugin
    ```
  </Step>

  <Step title="Restart Copilot">
    Copilot picks up MCP servers on next launch or after running `/mcp` inside a session.
  </Step>

  <Step title="Verify">
    ```bash theme={"dark"}
    curl http://localhost:3111/agentmemory/health
    ```

    Run one prompt and check the Sessions tab at `http://localhost:3113`.
  </Step>
</Steps>

## What connect writes

The Copilot entry extends the standard block with `type` and a `tools` allowlist:

```json ~/.copilot/mcp-config.json theme={"dark"}
{
  "mcpServers": {
    "agentmemory": {
      "type": "local",
      "command": "npx",
      "args": ["-y", "@agentmemory/mcp"],
      "env": {
        "AGENTMEMORY_URL": "${AGENTMEMORY_URL:-http://localhost:3111}",
        "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET:-}",
        "AGENTMEMORY_TOOLS": "${AGENTMEMORY_TOOLS:-all}"
      },
      "tools": ["*"]
    }
  }
}
```

On Windows the adapter writes `cmd.exe` with `["/d", "/s", "/c", "npx", "-y", "@agentmemory/mcp"]` as the command, since Copilot spawns the server without a shell.

`connect` also writes a memory-usage guideline block into `~/.copilot/copilot-instructions.md` so the agent calls `memory_recall` and `memory_save` on its own. Skip with `--no-guidelines`.

## Capture model

MCP wiring alone gives the 54 tools but no automatic capture. The plugin adds it: the bundled `hooks.copilot.json` manifest registers 11 events in Copilot's camelCase scheme, `sessionStart`, `userPromptSubmitted`, `preToolUse`, `postToolUse`, `postToolUseFailure`, `preCompact`, `agentStop`, `sessionEnd`, `subagentStart`, `subagentStop`, and `notification`, each posting to the REST API on 3111.

## Troubleshooting

<AccordionGroup>
  <Accordion title="Server wired but tools not listed">
    Copilot loads `mcp-config.json` at launch. Run `/mcp` inside the session or restart the CLI. If `COPILOT_HOME` is set, confirm the adapter wrote to `$COPILOT_HOME/mcp-config.json` rather than `~/.copilot/`; the summary line prints the exact path.
  </Accordion>

  <Accordion title="Tools available but nothing captured">
    That is expected with MCP-only wiring. Install the plugin (`copilot plugin install rohitg00/agentmemory:plugin`) to get the 11 lifecycle events.
  </Accordion>
</AccordionGroup>

Adapter source: `src/cli/connect/copilot-cli.ts`. Hook manifest: `plugin/hooks/hooks.copilot.json`.
