Gazebo
    ServicesAgentsVaultsDocsWritingPricing
    Log inSign up
    Log in
    GazeboWritingMCP Config Security: Protect API Keys and Bearer Tokens

    MCP Config Security: Protect API Keys and Bearer Tokens

    Share MCP templates without live credentials, protect broker tokens as well as provider keys, and respond correctly when configuration exposes a secret.

    July 28, 2026·5 min

    Quick answer: MCP authentication tokens are secrets, even when they are not provider API keys. Share configuration structure without live credentials, use the storage or interpolation supported by your client, and treat a leaked Gazebo token as a potential path to authorised provider-key retrieval.

    Configuration structure and credential values are different

    A server URL, transport type and variable reference can often be shared. A resolved bearer token, provider key, OAuth refresh token or client secret requires protection.

    Replacing a Stripe key with a Gazebo agent token changes which system checks access and how future retrieval can be revoked. It does not make the new token safe to commit or publish. Anyone possessing a valid token may be able to retrieve the credentials its policy allows.

    Likewise, a protected local configuration file is not automatically a public leak. Assess who can read it, what processes run with those permissions, and where it is synced, backed up or exported. Avoid claims that every process on a machine can read every file.

    Use the configuration your client actually supports

    Paths, scopes and interpolation differ:

    ClientDocumented configuration distinction
    CursorProject .cursor/mcp.json versus global ~/.cursor/mcp.json; ${env:NAME} interpolation in supported fields. Remote HTTP does not support envFile.
    Claude Code terminalProject .mcp.json, with "type": "http" for this remote setup; ${NAME} variable references. Local and user scopes are separate.
    Current CascadeUse Open MCP config file for the installed client. Current documentation distinguishes managed configuration from editor discovery files.

    Do not rename a file to windsurf-mcp.json, export a variable and assume a client imports it. Desktop launchers may not inherit a terminal's environment.

    Follow the maintained Cursor, Claude Code and Devin / Windsurf guides, then check the vendor documentation for your installed version.

    Share a secret-free template

    For example, this Cursor remote-HTTP template contains an environment reference, not a token value:

    {
      "mcpServers": {
        "gazebo": {
          "url": "https://app.gazebohq.com/api/mcp",
          "headers": {
            "Authorization": "Bearer ${env:GAZEBO_AGENT_TOKEN}"
          }
        }
      }
    }
    

    Keep the actual variable value in an appropriate protected location and make it available only to the intended consumer. Do not resolve it into the committed file, use a live secret as a fallback, paste it into onboarding documents or expose it in shell history and diagnostics.

    Claude Code uses different interpolation and requires the HTTP type field. This is not a universal copy-and-paste MCP configuration.

    For OAuth clients, use the supported sign-in and credential-storage flow rather than manually copying access or refresh tokens. OAuth storage is still sensitive, even when it is outside the project file.

    Know which boundary a token gives you

    A Gazebo agent token authenticates a retrieval identity. OAuth adds explicit approval of service keys. Neither path makes a returned provider credential newly scoped, temporary or invisible to the runtime.

    get_credential returns the actual configured provider key after release-policy checks. The key may enter tool output, model context, session storage or host infrastructure depending on the client. Its provider permissions determine what it can subsequently do.

    A native provider tool that keeps a key internal has a different exposure model from a retrieval tool. Do not assume that substituting the latter solves every configuration or prompt-injection risk.

    If a live credential reaches Git or another sharing surface

    Treat the exposure according to who could access it and what it authorises. Removing the visible line does not remove copies or invalidate a credential.

    1. Contain promptly. Revoke an exposed Gazebo token or connection to stop new retrieval. If provider keys were directly exposed or may have been retrieved, assess their provider-side restriction, revocation or replacement too. Do not wait for a complete investigation before stopping active misuse.
    2. Preserve and inspect relevant evidence. Coordinate this with containment. Record exposure timing and consult retrieval, runtime and provider records without reproducing secrets in the incident notes.
    3. Restore legitimate access safely. Replace affected credentials and verify dependent consumers. Do not restore a compromised key merely to recover a broken integration; use the incident plan to manage availability tradeoffs.
    4. Clean the actual disclosure surfaces. Remove live values from tracked files, shared snippets, logs and exports where possible. Decide whether history rewriting is warranted, preserving evidence and coordinating with collaborators before disruptive changes. It does not recall other people's copies.
    5. Prevent recurrence. Share templates, protect actual values and review the relevant files and outputs. Gitignore rules do not untrack existing files or erase history.

    See the incident-response guide for the broader containment process.

    Keep useful configuration without publishing secrets

    Do not indiscriminately ignore every MCP configuration directory if the team needs safe templates or non-secret settings. Choose between a secret-free tracked template, supported external references and appropriately protected local configuration.

    If several people use the same template, supply separate authentication material where distinct access and attribution are needed. A shared profile or token cannot establish which person or unique session retrieved a key.

    An instruction selecting one profile is not isolation from other enabled profiles. Project configuration scope and runtime access controls need separate review.

    Scanning is a check, not a guarantee

    The Gazebo scanner can help inspect a pasted configuration for supported patterns. A clean result is not proof that no live credential is present; unusual tokens and credential types may be missed.

    For broader coverage, include relevant files, permitted exports and history in a deliberate scanning plan. Protect scan findings because reports can become another disclosure surface.

    Review logs and revocation honestly

    Gazebo history describes credential-retrieval attempts, not every API request made with a returned key. The identity and history tools themselves do not create credential-access events.

    Revoke Gazebo access to stop future retrieval. Restrict or invalidate a retained provider key at its provider when necessary. These are complementary actions, not interchangeable promises of immediate containment.


    Last reviewed: 8 November 2026. Configuration references: Cursor MCP, Claude Code MCP and current Cascade MCP.

    Frequently asked questions

    Is it safe to put API keys in mcp.json?

    Never commit or publish live provider keys, broker tokens or OAuth credentials. A protected local configuration has a different exposure model, depending on permissions and sharing. Prefer the client's supported credential storage or external references, and protect any resolved values.

    What happens if my mcp.json gets committed to git?

    A secret-free template is different from a file containing live credentials. If live values were exposed, contain promptly: invalidate the affected authentication material and assess provider keys it may have disclosed. Preserve relevant evidence and clean sharing surfaces; deleting a line or rewriting history does not invalidate copies.

    How is an MCP config file different from a .env file?

    Both can contain sensitive plaintext values, depending on how they are configured. MCP files also define server execution, transports and authentication, with client-specific project and global scopes. Risk depends on file permissions, actual contents, runtime access and sharing—not the filename alone.

    What should I put in my MCP config instead of API keys?

    Share endpoint and transport settings with supported secret references, not resolved tokens. Cursor and Claude Code use different interpolation syntax. A Gazebo agent token is also a secret because it can authorise credential retrieval; replacing a provider key with that token does not make it safe to publish.

    Can prompt injection steal credentials from an MCP config file?

    An injection may attempt to use permitted tools to read configuration or retrieve credentials. Whether it succeeds depends on the client, runtime and controls. The model does not automatically receive every config file, but a broker token does not eliminate this risk or protect a key after retrieval.

    How do I revoke a compromised MCP token without breaking other agents?

    Revoke the agent identity to block new credential retrieval immediately. Other profiles keep working. If the runtime already received a provider key, restrict, revoke or expire it at the provider to stop further use.

    Give your agents the access they need

    Scoped credential retrieval, access logs, and revocable agent access — for your AI tools.

    Get started free

    Agent pages

    CursorClaude CodeWindsurf

    Service pages

    GitHubStripeVercel

    Related reading

    Secret Scanning for AI Codebases: Limits and GapsClaude Code API Credentials: Setup and Access BoundariesWindsurf and Devin Credentials: MCP Setup and Trust Boundaries
    ← Back to writing
    Gazebo

    Credential management for AI agents. Control credential retrieval, review access logs, and revoke an agent’s future retrieval without rotating shared API keys.

    Gazebo

    • Account
    • Demo
    • Pricing

    Explore

    • Services
    • Agents
    • Vaults

    Developers

    • Docs
    • SDK
    • CLI
    • API
    • MCP

    Content

    • Writing
    • Topics
    • Blog

    Company

    • About
    • Contact
    • hello@gazebohq.com

    © 2026 Gazebo. All rights reserved.

    PrivacyTermsSecurity