mcpField
I
inference-mcp

inference-mcp

Local
github.com/BSVKeyAI & Agents0Updated 2d ago

About inference-mcp

inference-mcp is an MCP server for agents to call Claude and Grok through inference.bsvkey.com, with token-based billing settled in BSV or XRP. It supports prepaid channels or per-call payments, and can verify signed usage receipts and charges offline.

Key features

  1. 01Run Claude and Grok inference
  2. 02Prepaid channels billed per token
  3. 03Per-call payments in BSV or XRP
  4. 04Verify usage receipts and charges
  5. 05List models and check channel balance

Use cases

  1. 01Provide on-demand inference to agents
  2. 02Prepay in BSV and track usage
  3. 03Pay for individual inference calls in XRP
  4. 04Audit channel usage and charges

MCP support

The MCP server exposes tools for model discovery, inference, channel balances and setup, and inference paid in BSV or XRP.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"bsvkey-inference": {
"command": "npx",
"args": [
"-y",
"@bsvkey/inference-mcp"
],
"env": {
"BSVKEY_API_KEY": "<BSVKEY_API_KEY>",
"BSVKEY_BASE_URL": "<BSVKEY_BASE_URL>",
"BSVKEY_WIF": "<BSVKEY_WIF>",
"BSVKEY_FUNDED_SATS": "<BSVKEY_FUNDED_SATS>",
"BSVKEY_RECEIPT_STATE": "<BSVKEY_RECEIPT_STATE>"
}
}
}
}
Run commandnpx -y @bsvkey/inference-mcp
Environment variables to set
BSVKEY_API_KEYSecretA funded channel key in the form channelId:channelSecret. Open + fund a channel once at https://inference.bsvkey.com. Optional (can be passed per call).
BSVKEY_BASE_URLSecretGateway base URL. Defaults to https://inference.bsvkey.com/v1; override to point at a self-hosted deployment.
BSVKEY_WIFSecretA funded BSV private key (WIF) used by the x402_infer tool to pay per call in BSV (no channel). Signing is local; the key never leaves the process. Optional (can be passed per call).
BSVKEY_FUNDED_SATSSecretThe amount you funded your channel with on-chain. When set, usage receipts are verified against this instead of the broker-signed fundedSats. Optional (can be passed per call as fundedSats).
BSVKEY_RECEIPT_STATESecretPath to a JSON file where per-channel receipt continuity (seq + running totals) is persisted, so replays are caught across restarts. Optional; in-memory only if unset.

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
npm@bsvkey/inference-mcp1.3.5

Tools

6

Saved tool list · updated 3d ago

This tool takes no parameters.

Details

From the project README

@bsvkey/inference-mcp

An MCP server that lets any agent buy Claude & Grok inference metered per token, settled in BSV, through the hosted gateway at inference.bsvkey.com. Zero dependencies (Node ≥ 18, uses global fetch). It's a thin HTTP client — it never holds your keys or runs models; every call is billed through the gateway.

Tools: list_models, infer, channel_balance, open_channel, x402_infer, xrp_infer.

Two ways to pay: a prepaid channel (infer, fund once, draw down per token) or per call via x402 (x402_infer — no channel; the agent pays each request in BSV with its own key). x402_infer needs a funded WIF (wif arg or BSVKEY_WIF) and the optional @bsvkey/x402-bsv-client + @bsv/sdk packages (installed with this one).

