# MCP server

The OpenGrid API as MCP tools, at one address.

The server is at `https://api.opengrid.one/mcp` (Streamable HTTP). It authenticates with your API key in the `Authorization` header, so a key's spend limit caps what the agent can use.

## Add the server

Export your key first (`export OPENGRID_API_KEY=og_live_...`), then run the command for your host.

Claude Code:

```sh
claude mcp add --transport http opengrid https://api.opengrid.one/mcp \
  --header "Authorization: Bearer $OPENGRID_API_KEY"
```

Codex:

```sh
codex mcp add opengrid --url https://api.opengrid.one/mcp \
  --bearer-token-env-var OPENGRID_API_KEY
```

Cursor and others:

```json
{
  "mcpServers": {
    "opengrid": {
      "url": "https://api.opengrid.one/mcp",
      "headers": { "Authorization": "Bearer og_live_..." }
    }
  }
}
```

For Cursor, the JSON goes in `~/.cursor/mcp.json`. Other hosts take the same shape in their own MCP config.

## Tools

| Tool | What it does |
|---|---|
| `list_models` | Models that can run now, with starting prices. Filter by category or a search word. |
| `get_model` | One model's variants, prices, quantity limits and input fields. |
| `estimate` | The exact price of a request and the most it can cost. Charges nothing. |
| `generate` | Starts a generation and waits up to 50 seconds for the result. |
| `get_generation` | A generation's status, charge and result links. Waits for an unfinished one. |
| `list_generations` | Your most recent generations. |
| `get_balance` | Your credit balance and limits. |

## How it behaves

- The server tells the agent to price a job and get your agreement before it spends.
- `generate` waits up to 50 seconds. A longer job comes back still running, and the agent calls `get_generation` to keep waiting.
- Every tool is the same call as the REST API with your key, so prices, limits and refunds are identical.
- Result links are signed for one hour. Ask the agent to save a file you want to keep.

> Hosts that only connect through OAuth sign-in, such as custom connectors in the Claude and ChatGPT apps, are not supported yet. Use the [skill file](https://opengrid.one/docs/skill) there if the host can run commands.

Source: https://opengrid.one/docs/mcp
