Skip to main content
Lesson 12 of 12 · Remote MCP: Connect External Tools

Recap and Hands-On Practice

Lesson 12 of 12 Updated July 29, 2026 Developer
On this page
  1. What We’ve Covered
  2. The Six Parameters at a Glance
  3. Checks Before Going to Production
  4. Your First Agent, in Three Steps
  5. What Remains True After This Course
  6. Key Takeaways
  7. Test Your Knowledge

What We’ve Covered

This course took you from the Model Context Protocol concept to a production-ready configuration. If you remember only one thing, let it be this: MCP lets Grok connect to external tool servers via HTTPS, automatically discovering and using exposed tools without manual client-side configuration.

Architecturally, four points structure everything else. Remote MCP works exclusively over HTTPS, ruling out plain HTTP, localhost, and stdio transport for local servers. Two transports are supported: modern stateless Streaming HTTP and persistent SSE, and the server dictates which one—you don’t choose. Finally, three interfaces provide access to this mechanism: the native xAI SDK (recommended), the Responses API for OpenAI compatibility, and the Voice Agent API for voice agents.

The Six Parameters at a Glance

ParameterRequiredFunction
server_urlYesHTTPS address of the MCP server
server_labelYesUnique identifier, prefixes tools
server_descriptionNoNatural language description to guide Grok
allowed_tool_namesNoAllowlist of accessible tools
authorizationNoAuthentication token (Bearer, API key)
headersNoAdditional HTTP headers

Two required, four optional: that’s the entire configuration surface for remote MCP. The optional ones aren’t just comfort features, though. allowed_tool_names handles your security, and server_description ensures accurate selection when multiple servers coexist.

Checks Before Going to Production

Three categories of controls warrant explicit verification. On the security side, ensure URLs use HTTPS with valid certificates, every internal server has its authentication token, these tokens live in environment variables, tools are restricted to the necessary minimum, and regular token rotation is planned rather than hoped for.

On the configuration side, each server must have a unique, descriptive server_label, and its server_description must be precise and up to date—a description describing an earlier server version misleads the model. Keep the total number of tools reasonable, around ten to twenty per session, and remove servers from the configuration whose tools no one calls anymore.

On the observability side, plan for incidents beforehand: tool calls traced in your logs, alerts on MCP connection errors, tracking token usage per server, and measuring call latency. The latter is often neglected even though it constitutes the first signal of a degrading server.

Your First Agent, in Three Steps

The best way to solidify this course is to build progressively. Start with a public server, without authentication, to validate that the mechanics work end to end.

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

client = Client(api_key=os.getenv("XAI_API_KEY"))

chat = client.chat.create(
    model="grok-4.20-0309-reasoning",
    tools=[
        mcp(
            server_url="https://mcp.deepwiki.com/mcp",
            server_label="deepwiki"
        )
    ],
)

Test with a request that actually forces the model to consult the repository, such as “explain the architecture of the fastapi/fastapi project to me.” If the response arrives and cites the actual project structure, your MCP connection is operational.

Next, add a native tool to see Grok arbitrate between two sources of different natures. The server description becomes useful here, precisely because there is now a choice to make.

tools=[
    mcp(
        server_url="https://mcp.deepwiki.com/mcp",
        server_label="deepwiki",
        server_description="Documentation for open-source GitHub projects"
    ),
    {"type": "web_search"},
]

Finally, take the step to an internal server, with authentication and tool restriction. This is the step where everything you’ve seen about security becomes concrete.

tools=[
    mcp(server_url="https://mcp.deepwiki.com/mcp", server_label="deepwiki"),
    mcp(
        server_url="https://api.your-server.com/mcp",
        server_label="internal",
        server_description="Company internal data and tools",
        authorization=f"Bearer {os.getenv('INTERNAL_TOKEN')}",
        allowed_tool_names=["search", "get_document"]
    ),
    {"type": "web_search"},
]

What Remains True After This Course

Four limitations will accompany all your MCP projects with Grok. The Responses API in OpenAI format supports neither require_approval nor connector_id, which brings you back to the native SDK whenever you want human validation before execution. Stdio transport, and thus local MCP servers, remains out of reach: HTTPS only. Each exposed tool consumes context, making minimalism an architectural decision rather than an afterthought. And network latency adds up with each call, so an agent chaining several MCP tools will respond more slowly than an agent calling just one.

None of these constraints are blockers. All are circumvented by design choices made with full knowledge, which is precisely what this course has given you.

Key Takeaways

  • Remote MCP connects Grok to external tools via HTTPS in a few lines of configuration
  • Six parameters suffice to configure an MCP server (two required, four optional)
  • Security relies on the trio of HTTPS + authentication + tool restriction
  • Start with a public server (DeepWiki) then progress to authenticated multi-server
  • Combine MCP and native tools to create versatile agents

Test Your Knowledge

Remote MCP servers in the Grok API: you’ve earned this recap.

1. What does Grok API's MCP support allow?

Answer: Connect remote MCP servers as model tools: Grok calls their capabilities during generation—your systems and the MCP ecosystem become extensions.

2. How do you declare an MCP server in a request?

Answer: Via server_url and server_label, with description and allowlist of authorized tools—and the authentication headers required for access.

3. What does multi-server configuration allow?

Answer: Combine multiple MCP servers in a single request—each labeled—and mix them with built-in tools (web, X): orchestration remains with the model.

4. Which transports are supported?

Answer: Streaming HTTP and SSE—the protocol’s remote transports: the server lives where you want, the API connects to it.

5. What security rules for remote servers?

Answer: Authorize only necessary tools, authenticate seriously, and treat server responses as data to validate—a third-party MCP server is a potential attack surface.

Declare, restrict, authenticate, combine: remote MCP extends Grok to your systems—under your rules.