# Ferrite Worker for developers

Ferrite Worker runs JavaScript and TypeScript that a program or an AI assistant wrote, with no access to anything except what each request lends it.

Call the same operations over plain HTTP, as MCP tools, or from a page through WebMCP. The base URL is `https://worker.ferrite.run`.

## Quickstart

Read something first. This request needs no setup:

```sh
curl -s 'https://worker.ferrite.run/api/service'
```

Read what this worker is and whether it can run code now. Use it as a health check, or before the first run to learn the engine and where to send requests. Returns the version, the engine, the run endpoint and whether runs are being accepted.

Then change something.

```sh
curl -s -X POST 'https://worker.ferrite.run/run/' \
  -H 'content-type: application/json' \
  -H 'idempotency-key: run_code-1' \
  -d '{"client_token":"YOUR_CLIENT_TOKEN","code":"return [3, 4, 5].map((n) => n * n);"}'
```

To use Ferrite Worker from an AI assistant, add its MCP server:

```sh
claude mcp add --transport http ferrite-worker https://worker.ferrite.run/mcp
```

## Authentication and API keys

Reading needs no credential: `get_service`, `get_limits`, `list_capabilities`, `list_examples` and `get_example` answer anyone. `run_code` needs the worker's client token, sent as `client_token` in the JSON body over HTTP or as the argument of the same name over MCP. Without it nothing runs: over HTTP the answer is 401, and over MCP the call returns a tool result with `isError` set and the code `unauthorized`. The token is issued by the operator, and the [contact page](/contact) is where to ask for one. The worker accepts no OAuth token and no `Authorization` header.

## Sandbox

The public reads are the place to start. `get_example` returns complete requests together with the reply each one gives, and every one of them is executed by the worker's own tests, so you can design a request and know what to expect before you hold a token. Each run starts a fresh interpreter, and the outbound hosts a run may be lent are public test and data services.

The [sandbox page](/sandbox) is the place to start.

## Endpoints

| Operation | Request | What it does |
| --- | --- | --- |
| `get_service` | `GET /api/service` | Read what this worker is and whether it can run code now. Use it as a health check, or before the first run to learn the engine and where to send requests. Returns the version, the engine, the run endpoint and whether runs are being accepted. |
| `get_limits` | `GET /api/limits` | Read every limit a run is held to: instructions, memory, time, output, outside calls and requests per minute. Use it before sending a program that loops, logs a lot or makes many calls. Returns each default and maximum, and the meaning of every exit code. |
| `list_capabilities` | `GET /api/capabilities` | List everything a run can be lent: stores, file stores, in-memory files, outbound hosts and host operations. Use it to write the caps object of a run_code request. Returns each field with what it grants, how the program uses it, and the hosts and bindings that can be named. |
| `list_examples` | `GET /api/examples` | List the worked examples. Use it when you are about to write a program and want a request that is known to work as a starting point. Returns the identifier, title and description of each example, in reading order. |
| `get_example` | `GET /api/examples/{id}` | Read one worked example in full. Use it to copy a request shape for run_code and to see exactly what comes back. Returns the request without a client token, and the output, console lines and call count its reply contains. |
| `run_code` | `POST /run/` | Run a JavaScript or TypeScript program with only the access this request lends it. Use it when one short program can do the work of many separate calls, or when code from a model has to run safely; read list_capabilities first. Needs the worker's client token. Returns the program's value, its console lines, an exit code and the number of calls it made. |

The [OpenAPI 3.1 document](/openapi.json) describes every parameter and response. The MCP server at `https://worker.ferrite.run/mcp` exposes the same operations as tools with the same names.

## Example requests

### `get_service`

```sh
curl -s 'https://worker.ferrite.run/api/service'
```

### `get_limits`

```sh
curl -s 'https://worker.ferrite.run/api/limits'
```

### `list_capabilities`

```sh
curl -s 'https://worker.ferrite.run/api/capabilities'
```

### `list_examples`

```sh
curl -s 'https://worker.ferrite.run/api/examples'
```

### `get_example`

```sh
curl -s 'https://worker.ferrite.run/api/examples/group-orders'
```

### `run_code`

```sh
curl -s -X POST 'https://worker.ferrite.run/run/' \
  -H 'content-type: application/json' \
  -H 'idempotency-key: run_code-1' \
  -d '{"client_token":"YOUR_CLIENT_TOKEN","code":"return [3, 4, 5].map((n) => n * n);"}'
```

## Conventions

- Rate limits: every response carries `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset`. A `429` also carries `Retry-After`, in seconds.
- Errors: refusals are RFC 9457 `application/problem+json` with a stable `type`, a `detail` written to be read, and a `hint` when there is a next step.
- Versioning: this is version 0.2.0. A change that would break a caller is announced with `Deprecation` and `Sunset` headers at least 90 days ahead.
- Markdown: add `.md` to a page path, or send `Accept: text/markdown`.

## Machine-readable descriptions

- [llms.txt](/llms.txt): orientation for agents
- [OpenAPI](/openapi.json): operations and schemas
- [Agent skills](/.well-known/agent-skills/index.json): installable instructions
- [Agentic Resource Discovery](/.well-known/ard.json): the catalogue of everything here
- [Pricing](/pricing.md)

Questions: see the [contact page](/contact).
