Skip to main content
What you’ll learn:
  • How to use OAuth sessions
  • Combining OAuth with provider sessions

Using OAuth Sessions

After a user completes OAuth authorization, pass their session ID when creating MCP sessions:
await metorial.withProviderSession(
    provider,
    {
        serverDeployments: [
            {
                serverDeploymentId: 'slack-deployment-id',
                oauthSessionId: storedOAuthSessionId // From your database
            }
        ]
    },
    async ({ tools, closeSession }) => {
        // Tools now have access to user's Slack
        await closeSession();
    }
);

Multiple OAuth Sessions

Combine multiple OAuth integrations in one session:
{
    serverDeployments: [
        {
            serverDeploymentId: 'github-deployment',
            oauthSessionId: githubOAuthSession
        },
        {
            serverDeploymentId: 'slack-deployment',
            oauthSessionId: slackOAuthSession
        }
    ]
}