Securing Claude Tool Use with MCP

Model Context Protocol makes it easier for Claude applications to connect to tools, data sources, and external services. That flexibility also changes the security boundary. Once an agent can read files, call APIs, create tickets, modify repositories, or act on business systems, the risk is no longer limited to generating an incorrect answer. The model can cause an external side effect. Secure tool use therefore requires controls around identity, authorization, scope, tool definition, user consent, untrusted content, logging, and human confirmation. The core principle is that MCP standardizes capability exposure, but the application must still enforce identity, permissions, audit policy, and approval around those capabilities.

Production security begins when you ask what a compromised or confused agent could do through each connected server.

Start with the smallest tool surface

Every exposed tool adds capability the model can potentially invoke. Do not connect a broad administrative API when the workflow only needs one read operation. Prefer narrowly scoped functions with explicit parameters and predictable responses. Anthropic’s tool-use guidance emphasizes detailed tool descriptions, clear parameter schemas, and high-signal responses. Good definitions improve tool selection, but they also make security review easier because the intended action is unambiguous. Separate read tools from write tools where practical. The application can allow broad read access while requiring additional approval or credentials for changes.

A secure MCP deployment is not finished at launch. New tools, scopes, and model versions change the risk surface and should trigger review. The strongest agent architecture assumes the model can misunderstand a request, encounter malicious content, or choose the wrong tool. Security comes from making those mistakes survivable: narrow permissions, validated parameters, safe destinations, explicit consent, reversible workflows, human review, and complete evidence. MCP standardizes how tools are described and connected, but it does not turn tool calls into trusted actions automatically. Conventional application security still applies, and agent-specific threats add another layer.

MCP server inventory should be governed like any other integration inventory. Record owner, purpose, data accessed, credentials used, scopes granted, allowed clients, network exposure, version, and review date. Remove servers that no longer have a business owner. A forgotten local or remote server can become a durable path to sensitive capabilities long after the original prototype is abandoned.

For local developer MCP servers, consider the host itself part of the trust boundary. File-system access, shell execution, browser control, and source-code credentials can make a local server extremely powerful. Use separate development profiles, review install sources, and avoid enabling high-privilege servers globally when only one project requires them.

Least privilege belongs at the credential layer

Prompt instructions are not an access-control system. Even if the agent is told never to delete records, the backing credential should not have deletion permission unless deletion is required. Use dedicated service identities, minimal OAuth scopes, resource-level restrictions, environment separation, and short-lived credentials where supported. A tool server should enforce authorization independently of whatever the model asks it to do.

MCP authorization must preserve user consent

The MCP security guidance documents confused-deputy risks when a proxy server connects clients to third-party APIs. If authorization is not tied correctly to the requesting client and user, a malicious flow can exploit existing consent and obtain access that the user did not intend.

Per-client consent, redirect validation and token isolation remain necessary. In the July 2026 MCP authorization specification, the OAuth client identifies the intended MCP server through a resource parameter in both authorization and token requests. The client also validates an authorization response’s iss against the expected, previously verified authorization-server issuer when that field is present, and rejects its absence when the server’s metadata says it will be supplied. One user’s earlier consent must not silently authorize a different client or service.

For a remote server, MCP’s token audience requirements put a separate check at the resource server: reject tokens that were not issued for that MCP server, then evaluate the requesting principal’s permitted action. Neither a client-supplied name nor a plausible model-generated parameter proves identity or consent. When the server also calls a CRM or other downstream API, obtain a separate appropriate downstream token rather than passing through the MCP access token. These are standard web-security problems expressed through an agent protocol. OAuth still needs the same discipline it requires outside AI systems.

A hypothetical data assistant might connect to a CRM through one MCP server while several separate Claude clients use that server. User approval for the first client must not silently authorize a different client to read the same records. The authorization flow should bind the right user, client and server, validate redirect targets and token audience, and grant only the scopes needed for the specific capability. A token intended for looking up contact details should not grant bulk export or contact deletion. The server must reject unauthorized calls even when the model supplies plausible tool arguments or points to an apparently valid prior consent screen.

During review, test deliberate cross-client confusion, an expired authorization grant, and an instruction embedded in a retrieved contact note that asks the agent to export unrelated records. The expected behavior is straightforward: enforce the permission decision outside the model, treat the note as untrusted data, and record any rejection for investigation without revealing sensitive token material in logs. The goal is not to make Claude memorize security policies; it is to build an integration whose authority remains correct when Claude makes an incorrect suggestion.

Do not pass third-party tokens through blindly

MCP guidance warns about token passthrough because a server that simply forwards tokens can lose control over audience, scope, and validation. Tokens should be accepted and used only in the context they were issued for. The server should validate credentials, enforce expected audiences and scopes, and obtain appropriate downstream authorization rather than acting as an opaque credential tunnel. This matters especially for multi-tenant or enterprise systems. One compromised integration should not let an agent reuse a token against a different resource.

