mcp-use TypeScript API
    Preparing search index...

    Function useDynamicTool

    • Call a tool whose registration cannot be represented by an exported ToolRef, such as a tool created from a loop, runtime configuration, or an OpenAPI document.

      Prefer useCallTool for statically declared tools. This explicit escape hatch requires callers to supply the contract because TypeScript cannot infer runtime-only registrations.

      Type Parameters

      • Args extends Record<string, unknown>

        Explicit tool argument object type.

      • Result = unknown

        Expected structuredContent type for a successful result.

      Parameters

      • name: string

        Runtime-registered tool name.

      Returns CallToolHandle<Args, Result>

      A call handle using the explicitly supplied contract.

      const lookup = useDynamicTool<{ id: string }, { value: string }>("lookup");
      const result = await lookup.callTool({ id: "item-1" });