MCP for agents

Use OpenMayhem models from MCP-compatible agents. The hosted server and local bridge use your existing account, API key, credit, and receipts.

View as Markdown
Preview: the hosted endpoint is live for testing. The npm package and official MCP Registry entry remain unpublished until final review.

Set up

Create a restricted API key in your dashboard. Give it only the model scopes you need, BILLING_READ for balance checks, a per-request cap, and a spend limit.

API keys

Hosted connection

For clients that support Streamable HTTP and secret headers:

URL: https://mcp.openmayhem.ai/mcp
Header: X-OpenMayhem-API-Key: sk-om-v1-...

Local stdio bridge

For clients that start a local MCP process, keep the key in the environment:

OPENMAYHEM_API_KEY=sk-om-v1-... npx -y @openmayhem/mcp

Client setup

Set the API key in the environment before starting the client. Use the hosted connection where secret headers are supported; use the stdio bridge for local-process clients.

Environment

# macOS / Linux
export OPENMAYHEM_API_KEY="sk-om-v1-..."

# Windows PowerShell
$env:OPENMAYHEM_API_KEY = "sk-om-v1-..."

Codex

Codex connects directly to the hosted server and reads the secret header from the environment.

# ~/.codex/config.toml
[mcp_servers.openmayhem]
url = "https://mcp.openmayhem.ai/mcp"
env_http_headers = { "X-OpenMayhem-API-Key" = "OPENMAYHEM_API_KEY" }
default_tools_approval_mode = "approve"

Claude Code

Claude Code starts the stdio bridge. Restart Claude after adding the server.

claude mcp add --scope user openmayhem -- npx -y @openmayhem/mcp
claude mcp get openmayhem

Hermes

Hermes starts the stdio bridge and can verify tool discovery with its MCP test command.

hermes mcp add openmayhem --command npx --args -y @openmayhem/mcp
hermes mcp test openmayhem

OpenClaw

OpenClaw starts the stdio bridge from its MCP server configuration.

// ~/.openclaw/openclaw.json
{
  "mcp": {
    "servers": {
      "openmayhem": {
        "command": "npx",
        "args": ["-y", "@openmayhem/mcp"]
      }
    }
  }
}

OpenCode

OpenCode connects directly to the hosted server and resolves the API key from the environment.

// opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "servers": {
      "openmayhem": {
        "type": "remote",
        "url": "https://mcp.openmayhem.ai/mcp",
        "oauth": false,
        "headers": {
          "X-OpenMayhem-API-Key": "{env:OPENMAYHEM_API_KEY}"
        }
      }
    }
  }
}
After setup, ask the client to check your OpenMayhem balance and estimate a request. Run a paid tool only after reviewing the model, estimate and maximum cost.
ChatGPT directory support requires OpenMayhem account linking through OAuth. It is not enabled in this preview and API keys must not be pasted into ChatGPT prompts or tool arguments.

Your first MCP call

Every paid call follows the same four-step flow.

  1. Discover. Use list_models to filter live routes, then get_model to read the selected model’s exact request contract.
  2. Estimate. Pass the endpoint, model and exact request to estimate_request. It validates the request, creates no hold and returns a ten-minute estimate.
  3. Execute. Review the estimate, then pass the unchanged request, estimate_id and an explicit max_cost_usd to the matching paid tool.
  4. Collect. Text and embeddings return directly. Media and workflows return a job_id; use get_job, then get_artifact.

Exact estimate and execution

The request object must remain identical between estimate_request and the paid tool. The model pages contain ready-to-copy MCP calls for every supported model.

Tool: estimate_request
{
  "endpoint": "EMBEDDINGS",
  "model": "qwen/qwen3-embedding-4b",
  "request": {
    "input": ["First chunk", "Second chunk"],
    "dimensions": 1536,
    "encoding_format": "float"
  }
}
Tool: embed
{
  "model": "qwen/qwen3-embedding-4b",
  "request": {
    "input": ["First chunk", "Second chunk"],
    "dimensions": 1536,
    "encoding_format": "float"
  },
  "estimate_id": "<estimate_id from estimate_request>",
  "max_cost_usd": "<maximum_cost_usd from estimate_request>"
}

Open the model catalog for model-specific MCP examples.

Tools

Free tools list models, read model details, estimate exact requests, check balance, count tokens, poll or cancel jobs, and create short-lived artifact links. They do not spend model credit.

Discovery and control

