An integration is secure or insecure at each hop: user to application, application to Claude, the host to a tool, the tool to a downstream system. At every hop ask three questions. Who is the caller (authentication)? What may that caller do (authorisation)? Where does the secret live, and for how long (credential lifecycle)? Most gaps in Claude integrations are a hop where the answer is "nobody checked", because a shared credential or a prompt instruction stood in for a real control. This lesson is architect-level analysis, not SDK how-to; capability scope is Lesson 1.1 and guardrail layers are Domain 4.
Credentials for the Claude API itself
Anthropic's authentication docs describe three methods: an API key (a static secret sent as a bearer token; the legacy x-api-key header is still accepted), Workload Identity Federation (a short-lived token exchanged from your identity provider, so no static secret is distributed or rotated) and App Attest (short-lived tokens for attested iOS and macOS installations that call the API directly). The design questions:
- Static or short-lived? Static keys suit development and servers with good secret storage. For production on a cloud platform, CI or Kubernetes, federation removes the long-lived secret, though it is only as strong as your identity provider's configuration.
- Whose identity does the key carry? Personal and service-account keys act as an identity and stop working when it is removed; the legacy workspace key belongs to no one and can outlive its creator. Shared or automated workloads should use a service account, not a person's key.
- How wide is it? A key can be scoped to one workspace. Separate workspaces and keys per environment or team bound a leak or a runaway loop and make usage attributable. Set an expiration at creation, but it does not replace a secrets manager.
- Where can it be read? Never in a prompt, log, repository (history counts) or client-side code. Browser and mobile clients call your backend, which holds the credential and can authorise and rate-limit per user; App Attest is the documented option for iOS and macOS apps calling the API directly.
Credentials and identity for tools and MCP servers
The model must never hold a secret. Credentials are attached by the tool implementation or the MCP host on the outbound call, never placed in the prompt. Some specifics worth knowing:
- With the Messages API MCP connector, the
authorization_tokenin the server definition is a credential your application obtained and must refresh; treat it like an API key. The connector is beta and not covered by zero-data-retention arrangements, which matters for data-flow reviews. - Claude Code's
.mcp.jsonsupports${VAR}expansion, so the file is shared while each developer's token stays local. Claude Code also reads credential variables such asANTHROPIC_API_KEYas empty in remote servers' URL and headers so a shared config cannot leak them. - For local stdio servers the MCP specification says to take credentials from the environment rather than run the HTTP authorisation flow. A local server runs with the client's privileges, so a malicious startup command is arbitrary code execution; require explicit consent and sandbox it.
Per-user or shared identity: the confused deputy
The most consequential decision is whether a tool acts as the end user or as the service. A shared, broadly scoped service account makes the agent a confused deputy: it holds authority the requesting user lacks, and anything that steers it (a user request, or an instruction injected through tool output) can spend that authority. Delegated per-user tokens keep the downstream system's own authorisation in the loop. The MCP specification sets the rules for HTTP servers. The points below hold in revision 2025-11-25 and in the current 2026-07-28 revision; check the current revision before relying on section details:
- A protected MCP server is an OAuth resource server. Clients must send the RFC 8707
resourceparameter, and the server must validate that a token was issued for it. - Token passthrough is forbidden. A server must not accept tokens not issued for it, nor forward the client's token upstream; when it calls an upstream API it uses a separate upstream token. Passthrough defeats audience controls and blurs the audit trail.
- An MCP proxy using a static client ID with a third-party authorisation server, dynamic client registration and a consent cookie is a classic confused-deputy target, so it must obtain per-client user consent before forwarding.
- Scope minimisation: start with low-risk scopes and escalate through scope challenges (403
insufficient_scope); avoid wildcard or all-scopes tokens, which enlarge the damage of a theft. - A session ID or state handle is not authentication: every inbound request must be verified. The 2026-07-28 revision is stateless with no protocol-level sessions, so servers that need state mint an explicit handle, and the same rule applies to it.
Key concept: check authority where the data lives
The system that owns the data must decide, with the requesting user's identity, whether the call is allowed. A prompt, a tool description or an agent-side allowlist can reduce what the agent tries; only the resource can refuse what the agent is permitted to do.
Enforcement layers, from weakest to strongest
- Prompt or description ("only read"): guidance only; an injected instruction can override it.
- Agent-side permission rules: Claude Code evaluates deny, then ask, then allow, first match wins. Its Bash argument patterns are documented as fragile, so use the sandbox or a hook when a restriction must hold.
- Tool design: a
get_order_status(order_id)tool rather thanquery_database(sql); an MCP allowlist that fails closed. - Credential scope: a read-only database role or a narrowly scoped token behind the tool, so even a hijacked call cannot write.
- Resource-side authorisation with per-user identity, plus audit logs that record the user and the agent action.
For one-off privileged work, grant access for the task or session and revoke it afterwards; standing access granted for a past task is exactly what a later injection exploits.
Common exam distractor
"The key is no longer in the repository, so it is safe" ignores history, logs, tickets and chat, so rotate anything ever exposed. "Forward the user's token to the downstream API for simplicity" is the forbidden passthrough pattern. "MCP is an official protocol, so its servers are trusted" confuses the protocol with a particular server: a third-party server's tool results are untrusted input. And "log every call" is detective, not preventive, so it never closes an authorisation gap.