Skip to content

Commit ab2e1e8

Browse files
authored
fix: restrict access to mcp server in self-hosted (supabase#39849)
* add routes for local remote mcp * add additional plugins to kong to restrict mcp * prohibit access to /api/mcp and /mcp by default * add comments to warn the user about local access only
1 parent 8855d05 commit ab2e1e8

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

docker/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ services:
7171
KONG_DECLARATIVE_CONFIG: /home/kong/kong.yml
7272
# https://github.com/supabase/cli/issues/14
7373
KONG_DNS_ORDER: LAST,A,CNAME
74-
KONG_PLUGINS: request-transformer,cors,key-auth,acl,basic-auth
74+
KONG_PLUGINS: request-transformer,cors,key-auth,acl,basic-auth,request-termination,ip-restriction
7575
KONG_NGINX_PROXY_PROXY_BUFFER_SIZE: 160k
7676
KONG_NGINX_PROXY_PROXY_BUFFERS: 64 160k
7777
SUPABASE_ANON_KEY: ${ANON_KEY}

docker/volumes/api/kong.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,48 @@ services:
225225
allow:
226226
- admin
227227

228+
## Block access to /api/mcp
229+
- name: mcp-blocker
230+
_comment: 'Block direct access to /api/mcp'
231+
url: http://studio:3000/api/mcp
232+
routes:
233+
- name: mcp-blocker-route
234+
strip_path: true
235+
paths:
236+
- /api/mcp
237+
plugins:
238+
- name: request-termination
239+
config:
240+
status_code: 403
241+
message: "Access is forbidden."
242+
243+
## MCP endpoint - local access
244+
- name: mcp
245+
_comment: 'MCP: /mcp -> http://studio:3000/api/mcp (local access)'
246+
url: http://studio:3000/api/mcp
247+
routes:
248+
- name: mcp
249+
strip_path: true
250+
paths:
251+
- /mcp
252+
plugins:
253+
# Block access to /mcp by default
254+
- name: request-termination
255+
config:
256+
status_code: 403
257+
message: "Access is forbidden."
258+
# Enable local access (danger zone!)
259+
# 1. Comment out the 'request-termination' section above
260+
# 2. Uncomment the entire section below, including 'deny'
261+
# 3. Add your local IPs to the 'allow' list
262+
#- name: cors
263+
#- name: ip-restriction
264+
# config:
265+
# allow:
266+
# - 127.0.0.1
267+
# - ::1
268+
# deny: []
269+
228270
## Protected Dashboard - catch all remaining routes
229271
- name: dashboard
230272
_comment: 'Studio: /* -> http://studio:3000/*'

0 commit comments

Comments
 (0)