server_url and server_label
On this page
Updated November 3, 2026 based on xAI’s Remote MCP Tools page:
server_labeldoes prefix tool calls, but the documentation doesn’t specify the exact prefix format; thelabel__toolnotation used in this course is a reading convention—verify the actual format in your API responses. Source: Remote MCP Tools.
The two parameters you can’t do without
Every connection between Grok and a remote MCP server relies on two parameters: server_url and server_label. They are non-negotiable—without them, the API rejects the request before attempting anything. All other parameters you encounter later refine this foundation; they never replace it.
server_url: The exact endpoint address
The server_url parameter contains the full URL of the MCP server Grok must connect to, and this URL follows strict rules.
The first is HTTPS. The URL must start with https://, and xAI rejects any unencrypted HTTP connection. The reason is straightforward: exchanges between Grok and the MCP server carry your users’ requests, tool results, and sometimes the authentication token itself. Letting this circulate in plaintext would be indefensible.
# Correct
mcp(server_url="https://mcp.deepwiki.com/mcp")
# Rejected by the API
mcp(server_url="http://mcp.deepwiki.com/mcp")
The second rule concerns path precision. The URL must point to the MCP endpoint, not the domain root. Almost all servers expose their endpoint on a dedicated path, and the convention varies from one to another. Here are three valid forms you will encounter:
https://mcp.deepwiki.com/mcp
https://api.example.com/mcp
https://tools.monentreprise.com/v1/mcp
The third rule follows from the first two: localhost and private IP addresses are excluded. The server must be reachable from xAI’s infrastructure, on a public domain, with a valid SSL certificate. This raises a concrete question during development, since the MCP server you are writing runs on your machine. The usual solution is to use a tunnel—ngrok or Cloudflare Tunnel, for example—which exposes your local instance behind a public HTTPS URL for the duration of your tests.
server_label: The server’s identity in the conversation
The server_label is a short identifier that Grok uses to prefix tool calls from this server. Its role is twofold: make traces readable, and remove any ambiguity when multiple servers coexist.
xAI’s documentation states that the label prefixes tool calls from this server, without specifying the exact prefix format. In this course, we denote a search_docs tool from the deepwiki server as deepwiki__search_docs, for readability: verify the actual format in API responses before building logic on top of it.
mcp(
server_url="https://mcp.deepwiki.com/mcp",
server_label="deepwiki"
)
# Tool calls from this server will be prefixed with "deepwiki"
Three criteria guide the choice of a good label. It must be short, since it adds to the name of every call and a verbose label unnecessarily bloats your logs. It must be descriptive, so the source of a call is readable at a glance without consulting the configuration. It must be unique in your configuration, otherwise you won’t be able to distinguish between two servers. The examples below meet these three requirements:
server_label="deepwiki" # GitHub documentation
server_label="crm" # Customer management system
server_label="jira" # Ticket tracking
server_label="search" # Internal search engine
This becomes much more tangible as soon as you connect multiple servers to the same session. Suppose your internal documentation and DeepWiki both expose a tool called search. Without distinct labels, tool names collide and Grok has no way of knowing which one to target. With labels, the two tools are prefixed differently—notated here as deepwiki__search and internal-docs__search—and the confusion disappears. You will revisit this point in the lesson dedicated to multi-server.
Minimal configuration in both SDKs
Together, these two parameters are enough to make a public MCP server work. With the native xAI SDK:
from xai_sdk.tools import mcp
tools = [
mcp(
server_url="https://mcp.deepwiki.com/mcp",
server_label="deepwiki"
)
]
And the exact equivalent with the Responses API in OpenAI format:
tools = [{
"type": "mcp",
"server_url": "https://mcp.deepwiki.com/mcp",
"server_label": "deepwiki",
}]
Key takeaways
server_urlandserver_labelare the only two required parameters- The URL must be HTTPS with a valid SSL certificate, no localhost
- The label prefixes all tool calls from this server (exact format is not documented; this course notes it as
label__tool) - Choose labels that are short, descriptive, and unique per server
- The label is essential for multi-server to avoid name conflicts