LetterMCP
FeaturesLong read

What an MCP Server Does When an Agent Calls a Tool

Tool descriptions and results act as executable instructions to the model, not inert data.

· 11 min read · Updated
Cover illustration for “What an MCP Server Does When an Agent Calls a Tool”
Features · September 21, 2026 · 11 min read · 2,366 words

A tool call inside the Model Context Protocol follows a fixed, traceable sequence, and most teams running agents in production have never walked through it step by step. That gap, between what the protocol actually does and what teams assume it does, is where the security exposure starts.

MCP came from Anthropic in late 2024, built to standardize how agents connect to outside tools, data, and systems. It rests on three building blocks: executable Tools, addressable Resources, and parameterized Prompts, all passed back and forth over JSON-RPC 2.0. Treat these as the vocabulary for everything that follows.

The sequence itself runs in a fixed order. The agent runtime, acting as the MCP client, opens with a tools/list request to the MCP server. The server answers with the tools it has on offer: names, descriptions, and input schemas, handed to the client and passed straight into the language model. The model reads those specifications and picks a tool, along with the arguments to call it with. The client turns that choice into a tools/call request back to the server. The server then executes the tool against whatever system sits behind it, a database, a SaaS API, a filesystem, and sends back a result. The client appends that result to the model's context, and the model reads it and decides what happens next.

Six steps, one loop. Nothing in that sequence is exotic. A request goes out, a tool gets listed, a choice gets made, a call gets executed, a result comes back, and the model acts on it. The mechanics are plain. What happens the moment that tool description and that tool result land inside the model's context is the subject of the next section.

Why the tool description and the tool result are both executable

The important fact about an MCP tool call is what happens to the output afterward: the tool description and the tool result both land inside the model's context window, and the model treats both as instruction, not as inert data to be parsed and discarded.

Compare this to an ordinary API dependency. When a service like Stripe sends back a response, deterministic code decides what happens with it: a field gets read, a value gets stored, a condition gets checked. Code that ignores stray text is doing its job correctly. An MCP server's response doesn't go through that kind of filter. A language model reads it, and a language model's whole design is to follow instructions found in its context. There is no clean line between "the server's data" and "what the agent should do next," because the thing reading the response can't tell the difference on its own.

So the habits teams bring over from API integration work don't hold up for MCP. Engineers read the documentation, check the schema, confirm the endpoint behaves as described, and move on, the same habit that's served them for every REST dependency they've ever wired up. That habit assumes the response is inert once it's consumed. MCP responses aren't consumed that way. CyberArk's 2025 research found that every field a server controls, tool names, descriptions, arguments, results, error strings, functions as a potential injection channel, because the model reads all of it as context it might need to act on.

The irony sits right at the center of MCP's design goal. The protocol exists to kill the M×N connector problem, the need for custom integration code between every model and every tool. Standardized, model-readable tool definitions solved that problem elegantly. That same standardization, descriptions written in plain language for a model to interpret, is what turns every connector into a possible instruction source.

An MCP server behaves more like a browser extension than a REST dependency. A browser extension runs inside the environment, and its output shapes what gets shown and what happens next. A REST dependency sits at arm's length, and its data gets processed and judged before anything acts on it. MCP servers sit on the extension side of that line: in-process, trusted by default, and capable of shaping the agent's next move through nothing more than the words in a description field. So this is where the real security boundary lives, and this is why platforms like Runlayer place real-time MCP scanning and tool-call-depth policy enforcement at the moment a tool gets listed or invoked, before the model ever reads it.

The attack classes that exploit this boundary, from tool poisoning to confused deputy

Once tool descriptions and tool results count as executable context, you get a specific set of attacks that has no real equivalent in conventional API security.

Tool poisoning is the dominant pattern. An attacker hides instructions inside a tool's name, description, parameter schema, or return values, and the model reads them as part of its working context and follows them. A poisoned tool can ship inside a package, a config file, or a remote server, and it works on every invocation, silently, across every session, until someone finds it, which makes it more durable than a one-off prompt injection. The MCPTox benchmark tested adversarial versions of 353 real tools pulled from 45 live MCP servers against 20 language models, and the average attack success rate was high enough to matter operationally, with the worst case reaching nearly three-quarters against a leading reasoning model.

