Laya MCP server
Give Claude, Cursor or any other AI assistant Laya's fast, calibrated decisions as built-in tools. One address, your existing API key, no code.
https://api.laya.studio/mcpStreamable HTTP · Bearer lsk_live_… keyWhat is MCP, in plain words?
MCP (the Model Context Protocol) is an open standard for plugging tools into AI assistants, a bit like USB for AI apps. You give your assistant the address of an MCP server; it reads the list of tools the server offers and calls them when they help with what you asked.
Laya's MCP server offers decision tools. Ask Claude "which of these 200 tickets are refund requests, and how sure are you?" and it can call Laya's classify tool on each one, getting a label with a probability back in about a tenth of a second instead of writing out its reasoning. Laya never generates text, so it cannot invent a label that is not on your list.
- Product and ops teams: triage, tag and score text straight from a chat with Claude.
- Developers: let your coding agent label data, check outputs or route requests while it works.
- Everyone: the same key, billing, limits and data residency as the REST API.
Connect your assistant
You need an API key from the dashboard (new workspaces get 5 free runs). Pick your client, paste your key if you like, and copy the snippet.
Run once in your terminal. Add --scope user to make Laya available in every project.
Then type /mcp inside Claude Code to check that "laya" is connected.
Claude Code in one line
To keep every call in Switzerland, add a second header: --header "x-laya-residency: ch" (JSON configs: add "x-laya-residency": "ch" to headers). See data residency.
The six tools
Pick a tool to see what it does, its parameters and an example call. The four decision tools can run live on the free demo, right here.
Answer typed questions about a text
Run a full Laya decision: answer up to 32 typed questions about one piece of text (the "state") in a single forward pass, each with a probability. Question types: "choice" picks one label from criteria (object label→description, or an array of labels); "score" rates on ordered levels (criteria is the ordered list of levels, answer.score is the expected level index); "noul" asks whether a statement is true (answer.noul is P(true)). Laya never generates text, so it cannot invent a label. Billed per input token read (1 credit = 1 input token; the text is read once per question); failed calls are free. Prefer classify, yes_no or score for a single question; use decide to ask several questions at once.
| Parameter | What it is |
|---|---|
staterequiredstring | object | array | What to decide about: a string, or a JSON object/array (serialised to JSON). Only the first ~512 tokens (English) or ~1,024 (multilingual) are read per question. |
questionsrequiredobject | Map of your own question ids to question definitions. 1 to 32 questions. |
model"english" | "multilingual" | "typed-decisions" | Optional checkpoint. Omit for automatic routing (English → "english", other languages → "multilingual"). Use "typed-decisions" only for the customer-service, invoice, security-incident and agent-trace workflows. |
langstring | Optional language hint such as "en", "de" or "pt-BR". Helps with short non-English text. |
Every result also comes back as a text block holding the same JSON, for clients that ignore structuredContent. Errors (bad arguments, not enough credits, busy capacity) come back as a result with isError: true and a plain-English message the assistant can act on.
decide takes the full question format from choice, score and noul questions; classify, yes_no and score are shortcuts for a single question.
Billing, limits and errors
MCP tool calls use the same pipeline as POST /v1/systemone: the same key, rate limit, credit balance and usage records (logged with the endpoint name mcp). Each successful tool call is one run: the first 5 free runs of a workspace cost nothing, then you pay the input tokens the model reads (1 credit = 1 input token, $0.0294 per 1M input tokens). Failed calls are free. See pricing.
| Status | Meaning |
|---|---|
200 | JSON-RPC response. Tool problems (bad arguments, not enough credits, capacity busy) come back as a tool result with isError: true and a plain-English message. |
202 | The message was a notification (for example notifications/initialized); there is no body. |
400 | Invalid JSON (-32700), an empty or oversized batch, or an unsupported MCP-Protocol-Version. |
401 | Missing or invalid key. Comes with WWW-Authenticate: Bearer and a JSON-RPC error body. |
405 | GET or DELETE: there is no SSE stream and no session to end. Use POST. |
429 | Rate limited per key. Honour Retry-After. |
Unknown methods return JSON-RPC error -32601; an unknown tool name returns -32602. Batches (a JSON array of messages) are supported and run in order. More in errors, limits & retries.
Protocol details (for client builders)
Streamable HTTP transport, JSON responses only. Protocol version 2025-06-18; clients asking for 2025-03-26 or 2024-11-05 get that version back. Supported methods: initialize, notifications/initialized, ping, tools/list and tools/call. A session id is returned on initialize but never required.
Questions
What is an MCP server?
MCP (Model Context Protocol) is an open standard that lets AI assistants such as Claude or Cursor use outside tools. An MCP server is a web address that lists tools and runs them when the assistant asks. Laya’s MCP server gives your assistant fast, calibrated classification and yes/no decisions.
Does the Laya MCP server cost extra?
No. Tool calls are billed exactly like the REST API: per input token (1 credit = 1 input token, $0.0294 per 1M input tokens), and failed calls are free. The usage tool is free. Every workspace starts with 5 free runs; each successful tool call uses one.
Which key do I use?
The same lsk_live_ API key you use for the REST API, sent as "Authorization: Bearer lsk_live_…". Create one in the dashboard under API keys.
Can I keep MCP calls in Switzerland?
Yes. Send the header "x-laya-residency: ch" with your MCP client configuration, or turn on Swiss-only mode for the workspace. The header can only tighten residency, never loosen it.
Does it support OAuth or SSE streaming?
Not today. The server speaks the Streamable HTTP transport with plain JSON responses and authenticates with your API key as a bearer token. Every call is a single fast request, so there is nothing to stream.