Which version line?
v2 — current (@modelcontextprotocol/inspector@latest)
Which client?
Web
Inspector version
2.2.0
Node version
v22.23.1
Operating system (and browser, for the web client)
windows, chrome
Transport
stdio
MCP server under inspection
own server via mcp sdk. modern protocol, using basic auth
The SAFE_CSP_SOURCE regex in clients/web/src/utils/sandbox-csp.ts rejects valid CSP keyword tokens like 'unsafe-eval' when declared in resourceDomains. This is a regression from v0.21.x where MCP Apps worked with 'unsafe-eval' in resourceDomains.
Steps to reproduce
- Register an MCP Apps resource with _meta.csp.resourceDomains containing 'unsafe-eval' ```
"_meta": {
"csp": {
"resourceDomains": ["http://localhost:8080", "'unsafe-eval'", "blob:", "data:"],
"connectDomains": ["ws://localhost:8080", "http://localhost:8080"]
}
}
2. Open the app in Inspector v2.2.0's Apps tab
3. Console shows: [[mcp-app sandbox] dropping unsafe CSP source: 'unsafe-eval'](vscode-file://vscode-app/c:/Users/z00550zt/AppData/Local/Programs/Microsoft%20VS%20Code/df53daabb1/resources/app/out/vs/code/electron-browser/workbench/workbench.html)
4. App crashes with EvalError: Evaluating a string as JavaScript violates the following Content Security Policy directive
### Expected behavior
'unsafe-eval' should pass through approveCspSources and be included in the [script-src](vscode-file://vscode-app/c:/Users/z00550zt/AppData/Local/Programs/Microsoft%20VS%20Code/df53daabb1/resources/app/out/vs/code/electron-browser/workbench/workbench.html) directive, as it was in v0.21.x and as the MCP Apps spec (SEP-1865 §4) intends: ```
// From the spec's CSP construction example:
script-src 'self' 'unsafe-inline' ${csp?.resourceDomains?.join(' ') || ''};
The spec does not filter CSP keyword tokens from resourceDomains.
Root Cause
The SAFE_CSP_SOURCE regex requires the first character to be *, [a-zA-Z] (URL scheme), or [A-Za-z0-9] (hostname). A single quote ' doesn't match any alternative:
/^(?:\*|[a-zA-Z][a-zA-Z0-9+.-]*:...|(?:\*\.)?[A-Za-z0-9]...)$/
// 'unsafe-eval' starts with ' → no match → dropped
The approveCspSources comment says it screens for "injection safety" (preventing ;, ", <, > from breaking the CSP attribute). CSP keywords like 'unsafe-eval' don't contain injection characters and should be allowed.
Actual behavior
app crashed
Logs, errors, or screenshots
No response
Already prototyped a fix?
Add a pattern for CSP keyword tokens to the regex:
export const SAFE_CSP_SOURCE =
/^(?:'[a-z][a-z0-9-]*'|\*|[a-zA-Z][a-zA-Z0-9+.-]*:(?:\/\/...)?|...)$/;
// ^^^^^^^^^^^^^^^^^ new: matches 'unsafe-eval', 'wasm-unsafe-eval', etc.
Or use an explicit allowlist of known CSP keywords ('unsafe-eval', 'wasm-unsafe-eval', 'unsafe-hashes').
Before you submit
Which version line?
v2 — current (
@modelcontextprotocol/inspector@latest)Which client?
Web
Inspector version
2.2.0
Node version
v22.23.1
Operating system (and browser, for the web client)
windows, chrome
Transport
stdio
MCP server under inspection
own server via mcp sdk. modern protocol, using basic auth
The SAFE_CSP_SOURCE regex in clients/web/src/utils/sandbox-csp.ts rejects valid CSP keyword tokens like 'unsafe-eval' when declared in resourceDomains. This is a regression from v0.21.x where MCP Apps worked with 'unsafe-eval' in resourceDomains.
Steps to reproduce
"_meta": {
"csp": {
"resourceDomains": ["http://localhost:8080", "'unsafe-eval'", "blob:", "data:"],
"connectDomains": ["ws://localhost:8080", "http://localhost:8080"]
}
}
The spec does not filter CSP keyword tokens from resourceDomains.
Root Cause
The SAFE_CSP_SOURCE regex requires the first character to be *, [a-zA-Z] (URL scheme), or [A-Za-z0-9] (hostname). A single quote ' doesn't match any alternative:
The approveCspSources comment says it screens for "injection safety" (preventing ;, ", <, > from breaking the CSP attribute). CSP keywords like 'unsafe-eval' don't contain injection characters and should be allowed.
Actual behavior
app crashed
Logs, errors, or screenshots
No response
Already prototyped a fix?
Add a pattern for CSP keyword tokens to the regex:
Or use an explicit allowlist of known CSP keywords ('unsafe-eval', 'wasm-unsafe-eval', 'unsafe-hashes').
Before you submit