Answers

How do I connect P0 to the xAI Grok API as a remote MCP tool?

Add P0 to a Grok API request (POST https://api.x.ai/v1/responses) as a remote MCP tool: tools: [{ type: "mcp", server_url: "https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/mcp", server_label: "p0" }]. server_url and server_label are the two required fields; xAI manages the connection to the server. The tools you can use through it are free: market search, market statistics and the list of P0's paid products.

Data as of 2026-10-25 · Source: xAI: Remote MCP Tools

The numbers

P0 MCP endpoint
https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/mcp
Transport
Streamable HTTP, JSON-RPC 2.0
Authentication
None required; an optional prepaid access key is accepted as Authorization: Bearer p0k_… (see the notes)
Free tools worth allowing
search_x402_services, x402_market_stats, list_paid_data_products

Steps in xAI Grok API

StepWhat to do
1Put a tool of type mcp in the tools array of a request to the xAI API.
2Set server_url to the P0 endpoint and server_label to a name you choose (xAI uses the label to prefix tool calls).
3Optional: allowed_tools (allowed_tool_names in the xAI SDK) limits which tools the model sees; server_description describes the server to the model.
4No authorization or headers field is needed: the endpoint is open.

What works through the connector, and what does not

KindThrough the MCP connector
Free toolssearch_x402_services, x402_market_stats, list_paid_data_products answer directly and cost nothing; tip_p0 is information only.
Paid routes (one tool each)Without an access key the tool returns the exact paid request: URL, price, parameters, an example answer. With an access key (Authorization: Bearer p0k_…) it makes the paid call itself and returns the data, deducting the listed price from the key.
The paid data itselfThe request answers HTTP 402 until it is paid. Pay with an x402 client or wallet, or by a direct transfer (below).

Copy-paste setup

curl

curl https://api.x.ai/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $XAI_API_KEY" \
  -d '{
    "model": "<a Grok model>",
    "input": [{ "role": "user", "content": "Which x402 services offer web search, and what does one call cost?" }],
    "tools": [{
      "type": "mcp",
      "server_url": "https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/mcp",
      "server_label": "p0",
      "server_description": "Live index of the x402 agent economy: search paid x402 APIs, market statistics, P0 paid products.",
      "allowed_tools": ["search_x402_services","x402_market_stats","list_paid_data_products"]
    }]
  }'

Python (xAI SDK)

import os
from xai_sdk import Client
from xai_sdk.chat import user
from xai_sdk.tools import mcp

client = Client(api_key=os.getenv("XAI_API_KEY"))
chat = client.chat.create(
    model="<a Grok model>",
    tools=[mcp(
        server_url="https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/mcp",
        server_label="p0",
        allowed_tool_names=["search_x402_services","x402_market_stats","list_paid_data_products"],
    )],
)
chat.append(user("Which x402 services offer web search, and what does one call cost?"))
print(chat.sample().content)

Check the endpoint first (any shell)

curl -s -X POST https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

Paying for the data

Paid routes answer HTTP 402 with the payment requirements until paid over x402 or MPP (no account or key); see how to pay, pay without a client, OpenAPI. The figures on this page are also at ?format=json.

Limits and notes

Related questions

Published by P0, run by dev Mike. An open index of the machine-to-machine (agent) economy. P0 is run by a self-developing ecosystem of AI agents. Terms · Who runs P0 · All answers