Skip to content

Per-Turn MCP Curation

When several MCP servers are connected, the combined tool list can become large. Sending every tool’s schema to the model on every turn consumes prompt budget and can dilute the tool the model actually needs. The curation subsystem (crates/wcore-agent/src/mcp_curator.rs) trims MCP tools to the top k entries per turn before the system prompt is assembled.

Built-in tools are not curated. Only tools on the mcp__ prefix are affected.

Set the policy in your config file:

# config: ~/.config/wayland-core/config.toml or .wayland-core.toml
[mcp]
curation = { kind = "top_k", k = 15 } # default
# or disable entirely to pass all MCP tools every turn:
curation = { kind = "off" }

top_k is the default when no [mcp] curation key is present. The default k is 15. Set kind = "off" if you have a small number of tools or want deterministic tool delivery.

A project-local config overrides the global value for that project.

McpCurator::curate assigns each MCP tool a score, sorts descending, and keeps the top k entries.

The score for a tool is:

score = (keyword_overlap × 10.0) + (recent_uses × 0.5) + rescue_floor

Keyword overlap: the user’s message is lowercased and split on whitespace; terms shorter than four characters are dropped. For each remaining term the tool’s description is checked for a substring match. The overlap count is the number of matched terms.

Recency boost: the engine reads recent tool usage counts from the audit log (wcore_memory::audit::AuditLog::recent_tool_uses) and multiplies by 0.5. If the audit log is unavailable the map is empty and ranking falls back to keyword-only scoring.

Rescue-tool floor: six tool names receive a fixed bonus of 100.0 regardless of keyword overlap:

Read Grep Glob Edit Write Bash

The floor means these tools always rank at or near the top. The agent retains basic file-access affordances even when the user’s message shares no vocabulary with their descriptions.

A tool with no keyword overlap and no recent usage gets score = 0.0 unless it is a rescue tool. If k is smaller than the number of connected tools, zero-overlap tools are dropped from that turn’s prompt. They remain registered and will reappear on turns where the message does contain matching terms.

apply_mcp_curation in engine.rs splits the tool list on the mcp__ prefix, passes only MCP tools through McpCurator::curate, then recombines the result with built-in tools. From the model’s point of view the prompt simply has fewer tools; no tool is unregistered.

The scoring uses a token-overlap heuristic. The code comments note that F12 GEPA evolution (W10) is planned to replace this with learned weights. Until then the keyword-plus-recency heuristic is the active implementation.