@atlas/mcp#

MCP (Model Context Protocol) server exposing Atlas app internals as tools for AI/LLM debugging.

Architecture#

JSON-RPC over stdio with Content-Length framing (like LSP). No external dependencies.

Key Exports#

  • createMcpServer(tools, ctx) — creates an MCP server with stdin/stdout transport
  • createContext(opts?) — builds an AtlasMcpContext from optional service references
  • collectTools(ctx) — returns tools based on what services are available in context
  • defineTool(tool) — identity helper for defining a tool with type safety

AtlasMcpContext#

Holds optional references: db, cache, routes, config, storage, migrationsDir, logBuffer. Tools auto-register based on which fields are present.

Built-in Tools#

ToolRequiresDescription
db.querydbExecute SQL, returns rows as JSON
db.schemasdbList tables and columns
migrate.statusdb + migrationsDirShow applied/pending migrations
migrate.updb + migrationsDirRun pending migrations
migrate.downdb + migrationsDirRollback last migration
cache.getcacheGet value by key
cache.setcacheSet value with optional TTL
cache.delcacheDelete a key
cache.flushcacheFlush all entries
routes.listroutesList HTTP routes
config.showconfigShow config (secrets redacted)
storage.liststorageList files with optional prefix
storage.presignstorageGenerate presigned URL
health.check(always)Check service connectivity
docs.list(always)List every package reference, guide including docs/agents.md, and root documentation entry point
docs.read(always)Read one package, guide, or root documentation source
logs.taillogBufferGet recent log lines

The docs.* tools are always present so an agent connected to an Atlas-built app can self-introspect the framework — no web fetch required.

Usage#

Programmatic#

import { createContext, collectTools, createMcpServer } from "@atlas/mcp"

const ctx = createContext({ db, cache, routes })
const tools = collectTools(ctx)
const server = createMcpServer(tools, ctx)
await server.start()

CLI#

atlas mcp

Or directly:

bun run packages/mcp/entry.ts

Environment variables: DATABASE_URL, DATABASE_PATH, REDIS_URL, S3_ENDPOINT, S3_BUCKET, S3_ACCESS_KEY, S3_SECRET_KEY, S3_REGION.

Types#

  • McpServer = { start(): Promise<void>; stop(): void }
  • AtlasMcpContext = { db?, cache?, routes?, config?, storage?, migrationsDir?, logBuffer? }
  • Tool = { name; description; inputSchema; handler(input, ctx) → Promise<unknown> }
  • ToolInput — JSON-schema-shaped input descriptor

Dependencies#

Sibling packages are optional — pass only the services you want exposed:

  • @atlas/db — enables db.* and migrate.* tools
  • @atlas/cache — enables cache.* tools
  • @atlas/server — enables routes.list
  • @atlas/config — enables config.show (secrets redacted)
  • @atlas/storage — enables storage.* tools
  • @atlas/migrate — enables migrate.up / migrate.down

External: none. Pure JSON-RPC over stdio with Content-Length framing.

Testing#

bun test packages/mcp/
Canonical sourcepackages/mcp/AGENTS.md
Type to search guides and package references.