Skip to content

Server API

This page documents Claude Yard’s internal API for contributors building custom modules or integrations.

CLIENTSUICLIMCPVoiceSERVERHTTP + WebSocket (index.ts)MODULESCoreAppSyncVoiceUICORECore Ops — PTY lifecycle, signal parsing, sessions

Three layers:

  1. Server (server/index.ts) — routes requests to modules
  2. Modules (server/modules/) — each handles a domain (terminals, state, sync, voice)
  3. Core Ops (server/core/) — standalone process management, no UI awareness
MethodPathDescription
GET/api/stateCurrent app state (panels, layout, sessions)
GET/api/settingsApp settings
POST/api/settingsUpdate settings
GET/cwdServer working directory
GET/sessionsAll Claude sessions from disk
MethodPathDescription
GET/api/panelsList open terminal panels
POST/api/spawnSpawn a new terminal (shell or Claude)
POST/api/panels/:id/sendSend keystrokes to a panel
POST/api/panels/:id/closeClose a panel
POST/api/panels/:id/interruptSend SIGINT to a panel
MethodPathDescription
GET/api/layoutCurrent panel layout
POST/api/layoutSet panel layout
POST/api/browser/openOpen a browser panel
MethodPathDescription
GET/api/mcp/toolsList all available MCP tools
POST/api/tools/callCall any tool by name

The terminal WebSocket connects at ws://localhost:{port}/ws/terminal.

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 }

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 }

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 module
  • getMcpTools() — aggregates tools from all modules
  • getWsRoutes() — aggregates WebSocket routes
FilePurpose
server/index.tsServer orchestrator
server/core/core-ops.tsPTY lifecycle, spawn(), send()
server/core/signal-parser.tsTerminal escape sequence parser
server/modules/registry.tsModule registry with callTool()
server/modules/core/core-module.tsTerminal HTTP routes + WS handler
server/modules/app/app-module.tsState, layout, browser, MCP discovery
mcp-server.mjsMCP protocol proxy
cli.mjsCLI tool