Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
docs: add MCP servers → Sessions migration guide (twoslash-safe re-add of #3551)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Palash Kala committed
Jun 12, 2026 at 14:54 UTC
a6acec90719b4a5acf169ecb1a29959ae40ff1b1
2 files changed
+255
docs/content/docs/migration-guide/mcp-servers-to-sessions.mdx
new
+254
@@ -0,0 +1,254 @@
1
+---
2
+title: Migrating from MCP servers to Sessions
3
+description: Move from per-toolkit MCP server configs to the sessions paradigm
4
+keywords: [migrate, mcp, mcp server, sessions, upgrade]
5
+---
6
+
7
+This guide is for developers using Composio's **MCP servers** (`composio.mcp.create` /
8
+`composio.mcp.generate`, the "Single Toolkit MCP" flow) who want to migrate to **sessions**.
9
+
10
+Sessions are the next generation of the same idea: you still get an MCP URL that any MCP-compatible
11
+client connects to — but instead of standing up and managing a separate server config per toolkit,
12
+you create a session that handles tool discovery, authentication, context, and versioning for you.
13
+
14
+<Callout type="info">
15
+Starting fresh? Skip this guide and read [Configuring Sessions](/docs/configuring-sessions).
16
+</Callout>
17
+
18
+<Callout type="info">
19
+Just connecting apps to your own AI client (Claude, Cursor, ChatGPT) for personal use — not building
20
+an app? You don't need the SDK. Use **[Composio For You](https://connect.composio.dev)** to connect
21
+across 1000+ apps in a few clicks, then point your client at the URL it gives you. Switch to it any
22
+time from the product switcher in the top-left of the dashboard. Reserve `session.mcp.url` for
23
+programmatic, in-app use.
24
+</Callout>
25
+
26
+## What carries over (you keep all of this)
27
+
28
+- **Your tools** — every tool you exposed on a server is available in a session.
29
+- **Your auth configs and connected accounts** — pass the same `ac_…` IDs; your users **do not
30
+ re-authenticate**.
31
+- **The MCP URL pattern** — you still get a URL (`session.mcp.url`) that plugs into Claude Desktop,
32
+ Cursor, OpenAI Agents, Mastra — the same clients, the same protocol.
33
+- **Per-user isolation** — still keyed by `user_id`.
34
+- **Tool restriction** — you can still pin a session to an exact, fixed tool list (see Step 3).
35
+
36
+## What changes
37
+
38
+| | MCP servers (today) | Sessions |
39
+|---|---|---|
40
+| **Setup** | Create + manage a server config per toolkit (`composio.mcp.create`) | One `composio.create(user_id)` — no server object to manage |
41
+| **Get a URL** | `composio.mcp.generate(user_id, mcp_config_id)` → `instance.url` | `session.mcp.url` |
42
+| **Tools** | Fixed `allowed_tools` list, baked into the server | Dynamic discovery by default, **or** a fixed list (direct-tools preset) — your choice |
43
+| **Multiple toolkits** | One server per toolkit | One session spans many toolkits |
44
+| **Context** | All allowed tools always loaded | Managed — search/preload keep the agent's context lean |
45
+| **Versioning** | Manual | Handled automatically |
46
+| **Auth** | Pre-authenticate, then generate | Carries over; in-chat auth available, or `session.authorize()` |
47
+
48
+The *why*: a session is one managed endpoint that replaces N static server configs, gives the agent
49
+runtime tool discovery, and keeps context small — without losing the fixed-tool-list behavior you
50
+have today if that's what you want.
51
+
52
+## Migrating
53
+
54
+<Steps>
55
+<Step>
56
+<StepTitle>Replace the server config + generate with a session</StepTitle>
57
+
58
+The two-step "create a server, then generate a per-user URL" collapses into a single
59
+`composio.create(...)`. Pass the **same** toolkit, auth config, and tool list you had on the server.
60
+
61
+<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
62
+<Tab value="Python">
63
+```python
64
+from composio import Composio
65
+
66
+composio = Composio(api_key="YOUR_API_KEY")
67
+
68
+# Before: create a server config, then generate a per-user URL
69
+# server = composio.mcp.create(
70
+# name="my-gmail-server",
71
+# toolkits=[{"toolkit": "gmail", "auth_config": "ac_xyz123"}],
72
+# allowed_tools=["GMAIL_FETCH_EMAILS", "GMAIL_SEND_EMAIL"],
73
+# )
74
+# instance = composio.mcp.generate(user_id="user-123", mcp_config_id=server.id)
75
+# mcp_url = instance["url"]
76
+
77
+# After: one session, same toolkit + auth config + tools
78
+session = composio.create(
79
+ user_id="user-123",
80
+ toolkits=["gmail"],
81
+ auth_configs={"gmail": "ac_xyz123"},
82
+ tools={"gmail": {"enable": ["GMAIL_FETCH_EMAILS", "GMAIL_SEND_EMAIL"]}},
83
+)
84
+mcp_url = session.mcp.url
85
+```
86
+</Tab>
87
+<Tab value="TypeScript">
88
+```typescript
89
+import { Composio } from '@composio/core';
90
+
91
+const composio = new Composio({ apiKey: process.env.COMPOSIO_API_KEY });
92
+
93
+// Before: create a server config, then generate a per-user URL
94
+// const server = await composio.mcp.create("my-gmail-server", {
95
+// toolkits: [{ toolkit: "gmail", authConfigId: "ac_xyz123" }],
96
+// allowedTools: ["GMAIL_FETCH_EMAILS", "GMAIL_SEND_EMAIL"],
97
+// });
98
+// const instance = await composio.mcp.generate("user-123", server.id);
99
+// const mcpUrl = instance.url;
100
+
101
+// After: one session, same toolkit + auth config + tools
102
+const session = await composio.create("user-123", {
103
+ toolkits: ["gmail"],
104
+ authConfigs: { gmail: "ac_xyz123" },
105
+ tools: { gmail: { enable: ["GMAIL_FETCH_EMAILS", "GMAIL_SEND_EMAIL"] } },
106
+});
107
+const { mcp } = session;
108
+const mcpUrl = mcp.url;
109
+```
110
+</Tab>
111
+</Tabs>
112
+
113
+Same `user_id` + same auth config → existing connected accounts are picked up automatically. No
114
+re-auth.
115
+
116
+</Step>
117
+
118
+<Step>
119
+<StepTitle>Point your MCP client at the new URL</StepTitle>
120
+
121
+Swap the generated server URL for `session.mcp.url` wherever your client connects — Claude Desktop,
122
+Cursor, OpenAI Agents, Mastra. Nothing else about the client changes.
123
+
124
+```python
125
+# Before: https://backend.composio.dev/v3/mcp/<SERVER_ID>?user_id=<USER_ID>
126
+# After: session.mcp.url
127
+```
128
+
129
+</Step>
130
+
131
+<Step>
132
+<StepTitle>Keep an exact, fixed tool list (optional — closest 1:1 with your server)</StepTitle>
133
+
134
+By default a session gives the agent **dynamic** tool discovery (meta-tools). If you want the *same
135
+static behavior* as your old server — a fixed set of tools, no discovery — add the **direct-tools
136
+preset**. This preloads exactly the tools you enable and turns meta-tools off.
137
+
138
+<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
139
+<Tab value="Python">
140
+```python
141
+from composio import Composio, SESSION_PRESET_DIRECT_TOOLS
142
+
143
+session = composio.create(
144
+ user_id="user-123",
145
+ toolkits=["gmail"],
146
+ auth_configs={"gmail": "ac_xyz123"},
147
+ tools={"gmail": {"enable": ["GMAIL_FETCH_EMAILS", "GMAIL_SEND_EMAIL"]}},
148
+ session_preset=SESSION_PRESET_DIRECT_TOOLS,
149
+)
150
+```
151
+</Tab>
152
+<Tab value="TypeScript">
153
+```typescript
154
+import { Composio, SessionPreset } from '@composio/core';
155
+
156
+const composio = new Composio({ apiKey: process.env.COMPOSIO_API_KEY });
157
+// ---cut---
158
+const session = await composio.create("user-123", {
159
+ toolkits: ["gmail"],
160
+ authConfigs: { gmail: "ac_xyz123" },
161
+ tools: { gmail: { enable: ["GMAIL_FETCH_EMAILS", "GMAIL_SEND_EMAIL"] } },
162
+ sessionPreset: SessionPreset.DIRECT_TOOLS,
163
+});
164
+```
165
+</Tab>
166
+</Tabs>
167
+
168
+Leave the preset off to get the upgrade: the agent discovers and loads tools at runtime, so you can
169
+span many toolkits without bloating context.
170
+
171
+</Step>
172
+</Steps>
173
+
174
+## Beyond the MCP URL
175
+
176
+A session isn't only an MCP endpoint — it's also a normal SDK object, which is handy for non-agent
177
+code paths.
178
+
179
+### Native tools for your framework
180
+
181
+`session.tools()` returns provider-wrapped native tools for OpenAI, Anthropic, LangChain, the Vercel
182
+AI SDK, and others, so you skip manual schema wiring. With the direct-tools preset it returns your
183
+exact fixed tool set; by default it returns the meta-tools that drive runtime discovery.
184
+
185
+<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
186
+<Tab value="Python">
187
+```python
188
+tools = session.tools()
189
+```
190
+</Tab>
191
+<Tab value="TypeScript">
192
+```typescript
193
+import { Composio } from '@composio/core';
194
+const composio = new Composio({ apiKey: process.env.COMPOSIO_API_KEY });
195
+const session = await composio.create("user-123");
196
+// ---cut---
197
+const tools = await session.tools();
198
+```
199
+</Tab>
200
+</Tabs>
201
+
202
+### Execute a tool without an LLM
203
+
204
+For a deterministic, non-agent path, call a tool directly on the session.
205
+
206
+<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
207
+<Tab value="Python">
208
+```python
209
+result = session.execute(
210
+ "GITHUB_CREATE_ISSUE",
211
+ arguments={"owner": "my-org", "repo": "my-repo", "title": "Fix login bug"},
212
+)
213
+```
214
+</Tab>
215
+<Tab value="TypeScript">
216
+```typescript
217
+import { Composio } from '@composio/core';
218
+const composio = new Composio({ apiKey: process.env.COMPOSIO_API_KEY });
219
+const session = await composio.create("user-123");
220
+// ---cut---
221
+const result = await session.execute("GITHUB_CREATE_ISSUE", {
222
+ owner: "my-org",
223
+ repo: "my-repo",
224
+ title: "Fix login bug",
225
+});
226
+```
227
+</Tab>
228
+</Tabs>
229
+
230
+## Things to know
231
+
232
+- **Multiple toolkits on one endpoint** — where you ran several single-toolkit servers, one session
233
+ spans them all (`toolkits=["gmail", "slack", "github"]`). Fewer moving parts.
234
+- **Reuse one session — don't create one per request** — sessions persist and are reusable. Create a
235
+ session once and keep using it across calls; see [Configuring Sessions](/docs/configuring-sessions).
236
+- **Sharing one account across users** — sessions support **shared connections**
237
+ (`account_type:"SHARED"` + an allow/deny ACL), pinned per session. See
238
+ [Shared connections](/docs/authenticating-users/shared-connections).
239
+- **Tenant-specific params** (SharePoint sub-site, Jira subdomain) — prefill them via shared
240
+ credentials on the auth config.
241
+- **White-labeling carries over** — pass the same white-labeled auth config IDs; users keep seeing
242
+ your branding on consent screens. See [White-labeling authentication](/docs/white-labeling-authentication).
243
+- **Triggers** — unchanged; continue using `composio.triggers.*` and webhooks (triggers aren't part
244
+ of sessions yet).
245
+- **Dashboard** — sessions are created via the SDK. For no-code, personal app connections, use
246
+ [Composio For You](https://connect.composio.dev) — reachable from the product switcher in the
247
+ top-left of the dashboard.
248
+
249
+## Get started
250
+
251
+<Cards>
252
+ <Card title="Configuring Sessions" href="/docs/configuring-sessions" description="Toolkits, auth configs, account selection, presets, and session methods" />
253
+ <Card title="What is a session?" href="/docs/how-composio-works" description="How sessions scope tools and connected accounts" />
254
+</Cards>
docs/content/docs/migration-guide/meta.json
+1
@@ -2,6 +2,7 @@
2
"title": "Migration Guide",
3
"pages": [
4
"direct-to-sessions",
5
+ "mcp-servers-to-sessions",
6
"tool-router-beta",
7
"toolkit-versioning",
8
"new-sdk"