Secrets should be injected at execution time rather than exposed to the model or stored in tool descriptions. The agent usually needs the capability, not the credential value. Keep tokens out of prompts, logs, and tool results, rotate them through the underlying secret-management system, and scope them to the exact server or downstream service.

Remote tool inputs can create SSRF and destination risks

Tools that fetch URLs, connect to services, or follow user-provided endpoints can create server-side request forgery risk. A malicious input may try to make the MCP server reach internal metadata, private services, or unexpected networks. Validate destinations, restrict schemes and hosts where possible, resolve redirects carefully, and isolate the tool runtime from sensitive internal networks. Do not assume that because Claude generated the URL it is safe. The same principle applies to file paths, repository targets, cloud resource identifiers, and shell commands: validate tool parameters at the execution boundary.

Network egress is another control surface. An MCP server that only needs to reach one SaaS API should not automatically have unrestricted outbound access to the internet or internal infrastructure. Egress allowlists, proxy controls, DNS policy, and runtime isolation can reduce the damage if a tool is abused or an SSRF defense fails.

Prompt injection turns retrieved content into a security problem

An agent may read a webpage or document that contains instructions aimed at the model rather than the human. If the application lets retrieved content influence tool selection without guardrails, an attacker can attempt to redirect the workflow. Treat external content as untrusted data. Keep system policy separate, scope tools narrowly, validate high-impact parameters, and require confirmation for consequential writes. Show provenance when a proposed action depends on external content. Teams should know which tool calls occurred, what source content preceded them, and whether approvals were bypassed or denied.

MCP’s July 28, 2026 release removed the protocol-level session and Mcp-Session-Id header, along with the old initialization handshake. The current stateless protocol carries its protocol version and client capabilities on each request. Those metadata fields describe the protocol request; they are not a substitute for authenticated credentials, user consent or server-enforced access control.

Applications may still need state across tool calls. As the official state-handle security guidance explains, an explicit workflow or cart handle is not proof of the caller’s identity: generate non-predictable handles, bind them to a verified principal, enforce authorization on every use, expire them appropriately and do not expose them in public logs or tool output unnecessarily. The risk shifts from relying on one transport session to preventing cross-user access through ordinary application state.

Version matters when reviewing older installations. MCP servers still using the 2025-11-25 protocol or an earlier implementation may have protocol-managed session identifiers; those need their version-appropriate protections and migration review. For a deployment using 2026-07-28, inspect per-request authorization, application handles and actual tool effects instead of treating a missing Mcp-Session-Id as a security fault. Keep enough redacted audit context to investigate rejected or suspicious calls without recording tokens. Local MCP servers require care too. A compromised local server can inherit meaningful access to files, credentials, or developer systems. Install servers from trusted sources and review what permissions they actually receive.

Tool output needs validation too. A server can return malformed data, unexpected HTML, instructions embedded in text, or fields that do not match the semantic promise in the tool description. Treat tool results as untrusted external input unless the application has independently verified the source and structure. Structured response schemas can reduce ambiguity, but business validation is still required.

Human confirmation should protect irreversible actions

High-impact tools should present the proposed action before execution. A reviewer should see the destination, important parameters, scope, and expected effect. Confirmation is strongest when it is specific, not a generic “allow tool?” dialog. Build different policies for different tool classes. Reading a public issue may run automatically. Creating a draft may need lightweight confirmation. Merging code, deleting data, sending funds, or changing production access may require stronger approval or a separate workflow. Human review does not replace authorization. It adds another control when consequence justifies it.

Separate discovery from execution when the workflow is sensitive. One tool can search or propose targets, while a different, more restricted tool performs the write after policy checks. This prevents a malicious source from both choosing the destination and authorizing the action in one step. The pattern is especially useful for file changes, repository operations, account management, and financial workflows.

Logging should capture intent, execution, and result

For every meaningful tool call, preserve who initiated the request, which model and agent handled it, which tool was selected, the validated parameters, approval state, execution result, and relevant error. Sensitive values may need redaction, but the audit trail should still explain what happened. Use those logs for evaluation as well as incident response. Which tools are frequently rejected by users? Which parameters need correction? Which external sources precede suspicious requests? Operational evidence can reveal where the agent design needs tighter controls.

Include negative tests in release evaluation. Attempt an unauthorized resource, an unexpected redirect, an overbroad scope, a prompt-injection payload in retrieved content, a malformed tool result, and a high-impact action without approval. The system should reject or contain each case predictably. Security is stronger when failure behavior is tested deliberately rather than inferred from the happy path.

img