> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.getraya.app/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.getraya.app/_mcp/server.

# Reference

> **Warning**
>
> **Experimental, in beta.** Raya's MCP server is new and may change. For feedback, suggestions or problems, email [support@litwizlabs.ai](mailto:support@litwizlabs.ai).

## Server

|                |                                                                                      |
| -------------- | ------------------------------------------------------------------------------------ |
| Endpoint       | `https://mcp-beta.getraya.app/mcp`                                                   |
| Transport      | MCP over streamable HTTP (JSON responses)                                            |
| Authentication | An MCP key (`raya_mcp_...`) in the `X-API-Key` header. Regular API keys are refused. |
| Data           | Your team's agents and calls only                                                    |

## Tools

| Tool               | Does                                                                                                                                                                                                                                              |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `list_agents`      | Your agents, most recently updated first. Filter by name.                                                                                                                                                                                         |
| `get_agent`        | One agent's full configuration: the complete prompt with its `welcome` and `instructions` blocks, prompt size and limit, output prompt, tools (header values hidden), arguments, LLM option, languages, and knowledge base files with their sizes |
| `get_kb_file`      | One knowledge base file, as the agent reads it during a call                                                                                                                                                                                      |
| `list_llm_options` | LLM options available to your team, with simulation price in credits per 1M tokens and the prompt size limit                                                                                                                                      |
| `platform_faq`     | Raya's answers to common questions: ending calls, languages, call data, batches and callbacks, inbound numbers, models, plans and prices                                                                                                          |
| `list_calls`       | Real calls, newest first. Filter by agent, outcome and date.                                                                                                                                                                                      |
| `get_call`         | A real call's transcript, arguments, output and timing                                                                                                                                                                                            |
| `estimate_cost`    | The credits a planned set of simulations will cost, and how much would come from simulation credits. Nothing is run or charged.                                                                                                                   |
| `start_session`    | Start a simulated call and get the agent's opening line                                                                                                                                                                                           |
| `send_turn`        | Send the caller's next line, a silence, or answers to tool calls                                                                                                                                                                                  |
| `end_session`      | End the simulated call with a verdict. Returns the credits charged, how they were paid and what's left.                                                                                                                                           |
| `get_session`      | A simulated call's transcript, verdict and credits                                                                                                                                                                                                |
| `list_sessions`    | Your open simulated calls                                                                                                                                                                                                                         |

## Prompt size limit

Each LLM option has a prompt size limit, 8,000 tokens unless agreed otherwise. It applies to the agent's whole prompt. `get_agent` shows `prompt_tokens` and `prompt_token_limit`. A draft over the limit is refused with `PROMPT_TOO_LONG` before anything is charged. An agent whose live prompt is already over the limit can still be simulated, but a tested change has to bring it under.

## Limits

| Limit                                       | Value                                                                                    |
| ------------------------------------------- | ---------------------------------------------------------------------------------------- |
| Requests                                    | 10 per second per key                                                                    |
| Simulation model requests                   | Per team and overall, per minute and in flight. Over the limit: `429` with `Retry-After` |
| Open simulated calls per team               | 20                                                                                       |
| Idle timeout                                | 2 hours, then the simulated call ends and is charged                                     |
| Turns                                       | One at a time per simulated call; a turn can take up to about a minute                   |
| Caller line / tool result / draft overrides | 2 KB / 32 KB / 256 KB                                                                    |
| MCP keys per team                           | 10 active                                                                                |

## Errors

Over MCP, errors come back as a tool result with `isError: true` and this body.

| Status | `code`                                                 | Meaning                                                                                                 |
| ------ | ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------- |
| 400    | `INVALID_INPUT`                                        | A tool argument is missing or invalid; the message says which                                           |
| 401    | `UNAUTHORIZED`                                         | Missing, invalid or revoked MCP key, or a regular API key used instead                                  |
| 402    | `INSUFFICIENT_CREDITS`                                 | Your credits are over; email [support@litwizlabs.ai](mailto:support@litwizlabs.ai) to recharge          |
| 402    | `TEAM_SUSPENDED`                                       | Simulations are restricted on this account; email [support@litwizlabs.ai](mailto:support@litwizlabs.ai) |
| 403    | `HARNESS_ACCESS_DISABLED`                              | AI assistant access is turned off for your team                                                         |
| 404    | `AGENT_NOT_FOUND` / `SESSION_NOT_FOUND`                | Not found, or not your team's                                                                           |
| 409    | `TURN_IN_PROGRESS` / `TOOLS_PENDING` / `SESSION_ENDED` | One turn at a time; answer pending tool calls first; the simulated call is over                         |
| 413    | `OVERRIDES_TOO_LARGE`                                  | The draft overrides are over 256 KB                                                                     |
| 422    | `PROMPT_TOO_LONG`                                      | The draft is over the prompt size limit; the body has `prompt_tokens` and `prompt_token_limit`          |
| 422    | `UNSUPPORTED_LLM` / `LLM_NOT_ALLOWED`                  | This LLM option can't be simulated, or isn't available to your team; try `overrides.llm_option_id`      |
| 429    | `RATE_LIMITED`                                         | Over a limit; retry after `Retry-After` seconds                                                         |
| 502    | `MODEL_UNAVAILABLE`                                    | Temporary model issue; retry                                                                            |

## Simulated calls over REST

The same operations are plain HTTP endpoints under `https://mcp-beta.getraya.app/api/sim`, with your MCP key in `X-API-Key`.

| Endpoint                          | Does                                                                                                                                                                                                                                                 |
| --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `POST /api/sim/estimate`          | Estimate a plan: `agent_id`, `scenarios: [{ name, turns, runs }]`, optional `overrides`                                                                                                                                                              |
| `POST /api/sim/sessions`          | Start: `agent_id`, optional `call_type`, `agent_args`, `call_time` (ISO 8601 with offset), `timezone`, `initializer_values`, `overrides` (`welcome`, `instructions`, `tools`, `llm_option_id`), `labels` (`run_label`, `scenario`, `replay_of_call`) |
| `POST /api/sim/sessions/:id/turn` | Exactly one of `caller_text`, `event` (`silence` / `unclear`) or `tool_results` (`[{ tool_call_id, mode: "mock" \| "live", result }]`)                                                                                                               |
| `POST /api/sim/sessions/:id/end`  | Optional `result` (`pass` / `fail`) and `reason`. Returns `credits_charged`; ending twice charges once.                                                                                                                                              |
| `GET /api/sim/sessions/:id`       | Transcript, labels, verdict and credits, readable for 3 hours after the last turn                                                                                                                                                                    |
| `GET /api/sim/sessions`           | Your open simulated calls                                                                                                                                                                                                                            |

```bash
curl -X POST https://mcp-beta.getraya.app/api/sim/sessions \
  -H "X-API-Key: <YOUR_MCP_KEY>" -H "Content-Type: application/json" \
  -d '{ "agent_id": "123e4567-e89b-12d3-a456-426614174000", "labels": { "run_label": "intro fix v2" } }'
```

Every response carries `credits_so_far`. The response that ends a simulated call carries `credits_charged`, `charged_from` (how much came from `simulation_credits` and from `balance`) and `credits_left` (what remains of each); `GET /api/sim/sessions/:id` also returns `credits_left`. `POST /api/sim/estimate` also returns `simulation_credits_available` and `estimate_paid_from`.