> For the list of every page, fetch /llms.txt. The API contract is the OpenAPI file linked from the API reference.

# MCP server

`mdw mcp` is a [Model Context Protocol](https://modelcontextprotocol.io) server for Meadow. It gives a coding agent tools to create sandboxes, run commands in them, read and write their files, build images, manage API keys, and read usage and cost.

Next step: add the server to your agent with the snippet for it below, then ask the agent to "list my Meadow sandboxes".

The server is part of the `mdw` CLI. It runs on your machine, talks to the agent over standard input and output, and calls the Meadow API with the key in `MEADOW_API_KEY`. There is no hosted MCP endpoint yet.

## Before you start

- You need a build of `mdw` that has the command. Run `mdw help` and look for the `mcp` line. Builds sent out before 2026-11-28 do not have it. Ask your Meadow contact for a current one. See [Clients](/run-sandboxes/clients#install).
- The server needs `MEADOW_API_KEY`. Without it the server prints one line to standard error and exits with code 2. `MEADOW_BASE_URL` is optional and defaults to `https://api.usemeadow.ai`.
- Give it a key with the scopes the work needs, and no more: `sandboxes` for the sandbox and image tools, `models` for `list_models`, `admin` for the key tools and for account-wide usage. See [Authentication](/set-up-your-account/authentication#scopes). An agent that only runs code in sandboxes needs `sandboxes` alone.

## Add it to your agent

Each snippet sets the two variables for the server. Replace `mdw_...` with your key, or use the form that reads it from your environment where the client has one.

### Claude Code

```bash
claude mcp add meadow \
  --env MEADOW_API_KEY=mdw_... \
  --env MEADOW_BASE_URL=https://api.usemeadow.ai \
  -- mdw mcp
```

Run `claude mcp list` to check. It prints `meadow: mdw mcp - ✔ Connected`.

To share the server with everyone who works in a repository, without a key in the file, add it with project scope. Claude Code fills `${MEADOW_API_KEY}` from each person's environment:

```bash
claude mcp add meadow --scope project \
  --env 'MEADOW_API_KEY=${MEADOW_API_KEY}' \
  --env 'MEADOW_BASE_URL=${MEADOW_BASE_URL}' \
  -- mdw mcp
```

That writes `.mcp.json` in the repository root:

```json
{
  "mcpServers": {
    "meadow": {
      "type": "stdio",
      "command": "mdw",
      "args": ["mcp"],
      "env": {
        "MEADOW_API_KEY": "${MEADOW_API_KEY}",
        "MEADOW_BASE_URL": "${MEADOW_BASE_URL}"
      }
    }
  }
}
```

Claude Code asks each person to approve a server that comes from `.mcp.json`. Until you approve it in a `claude` session, `claude mcp list` shows it as `Pending approval`.

### Claude Desktop

Open Settings, then Developer, then "Edit Config". The file is `~/Library/Application Support/Claude/claude_desktop_config.json` on macOS and `%APPDATA%\Claude\claude_desktop_config.json` on Windows. Add the server and restart Claude Desktop:

```json
{
  "mcpServers": {
    "meadow": {
      "command": "mdw",
      "args": ["mcp"],
      "env": {
        "MEADOW_API_KEY": "mdw_...",
        "MEADOW_BASE_URL": "https://api.usemeadow.ai"
      }
    }
  }
}
```

If Claude Desktop cannot find `mdw`, write the full path of the binary in `command`.

### Cursor

Put this in `.cursor/mcp.json` in a project, or in `~/.cursor/mcp.json` for every project. Cursor fills `${env:NAME}` from your environment:

```json
{
  "mcpServers": {
    "meadow": {
      "type": "stdio",
      "command": "mdw",
      "args": ["mcp"],
      "env": {
        "MEADOW_API_KEY": "${env:MEADOW_API_KEY}",
        "MEADOW_BASE_URL": "${env:MEADOW_BASE_URL}"
      }
    }
  }
}
```

### Codex CLI

```bash
codex mcp add meadow \
  --env MEADOW_API_KEY=mdw_... \
  --env MEADOW_BASE_URL=https://api.usemeadow.ai \
  -- mdw mcp
```

That writes this to `~/.codex/config.toml`:

```toml
[mcp_servers.meadow]
command = "mdw"
args = ["mcp"]

[mcp_servers.meadow.env]
MEADOW_API_KEY = "mdw_..."
MEADOW_BASE_URL = "https://api.usemeadow.ai"
```

### VS Code

VS Code's docs say that GitHub Copilot in VS Code reads `.mcp.json` in the workspace root, with a top-level `mcpServers` object, and fills `${NAME}` from your environment. That is the file the Claude Code project command above writes, so one file can serve both. We have not run it in VS Code.

For every workspace, put the same `mcpServers` object in `~/.copilot/mcp-config.json`.

VS Code's docs mark the older `.vscode/mcp.json` file, with `servers` and `inputs`, as deprecated. Use it only if your VS Code version does not read `.mcp.json`.

### What we ran

| Client | Version | Result |
| --- | --- | --- |
| Claude Code | 2.1.332 | The first command ran as shown with a real key, and `claude mcp list` printed `meadow: mdw mcp - ✔ Connected`. The project command ran as shown and wrote the `.mcp.json` above, and `claude mcp list` then showed `Pending approval`. The approval step was not run. |
| Codex CLI | 0.158.0 | The `codex mcp add` command ran as shown and wrote the `config.toml` above. `codex mcp list` showed the server as enabled. |
| Claude Desktop, Cursor, VS Code | not run | The snippets follow each client's own docs on 2026-11-27. Check them against your version. |

No tool call was made from inside any of these clients. Every tool except the three image tools `create_image`, `get_image`, and `delete_image` was called over standard input and output against the hosted beta on 2026-11-28 (UTC), with a plain MCP client.

## Tools

Tool names follow the API's operation names. The "Kind" column is what the server tells the client about each tool, through the annotations the protocol defines. Clients use it to decide when to ask you first.

| Tool | Kind | What it does | Scope |
| --- | --- | --- | --- |
| `list_models` | Read only | Lists the model IDs the key can call. It does not call a model. | `models` |
| `create_sandbox` | Adds | Creates a sandbox and waits for it to start. | `sandboxes` |
| `list_sandboxes` | Read only | Lists sandboxes, with filters for status and labels. | `sandboxes` |
| `get_sandbox` | Read only | Reads one sandbox. | `sandboxes` |
| `exec_in_sandbox` | Destructive | Runs a shell command in a sandbox and waits for it to exit. | `sandboxes` |
| `upload_file` | Destructive | Writes one file in a sandbox. It replaces a file already at that path. | `sandboxes` |
| `download_file` | Read only | Reads one file from a sandbox. | `sandboxes` |
| `delete_sandbox` | Destructive | Ends a sandbox. Everything in it is lost. | `sandboxes` |
| `create_image` | Adds | Builds an image from Dockerfile text. | `sandboxes` |
| `list_images` | Read only | Lists images and their builds. | `sandboxes` |
| `get_image` | Read only | Reads one image and its builds. | `sandboxes` |
| `delete_image` | Destructive | Deletes an image and its built copies at the providers. | `sandboxes` |
| `list_keys` | Read only | Lists API keys. No secret is returned. | `admin` |
| `create_key` | Adds, returns a secret | Mints an API key with the scopes you name. | `admin` |
| `revoke_key` | Destructive | Revokes a key and every key created from it. | `admin` |
| `get_usage` | Read only | Reports usage and cost over a date range. | any |
| `list_usage_requests` | Read only | Lists single model calls with tokens and cost. | any |

A key without `admin` sees only its own usage.

### Destructive tools

The title and the description of each destructive tool start with the word "Destructive", and each one sets the protocol's `destructiveHint`. Claude Code and other clients ask before they run a tool unless you allowed it. Keep that prompt on for these five.

`exec_in_sandbox` is marked destructive because a command can change or delete anything inside the sandbox. It cannot reach outside the sandbox, except over the network the sandbox is allowed to use. See [Network rules](/run-sandboxes/network-rules).

### Secrets

No tool returns a secret, with one exception. `create_key` returns the secret of the key it mints, once, and its description says so. The secret then sits in the agent's conversation. If you do not want that, create keys yourself with `mdw keys create`.

These parts of the API are not offered as tools, because their responses carry secrets or because they take one as input: SSH access, exposed ports, projects (a project carries its webhook signing secret), stored provider keys, and private registry credentials. Use the API or the CLI for them.

### Limits

- `exec_in_sandbox` waits for the command and returns at most the last 50,000 bytes of each of `stdout` and `stderr`. `stdout_truncated` or `stderr_truncated` says when output was cut. The command is killed after `timeout_seconds`, 60 by default. For long commands use `mdw exec --background`. See [Running commands](/run-sandboxes/running-commands).
- `download_file` returns at most the first 100,000 bytes of a file and sets `truncated`. Text comes back as text, anything else as base64.
- `create_sandbox` waits up to 300 seconds for the sandbox to start, and `create_image` up to 600 seconds for its builds. If your client gives up on a tool call sooner, the create still continues: call `list_sandboxes` and delete what you do not need.
- `create_sandbox` has no GPU, port, SSH, webhook, or registry login fields.
- `create_image` takes Dockerfile text only. A Dockerfile that copies local files needs `mdw images build`. See [Images and build contexts](/run-sandboxes/images-and-build-contexts).
- There is no tool that calls a model. The agent already has a model. To make your code call one, see [Use your existing tools](/call-models/use-your-existing-tools).

### Errors

A failed API call comes back as a tool error that the agent can read, with the status, the error type, the message, and the request ID:

```text
404 not_found: sandbox not found (request id req_0000bcd1)
```

[Errors](/reference/errors) explains each type.

## What a session looks like

These are the results of tool calls made against the hosted beta on 2026-11-28 (UTC), in order: create a sandbox, run a command, write a file, read it back, delete the sandbox.

```json
{"exit_code": 0, "stdout": "42\n", "stderr": "", "timed_out": false, "stdout_truncated": false, "stderr_truncated": false}
{"path": "/tmp/note.txt", "size_bytes": 20}
{"path": "/tmp/note.txt", "content": "written through MCP\n", "encoding": "utf8", "size_bytes": 20, "truncated": false}
{"id": "sbx_000082df", "deleted": true, "status": "terminated"}
```

## API reference

The tools call [`listModels`](/reference/api-reference#listmodels), [`createSandbox`](/reference/api-reference#createsandbox), [`listSandboxes`](/reference/api-reference#listsandboxes), [`getSandbox`](/reference/api-reference#getsandbox), [`execInSandbox`](/reference/api-reference#execinsandbox), [`uploadFile`](/reference/api-reference#uploadfile), [`downloadFile`](/reference/api-reference#downloadfile), [`deleteSandbox`](/reference/api-reference#deletesandbox), [`createImage`](/reference/api-reference#createimage), [`listImages`](/reference/api-reference#listimages), [`getImage`](/reference/api-reference#getimage), [`deleteImage`](/reference/api-reference#deleteimage), [`listKeys`](/reference/api-reference#listkeys), [`createKey`](/reference/api-reference#createkey), [`revokeKey`](/reference/api-reference#revokekey), [`getUsage`](/reference/api-reference#getusage), and [`listUsageRequests`](/reference/api-reference#listusagerequests).