[ENHANCEMENT][PLUGINS]: Proactive secrets management integration for secrets detection plugin
Summary
The secrets detection plugin does excellent work catching leaked secrets in prompts, tool calls, and resources. However, the current approach is purely reactive — it detects secrets after they appear in the MCP message flow.
A complementary enhancement would be proactive secrets management integration that prevents secrets from entering the MCP pipeline in the first place.
Proposal
1. External Secrets Provider Integration
Allow the secrets detection plugin to work alongside external secrets managers:
- HashiCorp Vault — rotate and inject secrets via short-lived tokens
- AWS Secrets Manager / Azure Key Vault — cloud-native secrets
- Environment-based providers — for development/CI workflows
2. Secret Reference Resolution
Instead of passing raw secrets through MCP, tools could reference secrets by URI:
secret://vault/database/password
secret://env/API_KEY
The gateway resolves these references server-side, so secrets never appear in the client-facing message flow.
3. Defense in Depth
This creates a layered approach:
- Prevention — secrets resolved server-side, never exposed to clients
- Detection — current regex patterns catch any that slip through
- Response — redaction and alerting on detection
Prior Art
- Janee implements a secrets provider plugin system for MCP servers with this URI-based approach
- The MCP spec discussion on server-side filtering (RFC #668) covers related patterns
- OWASP secrets management cheat sheet
Implementation Notes
This could be implemented as:
- A new plugin (e.g.,
secrets_provider) that works alongsidesecrets_detection - An extension to the existing
secrets_detectionplugin with aprovidersconfig section - A middleware layer in the gateway that intercepts and resolves secret URIs
Happy to help with implementation if this direction makes sense.
Hello, Luca, thanks for the excellent suggestion, and I agree it deserves an implementation. Can we flesh out the issue somewhat with a few stories about how the feature would surface in a typical administration and execution flow? We're happy to accept your assistance .
Thanks @jonpspri! Here are some concrete user stories:
Story 1: Developer onboarding a new MCP tool
As a developer adding a database tool to my MCP server, I want to reference credentials by name instead of pasting them into tool configs, So that secrets never appear in prompts, tool calls, or logs.
Flow:
- Admin registers the credential:
secrets_provider.register("db-prod", source="vault", path="database/prod/password") - Tool config references it:
secret://db-prodinstead of a raw connection string - At runtime, the gateway resolves
secret://db-prodserver-side before the tool executes - The
secrets_detectionplugin acts as a safety net — if a raw secret somehow leaks into a message, it gets redacted
Story 2: Rotating credentials without downtime
As an ops engineer rotating API keys, I want to update the secret in one place and have all MCP tools pick up the new value, So that I do not need to restart servers or update tool configs.
Flow:
- Ops rotates the key in Vault (or the secrets provider)
- Next tool invocation resolves
secret://api-keyto the new value - No config changes, no restarts — resolution happens at call time
- Audit log shows which tools accessed which secrets and when
Story 3: Multi-agent environment with scoped access
As a platform admin running multiple agents through a shared MCP gateway, I want each agent to only access the secrets it needs, So that a compromised or misbehaving agent cannot read another agent's credentials.
Flow:
- Admin defines policies: Agent A can access
secret://github-token, Agent B can accesssecret://db-prod - Agent identity is passed through the gateway (e.g., via client certificate or header)
- The
secrets_providerplugin checks policy before resolving any secret reference - Unauthorized access attempts are logged and blocked
Proposed plugin config
secrets_provider:
providers:
vault:
type: hashicorp_vault
address: https://vault.internal:8200
auth: token
env:
type: environment
janee:
type: janee
url: http://localhost:3777
policies:
default:
allowed_secrets: []
agent-a:
allowed_secrets: ["github-token", "npm-token"]
agent-b:
allowed_secrets: ["db-prod"]
resolution:
scheme: "secret://"
cache_ttl: 300
The janee provider type would work with Janee, which already implements the MCP-native secret resolution and per-agent policy model described in Story 3. But the plugin architecture should be provider-agnostic so teams can use whatever backend fits their setup.
Happy to start on a draft implementation if you want to point me at the right extension points.