Pharaoh - Your AI breaks things it can't see
Pharaoh is a codebase knowledge graph MCP server that transforms your codebase into a queryable knowledge graph, enabling AI agents to understand, analyze, and manage code without reading files one-by-one.
Orientation & Discovery
get_codebase_map— Full architecture: all modules, dependency graph, hot files, and HTTP endpointspharaoh_recon— Batch recon combining codebase map, module deep-dives, function searches, blast radius, and dependency queries in a single parallel callget_module_context— Deep dive into a module: exports, dependencies, DB tables, endpoints, cron jobs, env vars, and spec alignmentsearch_functions— Find existing functions across the codebase to prevent duplicationget_design_system— Discover existing UI components, design tokens, and anti-patterns
Impact Analysis
get_blast_radius— Assess what breaks if you change a function, file, or module (up to 5 hops deep)query_dependencies— Trace dependency paths between modules, detect circular dependencies, and find shared componentscheck_reachability— Verify whether functions are reachable from production entry points to identify dead code (Pro)
Documentation & Specs
get_vision_docs— Retrieve PRDs, roadmaps, and specs with implementation status (Pro)get_vision_gaps— Find unimplemented specs and complex code without documentation (Pro)
Code Quality Auditing (Pro)
get_cross_repo_audit— Compare two repositories for code duplication and structural overlapget_consolidation_opportunities— Find duplicate logic, parallel consumers, and competing DB access patternsget_unused_code— Detect dead code unreachable from production entry pointsget_test_coverage— Identify modules and high-complexity functions lacking test coverageget_regression_risk— Score functions by regression likelihood based on complexity, exposure, churn, and downstream impact
Management & Administration
request_upload— Map a local repo into Pharaoh (metadata only, no source code uploaded)map_open_source_repo— Map a public GitHub repository for queryingsetup_environment— Install Pharaoh's recommended plugin bundle for Claude Codepharaoh_account— Manage subscription, toggle PR Guard, and trigger graph refreshespharaoh_feedback— Submit feedback on tool results to improve accuracy
Integrates with GitHub through a dedicated App and webhooks to automatically map repositories and synchronize codebase changes for architectural analysis.
Provides structural intelligence for Python codebases, allowing agents to map module dependencies, search for functions, and trace execution paths.
Provides structural intelligence for TypeScript codebases, allowing agents to map module dependencies, search for functions, and trace execution paths.
@pharaoh-so/mcp
MCP proxy for Pharaoh — 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 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:
npx @pharaoh-so/mcpThis 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
npx @pharaoh-so/mcpVerify the connection:
claude mcp listYou should see pharaoh listed as a stdio server.
Switching from SSE
If you previously added Pharaoh as an SSE server, remove it first:
claude mcp remove pharaoh
npx @pharaoh-so/mcpRelated MCP server: Context7 MCP
How It Works
Claude Code ← stdio → @pharaoh-so/mcp ← SSE/HTTP → mcp.pharaoh.soThe proxy implements the Model Context Protocol (MCP) specification:
Claude Code launches the proxy as a child process and communicates via stdio (stdin/stdout)
The proxy authenticates with Pharaoh using stored credentials (or triggers device flow)
All MCP messages (tool calls, responses, notifications) are relayed to the remote Pharaoh server over SSE (Server-Sent Events)
Pharaoh queries the knowledge graph and returns architectural data to the proxy
The proxy forwards responses back to Claude Code via stdio
Authentication uses RFC 8628 (OAuth 2.0 Device Authorization Grant) — no browser is needed on the machine running Claude Code.
Available Tools
Once connected, Pharaoh provides 19 MCP tools organized into four categories:
Orient (Free)
Tool | What it answers |
| What modules exist and how do they relate? |
| What does this module look like before I modify it? |
| Does this function already exist somewhere? |
| What UI components and tokens already exist? |
Investigate (Free + Pro)
Tool | What it answers |
| What breaks if I change this function/file/module? |
| How are these two modules connected? |
| Is this function actually reachable from entry points? |
| Is there a PRD or spec for this? |
Audit (Pro)
Tool | What it answers |
| What's specified but not built? What's built but not specified? |
| Are shared dependencies drifting between repos? |
| Where is duplicate or overlapping logic? |
| What code is never called and safe to delete? |
| Which modules/functions lack test coverage? |
| How risky is this change to production? |
Manage (Free)
Tool | What it answers |
| Map a local repo without installing the GitHub App |
| Install recommended development plugins |
| Check plan, toggle PR Guard, trigger refresh |
| Report false positives or tool issues |
| Org-level administration |
Inspect Mode
Use --inspect to dump the full tool manifest as JSON (useful for MCP registry validation and debugging):
npx @pharaoh-so/mcp --inspectThis 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 numberConfiguration
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:
npx @pharaoh-so/mcp --logoutCustom Server
For self-hosted Pharaoh instances or development, register manually:
claude mcp add --scope user pharaoh -- npx @pharaoh-so/mcp --server https://your-pharaoh-instance.comEnvironment Variables
Variable | Default | Description |
|
| Pharaoh server URL (alternative to |
Requirements
Node.js >= 18
Claude Code or any MCP-compatible AI client
A Pharaoh account — sign up at pharaoh.so
Security
Credentials are stored with restrictive file permissions (
0600— owner-read/write only)Authentication uses the RFC 8628 device authorization flow — no secrets are embedded in the package
All communication with the Pharaoh server uses HTTPS/TLS
No source code is ever transmitted — Pharaoh maps structural metadata (function names, file paths, dependency relationships) into a knowledge graph. Your code never leaves your machine.
Tokens expire after 7 days and are refreshed automatically
Only use trusted server URLs — the proxy sends your auth token to the configured server
Reporting Vulnerabilities
If you discover a security vulnerability, please report it responsibly by emailing 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 or try again in a few minutes.
"Token expired" or "401 Unauthorized"
Re-authenticate by running the proxy directly:
npx @pharaoh-so/mcpOr clear credentials and start fresh:
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:
npx @pharaoh-so/mcpNote 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:
npm install -g @pharaoh-so/mcp
claude mcp add --scope user pharaoh -- pharaoh-mcpHow Pharaoh Works
Pharaoh parses your repositories using tree-sitter and maps structural metadata into a Neo4j 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.
Fork the repository
Create your feature branch (
git checkout -b feature/amazing-feature)Commit your changes (
git commit -m 'Add amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
License
MIT -- Pharaoh, Inc.
Links
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Pharaoh-so/pharaoh'
If you have feedback or need assistance with the MCP directory API, please join our Discord server