# MCP server

> Connect an MCP client to https://api.mynth.io/mcp with OAuth or an API key to generate images and video, manage tasks, and configure Mynth.

Mynth runs a remote MCP server at `https://api.mynth.io/mcp`. It uses Streamable
HTTP, runs statelessly, and supports both MCP `2026-07-28` and 2025 clients.

## Connect

Sign in with your Mynth account through OAuth. When your client connects for the
first time, it opens a browser window to approve access. There is no key to copy
or store.

Codex reads `~/.codex/config.toml`, Cursor reads `.cursor/mcp.json`, and VS Code
reads `.vscode/mcp.json`.

**Claude Code**

```bash
claude mcp add --transport http mynth https://api.mynth.io/mcp
```

**Codex**

```toml
[mcp_servers.mynth]
url = "https://api.mynth.io/mcp"
```

**Cursor**

```json
{
  "mcpServers": {
    "mynth": {
      "url": "https://api.mynth.io/mcp"
    }
  }
}
```

**VS Code**

```json
{
  "servers": {
    "mynth": {
      "type": "http",
      "url": "https://api.mynth.io/mcp"
    }
  }
}
```

In Claude on the web or desktop, open **Settings**, go to **Connectors**, choose
**Add custom connector**, and enter `https://api.mynth.io/mcp`.

## Connect with an API key

For CI or headless agents where a browser login is not practical, pass a `mak_`
API key in the `Authorization` header instead of using OAuth:

```bash
claude mcp add --transport http mynth https://api.mynth.io/mcp --header "Authorization: Bearer $MYNTH_API_KEY"
```

The key's scopes decide which tools the server advertises and allows. OAuth signs
in as the account owner and sees every tool. Public access tokens (`pat_`) are
not accepted on `/mcp`.

## Tools

| Tool                  | What it does                                               | Scope (API key) |
| --------------------- | ---------------------------------------------------------- | --------------- |
| `get_account`         | Returns the account, auth details, and available balance   | Any             |
| `get_balance`         | Returns the account balance                                | `manage`        |
| `list_models`         | Lists image and video models with pricing and capabilities | Any             |
| `generate_image`      | Creates an image generation task                           | `generate`      |
| `estimate_image_cost` | Estimates an image generation request without charging     | `generate`      |
| `upload_images`       | Uploads base64-encoded images and returns their URLs       | `generate`      |
| `rate_image`          | Creates an image content rating task                       | `generate`      |
| `describe_image`      | Creates an alt text generation task                        | `generate`      |
| `review_image`        | Creates an image quality review task                       | `generate`      |
| `remove_background`   | Creates a background removal task                          | `generate`      |
| `upscale_image`       | Creates an image upscaling task                            | `generate`      |
| `generate_video`      | Creates a video generation task                            | `generate`      |
| `estimate_video_cost` | Estimates a video generation request without charging      | `generate`      |
| `list_tasks`          | Lists recent tasks                                         | `generate`      |
| `get_task`            | Returns the full record for one task                       | `generate`      |
| `wait_for_task`       | Polls a task until it settles or the timeout elapses       | `generate`      |
| `list_destinations`   | Lists storage destinations                                 | `manage`        |
| `get_destination`     | Returns one destination by id                              | `manage`        |
| `create_destination`  | Creates a storage destination                              | `manage`        |
| `update_destination`  | Updates a storage destination                              | `manage`        |
| `delete_destination`  | Deletes a storage destination                              | `manage`        |
| `test_destination`    | Sends a test write to a destination                        | `manage`        |
| `create_webhook`      | Creates a webhook endpoint                                 | `manage`        |
| `update_webhook`      | Updates a webhook endpoint                                 | `manage`        |
| `delete_webhook`      | Deletes a webhook endpoint                                 | `manage`        |
| `list_api_keys`       | Lists API keys on the account                              | `keys`          |
| `create_api_key`      | Creates an API key and returns the raw key once            | `keys`          |
| `update_api_key`      | Updates an API key's scopes or spending limit              | `keys`          |
| `delete_api_key`      | Deletes an API key immediately                             | `keys`          |

## Arguments

Tools that stand for a REST endpoint with a body take that body as `request`.
The `request` object is exactly the REST body, so the
[API reference](https://mynth.io/docs/api-reference/endpoints/image/generate.md) documents every
field. Task-creating tools also take an optional `idempotency_key`:

```json
{
  "request": { "model": "black-forest-labs/flux.2-pro", "prompt": "A lighthouse at dusk" },
  "idempotency_key": "lighthouse-1"
}
```

The same key with the same request returns the original task instead of
creating and charging a second one, and the result then carries
`replayed: true`. The estimate tools take `request` alone.

- Create tools (`create_destination`, `create_webhook`, `create_api_key`) take
  the REST body directly.
- Update tools take `{ id, <resource> }`, where the resource is the full new
  configuration: `destination`, `webhook` or `api_key`.
- `get_task` and `wait_for_task` take `task_id`. `wait_for_task` also takes
  `timeout_seconds`.
- List tools return `{ items: [...] }`. Delete tools return
  `{ id, deleted: true }`.

## How generation works

Every generation and analysis tool creates a task and returns the `task_id` and
`estimated_cost` at once. Call `wait_for_task` with that `task_id` to collect
the output.

`wait_for_task` polls for up to 55 seconds (default 45) and returns the full
result as soon as the task settles. If the task is still running when the timeout
elapses, `wait_for_task` returns the current status instead of failing so the
agent can call it again. When the client sends a progress token, each poll is
reported as a progress notification.

Costs are reserved on your balance when the task is created, just like the REST
API. `estimate_image_cost` and `estimate_video_cost` are free. A `402`
(`insufficient_balance`) means the account needs a
[top-up](https://mynth.io/dashboard/wallet).

## Images from your machine

`upload_images` accepts base64-encoded image data and returns URLs, served for
one day, that you can pass to `inputs`. Keep one call under about 24 MB of
images and split larger batches across calls. If an image is already at a
public URL, pass that URL straight into `inputs` instead of uploading it.

## Errors

A tool error carries the same `code`, message and validation `issues` as the
REST API, in `structuredContent.error`. Arguments that do not match the tool's
schema are rejected by the MCP layer before the tool runs, with a plain-text
validation error. See [Errors](https://mynth.io/docs/api-reference/errors.md) for every error
code.

## Next steps

- [Authentication](https://mynth.io/docs/authentication.md): `mak_` keys, scopes, and spending limits.
- [Tasks](https://mynth.io/docs/concepts/tasks.md): statuses, partial failure, and file lifetimes.
- [Skills](https://mynth.io/docs/sdks/agents/skills.md): the Mynth skill for coding agents.
- [llms.txt](https://mynth.io/docs/sdks/agents/llms-txt.md): read these docs as plain markdown.
