
Add the xAI Docs MCP server
Add the xAI Docs MCP server
xAI hosts a Streamable HTTP MCP server at https://docs.x.ai/api/mcp so assistants can pull live documentation instead of pasting pages into prompts. The server is stateless — no session management.
Grok Build
grok mcp add --transport http xai-docs https://docs.x.ai/api/mcp
Or declare it in ~/.grok/config.toml:
[mcp_servers.xai-docs]
url = "https://docs.x.ai/api/mcp"
Verify:
grok mcp doctor xai-docs
General MCP add/remove and project scope: Add MCP servers in Grok Build. Doctor details: Diagnose MCP servers with grok mcp doctor.
Cursor, Zed, Windsurf, OpenCode
| Client | Where | Config |
|---|---|---|
| Cursor | Settings → MCP | Type url (Streamable HTTP), URL https://docs.x.ai/api/mcp |
| Zed | agent: open settings → MCP Servers |
JSON object with "xai-docs": { "url": "https://docs.x.ai/api/mcp" } |
| Windsurf | Settings → MCP | Same endpoint URL |
| OpenCode | Config under mcp |
"type": "remote", "url": "https://docs.x.ai/api/mcp", "enabled": true |
Zed example:
{
"xai-docs": {
"url": "https://docs.x.ai/api/mcp"
}
}
OpenCode example:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"xai-docs": {
"type": "remote",
"url": "https://docs.x.ai/api/mcp",
"enabled": true
}
}
}
Any Streamable HTTP MCP client can point at the same URL.
Tools
| Tool | Use |
|---|---|
list_doc_pages |
List available documentation pages |
get_doc_page |
Fetch one page by slug (e.g. developers/quickstart) |
search_docs |
Search docs; args include query and optional max_results |
TypeScript client sketch:
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
const client = new Client({ name: 'my-app', version: '1.0.0' });
const transport = new StreamableHTTPClientTransport(
new URL('https://docs.x.ai/api/mcp'),
);
await client.connect(transport);
const pages = await client.callTool({ name: 'list_doc_pages' });
const page = await client.callTool({
name: 'get_doc_page',
arguments: { slug: 'developers/quickstart' },
});
Call with curl
curl -X POST https://docs.x.ai/api/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "search_docs",
"arguments": { "query": "rate limits", "max_results": 3 }
},
"id": 3
}'
Initialize and tools/list use the same endpoint and headers; the server accepts JSON-RPC over HTTP.
Pitfalls
- Using a stdio transport for this host — the docs server is HTTP only at
https://docs.x.ai/api/mcp. - Skipping
grok mcp doctor xai-docsafter a Build add when tools never appear. - Expecting a session handshake beyond optional
initialize— the server runs stateless.