Skip to content

[Feature] Support Anthropic Tool Search for MCP tools #18074

Description

@LK-Corporation

Summary

Hermes Agent v0.11.0 sends the full schema of every registered MCP tool on every API call, regardless of relevance to the current turn. With multiple MCP servers connected, this becomes a significant fraction of every prompt.

Anthropic shipped Tool Search Tool (beta) precisely to solve this: tools marked defer_loading: true are not loaded into the model context until the model actively searches for them. The feature is supported across Anthropic API, Bedrock, Vertex AI, and Azure (i.e. all paths Hermes already uses).

This issue requests Hermes config support to opt MCP tools into Tool Search.

Why this matters (numbers)

Concrete sample

A real Hermes deployment (5 MCP servers, 34 tools total, mostly Haiku 4.5 via Bedrock) shows average prompt size 45K tokens/turn, of which ~22K is tool schema overhead (≈50%). Cache miss generations (start of session) cost $0.07-$0.10; cache hits cost $0.007. Tool Search would shrink the schema portion of the cache miss without affecting the rest of the prompt.

Proposed config surface

In ~/.hermes/config.yaml:

mcp_servers:
  vault-bridge:
    transport: streamable-http
    url: http://...:3142/mcp
    defer_loading: true   # NEW: marks all tools from this server as defer_loading=true

  cve-lookup:
    transport: stdio
    command: /usr/bin/node
    args: [...]
    defer_loading: true
    # OR per-tool override:
    tool_overrides:
      cve_lookup: { defer_loading: false }   # always-loaded for hot tools

agent:
  tool_search:
    enabled: true
    variant: bm25   # bm25 | regex
    # When enabled, Hermes adds the tool_search_tool definition to the tools array
    # and sends the `anthropic-beta: advanced-tool-use-2025-11-20` header on Anthropic-family providers

Implementation notes

  1. Header propagation: pass anthropic-beta: advanced-tool-use-2025-11-20 on Anthropic, Bedrock, Vertex, Azure paths. Skip on non-Anthropic providers (graceful degradation — Hermes already supports fallback model logic).
  2. tool_search_tool injection: when agent.tool_search.enabled: true, prepend the synthetic {"type": "tool_search_tool_bm25_20251119"} (or regex variant) to the tools array.
  3. Defer flag: when serializing each MCP-discovered tool to the API request, include defer_loading: <bool> as configured.
  4. Beta MCP header: also requires mcp-client-2025-11-20 per Anthropic docs.
  5. Backward compat: default tool_search.enabled: false, defer_loading: false — opt-in only. Existing deployments unchanged.

Related issues

References

Acceptance criteria

  • mcp_servers.<name>.defer_loading (bool) accepted and propagated to all tools from that server
  • mcp_servers.<name>.tool_overrides.<tool>.defer_loading (bool) optional per-tool override
  • agent.tool_search.enabled: true injects tool_search_tool_bm25_20251119 and advanced-tool-use-2025-11-20 header on Anthropic-family providers
  • No-op on non-Anthropic providers (graceful degradation)
  • Documentation updated in docs/user-guide/features/tools/
  • Telemetry: log when Tool Search is engaged + how many tools were deferred

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/toolsTool registry, model_tools, toolsetsprovider/anthropicAnthropic native Messages APItool/mcpMCP client and OAuthtype/featureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions