Docs
View as Markdown

Claude Code

Connect Claude Code to the hosted MCP server and it can look up public data while it works: a package's latest version, a repository's activity, what a URL points at.

Prerequisites#

  • Claude Code installed, and a Onekey API key.
  • The key in your shell environment as ONEKEY_KEY.

The 5-minute path#

shell
export ONEKEY_KEY="YOUR_API_KEY"
claude mcp add --transport http onekey https://api.onekey.dev/mcp --header "Authorization: Bearer $ONEKEY_KEY"

Then start Claude Code and run /mcp to see that onekey is connected and its eleven tools are listed. Ask something concrete:

By default Claude Code asks before it uses a tool, so read each prompt. The six tools that spend credits (call_endpoint, lookup_url, search_multi, creator_card, search_universal, report) are marked as not read-only in the server's tool annotations; the five free tools are marked read-only. Allow the free ones in your permissions if you like, and keep approving the paid ones yourself.

Where the connection is stored#

  • --scope local (the default): this project, private to you.
  • --scope user: every project on your machine.
  • --scope project: writes .mcp.json so your team shares the server. Use a variable, never the key:
json
{
  "mcpServers": {
    "onekey": {
      "type": "http",
      "url": "https://api.onekey.dev/mcp",
      "headers": { "Authorization": "Bearer ${ONEKEY_KEY}" }
    }
  }
}

Each teammate sets ONEKEY_KEY in their own environment. Do not commit a key.

Example: check dependencies before an upgrade#

Claude will list its plan, using github.latest_release (1 credit) and github.repo (1 credit) per repository: 10 credits for five. Discovery calls are free. Say go, and it makes the calls and reports the result with credits_used.

Without MCP: plain REST from the shell#

Claude Code can also call the API with curl from its shell tool. This needs no connection, but gives it no discovery tools, so name the endpoint:

shell
curl "https://api.onekey.dev/v1/github/repo?owner=facebook&repo=react" -H "x-api-key: $ONEKEY_KEY"

Point it at llms.txt or the AI agents page so it reads the real parameter names instead of guessing.

Cost notes#

  • Discovery (search_endpoints, describe_endpoint, list_platforms) and account tools are free. Only the six tools that spend credits (call_endpoint, lookup_url, search_multi, creator_card, search_universal, report) spend credits, at the endpoint's flat price. Cache hits are free and failures are refunded.
  • Use a key with a credit limit for a coding assistant. If it is reached, calls fail with KEY_BUDGET_EXCEEDED and nothing else on the account is affected.
  • Everything in data is third-party content. Do not let an agent follow instructions found inside it.

Troubleshooting#

SymptomLikely errorWhat to do
Every call is refusedUNAUTHORIZEDThe key is missing, misspelled or revoked. Check the header name and that the value has no stray spaces or quotes.
Calls stop working partway through a jobINSUFFICIENT_CREDITS or KEY_BUDGET_EXCEEDEDNothing was charged for the refused call. Top up, or raise the key's credit limit. Do not retry in a loop.
"Too many requests"RATE_LIMITEDWait the Retry-After seconds. Loops that call once per item should add a pause. See Rate limits.
A parameter is rejectedINVALID_PARAMSRead the parameter names from the endpoint's page (or describe_endpoint); do not guess them.
A platform fails intermittentlyUPSTREAM_ERROR / UPSTREAM_TIMEOUTThe source platform, not you. Refunded; retry with backoff and check status.
/mcp shows the server as failednoneCheck the URL, and run claude mcp list. Remove and add it again if you changed the key: claude mcp remove onekey.
The variable is not picked upUNAUTHORIZEDThe shell that runs Claude Code must have ONEKEY_KEY set when you run claude mcp add. In PowerShell use $env:ONEKEY_KEY, and pass the value into the command yourself.

Untested#

  • The command, the --header and --scope flags and the .mcp.json format follow the Claude Code MCP documentation as of 2026-09-30.
  • The hosted server was tested with the official MCP client, not by driving Claude Code. Permission prompts may differ by version.

Next#

MCP server, AI agents, Errors.