← All rules
mcp-scan rule
Env var prefix risk
env-var-prefix-risklowWhat mcp-scan saw
With requiredEnvVarPrefix set in .mcp-scan.json, the scan loop tested every key in the server's env block with startsWith against that prefix and reported each one that does not match. The comparison is case-sensitive and produces one finding per non-matching key.
Why it fires
A prefix convention is what makes it possible to tell at a glance which variables an MCP server is allowed to read, which matters because env is inherited and a server can read far more than its own block. This is a policy rule, so it only exists once your team turns it on.
When this is a false positive
- Third-party servers hardcode their variable names. GITHUB_TOKEN, ANTHROPIC_API_KEY, and DATABASE_URL are read by name inside the package and cannot be renamed to fit your prefix.
- The check is case-sensitive, so a prefix of MYCO_ does not match myco_ and reports keys that follow the convention in spirit.
- It fires once per key, so a server with six standard variables produces six findings for one policy decision.
- The prefix in .mcp-scan.json may have been inherited from another repo. An empty string matches everything, so the rule is off by default.
How to fix it
- Open .mcp-scan.json and read requiredEnvVarPrefix. That value is the whole rule.
- For variables you control, rename them to carry the prefix and update the server that reads them.
- For third-party variables with fixed names, you cannot rename them. Decide whether the convention is worth the noise it produces on every such server.
- If the convention only applies to your own servers, set requiredEnvVarPrefix to an empty string and enforce it in code review instead.
- To suppress, add 'env-var-prefix-risk' to suppressRules in .mcp-scan.json.