Skip to main content
Glama
Pharaoh-so

Pharaoh - Your AI breaks things it can't see

by Pharaoh-so
README.md
# @pharaoh-so/mcp

[![npm version](https://img.shields.io/npm/v/@pharaoh-so/mcp)](https://www.npmjs.com/package/@pharaoh-so/mcp)
[![license](https://img.shields.io/npm/l/@pharaoh-so/mcp)](https://github.com/Pharaoh-so/pharaoh-mcp/blob/main/LICENSE)
[![node](https://img.shields.io/node/v/@pharaoh-so/mcp)](https://nodejs.org)
[![pharaoh MCP server](https://glama.ai/mcp/servers/Pharaoh-so/pharaoh/badges/score.svg)](https://glama.ai/mcp/servers/Pharaoh-so/pharaoh)

MCP proxy for [Pharaoh](https://pharaoh.so) — maps codebases into queryable knowledge graphs for AI agents.

Pharaoh gives AI coding assistants a complete architectural map of your codebase: every function, dependency, module, and connection. Instead of reading files one at a time, your AI agent queries the knowledge graph and gets instant answers about blast radius, unused code, dependency chains, and more.

This package enables [Claude Code](https://docs.anthropic.com/en/docs/build-with-claude/claude-code) to connect to Pharaoh in **headless environments** (VPS, SSH, containers, CI) where a browser isn't available for OAuth. It acts as a stdio-to-SSE proxy, presenting itself as a local MCP server while relaying all communication to the remote Pharaoh server.

## Quick Start

### Step 1 — Authenticate

Run the proxy directly to trigger the device authorization flow:

```bash
npx @pharaoh-so/mcp
```

This displays a device code and a URL. Open the URL on **any device** (phone, laptop, tablet) and enter the code to authorize. Credentials are saved to `~/.pharaoh/credentials.json` and remain valid for 7 days, with automatic re-authorization when they expire.

### Step 2 — Add to Claude Code

```bash
npx @pharaoh-so/mcp
```

Verify the connection:

```bash
claude mcp list
```

You should see `pharaoh` listed as a **stdio** server.

### Switching from SSE

If you previously added Pharaoh as an SSE server, remove it first:

```bash
claude mcp remove pharaoh
npx @pharaoh-so/mcp
```

## How It Works

```
Claude Code ← stdio → @pharaoh-so/mcp ← SSE/HTTP → mcp.pharaoh.so
```

The proxy implements the [Model Context Protocol](https://modelcontextprotocol.io/) (MCP) specification:

1. **Claude Code** launches the proxy as a child process and communicates via **stdio** (stdin/stdout)
2. **The proxy** authenticates with Pharaoh using stored credentials (or triggers device flow)
3. **All MCP messages** (tool calls, responses, notifications) are relayed to the remote Pharaoh server over **SSE** (Server-Sent Events)
4. **Pharaoh** queries the knowledge graph and returns architectural data to the proxy
5. **The proxy** forwards responses back to Claude Code via stdio

Authentication uses [RFC 8628](https://datatracker.ietf.org/doc/html/rfc8628) (OAuth 2.0 Device Authorization Grant) — no browser is needed on the machine running Claude Code.

## Available Tools

Once connected, Pharaoh provides these MCP tools:

### Orient

| Tool | What it answers |
|------|----------------|
| `get_codebase_map` | What modules exist and how do they relate? |
| `get_module_context` | What does this module look like before I modify it? |
| `search_functions` | Does this function already exist somewhere? |
| `pharaoh_recon` | Map, module context, search and blast radius in one call |

### Investigate

| Tool | What it answers |
|------|----------------|
| `get_blast_radius` | What breaks if I change this function/file/module? |

### Manage

| Tool | What it answers |
|------|----------------|
| `pharaoh_account` | Check plan, toggle PR Guard, trigger refresh |
| `pharaoh_admin` | Org-level administration |

## Inspect Mode

Use `--inspect` to dump the full tool manifest as JSON (useful for MCP registry validation and debugging):

```bash
npx @pharaoh-so/mcp --inspect
```

This outputs the complete list of tools with their schemas and exits immediately, without connecting to the server.

## CLI Options

```
Usage: pharaoh-mcp [options]

Options:
  --server <url>   Pharaoh server URL (default: https://mcp.pharaoh.so)
  --logout         Clear stored credentials and exit
  --inspect        Output tool manifest as JSON and exit
  --help           Show help
  --version        Show version number
```

## Configuration

### Credentials

Credentials are stored at `~/.pharaoh/credentials.json` with `0600` permissions (owner-read/write only). The file contains:

- **Access token** — used to authenticate MCP requests
- **Refresh token** — used to obtain new access tokens when they expire
- **Expiry timestamp** — tokens are refreshed automatically before expiration

To clear credentials:

```bash
npx @pharaoh-so/mcp --logout
```

### Custom Server

For self-hosted Pharaoh instances or development, register manually, pinned to a version (`npx @pharaoh-so/mcp --version` prints the one you have):

```bash
claude mcp add --scope user pharaoh -- npx @pharaoh-so/mcp@<version> --server https://your-pharaoh-instance.com
```

### Environment Variables

| Variable | Default | Description |
|----------|---------|-------------|
| `PHARAOH_SERVER_URL` | `https://mcp.pharaoh.so` | Pharaoh server URL (alternative to `--server`) |

## Requirements

- **Node.js** >= 18
- **Claude Code** or any MCP-compatible AI client
- A **Pharaoh account** — sign up at [pharaoh.so](https://pharaoh.so)

## Security

- Credentials are stored with restrictive file permissions (`0600` — owner-read/write only)
- Authentication uses the [RFC 8628](https://datatracker.ietf.org/doc/html/rfc8628) device authorization flow — no secrets are embedded in the package
- All communication with the Pharaoh server uses HTTPS/TLS
- The proxy never reads or sends your local files. Pharaoh reads your code from GitHub through its GitHub App, maps it into a knowledge graph of structural metadata (function names, file paths, dependency relationships), and deletes the clone when mapping ends.
- Tokens expire after 7 days and are refreshed automatically
- Only use trusted server URLs — the proxy sends your auth token to the configured server
- No telemetry. The proxy's only network calls are the device flow, token refresh, the MCP connection, and one registry lookup during interactive setup (below).

### What the installer writes on your machine

`npx @pharaoh-so/mcp` in a terminal is the interactive setup. Every later proxy start (Claude Code launching the server) repeats the plugin, skill and command steps so a new version takes effect, and nothing else.

| Path | Mode | When | What |
|------|------|------|------|
| `~/.pharaoh/` | `0700`, set again on every start | Always | Credentials and the Claude Code plugin marketplace |
| `~/.pharaoh/credentials.json` | `0600` | After sign-in | Access token, refresh token, expiry |
| `~/.pharaoh/claude-marketplace/` | — | `~/.claude/` exists | The one-plugin marketplace Claude Code installs as `pharaoh@pharaoh`: the skills and the Grep routing hook. Rewritten when the package version changes |
| `~/.claude/commands/plan.md`, `review.md` | — | `~/.claude/` exists | Slash commands. A file is written only when it is absent or is Pharaoh's: it carries the front-matter comment `# managed-by: pharaoh-mcp`, or has the exact header and `$ARGUMENTS` footer of a Pharaoh command from 0.3.46 or earlier. Any other file with that name is yours: it is kept, a symlink is never followed, and the setup output names it. Rename your file to keep both. 0.3.51 and earlier also wrote `sessions.md`; later versions delete it while it carries the marker |
| `~/.claude.json` | — | Interactive setup | Removes earlier `pharaoh` entries, then `claude mcp add --scope user pharaoh -- npx @pharaoh-so/mcp@<version>` |
| `~/.claude/settings.json` | — | Interactive setup, and only if the file already exists | Adds to `permissions.allow`, each by full name: `mcp__pharaoh__get_codebase_map`, `mcp__pharaoh__get_module_context`, `mcp__pharaoh__search_functions`, `mcp__pharaoh__get_blast_radius`, `mcp__pharaoh__get_unused_code`, `mcp__pharaoh__pharaoh_recon`, `mcp__pharaoh__pharaoh_account`. The setup prints a line saying what it did. The proxy never creates this file and never touches it on a start |
| `~/.agents/skills/pharaoh-review/` | — | `~/.codex/` exists | The review skill for Codex (`$pharaoh-review`), rewritten on every start. Other tools share `~/.agents/skills/`, so nothing else there is touched |
| `~/.openclaw/skills/`, `~/.openclaw/openclaw.json` | — | `~/.openclaw/` exists | Skills prefixed `pharaoh-`, and an `mcpServers.pharaoh` entry running `npx @pharaoh-so/mcp@<version>`. An entry that is not an `npx @pharaoh-so/mcp` command is left alone |

Versions 0.3.46 and earlier wrote one rule, `mcp__pharaoh`, on every proxy start. That prefix auto-approved every Pharaoh tool, including account deletion and `pharaoh_admin`, so a prompt injection could run them without a human prompt. The next interactive setup replaces that rule with the list above; account deletion, `pharaoh_admin` and any tool not listed prompt before they run. To take the blanket rule out by hand, delete `mcp__pharaoh` from `permissions.allow`.

### Pinned version and upgrades

Every registration the setup writes runs the exact version that wrote it (`npx @pharaoh-so/mcp@<version>`). A new release on npm changes nothing on your machine until you upgrade:

```bash
npx @pharaoh-so/mcp@latest
```

This signs you in again, rewrites the registration with the new version and refreshes the plugin. The interactive setup asks the npm registry for the newest version and prints a one-line hint when there is one; proxy starts never check.

### Reporting Vulnerabilities

If you discover a security vulnerability, please report it responsibly by emailing [security@pharaoh.so](mailto:security@pharaoh.so). Do not open a public issue.

## Troubleshooting

### "Connection refused" or "ECONNREFUSED"

The Pharaoh server may be temporarily unavailable. Check [status.pharaoh.so](https://pharaoh.so) or try again in a few minutes.

### "Token expired" or "401 Unauthorized"

Re-authenticate by running the proxy directly:

```bash
npx @pharaoh-so/mcp
```

Or clear credentials and start fresh:

```bash
npx @pharaoh-so/mcp --logout
npx @pharaoh-so/mcp
```

### "pharaoh" not showing in `claude mcp list`

Make sure you added it with the correct command:

```bash
npx @pharaoh-so/mcp
```

Note the `--` separator between `pharaoh` and `npx`.

### Device code not working

- Ensure you're opening the URL on a device with browser access
- The device code expires after 15 minutes — request a new one by re-running the command
- Check that you're logged into GitHub when authorizing

### Slow startup

The first run after installation may take a moment as npm downloads the package. Subsequent runs use the cached version. To pre-install globally:

```bash
npm install -g @pharaoh-so/mcp
claude mcp add --scope user pharaoh -- pharaoh-mcp
```

## How Pharaoh Works

Pharaoh parses your repositories using [tree-sitter](https://tree-sitter.github.io/) and maps structural metadata into a [Neo4j](https://neo4j.com/) knowledge graph. The graph contains:

- **Functions** — names, signatures, complexity scores, export visibility
- **Files** — paths, module membership, language classification
- **Modules** — logical groupings detected from directory structure
- **Dependencies** — import/export relationships, call chains, module connections
- **Vision specs** — PRD/spec documents linked to implementation

No source code is stored — only structural metadata. When an AI agent queries Pharaoh, it gets architectural facts in minimal tokens, not raw code dumps. This means your AI assistant can understand your entire codebase architecture without consuming its context window reading files one by one.

## Supported Languages

- **TypeScript / JavaScript** — full support (functions, classes, imports, exports, JSX)
- **Python** — full support (functions, classes, imports, decorators)
- More languages planned via tree-sitter grammar support

## Contributing

Contributions are welcome. Please open an issue first to discuss what you'd like to change.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## License

[MIT](LICENSE) -- Pharaoh, Inc.

## Links

- [Pharaoh website](https://pharaoh.so)
- [Documentation](https://docs.pharaoh.so)
- [MCP specification](https://modelcontextprotocol.io/)
- [Claude Code](https://docs.anthropic.com/en/docs/build-with-claude/claude-code)
- [Report an issue](https://github.com/Pharaoh-so/pharaoh-mcp/issues)

TDQS

A4.2/5.0

Scored across 7 tools

Disambiguation4/5

Most tools target clearly distinct questions: architecture map, module profile, blast radius, function search, dead code, account. The only real overlap is pharaoh_recon, which bundles codebase map, module profiles, searches, and blast radius, so an agent might hesitate between it and the individual tools. The descriptions do mitigate this with explicit 'call this when' guidance, but the batch wrapper is inherently a superset of other tools.

Naming Consistency4/5

Mostly consistent snake_case with a verb-first pattern (get_codebase_map, get_module_context, get_blast_radius, search_functions, get_unused_code). The two pharaoh_-prefixed tools (pharaoh_recon, pharaoh_account) break the verb_noun convention slightly, but remain readable and logically clustered as server-management operations.

Tool Count5/5

Seven tools is well-scoped for a codebase-intelligence server, and each tool earns its place: map, module context, impact analysis, function search, dead-code detection, batch recon, and account management. No padding or obviously trivial tool.

Completeness4/5

Coverage is strong for architecture understanding, change impact, function discovery, and unused-code cleanup. The notable gap is that none of the tools return actual source code bodies or line contents—agents can locate and assess functions but cannot read the implementation, which may force a fallback to another file-access mechanism.

Maintenance

ActivityMaintained
ResponsivenessNo issues