Appearance
npm package
Not on npm yet
We have not published this package, so the commands on this page do not work yet.
@api3/airnodehub-mcp puts two things in front of the Hub's MCP server that the server leaves to you: it pays for priced calls from a wallet you give it, within limits you set, and it verifies every response on your machine before handing it over. Your client sees the same tools it would see from the Hub, over stdio.
Priced calls are paid in aUSD, a test dollar, and aUSD is the only token this version signs for, so it cannot spend real money. See paying for how to mint it.
Connecting
Add it to your MCP client's configuration. Clients differ in where this lives, but they all want the same command:
json
{
"mcpServers": {
"airnodehub": {
"command": "npx",
"args": ["--yes", "@api3/airnodehub-mcp"],
"env": {
"AIRNODEHUB_PRIVATE_KEY": "0x…"
}
}
}
}Leave the key out and everything still works except paying: you can browse the catalogue and make free calls, and a priced call answers with its payment requirements. It needs Node.js 22 or later.
| Variable | Default | What it does |
|---|---|---|
AIRNODEHUB_PRIVATE_KEY | none | The key of the wallet that pays. |
AIRNODEHUB_MAX_PER_CALL_USD | 0.1 | The most it will sign for one call. |
AIRNODEHUB_MAX_SESSION_USD | 1 | The most it will sign for until it restarts. |
AIRNODEHUB_MAX_RESPONSE_AGE_SECONDS | 300 | How long ago an answer may have been signed. |
AIRNODEHUB_URL | https://airnodehub.api3.org/mcp | The MCP server it forwards to. |
AIRNODEHUB_RPC_URL | https://sepolia.base.org | The Base Sepolia RPC for a metered payment. |
Give it a wallet made for this, holding only what you are happy for an agent to spend. The key sits in your client's configuration, and the agent decides which calls to make.
What it does with a priced call
Your agent calls call-operation as usual. When the answer is a price, the package checks it against what the listing publishes before it signs anything. It refuses any token but aUSD or one the listing does not name, a recipient other than the one in the Airnode's own document, an amount above the listing's price, a payment that would stay valid for more than ten minutes, and anything over your limits. Your agent gets the refusal as a tool error and nothing is signed.
Otherwise it signs the payment, sends the call again, and returns the answer. The wallet-status tool it adds says which address is paying and how much is left to spend.
Some listings set a price per unit, such as one unit per credit the upstream spends, and the Airnode counts the units of each call. The package cannot know that count before the call, so it pays what the Airnode asks. Your limits are the only cap on those calls.
Some listings meter an operation, such as a chat completion that costs what the model reads and writes. The Airnode asks for a ceiling, the package authorizes up to that ceiling through Permit2, and the Airnode charges what the call cost. The answer says both, the ceiling it authorized and the charge the receipt states. The limits count the whole ceiling, since the authorization can settle for up to that much. So the package refuses a ceiling above your limit for one call, and for a chat completion a lower max_completion_tokens lowers the ceiling. The whole ceiling stays counted after the call, whatever the receipt says it charged, because nothing signs the receipt.
Before a metered payment, the package reads your wallet's aUSD allowance for Permit2 over AIRNODEHUB_RPC_URL. When the allowance is short of the ceiling, it also signs an EIP-2612 permit for that ceiling, which the facilitator submits with the payment. You need no gas for either.
The limits count every payment it signs, including one an answer says was refused, because whoever holds a signed payment can settle it until it lapses, whatever they tell you. So a refused call uses up its share of the session limit. The limits reset when the process restarts. It does not read your balance, so a wallet that runs out finds out from the refusal. If a paid call fails, the error says a payment was sent, since calling again may pay twice.
What it does with a response
Before you see the answer to a call-operation, the package checks that the listing's address signed it, for exactly the request that was sent, over exactly the bytes that came back, within the last five minutes. What your agent gets is built from the attestation that passed, along with a line saying so and a verification field in the structured result. A paid call also says what it cost, under paidUsd, what the package signed for under authorizedUsd, and the receipt under settlement, which nothing signs. For a metered call, authorizedUsd is the ceiling and paidUsd comes from the receipt. An answer that fails is withheld, and your agent gets the reason as a tool error.
An error has nothing signed in it, and may quote what an upstream said, so it is passed along marked as unverified rather than withheld. The package's other tools answer as the Hub does, without a check.
This catches an answer changed or replayed on its way to you. It does not catch a Hub lying about a listing. The address, the price and the URL of the Airnode's document all come from the Hub, since they are what we vouch for, so a Hub that lied about all of them could have you pay the wrong recipient, up to your limits. Before a paid call the package also fetches that document from your machine, so a lying Hub can choose an HTTPS host it reaches, including one on your own network. A clock that is far off makes good answers look old, which AIRNODEHUB_MAX_RESPONSE_AGE_SECONDS can loosen. Attestation has the algorithm, and on a listing that is not first-party the signature is provenance for the relay rather than for producing the data.
Using it from a program
The same package works without an MCP client. A call answers with the verified data or throws, with the reason as the error's message:
ts
import { connectToHub } from '@api3/airnodehub-mcp';
const hub = await connectToHub();
const { data, attestation } = await hub.call('nodary', 'latestFeeds', { name: 'ETH/USD' });
console.log(data, attestation.airnode);
await hub.close();data is the provider's body as one string, since that is what the signature covers. To pay for priced calls, pass a viem local account as account, and limits with maxPerCallUsd and maxSessionUsd to change the limits above, and maxResponseAgeSeconds to change how old an answer may be.