# Configure Content Security Policy for the Subtext Capture Snippet
Source: https://subtext.fullstory.com/docs/api/csp
Allow the Subtext capture snippet's script and network requests through your app's Content Security Policy.
If your app sends a `Content-Security-Policy`, it blocks the capture snippet's script from loading and the SDK's network calls from reaching Fullstory until your policy allows them. You need to allow both Fullstory hosts across three directives — `script-src`, `connect-src`, and `img-src`. Update the policy before you [install the snippet](/docs/install/overview) so capture works from the first page load.
Update the policy before you install the snippet. If you leave a restrictive policy in place, capture silently fails — the script never loads and no errors surface to your users.
## Where CSP lives
Look for the policy in these places:
* Framework config — `next.config.js` (`headers()`), `vercel.json`, `netlify.toml` `[[headers]]` blocks.
* Middleware — Express/Fastify `helmet`, Next.js `middleware.ts`, custom response-header middleware.
* HTML meta tag — `` in the HTML entry point.
* Hosting platform — Vercel/Netlify/Cloudflare dashboard or Workers script.
## Required directives
### `script-src`
Add both Fullstory hosts. The snippet runs an inline bootstrap, so you also need `'unsafe-inline'` — or a nonce.
```
script-src 'self' https://edge.fullstory.com https://rs.fullstory.com 'unsafe-inline';
```
If you already use nonces, prefer that approach:
```
script-src 'self' https://edge.fullstory.com https://rs.fullstory.com 'nonce-';
```
Then add the nonce to the snippet's `
```
The snippet loads `fs.js` from Fullstory's edge asynchronously. It does not block rendering and adds no measurable overhead to page load time.
The plugin is the fastest way to connect an agent: it configures the MCP server connection and installs the Subtext skills and commands in one step, and it updates automatically.
**Claude Code** (full plugin — MCP server, skills, and commands):
```text theme={null}
/plugin marketplace add fullstorydev/subtext
/plugin install subtext@subtext-marketplace
```
**Cursor** — install [Subtext from the Cursor marketplace](https://cursor.com/marketplace/subtext) directly inside Cursor.
**Codex** — open `/plugins` and install **subtext** from the repo marketplace.
**Gemini CLI**:
```bash theme={null}
gemini extensions install https://github.com/fullstorydev/subtext
```
**Windsurf and other editors** — install the skills via [OpenSkills](https://github.com/fullstorydev/subtext), then add the MCP server manually in the next step:
```bash theme={null}
npx openskills install fullstorydev/subtext
npx openskills sync
```
**claude.ai** — Subtext is also available as a connector in the [Claude directory](https://claude.ai/directory/connectors/subtext).
If you installed the plugin for Claude Code, Cursor, Codex, or Gemini CLI, the MCP server is configured for you — skip the next step and go straight to verification.
If your tool didn't configure MCP servers automatically during installation, add the server by hand. Subtext's MCP server is hosted — `https://api.fullstory.com/mcp/subtext` over HTTP, with no local process to run.
Add the server URL without any headers — your tool handles the OAuth flow automatically.
```json Claude Code (~/.claude/settings.json) theme={null}
{
"mcpServers": {
"subtext": {
"type": "http",
"url": "https://api.fullstory.com/mcp/subtext"
}
}
}
```
```json Cursor (Settings → MCP → Add Server) theme={null}
{
"subtext": {
"type": "http",
"url": "https://api.fullstory.com/mcp/subtext"
}
}
```
Get your API key from [Settings → API Keys](https://app.fullstory.com/ui/org/settings/apikeys) and pass it as a Bearer token header.
```json Claude Code (~/.claude/settings.json) theme={null}
{
"mcpServers": {
"subtext": {
"type": "http",
"url": "https://api.fullstory.com/mcp/subtext",
"headers": {
"Authorization": "Bearer YOUR_SUBTEXT_API_KEY"
}
}
}
}
```
```json Cursor (Settings → MCP → Add Server) theme={null}
{
"subtext": {
"type": "http",
"url": "https://api.fullstory.com/mcp/subtext",
"headers": {
"Authorization": "Bearer YOUR_SUBTEXT_API_KEY"
}
}
}
```
Keep your API key private. Do not commit it to source control. If you are working in a team environment, use environment variable injection or a secrets manager rather than hardcoding the key in a shared config file.
Any tool that accepts a remote MCP URL — Linear's **Custom URL…** field, for example — takes the same endpoint directly.
Once saved, restart your agent or reload its MCP configuration.
With the snippet deployed and your agent connected, run through this checklist to confirm everything is working end to end:
**Capture is working:**
1. Open your application in a browser and navigate to a few pages.
2. Go to **Subtext → Sessions**. A new session should appear within 60 seconds.
3. Click into the session and confirm you can see a replay timeline with page events.
**MCP server is reachable:**
1. Open your agent (Claude Code, Cursor, etc.) in the project where you installed the plugin or added the MCP config.
2. Ask it: *"List my recent Subtext sessions."*
3. The agent should respond with a list of sessions from your account. If it returns an authentication error, redo the OAuth flow (or check the Bearer token value), and confirm the config file is in the correct location for your agent.
**Skills are available:**
1. In your agent, type `/` and look for Subtext skills in the command list (e.g., `/subtext:subtext-review`, `/subtext:subtext-session`).
2. If they do not appear, reinstall the plugin (or re-run `npx openskills sync`) and restart your agent.
If sessions appear in the Subtext dashboard but the MCP server cannot be reached, the most common cause is a misplaced or malformed MCP config file. Check that the JSON is valid (no trailing commas) and that the file path matches what your agent expects.
The capture snippet records full production sessions and masks all form inputs by default. Once your agent is connected, it can review sessions, flag additional PII, and propose masking rules for your approval — closing the privacy governance loop without manual scrubbing.
# Install Subtext in a Next.js App Router Application
Source: https://subtext.fullstory.com/docs/install/next-app-router
Add the Subtext capture snippet to your Next.js App Router project by inserting it into app/layout.tsx using the Script component.
The fastest way to add Subtext to a Next.js App Router project is to drop the capture snippet into your root layout file. Because `app/layout.tsx` wraps every route in your application, the snippet loads once and records sessions across your entire site. The `
{children}