Vet the MCP Server Before You Trust Its Tools
A tool's description is a prompt the model reads, and an MCP server can change it after you approved it. Write three functions that pin a server's tools and check them before use. Each tool is {"name": ..., "description": ..., "input_schema": {"properties": {arg: {"description": ...}}}}.
pin(tools) returns {name: digest}, where digest is the sha256 hexdigest of the tool's spec as canonical JSON (json.dumps with sort_keys=True and separators=(",", ":")).
vet(tools, pins) returns findings, one per problem, {"tool": name, "code": code, "detail": text}, in the order the tools are given, and for one tool in this fixed order of codes:
changed: the tool's digest differs from its pin.unpinned: the tool is not inpins.hidden-instruction: the description hides text from the user, inside<IMPORTANT>...</IMPORTANT>, inside an HTML comment<!-- ... -->, or in the phrasesdo not tell the user,do not mentionorwithout telling.secret-path: the description or any argument's description names~/.ssh,id_rsa,.env,~/.aws,/etc/passwdorcredentials.json.cross-tool: the description tells the model to hand a result to another of the server's tools, a wordpass,send,forwardorincludeand another tool's name in the same sentence.
allowed(tools, pins) returns the tools, in their original order, that vet found nothing wrong with.
Text matching is case insensitive. A tool can earn several findings.