ToolWhat it doesKey inputsWhat comes back
list_modelsFilter and page through live models, capabilities, prices, speed, context and availability.endpoint, modality, available, capability/routing filters, sort, limit, cursorPaginated model summaries and next_cursor
get_modelRead one model’s live request contract, price, limits and routes.modelLive request contract, pricing, limits, routes and availability
estimate_requestValidate an exact request and receive expected cost, maximum hold, route details and estimate_id without spending credit.endpoint, model, exact request, optional routingestimate_id, expected cost, maximum hold and route information
get_balanceRead posted, reserved and available credit, optionally split by rail.include_railsPosted, reserved and available credit
count_tokensCount a prompt or chat messages with the selected model’s tokenizer.model plus exactly one of prompt or messages; optional routingToken count and optional token IDs
get_jobRead status, billing state, cost and artifacts for an owned async job.job_idJob status, billing state, cost and artifacts
cancel_jobRequest cancellation of an owned async job.job_idCurrent cancellation/job state
get_artifactCreate a short-lived HTTPS link for an owned artifact.artifact_id, downloadArtifact metadata and short-lived HTTPS resource link

Paid tools run chat, Responses, embeddings, images, video, speech, transcription, audio, music, and workflows. Each paid call needs a recent estimate_id and an explicit max_cost_usd.

Run models

ToolWhat it doesKey inputsWhat comes back
chat
CHAT
Run Chat Completions for a text or multimodal chat model.model, request, estimate_id, max_cost_usd, optional routing/idempotency_tokenChat Completions response
create_response
RESPONSES
Run an OpenAI Responses-compatible request.Same paid-call envelopeResponses-compatible response
embed
EMBEDDINGS
Create one or batched embeddings while preserving input order and dimensions.Same paid-call envelope; request.input accepts one string or an arrayOrdered embedding vectors and usage
generate_image
IMAGES
Start an image-generation job.Same paid-call envelopeDurable job handle
generate_video
VIDEOS
Start a video-generation job.Same paid-call envelopeDurable job handle
generate_speech
AUDIO_SPEECH
Start a text-to-speech job.Same paid-call envelopeDurable job handle
transcribe_audio
AUDIO_TRANSCRIPTIONS
Start transcription for uploaded audio.Same paid-call envelope with bounded base64 audioDurable job handle
generate_audio
AUDIO_GENERATIONS
Start a general audio-generation job.Same paid-call envelopeDurable job handle
generate_music
MUSIC
Start a music-generation job.Same paid-call envelopeDurable job handle
run_workflow
WORKFLOWS
Start a catalog-supported media workflow with its exact graph and files.Same paid-call envelope with the model’s admitted workflow and input_filesDurable job handle

Routing controls

Add the same routing object to estimate_request and the paid tool when you need a specific trust tier, context size, quantization, provider set, throughput, admission wait or price ceiling.

{
  "min_attestation_tier": 2,
  "min_context_tokens": 131072,
  "quantization": "nvfp4",
  "preferred_providers": ["<64-character provider id>"],
  "hedge": false,
  "min_throughput_tokens_per_second": 20,
  "max_wait_ms": 60000,
  "max_input_price_per_million_usd": "0.10",
  "max_output_price_per_million_usd": "0.50",
  "max_representative_request_price_usd": "0.25"
}
max_wait_ms controls provider admission only. It does not limit generation or job runtime.

Jobs and artifacts

Image, video, speech, transcription, generated audio, music and workflows are asynchronous. The paid tool returns a durable job handle. Poll get_job until it succeeds or fails; then use get_artifact for each artifact_id.

Tool: get_job
{ "job_id": "<job_id from the paid tool>" }

Tool: get_artifact
{ "artifact_id": "<artifact_id from get_job>", "download": false }

Tool: cancel_job
{ "job_id": "<job_id from the paid tool>" }

cancel_job requests cancellation. Work already completed can still settle. Artifact links are short-lived, so request a fresh link when needed.

Retries and idempotency

Omit idempotency_token for normal calls. Set it only when retrying the same logical paid call with the same estimate and request. Use a new estimate and token for new work.

Runtime and size limits

MCP does not impose a generation or job runtime deadline. Long model calls may continue until the caller cancels, the provider finishes or the service is shut down. Body and upload limits still protect memory, and max_wait_ms remains an admission wait.

How payment works

An estimate creates no hold. When a paid call starts, OpenMayhem reserves at most the approved maximum on one eligible balance rail. Signed usage settles the actual cost and releases the rest. FIAT, TNK, and TAP remain separate and are never combined for one request.

Add credit on the OpenMayhem site. MCP never asks for card details, wallet keys, crypto transaction hashes, or an API key as a tool argument.

Failures and retries

Tool errors return a stable code, message and HTTP status. Correct validation errors before retrying. Retry availability errors with bounded backoff. If billing is reconciling or the outcome is unknown, inspect the same job or request instead of starting duplicate paid work.

Reuse one idempotency token only for retries of the same call. A confirmed zero-work failure releases the hold. If the outcome is uncertain, the job stays reconciling until canonical evidence settles or releases it; do not submit a second paid call.

Revoke the API key in your dashboard to stop access immediately.