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 session = await composio.create("user-123", {
157
+ toolkits: ["gmail"],
158
+ authConfigs: { gmail: "ac_xyz123" },
159
+ tools: { gmail: { enable: ["GMAIL_FETCH_EMAILS", "GMAIL_SEND_EMAIL"] } },
160
+ sessionPreset: SessionPreset.DIRECT_TOOLS,
161
+});
162
+```
163
+</Tab>
164
+</Tabs>
165
+
166
+Leave the preset off to get the upgrade: the agent discovers and loads tools at runtime, so you can
167
+span many toolkits without bloating context.
168
+
169
+</Step>
170
+</Steps>
171
+
172
+## Things to know
173
+
174
+- **Multiple toolkits on one endpoint** — where you ran several single-toolkit servers, one session
175
+ spans them all (`toolkits=["gmail", "slack", "github"]`). Fewer moving parts.
176
+- **Reuse one session — don't create one per request** — sessions persist and are reusable. Create a
177
+ session once and keep using it across calls; see [Configuring Sessions](/docs/configuring-sessions).
178
+- **Use the session's tools natively in your framework** — `session.tools()` returns
179
+ provider-wrapped native tools for OpenAI, Anthropic, LangChain, the Vercel AI SDK, and others, so
180
+ you skip manual schema wiring. With the direct-tools preset it returns your exact fixed tool set;
181
+ by default it returns the meta-tools that drive runtime discovery.
182
+- **Execute a tool without an LLM** — for a deterministic, non-agent path, call a tool directly on
183
+ the session:
184
+
185
+ <Tabs groupId="language" items={['Python', 'TypeScript']} persist>
186
+ <Tab value="Python">
187
+ ```python
188
+ result = session.execute(
189
+ "GITHUB_CREATE_ISSUE",
190
+ arguments={"owner": "my-org", "repo": "my-repo", "title": "Fix login bug"},
191
+ )
192
+ ```
193
+ </Tab>
194
+ <Tab value="TypeScript">
195
+ ```typescript
196
+ const result = await session.execute("GITHUB_CREATE_ISSUE", {
197
+ owner: "my-org",
198
+ repo: "my-repo",
199
+ title: "Fix login bug",
200
+ });
201
+ ```
202
+ </Tab>
203
+ </Tabs>
204
+
205
+- **Sharing one account across users** — sessions support **shared connections**
206
+ (`account_type:"SHARED"` + an allow/deny ACL), pinned per session. See
207
+ [Shared connections](/docs/authenticating-users/shared-connections).
208
+- **Tenant-specific params** (SharePoint sub-site, Jira subdomain) — prefill them via shared
209
+ credentials on the auth config.
210
+- **White-labeling carries over** — pass the same white-labeled auth config IDs; users keep seeing
211
+ your branding on consent screens. See [White-labeling authentication](/docs/white-labeling-authentication).
212
+- **Triggers** — unchanged; continue using `composio.triggers.*` and webhooks (triggers aren't part
213
+ of sessions yet).
214
+- **Dashboard** — sessions are created via the SDK. For no-code, personal app connections, use
215
+ [Composio For You](https://connect.composio.dev) — reachable from the product switcher in the
216
+ top-left of the dashboard.
217
+
218
+## Get started
219
+
220
+<Cards>
221
+ <Card title="Configuring Sessions" href="/docs/configuring-sessions" description="Toolkits, auth configs, account selection, presets, and session methods" />
222
+ <Card title="What is a session?" href="/docs/how-composio-works" description="How sessions scope tools and connected accounts" />
223
+</Cards>