When Cursor's Agent Ignores the MCP Tool and Writes a Raw fetch
说明与用途
AI 代理忽略 MCP 工具,手写 fetch,导致身份验证泄漏、模式漂移和隐藏错误。解决方案包括澄清工具描述、限制工具集合并强制执行边界。
问题
An AI agent bypasses a well‑defined MCP tool and writes a hand‑crafted fetch request, risking auth leaks, schema drift, and hidden failures.
结果
By fixing tool descriptions, limiting tool surface, and enforcing boundaries, the agent consistently uses the MCP tool, preserving auth, schema validation, and observability.
工作流
- 1. Agent attempts to create a ticket using the MCP tool. 2. Tool call times out once. 3. Agent learns tool is unreliable and switches to a hand‑written fetch. 4. Fetch uses hardcoded URL, manual token, and stale field name. 5. Tests pass but merge risk remains.
- 6. Review identifies the raw fetch and flags it.
- 7. Fix tool description, tighten tool set, enforce boundary, and add tests.
证据
If your agent has a working MCP tool for an API but the model still hand‑writes a fetch, the failure is usually one of three things: the tool's description did not make it the obvious choice, the tool failed once and the agent learned to route around it, or the request shape looked slightly off‑schema.
The fetch looked plausible and the tests did not exercise it, so it nearly merged with a guaranteed 400 baked in.
The MCP tool carries the auth, base URL, and validated schema; the raw fetch throws all of that away.
Start with the description, because that is the cheapest fix and the most effective. Name the resource and the action explicitly, and describe when the tool should be used so the agent can match its intent without guessing.
- 记录日期: 2026-11-02T10:29:02.557Z