Source: https://www.tokenify.dev/docs/mcp/

# The MCP server

Image and video generation as tools an agent can call, paid from a project's balance.

Tokenify is a remote MCP server at `https://api.tokenify.dev/mcp`. An agent connected to it can list the models, price a generation before making it, generate images and video, upload a reference image, read the balance and hand its user a link to top up — through the same admission, limits and billing as the HTTP API, so a tool call costs what the equivalent request costs.

Text models are listed but not run as tools: an agent calls them over the HTTP API ([chat completions](https://www.tokenify.dev/docs/chat-completions/), Responses or Messages) with an API key, or with a token for the whole API — a token for `/mcp` alone is refused there.

### In the Claude and Codex apps

No terminal is needed. In Claude — claude.ai or the desktop app — open **Connectors**, choose **Add custom connector** and enter `https://api.tokenify.dev/mcp`; Claude opens Tokenify to sign in, and returns to Claude when you allow it. On a Team or Enterprise plan an owner adds it for the organisation.

In the Claude Code desktop app or IDE panel, type `/mcp` and add a server named `tokenify` with the HTTP transport and that URL, then start a new conversation. In the Codex app or IDE extension, open **Settings > MCP servers > Add server**, choose Streamable HTTP, restart, and choose **Authenticate** next to it. The Codex app, its IDE extension and its command line share one configuration, so adding it in one adds it to all three.

Or ask the agent: paste this into Claude Code's chat and it runs the install itself (Codex takes the `codex mcp add` line below the same way).

```
Add the Tokenify MCP server for all my projects by running: claude mcp add --transport http --scope user tokenify https://api.tokenify.dev/mcp
```

### In a terminal

Claude Code connects with one command, and signs in through the browser the first time:

```bash
claude mcp add --transport http tokenify https://api.tokenify.dev/mcp
```

Codex adds it with one command and signs in with a second, which opens the browser:

```bash
codex mcp add tokenify --url https://api.tokenify.dev/mcp
codex mcp login tokenify
```

### Signing in from another device

An agent on a server and a browser on a phone is fine. Approve on the phone, choose **… is on another device**, and paste the line it gives you — it carries a short code — into Claude Code's chat. The agent fetches it on its own computer, which finishes the sign-in there, and the approval page moves on to the console's Agents tab. The code works for ten minutes, only with the app that started the sign-in. If Claude Code is showing a box that asks for a URL, the page copies the sign-in URL for it. Apps wait about five minutes for a sign-in, so approve within that.

For Codex on a server, start the sign-in in a terminal there with `codex mcp login --no-browser tokenify`: it prints the sign-in link and asks for a _Callback URL_. Open the link on your phone, approve, choose **Codex is on another device**, copy the sign-in URL and paste it at the prompt. Asked to sign in from its own chat instead, Codex waits on the sign-in in the foreground and cannot act on a line pasted meanwhile.

Every connected app is listed on the console's **Agents** tab: who connected it, when it was last used, what it has spent, and the limits it was connected with — which kinds of model, a daily limit, and the amount at or above which it must ask you first. Change them there, or disconnect it. The daily limit is hard: a call is refused unless the most it could cost fits in what is left of the day, counting what has settled and what is still running; the ask-first amount makes Tokenify refuse a tool call at or above it unless the agent passes the price you agreed to.

### Running Codex unattended

Codex asks you to approve every tool call that is not read-only, which is what you want in a conversation. Under `codex exec`, where nobody is there to approve, it refuses them instead (“MCP tool call requires approval”); for automation, approve the Tokenify tools for that run:

```bash
codex exec -c 'mcp_servers.tokenify.default_tools_approval_mode="approve"' "…"
```

Pass it per run, as above. Written into `~/.codex/config.toml` instead, it applies to your conversations too, where Codex then stops asking before a call that spends; Tokenify still asks for your agreement at or above the project's confirmation threshold.

Any client that speaks the Streamable HTTP transport works the same way: give it the URL. It discovers how to sign in from the server ([OAuth](https://www.tokenify.dev/docs/oauth/)), and the person picks the project whose balance the agent may spend. A client that takes a header instead can send an API key as `Authorization: Bearer tk-live-…`.

The server speaks the `2025-06-18` and `2025-03-26` revisions of the protocol, statelessly: every message is a POST answered in full, with no session to keep open. Under `2025-03-26` a POST may carry a batch of up to 20 messages; `2025-06-18` removed batching, so a client on it sends one message per POST. A connection sends at most 300 messages a minute.

## [The tools](https://www.tokenify.dev/docs/mcp/#tools)

| Tool            | What it does                                                                                                                                                                                                                                                                                                                                           | Costs                       |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------- |
| list\_models    | Image, video and text models with their prices; video per second, by resolution.                                                                                                                                                                                                                                                                       | Nothing                     |
| estimate\_cost  | The most a generate call would cost, the balance, and whether the project asks for confirmation at that price. Takes the generate call’s arguments. With a reference video uploaded through create\_upload it also gives the likely cost at the video’s measured length; the hold still assumes the longest reference a request may carry.             | Nothing                     |
| generate\_image | Generates 1–4 images, from a prompt and optional reference images; returns URLs that expire after 7 days.                                                                                                                                                                                                                                              | The images                  |
| generate\_video | Starts a video and returns a job id. At most 3 unfinished videos per project from agents.                                                                                                                                                                                                                                                              | The video, when it finishes |
| get\_job        | A video’s status, and its URL once it has succeeded. Can wait up to 25 seconds.                                                                                                                                                                                                                                                                        | Nothing                     |
| create\_upload  | A link to upload a local image (up to 10 MB), video (MP4 or MOV, up to 50 MB) or audio file (MP3 or WAV, up to 15 MB) with curl from the agent’s shell, so the file does not pass through the conversation — and the URL to send as a reference or first frame. A video uploaded this way is measured, so estimate\_cost quotes it at its real length. | Nothing                     |
| upload\_file    | Stores a small PNG, JPEG or WebP (up to 2 MB) sent as base64, for use as a reference image or first frame.                                                                                                                                                                                                                                             | Nothing                     |
| get\_balance    | The balance, what agents have spent today, and the project’s spending settings.                                                                                                                                                                                                                                                                        | Nothing                     |
| top\_up         | A link for the user to add credit to the project, valid for 30 minutes.                                                                                                                                                                                                                                                                                | Nothing                     |

Generated files are kept for seven days: an agent should download what it needs into the project. Uploads count against 100 an hour per connection and 300 an hour per project.

## [What an agent may spend](https://www.tokenify.dev/docs/mcp/#spending)

A project decides, in the console under **Settings → Agents**, three things about the money its agents spend through MCP. HTTP requests with the same key are not affected by any of them.

| Setting             | Default | What happens                                                                                                                                                                                                                                                                                                                                    |
| ------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Ask before spending | $1      | A call that would cost at least this much is refused with confirmation\_required and the exact price, unless it names a max\_cost\_usd. The agent tells the user the price; if they agree, it calls again with max\_cost\_usd set to it. 0 never asks.                                                                                          |
| Daily cap           | None    | A call that would take the day’s agent spend — settled, plus videos still running, plus the call itself — past the cap is refused with agent\_daily\_cap\_reached. Resets at 00:00 UTC. A budget rather than a hard limit: image calls running at the same moment are not counted against each other, so a burst can end a little past the cap. |
| Reminders           | None    | Up to five amounts. When agents pass one in a day, the owners and admins are emailed, and the next tool result says so once.                                                                                                                                                                                                                    |

`max_cost_usd` on a generate call is a ceiling either way: a call that would cost more is refused with `price_above_max` and its price, and nothing is held. What is charged follows what was delivered, and is never more than the price quoted.

## [Topping up from the conversation](https://www.tokenify.dev/docs/mcp/#top-up)

When a call is refused for want of credit, the tool’s error says what is missing — the balance and the price — and carries a link the agent passes to its user. `top_up` makes one on request, for an amount the agent suggests. The link opens Tokenify’s payment page for the project: the person signs in as the account that connected the agent, picks an amount and pays by card or crypto. Once the payment clears, the agent can try again.

A link only works for the person whose agent made it, while they can add credit to the project — an owner or an admin — and only puts money into that project. For 30 minutes, and until a payment through it goes through, it can start a checkout; a payment page it already opened can still be paid after that, and credits the project like any other. Video models open once a project has paid in at least $5; a free project’s video request is answered with a link too.

## [Tool errors](https://www.tokenify.dev/docs/mcp/#errors)

A refused tool call is a tool result with `isError: true`, whose text starts with the reason in brackets, then says what to do. The HTTP API’s codes keep their meaning here — see [errors](https://www.tokenify.dev/docs/errors/) — and these are the MCP server’s own:

| Code                       | Meaning                                                                             | Retry?                                          |
| -------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------- |
| confirmation\_required     | At or above the price the project asks agents to confirm. The text gives the price. | Yes — with max\_cost\_usd, once the user agrees |
| agent\_daily\_cap\_reached | The call would take the project’s daily agent spend past its cap.                   | After 00:00 UTC, or a higher cap                |
| price\_above\_max          | The call would cost more than max\_cost\_usd. The text gives the price.             | With a higher ceiling                           |
| insufficient\_credit       | Not enough credit; the text has the balance, the price and a top-up link.           | Once the user has paid                          |
| video\_needs\_topup        | Video needs a project that has paid in at least $5; the text has a link.            | Once the user has paid                          |
| moderation\_blocked        | The model refused the prompt or an input. Nothing was charged.                      | With a different prompt                         |
| too\_many\_uploads         | Past 100 uploads an hour for the connection, or 300 for the project.                | Within the hour                                 |
| too\_many\_topup\_links    | Past 30 top-up links an hour for the connection. The text gives the billing page.   | Use a link already made                         |
| invalid\_amount            | A top\_up amount outside $5–$5,000.                                                 | With an amount inside it                        |

Last updated 2026-11-25.
