> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rockapi.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# RockAPI MCP: connect AI agents to 50+ models with one key

> RockAPI now supports the Model Context Protocol. Learn what MCP changes for AI agents, how to add the RockAPI MCP server in Claude Code, Cursor, Codex, or Claude Desktop, and how to verify the connection.

RockAPI now speaks the **Model Context Protocol (MCP)**. Instead of writing glue code for every agent framework, you add one MCP server to your client and let the agent call RockAPI with the API key you already use.

This guide covers what MCP actually changes, the two layers you configure separately, and the exact steps to connect an MCP client and verify it works.

![RockAPI MCP architecture diagram showing an AI agent connecting through an MCP client to the RockAPI MCP server and then to OpenAI, Claude, and Gemini models](https://mintcdn.com/rockapi/H_B3LeAF53GjlC9D/images/blog/rockapi-mcp-architecture.svg?fit=max\&auto=format\&n=H_B3LeAF53GjlC9D\&q=85\&s=e510582e3dffb537393cef696ce25283)

## What MCP actually changes

MCP is a standard way for an AI client to discover and call tools on a server. Before MCP, every agent framework invented its own plugin format, so the same capability had to be re-implemented for Claude Code, Cursor, Codex, and everything else.

| Without MCP | With MCP |
| - | - |
| A custom integration per client and per provider | One server definition that any MCP client can load |
| Tool schemas copy-pasted into prompts | Schemas discovered at runtime through `tools/list` |
| Auth logic repeated in each integration | One endpoint with one Bearer key |
| Model and tools coupled in the same config | Model choice and tool access configured independently |

The practical result: your agent gains a stable capability surface, and you stop maintaining parallel integrations.

## Two layers you configure separately

This is the most common source of confusion, so separate them before you start.

| Layer | Question it answers | Where it is configured |
| - | - | - |
| Model layer | Which LLM generates the reasoning and text? | The client's model or provider setting |
| Tool layer | Which tools and data can the agent reach? | The MCP server entry in the client |

RockAPI sits on the tool layer when you add it as an MCP server. It sits on the model layer when you use it as the model provider through the [OpenAI-compatible API](https://docs.rockapi.ai/blog/buyers/openai-compatible-api.md). You can use both at once, but they are two separate entries.

## Before you start

1. **Create an API key.** Generate one at [rockapi.ai/keys](https://rockapi.ai/keys) and store it in an environment variable, never in a file you commit.
2. **Copy the MCP configuration.** Your console shows the MCP endpoint and the header format for your account. Use the value shown there rather than typing a URL from memory.
3. **Confirm your client supports MCP.** Claude Code, Cursor, Codex, VS Code, and Claude Desktop all ship MCP support. Check your client version if the command below is rejected.
4. **Decide the model.** Whichever client you use, the agent still needs an LLM. Pick it in the client's provider settings, or route it through RockAPI.

```bash theme={null}
export ROCKAPI_API_KEY="sk-your-key"
export ROCKAPI_MCP_URL="<endpoint shown on your console MCP page>"
```

## Add the MCP server

The command differs per client, but the inputs are identical: a URL, a transport, and an `Authorization: Bearer` header.

### Claude Code

```bash theme={null}
claude mcp add --transport http rockapi "$ROCKAPI_MCP_URL" \
  --header "Authorization: Bearer $ROCKAPI_API_KEY"
```

Verify it registered:

```bash theme={null}
claude mcp list
```

### Codex

Add the server to `~/.codex/config.toml`. Reading the token from an environment variable keeps the secret out of the file:

```toml theme={null}
[mcp_servers.rockapi]
url = "https://your-mcp-endpoint-from-console"
bearer_token_env_var = "ROCKAPI_API_KEY"
```

### Cursor and VS Code

Both accept an HTTP MCP server in their JSON config. Use the env interpolation syntax your client documents so the key is not stored in plain text:

```json theme={null}
{
  "mcpServers": {
    "rockapi": {
      "type": "http",
      "url": "${env:ROCKAPI_MCP_URL}",
      "headers": {
        "Authorization": "Bearer ${env:ROCKAPI_API_KEY}"
      }
    }
  }
}
```

### Claude Desktop

Claude Desktop launches command-based servers, so point it at the `mcp-remote` bridge:

```json theme={null}
{
  "mcpServers": {
    "rockapi": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote",
        "https://your-mcp-endpoint-from-console",
        "--header",
        "Authorization: Bearer ${ROCKAPI_API_KEY}"
      ]
    }
  }
}
```

## Verify the connection

Do not move to production after a server shows as connected. Confirm the four behaviors below.

| Check | How to run it | What good looks like |
| - | - | - |
| Server is registered | `claude mcp list` or the client's MCP panel | The server appears as connected, not errored |
| Tools are discovered | Ask the agent to list available tools | A non-empty tool list returns without a 401 |
| A call succeeds | Ask the agent to perform one read-only action | A structured result, not a timeout |
| Failure is legible | Temporarily use a wrong key | A clear auth error, not a silent empty answer |

If the server connects but calls fail, the problem is usually the token, not the transport. Rotate the key and retest before you debug anything else.

## Operating rules that save incidents

* **Scope the key.** Use a dedicated key for the MCP integration instead of your main production key, so you can revoke one without breaking the other.
* **Prefer read-only first.** Give the agent the narrowest capability that completes the task, and expand only when a real workflow requires it.
* **Watch spend separately.** Tool-driven agents issue many small calls. A separate key makes per-agent cost visible in the dashboard.
* **Keep secrets in the environment.** Keys pasted into committed config files are the most common leak in agent setups. See [secure API key management](https://docs.rockapi.ai/blog/buyers/secure-api-key-management.md).
* **Log tool calls.** When an agent misbehaves, the tool call sequence explains it faster than the final answer.

## FAQ

### Is MCP the same thing as an OpenAI-compatible API?

No. An OpenAI-compatible API standardizes how your code calls a model. MCP standardizes how an AI client discovers and calls tools. RockAPI offers both, and they are configured in different places.

### Do I still need an API key with MCP?

Yes. The MCP server is reachable, but the key is what identifies your account, applies your rate limits, and records usage on your bill.

### Can one MCP server serve several agents?

Yes, and that is the point. The same server entry works across clients, so a Claude Code session and a Cursor session reach the same capability set with the same key.

### Does MCP change how models are billed?

No. Billing follows the underlying model calls. See [pricing and billing](https://docs.rockapi.ai/pricing-and-billing.md) for how usage is counted.

### What if my client does not support HTTP MCP servers yet?

Use the `mcp-remote` bridge shown in the Claude Desktop example. It translates the HTTP endpoint into a local stdio process that any command-based client can launch.

## Next step

If you have not sent a request yet, start with the [quickstart](https://docs.rockapi.ai/quickstart.md), then read [models and providers](https://docs.rockapi.ai/models-and-providers.md) to pick the model behind your agent. For cost control across several agents, compare the [AI API gateway](https://docs.rockapi.ai/blog/buyers/ai-api-gateway.md) approach.

> [card] [Create an API key and connect your agent](https://rockapi.ai/sign-up?utm_source=docs\&utm_medium=referral\&utm_campaign=blog_buyers_mcp)
>
> Generate a key, copy the MCP configuration from your console, and verify the connection before production traffic.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.