4
---
5
6
<Callout type="warn" title="Deprecated">
7
-Use a session's MCP endpoint instead: `composio.create(user_id, mcp=True)` returns a session that exposes `session.mcp.url` / `session.mcp.headers`. The standalone `composio.mcp` server-management API is kept for backwards compatibility. See https://docs.composio.dev/docs/sessions-via-mcp
7
+Use a session's MCP endpoint instead: `composio.create(user_id, mcp=True)` returns a session that exposes `session.mcp.url` / `session.mcp.headers`. MCP is now opt-in per session; this standalone `composio.mcp` server-management API is kept only for backwards compatibility. Prefer the session MCP endpoint; do not generate new code against `composio.mcp`. See https://docs.composio.dev/docs/sessions-via-mcp
8
</Callout>
9
10
## Methods
34
35
```python
36
>>> # Using toolkit configuration objects with auth
37
- >>> server = composio.experimental.mcp.create(
38
- ... 'personal-mcp-server',
39
- ... toolkits=[
40
- ... {
41
- ... 'toolkit': 'github',
42
- ... 'auth_config_id': 'ac_xyz',
43
- ... },
44
- ... {
45
- ... 'toolkit': 'slack',
46
- ... 'auth_config_id': 'ac_abc',
47
- ... },
48
- ... ],
49
- ... allowed_tools=['GITHUB_CREATE_ISSUE', 'GITHUB_LIST_REPOS', 'SLACK_SEND_MESSAGE'],
50
- ... manually_manage_connections=False
51
- ... )
52
- >>>
53
- >>> # Using simple toolkit names (most common usage)
54
- >>> server = composio.experimental.mcp.create(
55
- ... 'simple-mcp-server',
56
- ... toolkits=['composio_search', 'text_to_pdf'],
57
- ... allowed_tools=['COMPOSIO_SEARCH_DUCK_DUCK_GO_SEARCH', 'TEXT_TO_PDF_CONVERT_TEXT_TO_PDF']
58
- ... )
59
- >>>
60
- >>> # Using all tools from toolkits (default behavior)
61
- >>> server = composio.experimental.mcp.create(
62
- ... 'all-tools-server',
63
- ... toolkits=['composio_search', 'text_to_pdf']
64
- ... # allowed_tools=None means all tools from these toolkits
65
- ... )
66
- >>>
67
- >>> # Get server instance for a user
68
- >>> mcp = server.generate('user_12345')
37
+>>> server = composio.experimental.mcp.create(
38
+... 'personal-mcp-server',
39
+... toolkits=[
40
+... {
41
+... 'toolkit': 'github',
42
+... 'auth_config_id': 'ac_xyz',
43
+... },
44
+... {
45
+... 'toolkit': 'slack',
46
+... 'auth_config_id': 'ac_abc',
47
+... },
48
+... ],
49
+... allowed_tools=['GITHUB_CREATE_ISSUE', 'GITHUB_LIST_REPOS', 'SLACK_SEND_MESSAGE'],
50
+... manually_manage_connections=False
51
+... )
52
+>>>
53
+>>> # Using simple toolkit names (most common usage)
54
+>>> server = composio.experimental.mcp.create(
55
+... 'simple-mcp-server',
56
+... toolkits=['composio_search', 'text_to_pdf'],
57
+... allowed_tools=['COMPOSIO_SEARCH_DUCK_DUCK_GO_SEARCH', 'TEXT_TO_PDF_CONVERT_TEXT_TO_PDF']
58
+... )
59
+>>>
60
+>>> # Using all tools from toolkits (default behavior)
61
+>>> server = composio.experimental.mcp.create(
62
+... 'all-tools-server',
63
+... toolkits=['composio_search', 'text_to_pdf']
64
+... # allowed_tools=None means all tools from these toolkits
65
+... )
66
+>>>
67
+>>> # Get server instance for a user
68
+>>> mcp = server.generate('user_12345')
69
```
70
71
---
98
99
```python
100
>>> # List all servers
101
- >>> all_servers = composio.experimental.mcp.list()
102
- >>>
103
- >>> # List with pagination
104
- >>> paged_servers = composio.experimental.mcp.list(page_no=2, limit=5)
105
- >>>
106
- >>> # Filter by toolkit
107
- >>> github_servers = composio.experimental.mcp.list(toolkits='github', name='personal')
101
+>>> all_servers = composio.experimental.mcp.list()
102
+>>>
103
+>>> # List with pagination
104
+>>> paged_servers = composio.experimental.mcp.list(page_no=2, limit=5)
105
+>>>
106
+>>> # Filter by toolkit
107
+>>> github_servers = composio.experimental.mcp.list(toolkits='github', name='personal')
108
```
109
110
---
127
128
```python
129
>>> server = composio.experimental.mcp.get('mcp_12345')
130
- >>>
131
- >>> print(server['name']) # "My Personal MCP Server"
132
- >>> print(server['allowed_tools']) # ["GITHUB_CREATE_ISSUE", "SLACK_SEND_MESSAGE"]
133
- >>> print(server['toolkits']) # ["github", "slack"]
134
- >>> print(server['server_instance_count']) # 3
130
+>>>
131
+>>> print(server['name']) # "My Personal MCP Server"
132
+>>> print(server['allowed_tools']) # ["GITHUB_CREATE_ISSUE", "SLACK_SEND_MESSAGE"]
133
+>>> print(server['toolkits']) # ["github", "slack"]
134
+>>> print(server['server_instance_count']) # 3
135
```
136
137
---
158
159
```python
160
>>> # Update server name only
161
- >>> updated_server = composio.experimental.mcp.update(
162
- ... 'mcp_12345',
163
- ... name='My Updated MCP Server'
164
- ... )
165
- >>>
166
- >>> # Update toolkits and tools
167
- >>> server_with_new_tools = composio.experimental.mcp.update(
168
- ... 'mcp_12345',
169
- ... toolkits=['github', 'slack'],
170
- ... allowed_tools=['GITHUB_CREATE_ISSUE', 'SLACK_SEND_MESSAGE']
171
- ... )
172
- >>>
173
- >>> # Update with auth configs
174
- >>> server_with_auth = composio.experimental.mcp.update(
175
- ... 'mcp_12345',
176
- ... toolkits=[
177
- ... {'toolkit': 'github', 'auth_config_id': 'auth_abc123'},
178
- ... {'toolkit': 'slack', 'auth_config_id': 'auth_def456'}
179
- ... ],
180
- ... allowed_tools=['GITHUB_CREATE_ISSUE', 'SLACK_SEND_MESSAGE'],
181
- ... manually_manage_connections=False
182
- ... )
161
+>>> updated_server = composio.experimental.mcp.update(
162
+... 'mcp_12345',
163
+... name='My Updated MCP Server'
164
+... )
165
+>>>
166
+>>> # Update toolkits and tools
167
+>>> server_with_new_tools = composio.experimental.mcp.update(
168
+... 'mcp_12345',
169
+... toolkits=['github', 'slack'],
170
+... allowed_tools=['GITHUB_CREATE_ISSUE', 'SLACK_SEND_MESSAGE']
171
+... )
172
+>>>
173
+>>> # Update with auth configs
174
+>>> server_with_auth = composio.experimental.mcp.update(
175
+... 'mcp_12345',
176
+... toolkits=[
177
+... {'toolkit': 'github', 'auth_config_id': 'auth_abc123'},
178
+... {'toolkit': 'slack', 'auth_config_id': 'auth_def456'}
179
+... ],
180
+... allowed_tools=['GITHUB_CREATE_ISSUE', 'SLACK_SEND_MESSAGE'],
181
+... manually_manage_connections=False
182
+... )
183
```
184
185
---
206
207
```python
208
>>> # Delete a server
209
- >>> result = composio.experimental.mcp.delete('mcp_12345')
210
- >>>
211
- >>> if result['deleted']:
212
- ... print(f"Server {result['id']} has been successfully deleted")
213
- >>> else:
214
- ... print(f"Failed to delete server {result['id']}")
209
+>>> result = composio.experimental.mcp.delete('mcp_12345')
210
+>>>
211
+>>> if result['deleted']:
212
+... print(f"Server {result['id']} has been successfully deleted")
213
+>>> else:
214
+... print(f"Failed to delete server {result['id']}")
215
```
216
217
---
240
241
```python
242
>>> mcp = composio.experimental.mcp.generate(
243
- ... 'user_12345',
244
- ... 'mcp_67890',
245
- ... manually_manage_connections=False
246
- ... )
247
- >>>
248
- >>> print(mcp['url']) # Server URL for the user
249
- >>> print(mcp['allowed_tools']) # Available tools
243
+... 'user_12345',
244
+... 'mcp_67890',
245
+... manually_manage_connections=False
246
+... )
247
+>>>
248
+>>> print(mcp['url']) # Server URL for the user
249
+>>> print(mcp['allowed_tools']) # Available tools
250
```
251
252
---