Automatic Configuration
WhenbaseUrl is set (via MCPServer constructor or MCP_URL environment variable), mcp-use automatically configures CSP:
- Widget URLs use the correct domain
- CSP includes your server domain
- Works behind proxies and custom domains
connectDomains, resourceDomains, and baseUriDomains—you don’t need to add it manually.
Per-Widget Configuration
For widgets that need additional domains (APIs, CDNs, etc.), configure CSP in your widget metadata.MCP Apps (all compatible clients, ChatGPT, Claude etc..)
Withtype: "mcpApps", use camelCase in metadata.csp:
Apps SDK Format (ChatGPT only - DEPRECATED)
Withtype: "appsSdk", use snake_case in appsSdkMetadata["openai/widgetCSP"]:
Field Reference
| MCP Apps (camelCase) | Apps SDK (snake_case) | Description |
|---|---|---|
connectDomains | connect_domains | Domains for fetch, XHR, WebSocket |
resourceDomains | resource_domains | Domains for scripts, styles, images |
baseUriDomains | base_uri_domains | Domains for base URI (MCP Apps) |
frameDomains | frame_domains | Domains for iframe embeds |
redirectDomains | redirect_domains | Domains for redirects (ChatGPT-specific) |
scriptDirectives | script_directives | Custom script CSP directives, not all clients support this (e.g. ChatGPT) |
styleDirectives | style_directives | Custom style CSP directives |
Your CSP domains are merged with your server’s base URL automatically. For ChatGPT, OpenAI’s required domains (
*.oaistatic.com, etc.) are also added. For MCP Apps clients, only the domains you declare are used.Environment Variables
- MCP_URL: Base URL for widget assets and public files. Also used by the server to configure CSP.
- CSP_URLS: (Optional) Additional domains to whitelist. Supports comma-separated list. Required for static deployments where widget assets are served from different domains.
Static Deployments
When widgets are served from static storage (e.g., Supabase Storage) while the MCP server runs elsewhere, set:- MCP_URL: Where widget assets are stored
- MCP_SERVER_URL: Where the MCP server runs (for API calls)
- CSP_URLS: Domains for storage and API access (e.g.,
https://YOUR_PROJECT.supabase.co)
Inspector Debugging
The mcp-use Inspector provides a CSP Mode Toggle for testing:- Permissive — Relaxed CSP for debugging
- Widget-Declared — Enforces the widget’s declared CSP (production-like)
Next Steps
- MCP Apps — Unified metadata format for both protocols
- ChatGPT Apps SDK — Widget metadata and registration
- Supabase Deployment — Static deployment with CSP
- Debugging Widgets — Test CSP in the Inspector