Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: restrict access to mcp server in self-hosted (#39849)

Andrey A.ab2e1e891871
diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index 536ea8860d5..5d9b3e82fb9 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -71,7 +71,7 @@ services:
KONG_DECLARATIVE_CONFIG: /home/kong/kong.yml
# https://github.com/supabase/cli/issues/14
KONG_DNS_ORDER: LAST,A,CNAME
- KONG_PLUGINS: request-transformer,cors,key-auth,acl,basic-auth
+ KONG_PLUGINS: request-transformer,cors,key-auth,acl,basic-auth,request-termination,ip-restriction
KONG_NGINX_PROXY_PROXY_BUFFER_SIZE: 160k
KONG_NGINX_PROXY_PROXY_BUFFERS: 64 160k
SUPABASE_ANON_KEY: ${ANON_KEY}
diff --git a/docker/volumes/api/kong.yml b/docker/volumes/api/kong.yml
index 7abf42534c9..168634f5a9a 100644
--- a/docker/volumes/api/kong.yml
+++ b/docker/volumes/api/kong.yml
@@ -225,6 +225,48 @@ services:
allow:
- admin
+ ## Block access to /api/mcp
+ - name: mcp-blocker
+ _comment: 'Block direct access to /api/mcp'
+ url: http://studio:3000/api/mcp
+ routes:
+ - name: mcp-blocker-route
+ strip_path: true
+ paths:
+ - /api/mcp
+ plugins:
+ - name: request-termination
+ config:
+ status_code: 403
+ message: "Access is forbidden."
+
+ ## MCP endpoint - local access
+ - name: mcp
+ _comment: 'MCP: /mcp -> http://studio:3000/api/mcp (local access)'
+ url: http://studio:3000/api/mcp
+ routes:
+ - name: mcp
+ strip_path: true
+ paths:
+ - /mcp
+ plugins:
+ # Block access to /mcp by default
+ - name: request-termination
+ config:
+ status_code: 403
+ message: "Access is forbidden."
+ # Enable local access (danger zone!)
+ # 1. Comment out the 'request-termination' section above
+ # 2. Uncomment the entire section below, including 'deny'
+ # 3. Add your local IPs to the 'allow' list
+ #- name: cors
+ #- name: ip-restriction
+ # config:
+ # allow:
+ # - 127.0.0.1
+ # - ::1
+ # deny: []
+
## Protected Dashboard - catch all remaining routes
- name: dashboard
_comment: 'Studio: /* -> http://studio:3000/*'