Pay per call in XRP with xrp_infer: the tool gets a quote in XRP (priced from the XRP Ledger's own XRP/RLUSD market), signs one XRP Payment for exactly that locally, and the gateway checks it before broadcasting, waits for validation (a few seconds), and returns the answer, the settlement tx, and a signed receipt. It needs a funded XRP seed (xrpSeed arg or BSVKEY_XRP_SEED; create one at xrp.bsvkey.com/wallet) and the optional xrpl package (installed with this one; it needs Node 20.19+ or 22.12+). The account keeps a 1 XRP reserve that can't be spent.

Verifiable metering. Each infer call returns a signed usage receipt, and the tool auto-verifies it offline (with the optional packages installed): the result includes receiptVerified and meterVerified (true, false + receiptCheck, or null). It recovers the broker key (pinned from GET /v1/receipt-key); binds the receipt to the channel you called (from your API key, not the receipt's self-report); checks a monotonic sequence (no replay/gap) and running totals within the funded amount; recomputes the charge from the published rate (you can never be overcharged); and recomputes the token count from the exact bytes of your messages and the completion, under the pinned bsvkey-meter/1 tokenizer. So the channel payment is on-chain and both the meter and the charge are auditable, without trusting the broker's word.

Four things an unattended client should know:

  • Fails closed. If the pinned-key endpoint is unreachable, receiptVerified is null (unknown), never true — a down pin weakens the check to unknown, not to trusted.
  • Supply your funded amount. Set BSVKEY_FUNDED_SATS (or pass fundedSats) to the amount you funded on-chain. The receipt's own fundedSats is the broker's assertion; when you supply yours, a receipt claiming a different amount is rejected and totals are checked against what you actually paid.
  • Persist across restarts. Sequence continuity is in-memory by default (a replay before the first receipt this process sees would be invisible). Set BSVKEY_RECEIPT_STATE to a file path to persist per-channel seq/totals so replays are caught across restarts.
  • The receipt is the ledger. The GET /v1/channels/:id balance endpoint can lag the signed receipt by ~20s; trust the receipt, treat the endpoint as a cache.

Spec: https://inference.bsvkey.com/usage-receipts.md

Quick start

  1. Fund a channel once at https://inference.bsvkey.com (BRC-100 wallet, or load a key in-page). Copy the key it returns: channelId:channelSecret.
  2. Add the MCP server to your agent host (below), with that key in BSVKEY_API_KEY.
  3. Ask your agent to run inference — it calls infer and pays per token.

list_models and open_channel work with no key; infer and channel_balance need a funded channel key.

Install

Published on npm as @bsvkey/inference-mcp.

Claude Code
claude mcp add bsvkey-inference \
  --env BSVKEY_API_KEY=channelId:channelSecret \
  -- npx -y @bsvkey/inference-mcp
Claude Desktop / Codex / any MCP host (JSON config)
{
  "mcpServers": {
    "bsvkey-inference": {
      "command": "npx",
      "args": ["-y", "@bsvkey/inference-mcp"],
      "env": { "BSVKEY_API_KEY": "channelId:channelSecret" }
    }
  }
}

No npm? Grab the single-file server directly (https://inference.bsvkey.com/mcp/server.js) and use "command": "node", "args": ["server.js"].

Configuration (env)

VarDefaultMeaning
BSVKEY_BASE_URLhttps://inference.bsvkey.com/v1Gateway base URL (set to a self-hosted deployment if you run your own).
BSVKEY_API_KEY—channelId:channelSecret for a funded channel. Optional; can also be passed per call as apiKey.
BSVKEY_FUNDED_SATS—The amount you funded your channel with on-chain. When set, receipts are verified against it instead of the broker-signed fundedSats. Optional; per-call fundedSats.
BSVKEY_XRP_SEEDnoneAn XRP wallet seed for xrp_infer. Optional; can also be passed per call as xrpSeed. Never leaves this process.
BSVKEY_RECEIPT_STATE—Path to a JSON file for persisting per-channel receipt continuity (seq + totals) across restarts. Optional; in-memory only if unset.

Errors

A failed tool call returns isError: true with text in one fixed shape, so an agent can branch on the code without parsing prose:

error: <code> (<http status>): <message> [extra=value, ...]
CodeStatusToolWhat it meansWhat to do
no_channel_keyinfer, channel_balanceNo apiKey and no BSVKEY_API_KEYOpen a channel at the site (see open_channel)
invalid_channel401 / 404infer, channel_balanceChannel not found, wrong secret, or closedOpen a new channel
insufficient_balance402inferThe channel can't cover the worst case for this call; extras give requiredSats and balanceSatsTop up at the site, or lower maxTokens / turn off webSearch
invalid_request400infer, x402_inferUnknown model or policy, a model whose provider isn't enabled, or bad inputCall list_models
upstream_failed502inferThe model provider failedNothing is charged; retry or pick another model
no_wifx402_inferNo wif and no BSVKEY_WIFPass a funded key
verifier_missingx402_infer@bsvkey/x402-bsv-client / @bsv/sdk not installednpm i @bsvkey/x402-bsv-client @bsv/sdk
payment_failed402x402_inferThe payment didn't settle (e.g. the key's address is unfunded); extras give the reasonFund the address; nothing was spent
upstream_failed502x402_inferThe payment settled but the provider then failed; extras give settlementTxidNo automatic refund: email [email protected] with the txid
no_xrp_seedxrp_inferNo xrpSeed and no BSVKEY_XRP_SEEDPass a funded XRP seed
xrpl_missingxrp_inferThe xrpl package isn't installednpm i xrpl
node_too_oldxrp_inferNode is older than 20.19 / 22.12, which the xrpl package needsUpgrade Node (the other tools run on Node 18+)
insufficient_xrpxrp_inferThe wallet isn't activated, or can't cover the quote above its 1 XRP reserveFund it; nothing was spent
payment_failed402xrp_inferThe payment was refused before broadcast, or didn't settle; extras give the reasonNothing was spent unless a settlement tx is included
upstream_failed502xrp_inferThe payment settled but the provider then failed; extras give the settlement txNo automatic refund: email [email protected] with the tx

On a prepaid channel nothing is charged on any error. A successful infer can still report receiptVerified: false (the signed receipt didn't check out; see receiptCheck) or null (couldn't check: verifier missing, or the receipt-key endpoint was down).

Thinking models (claude-sonnet-5, claude-opus-5, claude-opus-5-5, claude-fable-5-1) bill their hidden reasoning as output, and maxTokens is raised to at least 1024 for them.

Verify it's wired (no key needed)

printf '%s\n' \
  '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}' \
  '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' \
  '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"list_models","arguments":{}}}' \
  | node server.js

Marketplace listing blurb

BSV Inference — Pay-per-token Claude & Grok, settled in BSV. Prepay a channel once, then meter every token with no subscription, account, or card. OpenAI- compatible, optional live web search, on-chain settlement. MCP + portable SKILL.md.

Publishing (operator)

  • Live on npm under the @bsvkey org (owner: interence). First publish: v1.0.0.
  • To ship an update: bump version in package.json, then npm publish --access public (2FA/security-key prompt applies).
  • Canonical source: https://github.com/BSVKey/inference-mcp
  • To list on a skills marketplace (e.g. bopen.ai), submit SKILL.md + this README.

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.