## TL;DR

Connecting to a local MCP server with the mcp helper fails with: Server URL resolves to internal IP: YOUR_HOST/mcp/sse. What is the correct way to use a local MCP server with the xAI SDK?

## Steps

1. Connecting to a local MCP server with the mcp helper fails with: Server URL resolves to internal IP: YOUR_HOST/mcp/sse. What is the correct way to use a local MCP server with the xAI SDK? My MCP server runs locally for development and is reachable from my machine. I would rather not expose it publicly just to test the integration.

2. Local MCP servers are not supported through the mcp helper function, which is why you get that internal IP error. The docs are being clarified on this. You can still use tools from a locally running MCP server, but you have to write a bit more code: extract the tool definitions from the server yourself and pass them in as regular tools. Source: https://github.com/xai-org/xai-sdk-python/issues/66

## When to use

You are seeing this: My MCP server runs locally for development and is reachable from my machine. Use this skill when you run into "xAI SDK local MCP server error: Server URL resolves to internal IP".

## When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

## Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

## Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

## Sources

- YOUR_HOST/mcp/sse

- https://github.com/xai-org/xai-sdk-python/issues/66
