You approved that MCP tool. How would you know if it changed?

2026-12-06来源 dev.toEnglish

You read the tool list. You clicked approve. Then the MCP server went on living its own life.

That is not a scandal. The spec expects it. A server that declares the listChanged capability can send a notifications/tools/list_changed message when its tools change, and the client then asks for the list again (MCP tools spec). Tool lists are meant to move.

So here is the question I want you to be able to answer: if the description of a tool you approved changed next week, would you know?

I am not saying your client ignores changes. Some will tell you, some may not, and I have not tested every one. This is a cheap check you control, no matter which client you use.

Why the description matters

The model reads tool names and descriptions to decide what to call and how. The spec also says clients must treat tool annotations as untrusted unless they come from a trusted server. A changed description is a changed instruction to your agent, written by whoever runs the server.

An update can be innocent. A new tool can be great. You just want to see it before the agent does.

The fix: pin the tool list, then diff it

Same idea as a lockfile:

  1. Ask the server for tools/list.
  2. Save every tool definition (name, description, input schema, annotations) to a JSON file.
  3. Commit that file.
  4. Before you start your agent, ask again and compare.

Here is a small script that does it for any stdio MCP server. Save it as mcp_pin.py. Python 3, no dependencies:

#!/usr/bin/env python3 """Pin and diff the tool definitions an MCP stdio server advertises. python3 mcp_pin.py pin mcp-tools.lock.json -- npx -y some-mcp-server python3 mcp_pin.py check mcp-tools.lock.json -- npx -y some-mcp-server """ import json, subprocess, sys def rpc_session(cmd): p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True) def send(msg): p.stdin.write(json.dumps(msg) + "\n"); p.stdin.flush() def call(i, method, params=None): send({"jsonrpc": "2.0", "id": i, "method": method, "params": params or {}}) while True: line = p.stdout.readline() if not line: sys.exit("server closed the pipe") msg = json.loads(line) if msg.get("id") == i: if "error" in msg: sys.exit(f"{method} failed: {msg['error']}") return msg["result"] call(1, "initialize", {"protocolVersion": "2025-06-18", "capabilities": {}, "clientInfo": {"name": "mcp-pin", "version": "0.1"}}) send({"jsonrpc": "2.0", "method": "notifications/initialized"}) tools, cursor, i = [], None, 2 while True: res = call(i, "tools/list", {"cursor": cursor} if cursor else {}) tools += res["tools"]; i += 1 cursor = res.get("nextCursor") if not cursor: break p.terminate() return {t["name"]: t for t in tools} def main(): mode, lock = sys.argv[1], sys.argv[2] cmd = sys.argv[sys.argv.index("--") + 1:] now = rpc_session(cmd) if mode == "pin": json.dump(now, open(lock, "w"), indent=2, sort_keys=True) print(f"pinned {len(now)} tools to {lock}") return old = json.load(open(lock)) bad = False for name in sorted(set(old) | set(now)): if name not in now: print(f"REMOVED {name}"); bad = True elif name not in old: print(f"NEW {name}"); bad = True elif old[name] != now[name]: keys = [k for k in set(old[name]) | set(now[name]) if old[name].get(k) != now[name].get(k)] print(f"CHANGED {name}: {', '.join(sorted(keys))}"); bad = True print("tool list matches the pin" if not bad else "review the changes above before you approve") sys.exit(1 if bad else 0) main() 

Pin once, after you have read what the server offers:

python3 mcp_pin.py pin mcp-tools.lock.json -- npx -y @modelcontextprotocol/server-filesystem /tmp # pinned 16 tools to mcp-tools.lock.json 

I ran that on the official filesystem server while writing this, and it found 16 tools. Your number may differ by version, which is exactly the point.

Check before each session:

python3 mcp_pin.py check mcp-tools.lock.json -- npx -y @modelcontextprotocol/server-filesystem /tmp # tool list matches the pin 

To see what a change looks like, I wrote a tiny demo server and made it add a sentence to one description and add a tool. The check output:

NEW export_all CHANGED read_order: description review the changes above before you approve 

The exit code is 1 when anything differs, so it works in a Makefile, a shell alias or CI.

Where to run it

  • Before you launch the agent. A one-line alias is enough: run the check, and only start the agent if it passes.
  • When .mcp.json or your Codex config changes. Run pin, then review the lockfile diff in the pull request like any dependency bump.
  • After you update a server. Update on purpose, pin again, read the diff.

Also pin the package version in the server command, for example npx -y some-server@1.2.3, so "latest" does not move under you. The lockfile tells you what changed. The version pin makes changes happen when you choose.

What this does not catch

Be honest with yourself about the limits:

  • Behavior behind the same definition. If the code changes but the tool name, description and schema stay the same, the pin sees nothing. Version pins, reading the source and a sandbox cover that.
  • Changes mid-session. This checks at the start. A list_changed notification while the agent is running is your client's job.
  • Only tools. Servers can also offer resources and prompts. Same idea, same script with another method, if you use them.
  • Only stdio. Remote servers over HTTP need a different transport and, usually, auth.
  • A server that answers differently to different callers. Cannot rule that out from outside.

A pin is a smoke alarm, not a vault. The vault part is cutting down what the agent can reach in the first place, and the free Agent Blast Radius Checklist walks you through that.

The 5-minute checklist

Do this Why
List every MCP server your agent can start You cannot pin what you forgot you installed
Pin each server's version in its command Updates happen when you choose
Run pin, read the file, commit it Your approved baseline
Run check before sessions or in CI Changes become a diff, not a surprise
Re-pin only after reading the diff The review is the whole point
Give each server the least access it needs Pins tell you about change, permissions limit the damage

Want the full checklist?

I keep a free 9-page Agent Blast Radius Checklist for this kind of review. It helps you see what your coding agent can read, run and reach on your machine, then cut it down in about 30 minutes. Built for Claude Code and Codex users. Grab it free here.

If you also want the bigger picture of where AI agents meet keys, wallets and signing power, the free AI + Blockchain Map is a 10-minute start, and Agent Security When Agents Hold Keys ($12) goes deeper. All ten guides are in one $39 bundle.

The script is also in the open-source repo, and the newsletter is at https://paxtechservices.substack.com if you want more notes like this.

I'm PTS, an IT and security consulting shop. Corrections welcome in the comments. Not affiliated with Anthropic, OpenAI or the MCP project.

原文:https://www.a8q9.cn/en/article/you-approved-that-mcp-tool-how-would-you-know-if-it-changed-859538.html

相关文章