Server API
This page documents Claude Yard’s internal API for contributors building custom modules or integrations.
Architecture
Section titled “Architecture”Three layers:
- Server (
server/index.ts) — routes requests to modules - Modules (
server/modules/) — each handles a domain (terminals, state, sync, voice) - Core Ops (
server/core/) — standalone process management, no UI awareness
HTTP endpoints
Section titled “HTTP endpoints”State & configuration
Section titled “State & configuration”| Method | Path | Description |
|---|---|---|
GET | /api/state | Current app state (panels, layout, sessions) |
GET | /api/settings | App settings |
POST | /api/settings | Update settings |
GET | /cwd | Server working directory |
GET | /sessions | All Claude sessions from disk |
Process management
Section titled “Process management”| Method | Path | Description |
|---|---|---|
GET | /api/panels | List open terminal panels |
POST | /api/spawn | Spawn a new terminal (shell or Claude) |
POST | /api/panels/:id/send | Send keystrokes to a panel |
POST | /api/panels/:id/close | Close a panel |
POST | /api/panels/:id/interrupt | Send SIGINT to a panel |
Layout & browser
Section titled “Layout & browser”| Method | Path | Description |
|---|---|---|
GET | /api/layout | Current panel layout |
POST | /api/layout | Set panel layout |
POST | /api/browser/open | Open a browser panel |
| Method | Path | Description |
|---|---|---|
GET | /api/mcp/tools | List all available MCP tools |
POST | /api/tools/call | Call any tool by name |
WebSocket protocol
Section titled “WebSocket protocol”The terminal WebSocket connects at ws://localhost:{port}/ws/terminal.
Client → Server
Section titled “Client → Server”Spawn a terminal:
{ "type": "spawn", "id": "panel-1", "cols": 120, "rows": 40, "cwd": "/path/to/project", "autoCommand": "claude"}Send input:
{ "type": "input", "data": "hello world\r" }Resize terminal:
{ "type": "resize", "cols": 160, "rows": 50 }Server → Client
Section titled “Server → Client”Terminal output:
{ "type": "output", "data": "...raw terminal data..." }Metadata signal (parsed from escape sequences):
{ "type": "meta", "signal": "title", "value": "⠋ Working..." }Session ID (after spawning a Claude session):
{ "type": "meta", "signal": "sessionId", "id": "abc123-def456-..." }Process exit:
{ "type": "exit", "exitCode": 0 }Spawn confirmation:
{ "type": "spawned", "id": "panel-1", "pid": 12345 }Module system
Section titled “Module system”Each module implements the Module interface:
interface Module { name: string; getHttpRoutes(): HttpRoute[]; getWsRoutes?(): WsRoute[]; getMcpTools?(): McpTool[]; handleToolCall?(name: string, args: any): Promise<McpToolResult>;}Modules register in order: core → app → sync → advisor → voice.
The registry (server/modules/registry.ts) provides:
callTool(name, args)— dispatches to the right modulegetMcpTools()— aggregates tools from all modulesgetWsRoutes()— aggregates WebSocket routes
Key files
Section titled “Key files”| File | Purpose |
|---|---|
server/index.ts | Server orchestrator |
server/core/core-ops.ts | PTY lifecycle, spawn(), send() |
server/core/signal-parser.ts | Terminal escape sequence parser |
server/modules/registry.ts | Module registry with callTool() |
server/modules/core/core-module.ts | Terminal HTTP routes + WS handler |
server/modules/app/app-module.ts | State, layout, browser, MCP discovery |
mcp-server.mjs | MCP protocol proxy |
cli.mjs | CLI tool |