Atlas MCP Server
The Atlas MCP Server exposes the code knowledge graph via the Model Context Protocol (MCP), allowing Claude, Cline, Roo, and other agents to query semantic code intelligence using standardized tools.Overview
The MCP server is a Node.js process that:- Opens the
.atlas/SQLite database for a project - Implements the MCP specification (tools, resources, protocol)
- Exposes Atlas functionality as AI-readable tools
- Handles concurrent requests from multiple agents
- Manages its own lifecycle (daemon, proxy, direct modes)
Architecture & Modes
The MCP server supports three runtime modes, decided at startup based on configuration and availability:1. Direct Mode
One process = one MCP client over stdio- Simplest setup
- No background daemon
- Process exits when client disconnects
- Used when:
ATLAS_NO_DAEMON=1environment variable is set- No
.atlas/directory exists - Daemon machinery fails to initialize
2. Proxy Mode
Thin stdio ← → socket bridge to a shared daemon- Used by default when
.atlas/exists and daemon is available - Proxy is lightweight, exits when agent disconnects
- Daemon persists in background, serves multiple clients
- Proxy carries PPID watchdog to gracefully tear down if host is killed
3. Daemon Mode
Shared background process with Unix socket or named pipe- Spawned on-demand by the first proxy
- Detached process, not a child of any host
- Survives individual agent disconnects
- Exits after client-refcount timeout (~5 minutes idle)
- Logs to
.atlas/daemon.log
- Lockfile at
.atlas/daemon.lockarbitrates startup races - Multiple launchers may race to spawn; only one wins
- Winner acquires O_EXCL lock, binds socket, serves all proxies
- Losers detect the lock, connect to winner’s socket
Server Startup & Discovery
From Tempest (Automatic)
When you enable Token Intelligence or start an agent in Tempest:-
Tempest’s Rust backend calls
start_atlas_index()if.atlas/doesn’t exist- Spawns
atlas --init --path <project>(background Node process) - Tauri toast polls for
.atlas/atlas.dbto appear - Background indexing happens while you work
- Spawns
-
When an agent spawns, Tempest starts the MCP server:
- Calls
invoke<boolean>("start_atlas_mcp", { projectPath }) - Spawns
node .../atlas/dist/mcp/server-entry.js --path <project> - Server immediately prints MCP handshake to stdout
- Calls
- The agent’s MCP host receives the server process and connects over stdio
.mcp.json(Claude Code, Cline, Roo, Zed, Windsurf standard).cursor/mcp.json(Cursor).gemini/settings.json(Google Gemini).kiro/settings/mcp.json(AWS Kiro).github/copilot/config.json(GitHub Copilot)
.mcp.json:
Manual Setup (Outside Tempest)
To connect any agent to Atlas:MCP Protocol Details
Initialization (Handshake)
When the MCP host starts the server process, the server writes MCP initialization messages to stdout:initialize, the server is ready to receive tool calls via tools/call.
Tools/List
Clients request available tools viatools/list:
Tool Invocation
Clients invoke tools viatools/call:
success: boolean— operation succeededisError?: boolean— tool result is an error (false for recoverable “no index” conditions)content: TextContent[]— tool output
Exposed Tools
The Atlas MCP server exposes the following tools to agents:atlas_search
Search the code graph by name or full-text. Purpose: Find symbols matching a query, ranked by relevance. Arguments:query(string, required): Search term (e.g., “authenticate”, “User”, “handleSubmit”)limit(number, optional): Max results to return (default: 20)
atlas_explore
Find relevant code context for a natural language query. Purpose: Answer “How does X work?” by returning a focused subgraph of relevant nodes and code snippets. Arguments:query(string, required): Task or question (e.g., “How does user login work?”)maxFiles(number, optional): Max files to include (default: adaptive based on project size)
atlas_node
Retrieve detailed information about a specific symbol. Purpose: Get a symbol’s definition, metadata, and related symbols. Arguments:symbol(string, required): Symbol name or qualified name (e.g., “authenticate” or “src/auth.ts::authenticate”)includeCode(boolean, optional): Include source code (default: true)kind(string, optional): Filter by node kind (e.g., “function”, “class”)includeRelated(boolean, optional): Include callers, callees, usages (default: false)
atlas_graph
Traverse the code graph to answer structural questions. Purpose: Explore relationships: “Who calls this?”, “What does this class extend?”, “Where is this variable used?” Arguments:query(string, required): Graph query in format<operation> <symbol>find_callers <symbol>— functions/methods that call thisfind_callees <symbol>— functions/methods this callsfind_usages <symbol>— all references to this symbolfind_type_hierarchy <symbol>— ancestors and descendantsfind_implementations <interface>— classes implementing this interfacefind_impact <symbol>— all symbols potentially affected by changes to thisfind_circular_dependencies— cycles in the codebasefind_dead_code— unreferenced symbols
atlas_status
Get project index status and statistics. Purpose: Check if index exists, how fresh it is, and get graph statistics. Arguments:projectPath(string, optional): Project path (default: cwd or discovered)
atlas_file_dependencies
Get files that a source file depends on. Purpose: Understand import structure and find integration points. Arguments:filePath(string, required): Path to file (relative to project root)
Agent Integration Examples
Claude (Claude Code)
Claude automatically uses Atlas tools when available. Example:Cline / Roo
Cline and Roo read MCP server config from.mcp.json and connect to Atlas automatically:
Zed, Windsurf, Cursor
These editors include their own AI agents with MCP support. Add Atlas to their MCP config: Zed (.zed/settings.json):.mcp.json.
Cursor (.cursor/mcp.json):
Standard MCP format.
Performance & Optimization
Tool Response Times
atlas_search: 10-100ms (depends on query specificity)atlas_explore: 50-500ms (includes graph traversal and code extraction)atlas_node: 5-50ms (cached queries)atlas_graph: 50-1000ms (depends on graph depth and size)atlas_status: < 5ms
- Per tool call: 100-500ms (network + execution)
- Typical agent query: 1-3 tool calls + LLM inference
- Total latency: Usually 2-5 seconds (LLM dominates)
Database Concurrency
Atlas uses SQLite with WAL (Write-Ahead Log) mode:- Multiple MCP clients can read simultaneously
- Background file watcher can write while tools are running
- No locks needed for reads (except when sync is in progress)
- Sync holds a file lock for 1-10 seconds on typical changes
- PPID watchdog (proxy mode): If host process dies (SIGKILL), proxy detects parent process death and shuts down gracefully
- Liveness watchdog (daemon mode): Heartbeat monitor that detects main-thread hangs and SIGKILLs the process if unresponsive for 10+ seconds
- Idle timeout (daemon mode): After 5 minutes with no clients, daemon exits to free resources
Token Efficiency
Typical token savings using Atlas:| Query | Without Atlas | With Atlas | Savings |
|---|---|---|---|
| ”How does auth work?“ | 2000-3000 tokens | 300-500 tokens | 75-85% |
| “Find all callers of X” | 1500-2000 tokens | 200-400 tokens | 80-90% |
| “Implement feature Y” | 3000-5000 tokens | 400-800 tokens | 75-85% |
| “Refactor module Z” | 2500-4000 tokens | 300-600 tokens | 80-88% |
- Returning ranked search results instead of whole files
- Providing symbol metadata instead of raw code parsing
- Showing relationships instead of requiring file reads
Troubleshooting
Server Won’t Start
Error: “Cannot resolve CLI script path to spawn the daemon”- Cause: Node entry point (
process.argv[1]) is invalid - Fix: Use full path to
server-entry.jsin MCP config
- Cause: Another process is indexing or the database is corrupted
- Fix: Wait for indexing to complete, or remove
.atlas/and re-index
Daemon Won’t Start
Error: “Could not bind socket” or “daemon.sock exists”- Cause: Stale socket from previous daemon or race condition
- Fix: Remove
.atlas/daemon.lockand retry - OR: Set
ATLAS_NO_DAEMON=1to run in direct mode instead
Proxy/Client Won’t Connect
Error: “ECONNREFUSED: connection refused”- Cause: Daemon didn’t start or socket isn’t ready
- Fix: Check
.atlas/daemon.logfor errors - Fallback:
ATLAS_NO_DAEMON=1to run in direct mode
Tool Returns Empty Results
Possible causes:-
Index is empty (no files indexed yet)
- Run
atlas index --path <project>manually - Check
atlas_statusto verify index exists
- Run
-
Query is too specific
- Try broader terms (“auth” instead of “authenticate”)
- Use
atlas_searchfirst to see what symbols exist
-
File is excluded
- Check
.gitignoreandatlas.jsonexclude patterns - Verify file is in an indexed language
- Check
MCP Connection Drops
Error: “MCP server disconnected” or repeated timeouts- Cause: Server process crashed or ran out of resources
- Check:
.atlas/daemon.logfor errors - Solution: Restart agent or Tempest
High Memory Usage
- Cause: Large graph or long-running daemon with many symbols
- Solution: Restart daemon (
kill -9process with PID from.atlas/daemon.lock) - Or: Use
ATLAS_NO_DAEMON=1for fresh process per agent
Architecture & Code Structure
Key files inpackages/atlas/src/mcp/:
index.ts— MCPServer class (main entry point)server-entry.ts— CLI entry point (handles —init, —path flags)engine.ts— MCP protocol implementation (tool schemas, dispatch)tools.ts— Tool handler implementations (search, explore, graph, etc.)daemon.ts— Detached daemon process lifecycleproxy.ts— Stdio ← → socket bridgetransport.ts— MCP protocol serializationsession.ts— Per-connection session statedaemon-manager.ts— Daemon lifecycle managementppid-watchdog.ts— Process parent monitoringliveness-watchdog.ts— Main thread health monitoringquery-pool.ts— Worker thread pool for graph queriesdynamic-boundaries.ts— Dynamic dispatch (scanning code for certain patterns)
Advanced Configuration
Disable Daemon Mode
Set environment variable to force direct mode (no background daemon):Custom Daemon Paths
The daemon socket path is computed from:- Project root
.atlas/directory - Hash of the absolute path (prevents collisions with symlinks)
- Linux/macOS:
/run/user/1000/atlas_<hash>.sock - Windows:
//./pipe/atlas_<hash>
Logging
Daemon logs to.atlas/daemon.log. Enable verbose logging:
Future Enhancements
Planned features for the MCP server:- WebSocket transport — For remote agents/IDEs
- Batch operations — Multiple queries in one RPC call
- Caching layer — Per-session query result cache
- Streaming responses — Large subgraphs streamed incrementally
- Custom resolvers — Plugin system for language-specific analysis
- Agent profiling — Metrics on tool usage and response times