> For the complete documentation index, see [llms.txt](https://pharaoh.so/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pharaoh.so/docs/setup/openclaw.md).

# OpenClaw

Connect Pharaoh to OpenClaw so your AI agent sees your codebase architecture. Works with desktop instances and headless bots on Signal, Telegram, Discord, and WhatsApp.

**Prerequisite:** [Install the GitHub App](/docs/setup/github-app.md) first.

## Setup

### Option A: Command

```
/mcp add pharaoh https://mcp.pharaoh.so/sse
```

Complete the GitHub OAuth flow when prompted.

### Option B: Config file (browser-based)

Add to your OpenClaw MCP configuration:

```json
{
  "mcpServers": {
    "pharaoh": {
      "url": "https://mcp.pharaoh.so/sse"
    }
  }
}
```

The OAuth flow runs on first connection.

### Option C: Headless bots (Signal, Telegram, Discord, WhatsApp)

Bots on messaging platforms have no browser. Use the stdio transport with device flow auth:

```json
{
  "mcpServers": {
    "pharaoh": {
      "command": "npx",
      "args": ["@pharaoh-so/mcp"]
    }
  }
}
```

On first run, the CLI prints a URL and a code. Open the URL on any device with a browser, enter the code, and authorize with GitHub. The bot stores the token and reconnects automatically after that.

## Verify

Ask your OpenClaw agent:

```
What modules does my codebase have?
```

The agent should call `get_codebase_map` and return a module breakdown with file counts, function counts, and dependency relationships.

## What happens automatically

* The agent calls Pharaoh tools before making architectural decisions - checking for duplicate functions, understanding callers, mapping module boundaries
* Every push to your default branch refreshes the graph within minutes
* No config files or per-repo setup needed after the initial install
* Pharaoh tools return structured data in minimal tokens so the agent has room to reason

## Troubleshooting

**"Skill not loading" or MCP tools don't appear:** Check that your OpenClaw version supports MCP. Update to the latest release if tools aren't showing.

**Auth fails in headless mode:** Use the stdio transport (Option C) with device flow. The SSE transport (Options A and B) requires a browser for OAuth.

**"No repos found" or empty results:** The GitHub App must be installed on the correct org or account. Go to [github.com/apps/pharaoh-so/installations/new](https://github.com/apps/pharaoh-so/installations/new) and verify the installation.

**Device code expired:** Device codes expire after 15 minutes. Run the bot again to get a new code.

**Bot authorized but returns no data:** Wait 1-3 minutes after installing the GitHub App for initial mapping to complete. Large repos take longer.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pharaoh.so/docs/setup/openclaw.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
