Connect to MCPs

To connect to remote servers, you have to first obtain a URL from the registry. Then, you may connect to it using MCP SDK's StreamableHTTPClientTransport.

Connecting to MCPs via the Smithery gateway conforms to the standard MCP specification for Streamable HTTP. The main difference is we offer the ability to pass a session configuration to the server via the config query parameter.

URL Format

The URL format is as follows:

http
https://server.smithery.ai/${qualifiedName}/mcp?config=${base64_encoded_config}&api_key=${smithery_api_key}

Creating the URL

Here's an example for constructing the URL with the required parameters:

typescript
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"

// Create server URL
const serverUrl = new URL("https://server.smithery.ai/{qualifiedName}/mcp")

// Prepare config
const config = {
// Your config object that matches the server's configSchema
}
const configString = JSON.stringify(config)

// Add config and API key to URL
// btoa() converts the JSON string to base64 for safe URL transmission
serverUrl.searchParams.set("config", btoa(configString))
serverUrl.searchParams.set("api_key", "your-smithery-api-key")

// Create transport with the configured URL
const transport = new StreamableHTTPClientTransport(serverUrl)

You can find the exact details of how to connect to the MCP on its server page under the API tab.

Limits

Each account is subject to a maximum on 10 free concurrent sessions. If you need more, please contact us.