The provided document offers an in-depth guide on how to manage Content Security Policy (CSP) for widgets or apps embedded within AI platforms like ChatGPT, Claude, and VS Code. Here are the key points summarized:
Understanding CSP in MCP Apps
- Purpose of CSP: It's a security feature that restricts what external resources can be loaded by your widget to prevent Cross-Site Scripting (XSS) attacks.
- Sandbox Restrictions: Besides CSP, other browser APIs like
localStorage,eval(), andwindow.open()are restricted within sandboxed iframes.
Basic Concepts
-
CSP Source Directives:
connect-src: Specifies origins for network requests (e.g., API calls).img-src/font-src/media-src: Specify sources for images, fonts, and media respectively.frame-src: Allows embedding of external content like YouTube videos.
-
CSP Declaration in MCP Apps:
- Use
_meta.ui.cspto declare CSP rules. - Platforms may have different implementations (e.g., ChatGPT requires an additional
openai/widgetCSPdeclaration).
- Use
Common
Read the full article at DEV Community
Want to create content about this topic? Use Nemati AI tools to generate articles, social posts, and more.

![[AINews] The Unreasonable Effectiveness of Closing the Loop](/_next/image?url=https%3A%2F%2Fmedia.nemati.ai%2Fmedia%2Fblog%2Fimages%2Farticles%2F600e22851bc7453b.webp&w=3840&q=75)



