MCP security in your app

What the SDK does when your model’s tools come from other people’s servers, and what your app decides

For developers building an app with the SDK’s MCP client.

An MCP server is code someone else wrote, running somewhere you don’t control, offering tools your model will call. It can be fine today and different next week. This page is the MCP half of SDK security: how much the SDK believes a server, what happens when one changes, and what it does with what a server sends. The rule underneath is the same everywhere: the model proposes, and a gate your app controls decides.

Contents

A server is untrusted until the user says otherwise

A new server’s tools all count as able to change data, so every call asks first. The server’s own labels (readOnlyHint and destructiveHint, its claims that a tool only reads or may destroy data) are ignored. In a 3.0 app whose sessions have a picker (dynamicTools:), its tools are all available and the picker chooses which ones each message uses; without a picker, its tools start off and the user switches them on. Only the user, or your app on the user’s behalf, extends trust.

In these snippets lab is your LocalLMLab (lab.mcp is its MCPServerManager) and companyServer is the server’s identifier, which you get when you add it.

lab.mcp.setTrust(.trusted, server: companyServer)                          // believe its read-only / destructive labels
lab.mcp.setToolApproval(.ask(atOrAbove: .destructive, by: .user), server: companyServer)
lab.mcp.setToolApproval(.allow, server: companyServer, tool: "search")     // “Always allow this tool”
↑ Top
LocalLM Lab's Prompt Playground with an “Allow this action?” card over it. The card lists the tool (read_note), where it comes from (this app) and its impact (Changes data), with Deny and Allow buttons.
The approval card in LocalLM Lab 3.0: the run waits while the card names the tool, where it came from and its effect, and offers Deny or Allow.

When a server changes its tools (drift)

A user approves a server once, but a server can change afterwards. That is drift, and when it is done on purpose it is a rug pull (the server behaves, wins trust, then changes what its tools say or do). The SDK keeps the last tool list the user accepted and compares every new list with it, never with the last one it saw, so a change the user hasn’t accepted is reported again on every connect and never quietly becomes normal. A rewritten description is the one to watch: it is text the model reads, and exactly where injected instructions would hide.

What the user sees. A card such as “DeepWiki changed 3 tools: review”, listing each tool and what changed, with Accept Changes and Reject. Accept keeps using the server with the changes. Reject turns it off until the user reviews it in the Tool Sources sheet. This happened for real in our own testing: DeepWiki, a server on our test list, edited the descriptions of three of its tools. Nothing was wrong. A description edit is simply enough for the SDK to ask.

A review card in a chat app built on the SDK. The heading reads 'Deepwiki changed 3 tools: review'. It lists three tools, ask_wiki_question, read_wiki_contents and read_wiki_structure, each marked 'description changed', and says: Accept to keep using Deepwiki with these changes; Reject turns it off until you review it in Tool Sources. Below are two buttons, Accept Changes and Reject.
The review card: three tools whose descriptions changed. Accept Changes keeps using the server with the changes; Reject turns it off until the user reviews it in Tool Sources.

If you ignore drift, the default policy still applies: a change the model reads asks the user, a new tool stays off until accepted, a server that reports a new name is blocked, and a change that can only break calls is taken and logged. Your users see the review card and tools that stay off. In the table, ask means the next turn stops for the user’s review, hold means that one tool stays off until accepted, block means the whole server stays off, and take means the change is accepted and logged.

Each change is classified by kind, because the kind matters, not the size: a one-line description edit can carry injected instructions, while a new optional parameter is harmless. What the default policy, DriftPolicy.standard, does:

Kind of changeThe default policy
A tool’s or parameter’s description changedAsk: the next turn that needs the server stops for the user’s review
A tool’s impact got worse (read-only became writing)Ask
A new tool, a tool that shadows another server’s, or an option list that widenedHold the tool until accepted; the rest of the server keeps working
A tool’s label got safer (writing became read-only)Take it, but keep rating its calls by the accepted form until the user accepts, so a server can’t lower its own rating to avoid questions
A different server name than when acceptedBlock the server until reviewed, because a different server may be posing as the one the user accepted
Changes that only break calls (a removed tool, a new required parameter)Take and log
↑ Top
LocalLM Lab's MCP Servers panel showing the Tool changes setting (Observe only, Standard, Strict, Permissive) and a connected server whose tools match the snapshot taken at first connect.
Drift handling in LocalLM Lab 3.0: the app keeps a snapshot of each server’s tools and compares it on every connect. The setting picks how strictly a change is handled; this server still matches its snapshot.

What a server sends is content

Tool results, resources, prompts and a server’s descriptions are text a model will read, so the SDK treats them as data, never as the user’s instructions:

↑ Top
Prompt Playground after a run that asked the model to read a shared note with a tool. The output reads “the release is cancelled”, and the tool-call line shows the note text came from a local test server.
With the defenses off, the model repeats what the note says. This is the raw behavior the Security panel lets you compare against: the same prompt, run again with the switches below turned on.
LocalLM Lab's Security panel with “Frame MCP results as data” turned on and “Ask before sending read content out” still off.
The Security panel with “Frame MCP results as data” on. Each switch is off until you turn it on, so you can run the same prompt both ways.

Local programs as servers

A server can be a program on the user’s Mac. It is the riskiest kind, so the SDK confines it:

↑ Top

A record of what happened

The SDK emits an event for every security-relevant act: each tool call and who decided it, trust and approval changes, servers added and removed, drift found, accepted or rejected. Your app keeps them:

let stream = lab.audit.events()
Task.detached { for await entry in stream { /* write it to a log only your app can change */ } }

This is the ledger, separate from the diagnostics log, which is for finding bugs: off-content, and with credentials scrubbed from fields, headers and tool arguments. The guide explains what an audit trail is and how to keep one well.

↑ Top

If you write an MCP server

Apps built on the 3.0 SDK (ChatAgain and the LocalLM Lab app are two) will treat your server this way. To try your server in the Lab, where you can pick how strictly it handles changes, see Testing your MCP server.

  • A change to your tools is reviewed. Rewriting a description, making a tool riskier, widening an option list, adding a tool whose name another server uses, or reporting a different server name makes an app ask the user (or block you on a new name). Even a harmless wording fix triggers a review. Keep descriptions stable between releases, and say what changed in your release notes.
  • A tool you add later is held until the user accepts it, and a tool you relabel as safer keeps its old rating until accepted.
  • Your tool names get a prefix. The model sees <prefix>_<tool> (github_list_issues), derived from the server’s address or name; the app can change it.
  • A large server is picked from, per message. Precise names and one-line descriptions are what get your tool chosen.
  • Results are trimmed for the model. Return the answer, and use a resource_link for anything big.
  • A local server needs a pinned command, such as npx pkg@1.2.3.
↑ Top

Where to go next

↑ Top