@devries-cameron20 / composio Mirror · read-only
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 03:37 UTC

next
mdx 151 lines 3.99 KB
Raw
1 ---
2 title: "Optional API Key Enforcement for MCP Servers"
3 description: "New project-level setting to require API key authentication for all MCP server requests"
4 date: "2026-01-08"
5 ---
6
7 We've introduced a new project-level security setting that allows you to require API key authentication for all MCP server requests. This opt-in feature gives you fine-grained control over who can access your MCP endpoints.
8
9 <Callout type="info">
10 **Opt-in today, default soon**: This feature is currently opt-in. Starting **March 1, 2026**, it will be enabled by default for new organizations. We recommend enabling it now to prepare your integrations.
11 </Callout>
12
13 ## What's New
14
15 A new **"Require API Key for MCP"** toggle is now available in your Project Settings. When enabled, all requests to your MCP servers must include a valid Composio API key in the request headers.
16
17 | Setting | Default | Impact |
18 |---------|---------|--------|
19 | `require_mcp_api_key` | `false` | Opt-in; no changes to existing behavior |
20
21 ## How It Works
22
23 When the setting is **disabled** (default):
24 - MCP servers work without API key authentication
25 - Existing integrations continue to function unchanged
26
27 When the setting is **enabled**:
28 - All MCP requests must include the `x-api-key` header with a valid Composio API key
29 - Requests without a valid API key receive `401 Unauthorized`
30 - Only API keys belonging to the same project are accepted
31
32 ### Request Examples
33
34 **Without API key (when enforcement is enabled):**
35 ```bash
36 curl -X POST "https://mcp.composio.dev/{your_mcp_server_url}" \
37 -H "Content-Type: application/json" \
38 -d '{"jsonrpc":"2.0","id":1,"method":"initialize"}'
39
40 # Response: 401 Unauthorized
41 ```
42
43 **With API key:**
44 ```bash
45 curl -X POST "https://mcp.composio.dev/{your_mcp_server_url}" \
46 -H "Content-Type: application/json" \
47 -H "x-api-key: ak_your_api_key" \
48 -d '{"jsonrpc":"2.0","id":1,"method":"initialize"}'
49
50 # Response: 200 OK
51 ```
52
53 ## Enabling the Setting
54
55 ### Via Dashboard
56
57 1. Navigate to [Project Settings](https://dashboard.composio.dev/~/project/settings/general?utm_source=docs&utm_medium=content&utm_campaign=changelog-01-08-26-mcp-api-key-enforcement)
58 2. Go to the **Project Configuration** tab
59 3. Find the **"Require API Key for MCP"** toggle
60 4. Enable the toggle
61
62 ![MCP API Key Toggle in Project Settings](/assets/images/mcp-api-key-toggle.png)
63
64 ### Via API
65
66 Update your project configuration using the API:
67
68 ```bash
69 curl -X PATCH "https://backend.composio.dev/api/v3/org/project/config" \
70 -H "Content-Type: application/json" \
71 -H "x-api-key: ak_your_api_key" \
72 -d '{"require_mcp_api_key": true}'
73 ```
74
75 **Response:**
76 ```json
77 {
78 "require_mcp_api_key": true,
79 "is_2FA_enabled": true,
80 "mask_secret_keys_in_connected_account": true,
81 "log_visibility_setting": "show_all"
82 }
83 ```
84
85 ### Via Code
86
87 <Tabs groupId="language" items={['Python', 'TypeScript']}>
88 <Tab value="Python">
89 ```python
90 import requests
91
92 response = requests.patch(
93 "https://backend.composio.dev/api/v3/org/project/config",
94 headers={
95 "Content-Type": "application/json",
96 "x-api-key": "ak_your_api_key"
97 },
98 json={"require_mcp_api_key": True}
99 )
100
101 print(response.json())
102 ```
103 </Tab>
104 <Tab value="TypeScript">
105 ```typescript
106 // @noErrors
107 const response = await fetch(
108 "https://backend.composio.dev/api/v3/org/project/config",
109 {
110 method: "PATCH",
111 headers: {
112 "Content-Type": "application/json",
113 "x-api-key": "ak_your_api_key"
114 },
115 body: JSON.stringify({ require_mcp_api_key: true })
116 }
117 );
118
119 console.log(await response.json());
120 ```
121 </Tab>
122 </Tabs>
123
124 ## When to Use This
125
126 Enable API key enforcement when you need to:
127
128 - **Prevent unauthorized access** to your MCP servers
129 - **Control which applications** can interact with your MCP endpoints
130 - **Add an extra security layer** for production deployments
131 - **Audit and track** MCP server usage through API key attribution
132
133 ## API Reference
134
135 ### Get Current Setting
136
137 ```http
138 GET /api/v3/org/project/config
139 ```
140
141 ### Update Setting
142
143 ```http
144 PATCH /api/v3/org/project/config
145 ```
146
147 ```json
148 {
149 "require_mcp_api_key": true
150 }
151 ```