Resources

MCP security

MCP secret management: how to scope API keys safely

MCP secret management keeps model-context servers and tools from relying on broad, copied API keys by resolving scoped credentials at runtime.

Answer target

How should teams manage secrets for MCP servers and tools?

Updated June 2, 2026

Short answer

MCP servers and tools should not depend on raw API keys pasted into config files or chat prompts. A safer pattern is to store secrets in a central credential layer, assign them to projects, and let the MCP tool resolve only the keys it has been directly granted.

Why MCP makes scoping more important

MCP connects models to external tools. That is useful, but it also means a model can trigger workflows that touch databases, code hosts, payments, analytics, or production infrastructure. If an MCP server is configured with a broad API key, every tool call that reaches that server inherits the blast radius of that key.

How to scope API keys for MCP

Scope should be explicit before the model or tool can use a credential. At minimum, teams should separate provider namespace, project assignment, runtime identity, and direct secret grant. That lets a finance MCP tool resolve Stripe test credentials without also seeing production database credentials.

  • Keep each external system under a provider namespace.
  • Assign secrets to the project that needs them.
  • Give each MCP server or tool runner its own agent identity.
  • Grant only the specific keys that identity should resolve.

Audit the resolution, not the raw value

Audit logs should explain which agent or human resolved which secret and from which context. They should not store raw credential values. This gives operators a useful trail without turning audit history into another secret store.

Practical workflow

  1. 1Name the MCP runtimeCreate a specific agent identity for the MCP server, connector, or tool runner.
  2. 2Attach it to the projectProject assignment limits which provider groups and candidate secrets are relevant.
  3. 3Grant direct secrets onlyDo not assume project visibility is the same as credential access.

Config-file MCP key vs Scoped runtime resolution

TopicConfig-file MCP keyScoped runtime resolution
ExposureThe raw key may sit in local config or process environment.The key is stored centrally and resolved only when needed.
RevocationEvery machine or config file has to be found and updated.Revoke the grant or rotate the stored secret centrally.
TraceabilityTool use and credential use are often disconnected.Resolution events are linked to the agent identity.

Where ScopeHold fits

ScopeHold gives MCP-style tool runners an agent identity, project assignment, direct secret grants, and audit history without asking users to paste long-lived keys into model chats.