[Bug] `validateProjectConfigSecurity` never runs, hardcoded-credential scanner is dead code
Description
validateMCPConfigSecurity is the app's only defense-in-depth signal for
"you committed a hardcoded credential into a project-level MCP config." It is
only invoked, via validateProjectConfigSecurity, on servers whose
.source === 'project'. But the object type that field lives on
(MCPServerWithSource) is stripped down to the plain MCPServerConfig
(which never had that field) before it reaches this call, so the filter is
always empty and the check never fires in the shipped app.
Root cause is an integration break between two refactors: mcp-config-loader.ts
tracks provenance on a wrapper type for its own merge logic, but the consumer
(config/index.ts) unwraps to the inner type before handing it to the
validator, silently discarding the field the validator's filter depends on.
The unit test for this validator (validation.spec.ts) passes only because
it hand-constructs an object with .source set directly on the inner type
a shape that never occurs in the real data flow which is exactly why this
break went unnoticed.
Location
source/config/mcp-config-loader.ts:47-63(mapServerConfignever copies.sourceonto the returnedMCPServerConfig)source/config/index.ts:704-705(loadAllMCPConfigs().map(item => item.server)strips the wrapper's.sourcefield)source/hooks/useAppInitialization.tsx:210(validateProjectConfigSecurity(config.mcpServers)called on the already-stripped array)source/config/validation.ts:58-60(filtersserver.source === 'project', alwaysundefinedon real objects)
Environment
- OS: Any
- Node version: v22.22.3
- Nanocoder version: 1.30.0
- Provider: N/A
- Model: N/A
Steps to Reproduce
- Add an MCP server entry to a project's
agents.config.jsonwith a hardcoded-looking secret, e.g."env": {"API_KEY": "sk-abc123..."}. - Start
nanocoderin that project. - Observe that no warning is logged, even though
validateMCPConfigSecurityis designed to detect exactly this pattern.
Alternatively, add a console.log (or breakpoint) inside
validateMCPConfigSecurity and confirm it is never reached for a real
project config, because the array passed to validateProjectConfigSecurity
contains objects with source: undefined.
Expected Behavior
A project-level MCP server config containing an apparent hardcoded credential
should trigger validateMCPConfigSecurity's warning.
Actual Behavior
The warning never fires for any real config, project-level or otherwise,
because the .source field its filter depends on is stripped before the
validator ever sees the data.
Additional Context
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] I can reproduce this issue consistently (established via code read
mapServerConfigand the.map(item => item.server)unwrap are directly verifiable as never setting/preserving.source) - [x] This issue occurs with the latest version of nanocoder
Suggested fix: preserve .source through the unwrap in config/index.ts
(don't discard the wrapper before validation), or have
validateProjectConfigSecurity accept the MCPServerWithSource[] array
directly instead of the stripped MCPServerConfig[].
Hey @akramcodez, almost done with the fix.. could you assign this to me ?