MCP
Connect an AI agent to the API through the Model Context Protocol, with every operation as a tool.
The API has a Model Context Protocol server, at /mcp on the same host as /v1. It is the public API by another transport: every operation of the OpenAPI contract is a tool, and calling a tool is making the request of that operation. Validation, scopes, idempotency, errors and rate limits are the same.
Connecting
- Endpoint:
POST /mcp. - Transport: Streamable HTTP, without sessions. Each
POSTstands on its own. - Protocol revision:
2026-07-28, and the earlier revisions for clients that have not moved yet. - Credential: the API key, in the
Authorizationheader, asBearer sk_test_….
The key is the same one that /v1 takes, and it decides the environment: a test key connects the agent to test mode, a live key to live. See Authentication. There is no OAuth sign-in: a client connects only if it can send a fixed header.
| Client | Where the header goes |
|---|---|
| Claude Code | claude mcp add --transport http xase https://API_HOST/mcp --header "Authorization: Bearer sk_test_…" |
| Claude | In Customize > Connectors, add a custom connector with the URL of /mcp, choose No sign in, and under Request headers add Authorization with the value Bearer sk_test_… |
| Cursor | In mcp.json, a server with "url" and "headers": {"Authorization": "Bearer ${env:XASE_API_KEY}"} |
| VS Code | In .mcp.json, a server with "type": "http", "url" and "headers": {"Authorization": "Bearer ${XASE_API_KEY}"} |
API_HOST stands for the host of the API. A client that only connects through OAuth, such as ChatGPT, cannot connect.
- Without a valid key the answer is
401, the same as in/v1. Some clients react to a401by starting an OAuth sign-in, which leads nowhere here: set the header. - A request that carries the
Originheader is refused with403and the codeorigin_not_allowed. The endpoint is for programs, and a browser sends that header when a web page makes the request. GETandDELETEanswer405: there is no stream and no session to open or close.- The server has tools only: no resources, no prompts, and it never asks the client for anything.
Tools
Each tool has the name of its operation in the contract, such as createCharge, and the description the contract gives it. The pages of each resource say what the operations do: Charges, Refunds, Disputes, Offers, Balance and Test mode.
The arguments of a tool are the fields of the request body of the operation, plus one argument for each of its parameters, under the name the contract gives it:
| In the contract | In the tool | Example |
|---|---|---|
| A field of the request body | An argument with the same name | amount_cents |
| A path parameter | An argument with the same name | id |
| A query parameter | An argument with the same name | limit |
| A header | An argument with the same name | Idempotency-Key |
So createCharge takes amount_cents, expires_in and Idempotency-Key, and getCharge takes id. An argument the contract does not have is refused, like a field that is not in the contract is refused in /v1.
The result of a tool is the JSON the operation answers, as text and as structured content. An operation that answers without a body, like simulatePayment, returns the description of that answer.
The tools a key sees
The list of tools is the list of what the key can do:
- Every operation asks the key for a scope, and a tool only appears for a key that has the scope of its operation. See What a key can do.
- A key with the
readscopes alone sees the seven tools that read,getCharge,listCharges,getRefund,listRefunds,getOffer,listOffersandgetBalance, and none that writes. - Writing does not include reading: a key with
charges:writealone seescreateChargeand notgetCharge. - A key created before an operation existed does not see its tool. Offers and the balance came after the first keys: an agent sees
createOfferorgetBalanceonly with a key created with their scopes. - The tools of test mode only appear for a test key, and ask it for the same scope as their operations,
charges:write.
Calling a tool that is not in the list of the key answers like calling a tool that does not exist. To give an agent fewer tools, give it a key with fewer scopes.
Errors
When the operation refuses the call, the result is marked as an error (isError) and its text is the same problem that /v1 answers. Read code, as in Errors: invalid_request lists each argument that the contract refuses, by the name of the argument.
A tool call spends the rate limit of the key, from the same bucket as the requests to /v1. Over the limit the result is the rate_limited error, and a second text block says in how many seconds to try again, as Retry-After: 4.
When you retry createCharge or createRefund, send the same Idempotency-Key: the call returns what the first one created. createOffer has no Idempotency-Key, and every call creates another offer: after a call that did not answer, call listOffers before trying again.
What to give an agent
- Start with a test key. The whole path runs in test mode:
createChargeandsimulatePaymentwithcharges:write,getChargewithcharges:read,createRefundwithrefunds:write,createOfferandarchiveOfferwithoffers:write, andgetBalancewithbalance:read. - Give the agent the key with the fewest scopes that does the job. An agent that only answers questions needs the
readscopes and nothing else. A key withoutrefunds:writecannot refund, whatever the agent is told. - Text typed by a buyer reaches the model. The
customerof a charge carries the name and the e-mail address the buyer typed at the checkout, and that text can be written as an instruction. An agent that holds a key withrefunds:writecan be talked into a refund. The damage has a ceiling: a refund only sends back to the payer what the payer paid, once. - Keep the confirmation of your client on. The tools that only read are marked as read-only, and every other tool is marked as destructive, which is what a client uses to ask before calling it. The mark is a hint to the client, not a control of the platform.