inference-mcp is an MCP (Model Context Protocol) server whose goal is to let any agent purchase Claude and Grok inference capabilities on a per-token paid basis, with fees settled in BSV and completed through the managed gateway inference.bsvkey.com. The project has zero dependencies, requires Node ≥ 18, and uses the global fetch; it is just a lightweight HTTP client that does not hold user keys and does not run models, and all calls are billed through the gateway.
Main capabilities It provides six tools: list_models, infer, channel_balance, open_channel, x402_infer, xrp_infer. There are two payment methods: one is the prepaid channel, top up once first and then deduct per token (infer); the other is per-call invocation through the x402 protocol, with no channel needed, where the agent uses its own key to pay BSV for each request (x402_infer). x402_infer requires a funded WIF (provided via the wif parameter or the BSVKEY_WIF environment variable), as well as the optional @bsvkey/x402-bsv-client and @bsv/sdk packages (installed together with this package).
XRP per-call payment xrp_infer supports per-call payment in XRP: the tool first obtains a quote priced in XRP (the price comes from the XRP Ledger's own XRP/RLUSD market), locally signs an XRP Payment for exactly that amount, the gateway checks before broadcasting, waits for validation (a few seconds), and then returns the answer, the settlement transaction, and the signed receipt. It requires a funded XRP seed (the xrpSeed parameter or BSVKEY_XRP_SEED; can be created at xrp.bsvkey.com/wallet), as well as the optional xrpl package (installed with this package, requires Node 20.19+ or 22.12+). The account retains a 1 XRP reserve, which cannot be spent.
Verifiable metering Each infer call returns a signed usage receipt; when the optional packages are installed, the tool automatically verifies it offline, and the result includes receiptVerified and meterVerified (true, false plus receiptCheck, or null). The verification contents include:Recover the broker public key (pinned from GET /v1/receipt-key); bind the receipt to the channel you are calling (based on your API key, not the receipt's self-report); check the monotonic sequence (no replay/gaps) and the cumulative total within the funded amount; recompute fees according to the public rate card (ensuring you cannot be overcharged); recompute the token count from the exact bytes of the message and completion using the pinned bsvkey-meter/1 tokenizer. Thus channel payments are on-chain, and metering and charges are auditable without trusting the broker's claims.
Four points for unattended clients to note
- Fail closed: if the pinned key endpoint is unreachable, receiptVerified is null (unknown), never true.
- Provide your funded amount: set BSVKEY_FUNDED_SATS (or pass fundedSats) to the amount you actually funded on-chain; the receipt's self-reported fundedSats is only the broker's assertion; if it does not match what you provide, reject the receipt, and check the total against the amount you actually paid.
- Persist across restarts: sequence continuity is in memory by default (replays before the first receipt seen by this process are invisible); set BSVKEY_RECEIPT_STATE to a file path to persist per-channel seq/total, thereby catching replays across restarts.
- The receipt is the ledger: the GET /v1/channels/:id balance endpoint may lag the signed receipt by about 20 seconds; trust the receipt and treat the endpoint as a cache.
Usage First, at https://inference.bsvkey.com fund the channel (BRC-100 wallet, or load the key on the page), and copy the returned channelId:channelSecret key. Then add the MCP server to the agent host and put that key in BSVKEY_API_KEY. After that, have the agent perform inference; it will call infer and pay per token. list_models and open_channel do not require a key; infer and channel_balance require a funded channel key.
Integration options
- npm package @bsvkey/inference-mcp, for JSON configuration in Claude Desktop / Codex / any MCP host.
- When npm is unavailable, you can directly obtain the single-file server https://inference.bsvkey.com/mcp/server.js,使用 "command": "node", "args": ["server.js"].
- Hosted option (no installation): MCP hosts that support remote servers can connect to https://inference.bsvkey.com/mcp(Streamable HTTP), also six tools. list_models and open_channel require no request headers; infer and channel_balance use the prepaid channel key in the Authorization header (or the per-call apiKey). The hosted server never receives private keys; x402_infer (BSV) and xrp_infer (XRP) work in two steps on the hosted side: first call without payment to get a quote, sign in your own wallet, then call with payment (a base64 X-PAYMENT value); the wif or xrpSeed parameters are rejected. The hosted server returns a signed receipt but does not verify it on your behalf; verify it offline with @bsvkey/x402-bsv-client; to sign payments locally with a key and verify receipts, use the aforementioned npm package.
Errors and billing details A failed tool call returns isError: true, with text in a fixed shape, so agents can branch on codes without parsing natural language. No errors on the prepaid channel are charged. A successful infer may still report receiptVerified: false (the signed receipt failed verification, see receiptCheck) or null (cannot verify: missing verifier or the receipt key endpoint is unavailable). Thinking models (claude-sonnet-5, claude-opus-5, claude-opus-5-5, claude-fable-5-1) count hidden reasoning as output, and their maxTokens is raised to at least 1024.
Use cases and limitations Suited to scenarios where you want to give agents access to Claude and Grok inference with pay-per-token billing and no subscription/account/credit card, and need on-chain settlement and auditable metering; OpenAI API compatible, optional real-time web search, provides MCP and a portable SKILL.md. Limitations include: dependence on the hosted gateway and BSV/XRP payment infrastructure; x402_infer and xrp_infer require the corresponding keys and optional packages; the hosted server does not verify receipts on your behalf; the balance endpoint has about a 20-second lag; XRP accounts have a 1 XRP non-spendable reserve.