Gazebo
    ServicesAgentsVaultsDocsWritingPricing
    Log inSign up
    Log in
    GazeboWritingClaude Code API Credentials: Setup and Access Boundaries

    Claude Code API Credentials: Setup and Access Boundaries

    Configure Claude Code terminal or desktop MCP access correctly, protect credentials, and separate retrieval permissions from provider operations.

    July 25, 2026·4 min

    Quick answer: Claude Code can use credentials available through its permitted tools and runtime. Configure MCP for the particular terminal or desktop surface, protect its authentication material, and distinguish permission to retrieve a key from permission to use that key at its provider.

    First identify the runtime and its permissions

    Claude Code's effective access depends on file and shell permissions, approval settings, sandboxing and the environment of the process doing the work. The model does not automatically see every environment variable, but a permitted tool may read or disclose one.

    Do not assume every .env file is automatically loaded or that Claude Code always checks environment credentials before tools. A file can be read, a framework may load it, and child processes may inherit variables; these are different access paths.

    A restricted provider key can limit what any consumer does. A broad shared key creates a wider risk, whether delivered through an environment variable or retrieved during a task.

    Choose terminal or desktop setup

    The maintained Claude Code guide separates two paths:

    • Terminal/CLI: remote HTTP MCP configuration and a manual agent token.
    • Desktop Code tab: a Gazebo connector using OAuth, with explicit approval of selected service keys.

    Normal Claude Chat, the desktop Code tab and terminal Claude Code are different execution surfaces. Do not copy one configuration into another and assume it has the same authentication or privacy properties.

    Terminal: use the correct HTTP configuration

    Create an agent and its token at Gazebo Agents. Configure only the retrieval access needed for the intended environment. Use a narrow provider credential underneath that policy.

    For project-scoped configuration, Claude Code documents .mcp.json at the project root—not .claude/mcp.json:

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

    Set GAZEBO_AGENT_TOKEN in the environment inherited by Claude Code. Its interpolation syntax here is ${NAME}, unlike Cursor's ${env:NAME}. Do not put a live token or a secret fallback value in committed JSON.

    Claude Code also supports local and user installation scopes; follow its current MCP documentation for their storage and precedence. A shared project file distributes configuration, not permission to share authentication material.

    Use /mcp or the documented CLI status commands to inspect the connection. Connection health is not proof that retrieval, denial and revocation all work. Gazebo's recorded terminal check covered connection health; see the compatibility guide for the exact test coverage.

    Desktop: approve named keys through OAuth

    In Claude's Code tab, use the connector flow described in the desktop setup guide. Connect the hosted endpoint, authenticate to Gazebo and approve only the keys needed. Do not supply a manual agent token for that OAuth path.

    The desktop Code-session OAuth flow has been tested with fictional data, including identity, named retrieval, retrieval history and rejection after revocation. Detailed evidence is in the compatibility guide.

    Selecting a local coding session does not make a remote connector local-only. The connector infrastructure and host can receive returned credentials.

    Verify with a fictional credential

    Start with get_identity and inspect the configured retrieval access. Then substitute your fictional service and approved key name:

    get_credential({ service: "your-test-service", key_name: "api_key", method: "GET" })
    

    OAuth requests must include the approved key name. The returned value is the actual stored credential, not a new narrowed token.

    Ask the client not to display it, inspect the corresponding event with list_audit_events, and test a retrieval that should be denied using fictional data. Revoke the test connection and confirm a new retrieval fails without signing in again.

    These checks concern Gazebo access. They do not establish which downstream provider operations ran.

    Separate retrieval policy from execution control

    A policy allowing a GET declaration does not make a write-capable Stripe key read-only. Once returned, the key's provider permissions govern its use. Restrict those permissions and apply approvals or sandbox controls at the actual executing tool where appropriate.

    Removing unnecessary inherited credentials can reduce alternative access paths. Do not delete application secrets blindly: identify legitimate consumers, separate environments and remove only access the coding runtime should not have. An instruction to use MCP is not enforcement against other available tools.

    Understand revocation and attribution

    Revoking a Gazebo identity stops future retrieval with that identity. If a key was already received or may have been exposed, restrict, revoke or replace it at the provider as appropriate. That can affect other consumers of a shared key.

    Use distinct identities for genuinely different consumers and environments. Reusing one token across developers or sessions weakens attribution and couples their retrieval revocation. A profile label alone does not prove a human identity or session.

    Gazebo records credential-retrieval attempts, not every API call, prompt or file operation. Investigate unexpected activity using runtime and provider evidence alongside retrieval history.

    For the broader boundaries, see MCP security and environment variables and agents.


    Last reviewed: 8 November 2026. Independent editorial; not affiliated with or endorsed by Anthropic. Setup details should be checked against Claude Code's current documentation.

    Frequently asked questions

    Is Claude Code secure with API keys?

    Assess the actual tools, permissions, sandbox and runtime environment. Use provider-restricted credentials and appropriate execution controls. MCP retrieval can centralise delivery and history, but does not keep a returned key hidden from the runtime or constrain its later provider use.

    How does Claude Code access API credentials?

    Permitted tools may read files, execute code or use inherited environment variables. The model does not automatically see every variable, and not every .env file is automatically loaded. Access and exposure depend on the execution environment and configured permissions.

    What is MCP and how does it help with Claude Code credential security?

    MCP connects clients to tools. Gazebo's MCP tools manage authorised retrieval of stored credentials and expose retrieval metadata. They do not execute provider requests, issue a newly narrowed key or prevent misuse of a credential already returned.

    How do I set up Claude Code with Gazebo's MCP?

    For terminal project configuration, use .mcp.json with type http, the hosted Gazebo URL and a protected manual agent token; documented header interpolation uses ${GAZEBO_AGENT_TOKEN}. The desktop Code tab has a separate OAuth connector path with explicit key approval. Follow the guide for the surface you actually use.

    Can I revoke Claude Code's access without rotating the underlying API key?

    Revoking the Gazebo identity or grant stops future retrieval through that connection. It does not invalidate keys already returned or remove other runtime access. Restrict, revoke or replace an exposed provider key as appropriate, accounting for other legitimate consumers.

    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

    Claude Code

    Service pages

    StripeGitHubVercelCloudflare

    Related reading

    Connect Cursor to Gazebo: OAuth and Credential RetrievalMCP Config Security: Protect API Keys and Bearer TokensSecret Scanning for AI Codebases: Limits and Gaps
    ← 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