Skip to content

[Story] mcp_load native tool (dynamic tool attachment escape hatch) #579

@edelauna

Description

@edelauna

Context

When dynamic loading is active (#578), the model may need a tool that wasn't in the initial top-K. `mcp_load` is the escape hatch: the model calls it with a natural-language query, and Zoo Code attaches the matching tools to the next API turn.

Depends on #578. Part 2 of 2 — see also #578.

Developer Notes

  • New native tool definition `src/core/prompts/tools/native-tools/mcp_load.ts`: schema `{ query: string }`.
  • New tool handler `src/core/tools/mcpLoadTool.ts`: calls `ToolRouter.search(query, scopedTools, searchK)`, adds results to `Task.attachedMcpToolNames`, returns the newly attached tool names + one-line descriptions. Idempotent: re-attaching an already-attached tool returns the current list without churn.
  • Register `mcp_load` in the native tool list; include it in the API tools array whenever dynamic loading is active (i.e. threshold was exceeded).
  • Add setting `mcp.dynamicLoad.searchK` (default 10).

Acceptance Criteria

  • `mcp_load` appears in the API tools array when and only when dynamic loading is active
  • Calling `mcp_load("specific query")` adds matching tools to `Task.attachedMcpToolNames`
  • Subsequent API call includes newly attached tools
  • Re-calling with the same query is idempotent (no duplicate entries)
  • Setting `mcp.dynamicLoad.searchK` registered in schema
  • Integration test: model calls `mcp_load` → correct tools attached on next turn

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions