MCP server: your 1xAi key in Claude Code and Cursor
1xAi's own MCP server is one URL that any MCP client (such as Claude Code or Cursor) connects to with your API key. The model inside that client gets five tools: the models and their prices, the estimated cost of a request, your balance, your usage, and a chat with any model. A chat is an ordinary POST /v1/chat/completions call: the same price, the same usage record and the same request id. The key's scope, model list, address list, rate limit and spend cap all apply.
Last updated:
The endpoint and the protocol
The server is at https://1xai.ir/v1/mcp (or https://api.1xai.ir/v1/mcp, which reaches the same service). It is remote MCP over Streamable HTTP: one URL that takes POST only, each JSON-RPC message its own request, and each answer one JSON object. The server keeps no session, opens no event stream and sends nothing on its own; GET and DELETE answer 405. Protocol versions: 2026-07-28 (no handshake), and 2025-11-25 and 2025-06-18 (with initialize).
- Authentication is the
Authorization: Bearer 1xai-...header, as on every/v1path (authentication). Sign-in with OAuth is not supported. - A request from a web page (one with an
Originheader) is refused with403, and the server sends no CORS header. Keep the key in the client's settings, never in a web page. - No tool fetches a URL, a file or any outside resource: the read tools read the account API itself, and chat is the gateway's own chat route.
Adding it to a client
Claude Code
claude mcp add --transport http 1xai https://1xai.ir/v1/mcp \ --header "Authorization: Bearer 1xai-..." # for every project claude mcp add --transport http 1xai --scope user https://1xai.ir/v1/mcp \ --header "Authorization: Bearer 1xai-..."
In a project's .mcp.json, which lives in the repository, do not write the key: put it in an environment variable of your own name. Claude Code leaves its own credential variables (such as ANTHROPIC_API_KEY) empty in a remote server's headers.
{
"mcpServers": {
"1xai": {
"type": "http",
"url": "https://1xai.ir/v1/mcp",
"headers": {
"Authorization": "Bearer ${ONEXAI_API_KEY}"
}
}
}
}Cursor
{
"mcpServers": {
"1xai": {
"url": "https://1xai.ir/v1/mcp",
"headers": {
"Authorization": "Bearer ${env:ONEXAI_API_KEY}"
}
}
}
}Claude Desktop
Claude Desktop's connectors attach a remote server through an OAuth sign-in and take no key. Use the open-source mcp-remote bridge instead: it runs on your own computer (it needs Node.js) and sends the key in the header. The snippet names one exact release of it, so npx never fetches a newer one unasked. Restart Claude Desktop after saving the file.
{
"mcpServers": {
"1xai": {
"command": "npx",
"args": ["-y", "mcp-remote@0.16.7", "https://1xai.ir/v1/mcp", "--transport", "http-only", "--header", "Authorization:${ONEXAI_AUTH}"],
"env": { "ONEXAI_AUTH": "Bearer 1xai-..." }
}
}
}Other clients
Any client that speaks remote MCP over Streamable HTTP and can send a header works: the URL https://1xai.ir/v1/mcp and the Authorization header. A client that knows only an OAuth sign-in cannot connect.
The tools
| Tool | What it does | Key scope |
|---|---|---|
list_models | What it does:The models this key can call, with each one's vendor, kind and list price in Toman per thousand input and output tokens. Filters: vendor, kind and search; at most 200 rows. | Key scope:inference, usage and full |
estimate_cost | What it does:The cost of a request in Toman before it is sent, from the model and the token counts, at your own account's rates. Nothing is charged. | Key scope:inference, usage and full |
get_balance | What it does:The spendable balance, the wallet and the gift credit. A company workspace key sees the spendable balance only. | Key scope:usage and full |
get_usage | What it does:Calls, tokens and Toman by day and by model; the same records as GET /v1/usage/summary (account API). days (default 7), or from and to; at most 90 days. | Key scope:usage and full |
chat | What it does:One chat completion: model, messages (plain text, at most 64) and max_tokens (default 1,024, at most 16,384). | Key scope:inference and full |
The tool list (tools/list) shows only the tools of the key's scope. A tool outside it gets a tool error with code key_scope_denied (scopes). An inference key sees the models and prices (what GET /v1/models already gives it), never the account's balance or usage. For a client that should only read, make a usage key: even if it leaks, it cannot spend.
What it costs
- The four read tools cost nothing.
chatis an ordinary API call: the same price, the same order of payment (plan credit, gift credit, then the wallet) and the same hold and refund asPOST /v1/chat/completions(billing).- Its usage record is in your logs. The
request_idof the tool's answer and theX-Request-Idheader of the HTTP answer are that record's id (response metadata), andcost_tomanis what it was billed. estimate_costgives the list price at your account's own markup; plan credit or gift credit may pay part of it.- Every MCP request is one request of the key's rate limit (rate limits).
Key controls
- The model list:
list_modelsshows only the models on it, andestimate_costandchatrefuse the others with codekey_model_not_allowed(model list). - The address list: a request from another address answers
403with codekey_ip_not_allowed, as on every/v1path (address list). - The key's spend cap:
chatcounts toward it, and a key at its cap answers401with codekey_capped. - Give MCP a key of its own, with a spend cap if the client chats (keys).
Limits
| What | Limit |
|---|---|
| A request body | Limit:1 MB; more answers 413 |
The messages of chat | Limit:64 plain-text messages |
max_tokens of chat | Limit:default 1,024, at most 16,384 |
The window of get_usage | Limit:at most 90 days |
The rows of list_models | Limit:at most 200 |
| The read tools, per key | Limit:list_models 60 a minute, estimate_cost 120 a minute, get_balance 60 a minute and get_usage 20 a minute |
A read tool past its own per-minute limit gets a tool error with code rate_limited; try again a minute later. chat has no separate limit: the key's own rate limit applies.
Errors
| Answer | When |
|---|---|
A tool result with isError: true | When:The tool hit a rule, or the gateway refused the call. structuredContent.error has the code (the codes of /v1: error reference) and the message, and for chat the request id and the gateway's HTTP status. |
401 | When:No key, or an unknown, revoked, expired or capped one. |
403 | When:An address off the list, the key's scope, or a request from a web page. |
405 | When:GET, DELETE or any method but POST. |
413 | When:A body over the limit. |
415 | When:A Content-Type other than application/json. |
| A JSON-RPC error | When:A malformed request (-32700 and -32600, a batch of messages included), an unknown method (-32601), bad params or an unknown tool (-32602), headers that do not match the body (-32020), or an unsupported version (-32022). |
1xAi is an independent gateway. It is not affiliated with, endorsed by, or a reseller for OpenAI, Anthropic, Google, DeepSeek, xAI, Moonshot AI, Z.ai, Alibaba Qwen, MiniMax or Tencent Hunyuan. Requests are relayed upstream rather than answered by models of our own, so each provider's own usage policies apply to what their models will and will not do, and their model availability is theirs to change. Current reachability is published on the status page.