Understanding Server Parameters
Configure detailed stdio, SSE, and Streamable HTTP connection parameters for MCPTools.
The recommended way to configure MCPTools is to use the command or url parameters.
Alternatively, you can use the server_params parameter with MCPTools to configure the connection to the MCP server in more detail.
When using the stdio transport, the server_params parameter should be an instance of StdioServerParameters. It contains the following keys:
command: The command to run the MCP server.- Use
npxfor mcp servers that can be installed via npm. - Use
uvxfor mcp servers that can be installed via uvx. - Use custom binary executables (e.g.,
./my-server,../usr/local/bin/my-server, or binaries in your PATH).
- Use
args: The arguments to pass to the MCP server.env: Optional environment variables to pass to the MCP server. The MCP SDK starts with its safe default environment, includingPATHand the platform's required home-directory variable, then overlays the entries you provide. This applies to an explicitStdioServerParametersinstance and to thecommandshortcut.
For example:
{
"GOOGLE_MAPS_API_KEY": os.getenv("GOOGLE_MAPS_API_KEY"),
}When using the SSE transport, the server_params parameter should be an instance of SSEClientParams. It contains the following fields:
url: The URL of the MCP server.headers: Headers to pass to the MCP server (optional).timeout: Timeout for the connection to the MCP server (optional).sse_read_timeout: Timeout for the SSE connection itself (optional).
When using the Streamable HTTP transport, the server_params parameter should be an instance of StreamableHTTPClientParams. It contains the following fields:
url: The URL of the MCP server.headers: Headers to pass to the MCP server (optional).timeout:Optional[float]in seconds for HTTP operations. Defaults to 30 seconds.sse_read_timeout:Optional[float]in seconds to wait for a new event before disconnecting. Defaults to 5 minutes.terminate_on_close: Whether to request termination of the server session when the client closes. This does not keep the local HTTP connection open.
SSE timeouts also use numeric seconds. Legacy timedelta values are normalized to seconds for compatibility.