mcp-context-forge icon indicating copy to clipboard operation
mcp-context-forge copied to clipboard

[ENHANCEMENT][PLUGINS]: Proactive secrets management integration for secrets detection plugin

Open lucamorettibuilds opened this issue 9 months ago • 2 comments

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:

  1. Prevention — secrets resolved server-side, never exposed to clients
  2. Detection — current regex patterns catch any that slip through
  3. 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 alongside secrets_detection
  • An extension to the existing secrets_detection plugin with a providers config section
  • A middleware layer in the gateway that intercepts and resolves secret URIs

Happy to help with implementation if this direction makes sense.

lucamorettibuilds avatar Feb 13 '26 08:02 lucamorettibuilds

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 .

jonpspri avatar Feb 18 '26 06:02 jonpspri

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:

  1. Admin registers the credential: secrets_provider.register("db-prod", source="vault", path="database/prod/password")
  2. Tool config references it: secret://db-prod instead of a raw connection string
  3. At runtime, the gateway resolves secret://db-prod server-side before the tool executes
  4. The secrets_detection plugin 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:

  1. Ops rotates the key in Vault (or the secrets provider)
  2. Next tool invocation resolves secret://api-key to the new value
  3. No config changes, no restarts — resolution happens at call time
  4. 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:

  1. Admin defines policies: Agent A can access secret://github-token, Agent B can access secret://db-prod
  2. Agent identity is passed through the gateway (e.g., via client certificate or header)
  3. The secrets_provider plugin checks policy before resolving any secret reference
  4. 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.

lucamorettibuilds avatar Feb 18 '26 07:02 lucamorettibuilds