Rug pulls exploit the gap between approval and execution. MCP includes a notifications/tools/list_changed mechanism that lets a server push an updated tool definition after a client has already connected to it. By default, nothing forces a re-approval, nothing pins a version, and nothing hashes the tool definition to catch a change. A server can look clean during a security review and then quietly swap in a malicious version afterward, with no part of the base protocol built to notice.

Prompt injection through tool results works through the same channel as the first two. Every tool call returns text that gets appended to the model's context, so any MCP server can become a push channel for indirect prompt injection. Whoever controls the contents of a Jira ticket, a Slack message, a database row, or a scraped webpage controls what the model reads on its next turn, and therefore what it decides to do.

Cross-server tool shadowing adds a multi-server dimension. An agent connected to both a poisoned server and a legitimate, high-privilege server can be steered by the poisoned one into calling tools on the legitimate server it would never have called on its own.

Confused deputy attacks turn the agent into an unwitting proxy. Server A returns a result instructing the agent to call a tool on Server B, using a token the agent already holds for Server B. Server B has no way to distinguish that call from a legitimate one, because the agent is presenting valid credentials the whole time. The MCP spec acknowledges this problem directly: it requires that proxy servers using static client IDs get user consent for each dynamically registered client before forwarding to third-party authorization servers, and that rule is straightforward to write down but hard to enforce consistently server by server.

Overprivileged tool scopes round out the picture. A tool built to read one table can carry write access to an entire database, simply because nobody scoped the credentials down after the initial build. An agent calling that tool inherits all of it, quietly, with no warning that the scope exceeds the task.

Six documented production attacks, 2025–2026

The attack classes below have each already shown up in a real, documented incident, confirming that the threat surface described above is being exploited rather than theorized about.

Invariant Labs built a proof-of-concept in April 2025, and it planted an instruction inside a simple_calculator tool. The instruction told the model that, on any call, it should also read ~/.ssh/id_rsa and ~/.cursor/mcp.json and pass their contents through a hidden parameter, turning an innocuous arithmetic tool into a credential exfiltration pipeline.

Koi Security found an npm package called postmark-mcp that mirrored a legitimate email tool faithfully for fifteen clean releases. A later version slipped in one line that secretly copied every email the agent sent to a hidden address, a supply chain insertion that passed through routine version review without raising a flag.

OX Security disclosed a systemic flaw in MCP's STDIO transport on April 15, 2026. The official SDKs, across Python, TypeScript, Java, and Rust, passed user-controlled configuration values in the command field straight to shell execution without sanitizing them first. The command ran on the host even when the target process failed to start as a valid MCP server. The TypeScript SDK carried a second, separate disclosed flaw on top of that, CVE-2026-25536, a cross-client data leak.

CVE-2026-73498 hit the Atlassian MCP integration. Its confluence_upload_attachment tool passed a client-supplied file path directly to open(file_path, 'rb') with no validation step, so any authenticated MCP client could read any file the server process could reach.

CVE-2026-33032, disclosed in March and April 2026, carried a CVSS score of 9.8. The flaw was in nginx-ui's MCP integration, where the message endpoint failed to authenticate command execution requests.

Microsoft Incident Response and Microsoft Defender Research published findings showing how attackers can hijack an agent acting on a user's behalf with nothing more than a poisoned tool description. The scenario involved a finance team's agent connected to a third-party invoice enrichment tool that had been approved once but never given a genuine security review. The attacker updated the tool's description after approval while leaving the visible name and summary untouched, so nothing about the tool looked different to anyone glancing at it.

The Deadbugz campaign, active in August 2026, distributed a malicious MCP server through public GitHub pull requests. A single account filed 23 pull requests across unrelated AI and developer tool projects in a 74-minute window. The server advertised text formatting and summarization. After exactly three tool calls, it rewrote the metadata it returned into instructions that hunted for SSH keys, AWS credentials, shell history, and Kubernetes config, concealing the activity from the user the whole time.

