MCP Server Configuration with Embedded Secret

Detects Model Context Protocol (MCP) server configuration files that hold a secret in plain text: an API key, token or password in a server's env block, or a bearer token or API key in its headers. These files (claude_desktop_config.json, .mcp.json, ~/.claude.json, .cursor/mcp.json, .vscode/mcp.json and similar) tell an AI client which tool servers to start and how to authenticate to them, are often committed or shared, and were collected by infostealers and npm supply-chain worms in 2026. A config that references a variable (${VAR}, ${env:NAME}, ${input:id}) or carries no secret does not match. This pattern finds stored secrets; ai-mcp-connector-risk covers over-broad scope wording.

Type
regex
Engine
boost_regex
Confidence
medium
Confidence justification
Medium confidence. The mcpServers schema (command, args and env for local servers; type, url and headers for remote ones) is documented by the Model Context Protocol project, Claude Code, Cursor and VS Code, and a literal value under a secret-named key inside that structure is almost always a real credential. The value itself is an opaque string with no fixed format, so the regex cannot validate it, and the same member names appear in other JSON configuration. Enforce tiers therefore require MCP context as well as the secret-shaped member.
Jurisdictions
global
Regulations
Criminal Code Act 1995 (Cth), Computer Fraud and Abuse Act, Computer Misuse Act 1990
Frameworks
CIS Controls, ISO 27001, NIST CSF, SOC 2
Data categories
credentials, security
Scope
narrow
Risk rating
8
Platform compatibility
Purview: Compatible, GCP DLP: Unsupported, Macie: Unsupported, Zscaler: Compatible, CrowdStrike DLP: Unsupported, Palo Alto: Unsupported, Netskope: Unsupported

Pattern

(?i)("[A-Za-z0-9_]{0,60}(?:API_?KEY|ACCESS_KEY|SECRET_KEY|PRIVATE_KEY|AUTH_KEY|TOKEN|SECRET|PASSWORD|PASSWD)"\s*:\s*"(?![<$/~.]|[^"]{0,40}(?:your|xxxx|\*{3}|redacted|placeholder|changeme))[^"\s$<>{}]{12,}")

Corroborative evidence keywords

mcpServers, mcp.json, claude_desktop_config.json, @modelcontextprotocol/, env, headers, Authorization

Proximity: 3000 characters

Should match

Should not match

Known false positives

References