SPB Git forge

spb/doc-api

Public
2commits 1branches 0releases
15.7 MBsize
maindefault branch
13 days agolast push
Python 88.3% TypeScript 7.6% Shell 4.1%
2.2 KB

# xAI Remote MCP tool (type: "mcp")

Status: DOCUMENTED · LIVE_VERIFIED (2026-09-19, grok-4.3 → https://mcp.deepwiki.com/mcp: mcp_call ask_question on xai-org/xai-sdk-python, mcp_calls: 1, answer "Python SDK for xAI language models chat.") Sources: https://docs.x.ai/developers/tools/remote-mcp · https://docs.x.ai/developers/tools/tool-usage-details · https://docs.x.ai/developers/advanced-api-usage/batch-api (MCP in batch) · OpenAPI ModelTool (mcp variant), McpCall Last verified: 2026-09-19

# Parameters

Field Required Notes
server_url yes Streamable HTTP or SSE transport only
server_label yes prefixes tool names in usage ({label}.{tool})
server_description no helps tool selection
allowed_tools no string[]; empty = all tools injected into context (xai-sdk: allowed_tool_names)
authorization no bearer token sent to the MCP server
headers no extra headers (xai-sdk: extra_headers)
require_approval, connector_id docs: not supported live: require_approval:"never" silently accepted
defer_loading alpha 403

Multiple MCP servers per request allowed. Also usable in Speech-to-Speech and Batch requests.

# Output

json
{"type":"mcp_call","id":"mcp_<resp>_call-…-0","status":"completed","name":"ask_question","server_label":"deepwiki","error":"",
 "arguments":"{\"repoName\":[\"xai-org/xai-sdk-python\"],\"question\":\"what does the repo do?\"}","output":"{\"content\":[{\"type\":\"text\",\"text\":\"This repository…\"}]}"}

output is always returned (no include needed). No mcp_list_tools item and no approval round-trip (unlike OpenAI). Response echoes tools:[{type:"mcp", server_label, server_url, allowed_tools:[], headers:{}, server_description:""}]. Live usage: 4 024 total tokens (555 reasoning, MCP output counted as input), cost ticks 55 721 500 ≈ $0.0056.

# Billing / security

No per-call fee — tokens only. Use HTTPS; xAI forwards your authorization/headers to the server; restrict with allowed_tools (read-only) and keep server metadata descriptive.

Examples: examples/xai/tools/mcp/. Test: tests/xai/test_tools.py::test_mcp_tool (RUN_EXPENSIVE_TESTS).