Skip to content

< CollectionsMCP, from the wire up · 5 of 5 ·108 · Level 05, Agents

Vet the MCP Server Before You Trust Its Tools

medium · implement · MCP

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:

  1. changed: the tool's digest differs from its pin.
  2. unpinned: the tool is not in pins.
  3. hidden-instruction: the description hides text from the user, inside <IMPORTANT>...</IMPORTANT>, inside an HTML comment <!-- ... -->, or in the phrases do not tell the user, do not mention or without telling.
  4. secret-path: the description or any argument's description names ~/.ssh, id_rsa, .env, ~/.aws, /etc/passwd or credentials.json.
  5. cross-tool: the description tells the model to hand a result to another of the server's tools, a word pass, send, forward or include and 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.