Skip to main content
Mesh runs a built-in Model Context Protocol (MCP) server, so any MCP-compatible agent or client — Claude Code, Claude Desktop, Cursor, or your own agent framework — can use Mesh’s models and tools directly, without writing any Mesh-specific HTTP code. The server exposes the Mesh API surface as MCP tools: an agent can run chat completions, reason with the Responses API, generate and edit images, create embeddings, moderate content, ask an evaluation model typed questions, search the web, query your RAG files, manage prompt templates, and check your balance. There are two ways to connect:
  • Sign in with Mesh (recommended) — the one-click OAuth flow modern MCP clients ship. Point the client at the Mesh endpoint and it opens a browser where you sign in and choose an organization. No API key to paste.
  • API key — pass an rsk_ key in the Authorization header, the same key you use for the REST API. Best for headless or automated clients.
Either way, every tool call runs the same authentication, rate-limit, spend-cap, balance, and usage pipeline as a direct API call.
The MCP server is a thin layer over the same routes as the REST API. Every tool call runs the identical authentication, rate-limit, spend-cap, balance, and usage-logging pipeline as a direct API call, and is billed to the same key.

Connection details

https://api.meshapi.ai/mcp without the slash answers with a 307 redirect to /mcp/. Use the trailing-slash URL so a client that doesn’t follow redirects on POST still connects. Most clients can sign in with Mesh: register the endpoint with no credential and approve the connection in a browser (see below). You can also connect with the same rsk_ API key you use for the REST API, passed in the Authorization header.

Connect a client

Sign in with Mesh

Point your client at the Mesh MCP endpoint without a key. It discovers Mesh’s authorization server from the endpoint, opens a browser where you sign in and choose which organization the connector acts on, and finishes the connection — nothing to copy or paste.
No --header: the first time you use the server, Claude Code sees that it needs authentication and opens your browser to sign in with Mesh and pick an organization.
On approval, Mesh creates an rsk_ API key bound to the organization you chose and hands the connector a short-lived token for it. The connector’s calls carry that organization’s rate limits, spend cap, model policy, and billing — identical to a key you create yourself. Manage or revoke the connection from Dashboard → API keys: revoking that key disconnects the connector.

API key

For a headless agent, CI, or a shared service, connect with an rsk_ key instead of a browser sign-in. Pass it in the Authorization header when registering the server.
Then, in a session, ask Claude to use the Mesh tools (e.g. “use mesh-api to draft a reply with openai/gpt-4o-mini”).
Keep your rsk_ key secret — it authorizes billable calls against your account. Treat an MCP client config that embeds the key like any other secret store, and rotate the key from the dashboard if it leaks.

Available tools

Tools mirror the REST API one-to-one. Inputs are OpenAI-shaped, so anything you know from the API reference carries over directly.

Inference

Catalog & account

Prompt templates

The server also exposes a resource, mesh://models, that returns the full model catalog as JSON — useful for clients that consume MCP resources rather than calling list_models.

Example: give an agent a document Q&A tool

A typical agent flow — upload a file, wait for embeddings, then answer questions grounded in it — is three tool calls:
1

Upload the document

Call upload_file with the file’s bytes base64-encoded. You get back a file_id.
2

Wait for embeddings

Poll get_file with the file_id until embedding_status is ready. Embedding is asynchronous, so a freshly uploaded file is not immediately searchable.
3

Search and answer

Call file_search with a natural-language query, then feed the returned passages into chat to get a grounded answer.

Authentication & billing

  • Auth: a connector signs in with Mesh (OAuth 2.1); an API-key client sends Authorization: Bearer rsk_.... Either resolves to an rsk_ key before any tool runs. A missing or invalid credential returns 401; a suspended key returns 403.
  • Limits & billing: billed tool calls inherit the key’s per-key rate limits, spend cap, model allow-list, and credit balance — exactly as a direct REST call. If a call would exceed a limit or your balance is insufficient, the tool returns an error carrying the Mesh message (e.g. “Insufficient balance.”).
  • Free tools: the catalog/account reads (list_models, list_voices, get_balance), the RAG file reads (list_files, get_file, upload_file), template management, and router_select are not billed. Everything under Inference, plus web_search and file_search, is billed.
  • Usage tracking: every billed tool call is logged to your usage history just like a REST request, so MCP traffic shows up in the dashboard and usage reports.

Limitations

Tool results are returned as a single payload — there is no token-by-token streaming of a chat/responses result over MCP. For streaming, use the REST API or an SDK.
The following Mesh capabilities are not yet exposed as MCP tools — use the REST API or an SDK for them:
  • Audio: text-to-speech and speech-to-text (transcription/translation)
  • Video generation and the async Batch API
  • Realtime audio (bidirectional WebSocket)
  • Usage-report queries
Other actions are deliberately never offered as tools — anything that mints or widens a credential, for instance. The MCP Capability Reference lists every one of them with the steps to do it elsewhere, so you can tell a deliberate omission from a gap.

Troubleshooting