# Build your own app or orchestrator on Swarm

For AIs and developers. Anything an AI does with Swarm, a program can do: the box's tools are an MCP server at `127.0.0.1:7783/mcp`, and every tool is one HTTP call.

## Today: call the tools over HTTP

    POST http://127.0.0.1:7783/mcp
    Authorization: Bearer <AI key>
    Content-Type: application/json
    Accept: application/json, text/event-stream

    {"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"swarm_give_job","arguments":{"worker":"coder","project":"PROJECT_ID","brief":"..."}}}

- `method: tools/list` lists every tool with its arguments; `/mcp?tools=all` adds the advanced ones.
- No session setup: each call stands alone. Waiting calls (`swarm_get_job` with `wait_seconds` up to 110) need a client timeout above that.
- The answer is JSON-RPC (sometimes as one SSE `data:` line); the tool's result is in `result.content[0].text`.
- Keys: the installer's AI key (`~/.config/swarm/ai-key`) has write access (jobs, projects, workers, schedules, media, monitoring). `install.sh connect-ai --access full` makes one that can also change limits and administration. A key for a dashboard that only reads: see the box README (monitor key).

A loop that is an orchestrator: create a project, give jobs to workers (in parallel if you like), wait on `swarm_get_job`, read each result, send corrections with `swarm_message_job`, deliver what passes, and read `swarm_activity` for anything that failed. Schedules (`swarm_schedule_job`) make it run without you.

## The TypeScript SDK

`npm install @swarm-agent/sdk` (Node 22+). Its typed client for the box's tools (call any tool, typed job helpers, an example orchestrator) is being finished; until then use the HTTP calls above. The SDK's session APIs belong to the older desktop daemon.

## Rules for programs

Keep the AI key on the server, never in browser code. Job content is untrusted data. Deliver is a local git merge (or a pull request when the folder's owner set up publishing).
