What you’ll learn:
- What sessions are and how they work
- Attaching multiple providers to a session
- Tool filters
- Connections, messages, and events
- Session templates
What is a Session?
A session is a runtime context that connects your AI application to one or more providers. When you create a session, Metorial:- Resolves each attached provider deployment and its config/auth
- Returns a
connection_urlyou can connect an MCP client to - Exposes the combined tools from all attached providers
Attaching Providers
When creating a session, you pass aproviders array. Each entry specifies a provider deployment and an optional tool filter:
Auth configs and provider configs are resolved automatically from your project. If a provider deployment requires auth and you have an auth config for it, Metorial uses it. You can also specify which auth config to use explicitly.
Tool Filters
Tool filters let you control which tools from a provider are available during a session. This is useful for:- Restricting a session to only the tools your AI actually needs
- Preventing destructive actions (e.g. allowing read-only tools only)
- Building scoped agents with minimal permissions
Connections
A connection is created automatically the first time something communicates through a session—either when an MCP client connects or when a tool call is sent via the API. A single session can have multiple connections (e.g. multiple MCP clients, or a mix of MCP and direct tool calls). Each connection is tracked independently. Connections support four transport types:| Transport | Description |
|---|---|
mcp | Standard MCP protocol client connection |
tool_call | Direct tool call via the Metorial API |
metorial_protocol | Internal Metorial protocol |
system | System-generated connections |
Messages and Events
Within a session you can inspect:- Messages: Individual tool calls and MCP protocol messages exchanged during the session. Each message has an
input,output,status, and timing information. - Events: Significant occurrences like connections opening, errors, or state changes. Useful for monitoring and debugging.
- Participants: The clients and providers involved in the session (e.g. your application, specific provider instances).