docs/content/docs/configuring-sessions.mdx
<Tabs groupId="language" items={['Python', 'TypeScript']} persist> <Tab value="Python">
session = composio.create(user_id="user_123")
By default, a session has access to all toolkits in the Composio catalog. Your agent can discover and use any of them through COMPOSIO_SEARCH_TOOLS. Use the options below to restrict or customize what's available.
Restrict the session to specific toolkits:
<Tabs groupId="language" items={['Python', 'TypeScript']} persist> <Tab value="Python">
# Using array format
session = composio.create(
user_id="user_123",
toolkits=["github", "gmail", "slack"]
)
# Using object format with enable key
session = composio.create(
user_id="user_123",
toolkits={"enable": ["github", "gmail", "slack"]}
)
// Using object format with enable key const session2 = await composio.create("user_123", { toolkits: { enable: ["github", "gmail", "slack"] }, });
</Tab>
</Tabs>
## Disabling toolkits
Keep all toolkits enabled except specific ones:
<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
<Tab value="Python">
```python
session = composio.create(
user_id="user_123",
toolkits={"disable": ["exa", "firecrawl"]}
)
Use your own OAuth credentials instead of Composio's defaults:
<Tabs groupId="language" items={['Python', 'TypeScript']} persist> <Tab value="Python">
session = composio.create(
user_id="user_123",
auth_configs={
"github": "ac_your_github_config",
"slack": "ac_your_slack_config"
}
)
See White-labeling authentication for branding, or Using custom auth configs for toolkits that require your own credentials.
If a user has multiple connected accounts for the same toolkit, you can specify which one to use:
<Tabs groupId="language" items={['Python', 'TypeScript']} persist> <Tab value="Python">
session = composio.create(
user_id="user_123",
connected_accounts={
"gmail": "ca_work_gmail",
"github": "ca_personal_github"
}
)
When executing a tool, the connected account is selected in this order:
connectedAccounts override if provided in session configauthConfigs override - finds or creates connection on that configIf a user has multiple connected accounts for a toolkit, the most recently connected one is used.
Get the MCP server URL to use with any MCP-compatible client.
<Tabs groupId="language" items={['Python', 'TypeScript']} persist> <Tab value="Python">
mcp_url = session.mcp.url
For framework examples, see provider-specific documentation like OpenAI Agents or Vercel AI SDK.
Get native tools from the session for use with AI frameworks.
<Tabs groupId="language" items={['Python', 'TypeScript']} persist> <Tab value="Python">
tools = session.tools()
Manually authenticate a user to a toolkit outside of the chat flow.
<Tabs groupId="language" items={['Python', 'TypeScript']} persist> <Tab value="Python">
connection_request = session.authorize("github")
print(connection_request.redirect_url)
connected_account = connection_request.wait_for_connection()
console.log(connectionRequest.redirectUrl);
const connectedAccount = await connectionRequest.waitForConnection();
</Tab>
</Tabs>
For more details, see [Manually authenticating users](/docs/authenticating-users/manually-authenticating).
### toolkits()
List available toolkits and their connection status. You can use this to build a UI showing which apps are connected.
<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
<Tab value="Python">
```python
toolkits = session.toolkits()
for toolkit in toolkits.items:
status = toolkit.connection.connected_account.id if toolkit.connection.is_active else "Not connected"
print(f"{toolkit.name}: {status}")
toolkits.items.forEach((toolkit) => {
console.log(${toolkit.name}: ${toolkit.connection?.connectedAccount?.id ?? "Not connected"});
});
</Tab>
</Tabs>
Returns the first 20 toolkits by default.
## What to read next
<Cards>
<Card icon={<MessageCircle />} title="In-chat authentication" href="/docs/authenticating-users/in-chat-authentication" description="Let the agent prompt users to connect accounts during conversation" />
<Card icon={<ShieldCheck />} title="Manual authentication" href="/docs/authenticating-users/manually-authenticating" description="Pre-authenticate users before chat using Connect Links and session.authorize()" />
<Card icon={<Wrench />} title="Enable & disable toolkits" href="/docs/toolkits/enable-and-disable-toolkits" description="Control which toolkits and individual tools are available in sessions" />
<Card icon={<Palette />} title="White-labeling authentication" href="/docs/white-labeling-authentication" description="Use your own OAuth apps so users see your branding on consent screens" />
</Cards>