> ## 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.

# Droid

> MCP wiring for Factory.ai's CLI plus native five-event auto-capture hooks

Droid ships a first-party hooks system in the same shape Claude Code uses, so it gets both MCP tools and native auto-capture from one command.

## Setup

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

  <Step title="Wire MCP and hooks">
    ```bash theme={"dark"}
    npx @agentmemory/agentmemory connect droid --with-hooks
    ```

    The adapter detects `~/.factory/`, backs up `mcp.json`, merges the entry, verifies it, and merges the hook manifest into `~/.factory/hooks.json`.
  </Step>

  <Step title="Restart droid">
    Start a new droid session and run `/mcp` to list configured servers.
  </Step>

  <Step title="Verify">
    Run one prompt, then check the Sessions tab at `http://localhost:3113`; with hooks installed the session and its tool calls appear without any tool invocation by the agent.
  </Step>
</Steps>

## What connect writes

Droid's schema requires an explicit `type` per entry; the adapter adds `"type": "stdio"` to the standard block:

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

Project-scoped overrides live at `<repo>/.factory/mcp.json`.

## What `--with-hooks` writes

`--with-hooks` merges the bundled `hooks.droid.json` manifest into `~/.factory/hooks.json`. Five events fire: `SessionStart`, `UserPromptSubmit`, `PreToolUse` (matcher `Edit|Create|Read|Glob|Grep`), `PostToolUse`, and `SessionEnd`. The merge is idempotent: re-installs replace only entries whose command points under the bundled `scripts/` directory, preserving your own hooks. The hooks installer runs even when MCP is already wired.

`connect` also upserts a memory-usage guideline block into the global `~/.factory/AGENTS.md`. Skip with `--no-guidelines`.

<Warning>
  Hook entries reference absolute paths under the installed package's `plugin/` directory. Re-run `agentmemory connect droid --with-hooks` after upgrading agentmemory to refresh them.
</Warning>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Droid hooks skipped: could not locate bundled plugin/ directory">
    The installer resolves the bundled `plugin/` directory of the installed `@agentmemory/agentmemory` package and skips hook install when it is missing. Reinstall the package and re-run; MCP wiring is applied regardless.
  </Accordion>

  <Accordion title="Server missing from /mcp after connect">
    Droid reads `~/.factory/mcp.json` at session start. Open a new session. If a project-level `.factory/mcp.json` exists in the repo, it overrides the user-level file; add the entry there too.
  </Accordion>
</AccordionGroup>

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