跳到正文
DEV Community· Jeff·· 14 小時前AI 評分56

如何為 Cursor Agent 精簡並挑選 MCP 工具

Limiting and Cherry-Picking MCP Tools for a Cursor Agent

AI 導讀

為 Cursor Agent 按任務只啟用所需 MCP 工具,可減少工具定義佔用上下文,並降低相似選項造成的誤選。建議按項目保存啟用集合,只在具體步驟需要時加回工具,並關閉不必要的廣泛搜尋、寫入或破壞性操作。若客戶端不支援單工具控制,可按領域拆分伺服器;但過度精簡可能令 Agent 重試、使用錯誤操作或停滯。

正文

Quick answer: When an MCP server exposes dozens of tools, Cursor loads every name and input schema into the agent's working context, which burns tokens and makes the model choose less reliably across many similar options. Cherry-pick the small set of tools the current task actually needs, disable the broad or risky ones, and keep separate enabled sets per project rather than handing the agent the full catalog.

Why a large tool set works against the agent

Each connected server contributes a tool list with a name, a description, and a JSON input schema for every operation. Those definitions sit in the context the model reads before it acts, and they stay there for the whole session. As the count grows, three problems show up.

The schema tokens crowd out room for the actual code and conversation. Similar tools become hard to tell apart, so the model can call the near-match instead of the right one or fill an argument against the wrong schema. A long tool menu also raises the chance the agent reaches for a tool when a direct edit would do, adding round trips. The tools are not bad; exposing all of them at once is a poor default.

What cherry-picking actually means

Cherry-picking is the client-side decision to enable a minimal tool set for the work in front of the agent. Instead of connecting a server and accepting every operation it ships, keep the few tools the task uses and turn the rest off, then expand the set only when a concrete need appears. This is one piece of the broader comparison hub on how client setup and agent behavior interact.

The unit of selection matters. Whole-server toggles are coarse: a server that holds one tool you need and ten you do not forces an all-or-nothing choice. Where the host allows per-tool control, prefer it, and group servers by domain so you can enable a focused set rather than a sprawling one.

How to decide what stays enabled

  1. List the operations the task genuinely calls for, and start with only those tools.
  2. Remove duplicate tools that do the same job through different servers, keeping the one with the clearer schema.
  3. Disable broad or write-capable tools the task does not need, especially anything that deletes or changes shared state.
  4. Keep names and descriptions distinct enough that two enabled tools cannot be confused at a glance.
  5. Save the enabled set per project, and add a tool back only when a step actually requires it.

Keep or disable by tool type

Tool type Default call Reason
Narrow read tools the task uses Keep Low blast radius, directly needed
Write tools for shared state Disable unless required Mistakes are hard to undo
Broad search across a whole system Limit Easy to over-call and flood context
Two tools with overlapping jobs Keep one Removes a near-match misfire
Admin or destructive operations Disable No place in a routine agent run

Honest limits

Host support is uneven. Some clients let you disable individual tools, while others only allow turning a whole server on or off, in which case the fix is splitting servers by domain rather than expecting a toggle the client does not have. Check what the host actually exposes before promising per-tool control.

Over-pruning has its own cost. An agent missing a tool it needs does not fail cleanly; it may retry, approximate with the wrong operation, or stall. The goal is a set matched to the task, not the smallest possible list, and you should re-verify a flow after each change rather than assume a disabled tool went unused. On the server side, a product such as Powerduck keeps its hosted MCP endpoint off until you expose it, issues a separate access key for agents, and lets you switch individual operations on or off, which enforces the same minimal-exposure rule before the client even connects.

Frequently asked questions

Does fewer tools make the agent weaker? Not if the set matches the task. Cutting tools the work never uses removes distractions and misfires; cutting a tool the task needs causes stalls, so the enabled list should follow the actual operations.

How do I know which tools a task uses? Watch a run and note the tool calls, or start from the planned steps and map each to an operation. The recorded calls also reveal tools that looked useful but never fired, which are candidates to disable.

Can I limit tools without client support? Partially. If the host only supports server-level toggles, split servers into smaller domain-focused services or ask the server team to expose a scoped endpoint, since the client cannot hide a tool it has no control over.

The bottom line

Every enabled MCP tool competes for the same limited context and adds another way for the agent to pick wrong. The practical default is a small, task-shaped enabled set with broad and destructive tools off, expanded deliberately rather than loaded wholesale. If you cannot control tools at the client, enforce the boundary by splitting servers or scoping the endpoint, and treat the full catalog as the exception, never the starting point.

來源:DEV Community · dev.to