MCP integration
APIHub exposes 9 tools over the Model Context Protocol so any compatible AI client can discover and call paid APIs.
Endpoint
MCP server is reachable at:
https://mcp.apihub.io/mcp
Transport: Streamable HTTP
Protocol version: 2025-03-26
Auth: Bearer ahk_... (Authorization header)The handshake methods (initialize, tools/list) are public so clients can discover available tools without an API key. Only tools/call requires auth.
Auto-config via CLI (recommended)
The CLI detects installed MCP clients and writes the right config file for each:
# install config for all detected clients
npx @apihubio/cli install
# or target a specific client
npx @apihubio/cli install --target claude
npx @apihubio/cli install --target cursor
npx @apihubio/cli install --target codex
npx @apihubio/cli install --target claude-codeSetup: Claude Desktop
Edit Claude Desktop's config file and restart the app:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"apihub": {
"url": "https://mcp.apihub.io/mcp",
"headers": {
"Authorization": "Bearer ahk_your_api_key_here"
}
}
}
}Verify: open Claude Desktop, start a new chat, ask "What APIHub tools are available?". You should see all 9 tools.
Setup: Cursor
Settings > MCP Servers, or edit ~/.cursor/mcp.json directly:
{
"mcpServers": {
"apihub": {
"url": "https://mcp.apihub.io/mcp",
"headers": {
"Authorization": "Bearer ahk_your_api_key_here"
}
}
}
}Setup: any MCP-compatible client
Same config shape works for any client that supports the Streamable HTTP transport. The two required fields are url and the Authorization header.
Available tools
Nine tools cover discovery, payment, and execution. Listed roughly in the order an agent typically uses them.
apihub_search
Read-only. Search onboarded services by query, category, price, or type. Returns up to 10 ranked matches with endpoints and pricing.
Args: query (string, required), category (string), max_price_microdollars (number), type ('api' | 'content')
apihub_list_services
Read-only. Browse the full onboarded catalog alphabetically. Use when you don't have a specific search query.
Args: limit (number, default 20, max 100)
apihub_get_service
Read-only. Full details for a service including all endpoints, schemas, and pricing.
Args: service_slug (string, required)
apihub_call
Sends payment. Calls an onboarded service endpoint. Debits credits and forwards to upstream. Returns body, status, and credits charged.
Args: service_slug (string, required), endpoint_path (string, required), method ('GET' | 'POST' | 'PUT' | 'DELETE'), body (string)
apihub_search_external
Read-only. Search the external x402 catalog (APIs not operated by APIHub but indexed from on-chain activity). Callable via credits.
Args: query (string), category (string), limit (number, default 10)
apihub_call_external
Sends payment. Call any external x402 URL. APIHub pays the provider and debits credits. No wallet required.
Args: url (string, required), method, body, headers
apihub_read_content
Sends payment. Read web content via a paid content gateway. Returns clean structured text.
Args: service (string, required), url (string, required)
apihub_topup
Returns payment instructions for purchasing credits via x402 (browser, CLI, or direct x402). Credits added once payment confirms.
Args: amount_dollars (number, required, min 5, max 10000)
apihub_balance
Read-only. Returns credit balance, total spending, and total request count.
Args: none
Example flow
A typical agent session via MCP looks like:
User: "What weather services are on APIHub?"
Agent: [calls apihub_search with query="weather"]
[shows results]
User: "Get me the current weather in London via the cheapest one"
Agent: [calls apihub_get_service to confirm endpoint shape]
[calls apihub_balance to confirm funds]
[calls apihub_call with service_slug + endpoint_path + body]
[returns weather data]
User: "I'm running low on credits"
Agent: [calls apihub_topup amount_dollars=10]
[shares the CLI command or browser URL]