Over 40 CVEs were disclosed against MCP implementations in 2026 alone, and researchers think hundreds of thousands of vulnerable servers are still exposed globally.

How weak authentication and credential models make this worse

These attacks land as easily as they do because most MCP deployments authenticate weakly, hand agents broad credentials, and scope permissions barely at all, which turns every tool call into a possible lateral movement path.

The common production pattern is this: a long-lived API key sits in an environment variable, handed to the agent with the full authority that key carries. No scoping down. No delegation. No real record of who or what the agent is acting as, or what it should and shouldn't be able to touch. More than a third of live MCP servers scanned by researchers run with no authentication at all, and researchers estimate 200,000 vulnerable MCP servers are exposed worldwide; a meaningful share of them leak credentials through hard-coded values sitting in configuration files.

The July 28, 2026 revision to the MCP spec, described by the protocol's lead maintainers as the largest revision since launch, takes this on directly. MCP servers are now formally defined as OAuth 2.1 resource servers. Servers must implement OAuth 2.0 Protected Resource Metadata, so a client can find the correct authorization server instead of having to guess. Clients must implement Resource Indicators, binding a token explicitly to the server it's meant for, which stops a malicious server from grabbing a token issued for a different one.

Enterprise-Managed Authorization was promoted to stable status in the same revision, and it closes the enterprise single sign-on gap: organizations can control MCP server access through their existing identity provider, with a zero-touch flow for end users. Anthropic, Microsoft, and Okta have adopted it. Asana, Atlassian, Canva, Figma, Granola, Linear, and Supabase support it on the server side.

EMA still leaves a hole. It's built for employees who reach MCP servers through an approved client, so it doesn't by itself establish a workload identity for an autonomous agent running with nobody present; the OAuth Client Credentials extension is meant to cover that separate problem. The sound credential model, a centralized vault that holds the actual credentials, handles the OAuth flows, and rotates secrets without the agent or the developer ever touching the raw values, points in the right direction. Most production deployments remain nowhere close to it. MCP servers behave more like in-process extensions than arm's-length API dependencies, so closing that gap needs continuous visibility into every tool definition and every result, and that is what an MCP control plane runs across every connection in an agent's environment to catch instruction injection before it executes.

Enterprise Governance: Registry, Identity, and Runtime Controls

Everything above points to the same conclusion: securing MCP at enterprise scale means controlling three things at once, which server a tool comes from, who or what is calling it, and what happens at the moment it runs.

An organization needs a single, authoritative list of every MCP server connected anywhere in its environment, what tools each one exposes, and what version of each tool definition was last reviewed. Without that list, a rug pull or a post-approval description change has nothing to be checked against.

Identity comes second. Every agent needs a scoped, revocable, individually identifiable credential rather than a shared long-lived key with blanket authority. OAuth 2.1 as a resource server model, Protected Resource Metadata, Resource Indicators, and Enterprise-Managed Authorization all move toward this, but none of them substitute for an organization actually assigning distinct identity to each agent and workload.

Runtime controls come last, and they matter most at the exact moment described at the start of this piece: the point where a tool description or a tool result lands in the model's context. Tool poisoning, rug pulls, and result-based prompt injection all exploit that same executable quality of MCP output. That is why enterprise deployments increasingly lean on platforms that enforce policy at tool-definition and tool-call depth, with tamper-proof audit trails covering every MCP interaction. That enforcement point sits exactly where the protocol sequence traced earlier hands control from server to model: the place where the boundary either holds or doesn't.

Sources

  1. Unsafe by Flow: Uncovering Bidirectional Data-Flow Risks in MCP Ecosystem
  2. The 2026-07-28 Specification
  3. MCP Security Crisis: Systemic Design Flaws in AI Agent Infrastructure
  4. MCPThreatHive: Automated Threat Intelligence for Model Context Protocol Ecosystems
  5. microsoft.com
  6. Enterprise-Managed Authorization: Zero-touch OAuth for MCP
  7. When MCP Servers Attack: Taxonomy, Feasibility, and Mitigation

More in Features