{"question":"How do I connect P0 to the xAI Grok API as a remote MCP tool?","answer":"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.","url":"https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/answers/mcp-xai-grok","data_as_of":"2026-10-25","facts":[{"label":"P0 MCP endpoint","value":"https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/mcp","text":"https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/mcp"},{"label":"Transport","value":"streamable-http","text":"Streamable HTTP, JSON-RPC 2.0"},{"label":"Authentication","value":"none required","text":"None required; an optional prepaid access key is accepted as Authorization: Bearer p0k_… (see the notes)"},{"label":"Free tools worth allowing","value":"search_x402_services, x402_market_stats, list_paid_data_products","text":"search_x402_services, x402_market_stats, list_paid_data_products"}],"tables":[{"title":"Steps in xAI Grok API","columns":["Step","What to do"],"rows":[{"step":"1","what":"Put a tool of type mcp in the tools array of a request to the xAI API."},{"step":"2","what":"Set server_url to the P0 endpoint and server_label to a name you choose (xAI uses the label to prefix tool calls)."},{"step":"3","what":"Optional: allowed_tools (allowed_tool_names in the xAI SDK) limits which tools the model sees; server_description describes the server to the model."},{"step":"4","what":"No authorization or headers field is needed: the endpoint is open."}]},{"title":"What works through the connector, and what does not","columns":["Kind","Through the MCP connector"],"rows":[["Free tools","search_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 itself","The request answers HTTP 402 until it is paid. Pay with an x402 client or wallet, or by a direct transfer (below)."]]}],"sources":[{"name":"xAI: Remote MCP Tools","url":"https://docs.x.ai/developers/tools/remote-mcp","as_of":null,"age_days":null,"stale":false,"note":"Vendor documentation read on 2026-10-25; menu names, limits and plan availability change. P0 is not affiliated with or endorsed by xAI."}],"not_loaded":[],"notes":["xAI's documentation says only the Streamable HTTP and SSE transports are supported; P0's endpoint is Streamable HTTP.","xAI states that the require_approval and connector_id parameters of the OpenAI Responses API are not supported on its API, so copy only the fields shown here.","xAI's page describes the remote MCP tool as available in its own SDK, in the OpenAI-compatible Responses API and in its Speech to Speech API.","Without an access key none of P0's MCP tools returns paid data. The connectors described here do not sign x402 payments (the documentation page used for this guide describes no payment support), so the paid call is made outside the connector, or with a prepaid access key (below).","To pay: use an x402-capable client or wallet (runnable JavaScript and Python snippets: https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/integrations), or send the price as a direct stablecoin or coin transfer and claim it with the transaction hash, GET <route>?tx=<hash> (details and addresses: https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/pay). The first call without payment shows the exact price.","Agents that speak A2A with the x402 extension can pay inside the A2A message flow at https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/a2a (the agent card lists the extension).","Access key (optional): an agent that cannot sign x402 buys a prepaid key once with x402 (USD 1, 5 or 20; the $5 key credits $5.25 of calls and the $20 key $22: https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/keys/buy?usd=5) and, where your platform lets you set an Authorization header or token for a remote MCP server, sends it as Authorization: Bearer p0k_…; the data tools then return the data and each call is deducted at its listed price. Balance is free at https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/keys/balance. Unused balance never expires and is not refunded. Where the platform has no such field, use the x402 route above.","The snippets follow the vendor documentation named below; P0 has not run them on a xAI Grok API account of its own.","Not legal, financial or security advice; P0 is not affiliated with or endorsed by any of the publishers named here."],"code":[{"title":"curl","text":"curl https://api.x.ai/v1/responses \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Authorization: Bearer $XAI_API_KEY\" \\\n  -d '{\n    \"model\": \"<a Grok model>\",\n    \"input\": [{ \"role\": \"user\", \"content\": \"Which x402 services offer web search, and what does one call cost?\" }],\n    \"tools\": [{\n      \"type\": \"mcp\",\n      \"server_url\": \"https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/mcp\",\n      \"server_label\": \"p0\",\n      \"server_description\": \"Live index of the x402 agent economy: search paid x402 APIs, market statistics, P0 paid products.\",\n      \"allowed_tools\": [\"search_x402_services\",\"x402_market_stats\",\"list_paid_data_products\"]\n    }]\n  }'"},{"title":"Python (xAI SDK)","text":"import os\nfrom xai_sdk import Client\nfrom xai_sdk.chat import user\nfrom xai_sdk.tools import mcp\n\nclient = Client(api_key=os.getenv(\"XAI_API_KEY\"))\nchat = client.chat.create(\n    model=\"<a Grok model>\",\n    tools=[mcp(\n        server_url=\"https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/mcp\",\n        server_label=\"p0\",\n        allowed_tool_names=[\"search_x402_services\",\"x402_market_stats\",\"list_paid_data_products\"],\n    )],\n)\nchat.append(user(\"Which x402 services offer web search, and what does one call cost?\"))\nprint(chat.sample().content)"},{"title":"Check the endpoint first (any shell)","text":"curl -s -X POST https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/mcp \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Accept: application/json, text/event-stream\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/list\"}'"}],"full_answer":[{"path":"/keys/buy?usd=5","url":"https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/keys/buy?usd=5","price_usd":null,"what":"buy a prepaid access key with one x402 payment (usd=1, 5 or 20; $5 credits $5.25, $20 credits $22), then send it as Authorization: Bearer"},{"path":"/pay","url":"https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/pay","price_usd":null,"what":"free page: pay without an x402 client, by a direct transfer claimed with the transaction hash"},{"path":"/integrations","url":"https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/integrations","price_usd":null,"what":"free page: runnable snippets that pay and call a route with an x402 client"},{"path":"/x402/test","url":"https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/x402/test","price_usd":0.001,"what":"the cheapest real paid call, to rehearse the payment with your client or wallet"},{"path":"/a2a","url":"https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/a2a","price_usd":null,"what":"A2A endpoint with the x402 extension (GET returns the agent card)"}],"related":["https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/answers/mcp-openai-responses","https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/answers/mcp-perplexity","https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/answers/pay-api-with-x402"],"license":"https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/terms","operator":"dev Mike","version":"2026-10-25.3"}