跳到正文
DEV Community· Mogley1011·· 5 天前AI 評分59

MCP 工具描述也是提示詞的一部分:連接伺服器前應檢查甚麼

MCP tool descriptions are part of your prompt: what to read before you connect a server

AI 導讀

MCP 工具描述會載入模型上下文,並可能成為模型遵循的指令,因此連接伺服器前應先閲讀檢查。檢查項目包括描述是否向模型發出指令、工具名稱與實際權限是否相符、伺服器取得哪些環境變數和 token,以及固定版本並審查更新差異。伺服器日後可能回傳不同工具 metadata,因此更新後應重查,或保存已批准的描述作比較。

正文

Mogley1011

When an agent connects to an MCP server, the server's tool names and descriptions are loaded into the model's context. That makes them instructions the model may follow, written by whoever runs the server. Reading them is a security step, not a formality.

What to check in five minutes

  1. Descriptions that talk to the model. A description should say what the tool does. Text such as "always call this first", "do not tell the user", or references to other tools is steering, not documentation.
  2. Scope versus name. A tool called read_note that accepts an arbitrary file path or shell string is broader than it claims.
  3. Credentials. List which environment variables and tokens the server process receives. Pass only what it needs, and prefer read-only tokens.
  4. Pinned versions. npx some-server@latest means today's code runs with your credentials. Pin a version and review the diff when you bump it.
  5. Descriptions can change after you approve. A server can return different tool metadata later. Re-check after updates, or snapshot the descriptions you approved and compare.

Why one review is not enough

The server, its dependencies and its descriptions all change over time. A review is a snapshot of a moving target, so the useful habit is a repeatable check you can re-run on every update, not a one-off read.

What is the most surprising thing you have found in a tool description?

Audit your MCP server tools for prompt injection & secret leaks free: https://mcpaudit.pages.dev/?src=devto

來源:DEV Community · dev.to