Connect any MCP client to Metorial without the SDK
Create a session with POST /sessions, then connect your MCP client over Streamable HTTP to its connection_url with your secret API key as a Bearer token.
To use Metorial from any MCP client, create a session and connect the client over Streamable HTTP to the session's connection_url. Send Authorization: Bearer <your secret API key> on every request. This guide does it with the official MCP SDK in TypeScript and Python and no Metorial SDK.
What you'll learn
- The endpoint, the headers and the two tokens it accepts
- How to create a session from the CLI or over REST
- How to list and call tools with the MCP SDK
Before you start
- Install the CLI and sign in
- A secret API key in
METORIAL_API_KEY - Node.js 20 or later, or Python 3.10 or later
The endpoint and headers
| What | Value |
|---|---|
| Create a session | POST https://api.metorial.com/sessions |
| REST headers | Authorization: Bearer <secret API key>, Metorial-Version: 2026-01-01-magnetar, Content-Type: application/json |
| MCP URL | The session's connection_url, in the form https://api.metorial.com/connect/mcp/<session-id> |
| MCP transport | Streamable HTTP |
| MCP auth | Authorization: Bearer <secret API key>, or the session's client_secret |
The client_secret starts with metorial_fk_ and works only for its own session. Use it when the MCP client runs somewhere you do not want to place your API key. Clients that cannot set headers can append it to the URL as ?key=<client_secret>.
With the CLI
Deploy a provider
Metorial Search is a built-in web search provider that needs no credentials. Copy the deployment ID (pde_...) from the output.
Create a session
The output contains the session ID, the connection_url and the client_secret. Paste the URL into any MCP client that supports Streamable HTTP and a Bearer token.
With an MCP SDK
Create the project
Write the client
Save this as client.ts or client.py. It creates a session over REST, connects, lists the tools, and calls the first one whose name contains search with a query argument. Change the tool and arguments for other providers.
Run it
To act as one user, add provider_auth_config_id to that provider's entry when you create the session. Let each user connect their own account shows where the ID comes from.
Check it worked
The program prints the tool names, then the content of the search result. Metorial prefixes each tool with the provider name and adds metorial_connection_status, a diagnostic tool, to every session.
See the session and its tool calls from the CLI:
Troubleshooting
Invalid API key
The Bearer token is not a key Metorial knows. API key is expired or has been revoked means the key existed and no longer works. Create a new one with metorial-admin api-keys create.
Secret API key required for MCP session connections
You sent a publishable key (metorial_pk_). Use a secret key (metorial_sk_) or the session's client_secret.
Fine grained token is not authorized for this session
You sent the client_secret of a different session.
Session has been archived or deleted
Create a new session and connect to its connection_url.
TypeError: streamable_http_client() got an unexpected keyword argument 'headers'
Version 2 of the MCP Python SDK takes headers on the httpx2.AsyncClient you pass as http_client, as in the sample. Version 1 used streamablehttp_client(url, headers=...).
Next steps
- Choose between the SDK, the REST API and plain MCP: when an adapter saves you this work
- Limit the tools an agent can use: serve only some of a provider's tools
- Set up a Magic MCP server: one fixed MCP URL with its own token, no session per run
- API reference: every endpoint, including sessions