Skip to main content

Module tool_visibility

Module tool_visibility 

Source
Expand description

Pure tool-visibility policy for the MCP tools/list response.

Extracted from the (async, server-bound) list_tools handler so the policy is unit-testable in isolation. The handler resolves the candidate set (lazy-core vs profile-authoritative vs full registry) and the per-call gates (role, workflow), then defers to these helpers for the stable rules:

  • Internal/meta tools are never advertised.
  • The active profile, disabled_tools, and the per-client ClientQuirks (Zed ctx_edit, native-editor ctx_patch) filter the candidates.
  • The universal invoker (ctx_call) is force-advertised in non-full mode so tools hidden by lazy/profile filtering stay reachable.

Structs§

ClientQuirks
Client-specific advertising quirks, resolved once per tools/list from the MCP clientInfo name and the candidate set.

Enums§

CandidateSet
Which candidate pool tools/list starts from, before per-tool gates run.

Constants§

INVOKER
The universal invoker tool name. A static-list MCP client can call any registered tool through it, even when that tool isn’t advertised.

Functions§

advertised_tool_defs_default
Computes the tool set this install advertises to a default client (no client quirks, no role restriction, no workflow gate, static tool list), including the live description compression. Offline counterpart of the tools/list handler for doctor overhead / ContextOverhead::measure — kept next to the pure gates so measurement cannot drift from policy. “No quirks” is the worst case: a client without a native editor sees ctx_patch too, so the reported overhead never understates.
candidate_set
Decides the candidate pool. Single source of truth for the tools/list handler AND offline measurement (doctor overhead), so the advertised surface and the reported overhead can never drift apart.
category_gate_applies
Whether the lazy per-category gate should filter the advertised tool set.
explicit_profile
Whether the user explicitly pinned a tool profile (config key, custom tool list, or env var) — the trigger for CandidateSet::ProfileAuthoritative.
is_tool_visible
Decides whether a tool name should appear in tools/list.
mark_auto_ctx_tool_used
Mark that the agent has invoked a ctx_* MCP tool in this session.
needs_invoker
Whether INVOKER must be force-added to the advertised set.
record_auto_turn
Increment the Auto-profile turn counter (call once per tools/list request).
resolve_auto_profile
Resolve ToolProfile::Auto to a concrete profile using session signals. Non-Auto profiles are returned as-is.
set_auto_system_prompt_tokens
Update the system prompt token estimate for Auto-profile resolution.