Tool Use: Agentic Capabilities and Protocols

Tool Use (also known as Function Calling) is the mechanism by which a Large Language Model (LLM) transcends static text generation to perform deterministic actions in the physical or digital world. It transforms the model from a chatbot into a reasoning engine capable of orchestrating complex workflows.

1. How it Works: The Mechanics

The interaction follows a structured Observe-Reason-Act loop. In the Wikantik ecosystem, this is facilitated by the Model Context Protocol (MCP).

The Tool Call Loop

  1. Intent Detection: The model identifies that a user request requires external data (e.g., "Find all pages in the finance cluster") or a mutating action (e.g., "Verify this page").
  2. Schema Selection: The model selects the appropriate tool based on JSON schema descriptions provided in the system prompt.
  3. Parameter Generation: The model generates the arguments for the tool call, adhering to the required types and formats.
  4. Dispatch & Execution: The orchestrator (the client interface) routes the request to the relevant MCP server (Knowledge or Admin). The server executes the deterministic Java code.
  5. Observation: The system returns the tool result (the observation) to the model.
  6. Final Response: The model reasons over the observation to either provide a final answer or initiate another tool call.

Schema Enforcement

Tools are defined using JSON Schema, which acts as the contract between the model and the code.

2. How to Develop Tools: The Developer's Path

Developing new capabilities for Wikantik agents involves extending the MCP surface.

The McpTool Interface

Every tool must implement the com.wikantik.mcp.tools.McpTool interface:

public interface McpTool {
    String name(); // The snake_case name used by the agent
    McpSchema.Tool definition(); // The JSON schema description and arguments
    McpSchema.CallToolResult execute(Map<String, Object> arguments); // The implementation logic
}

Strategic Placement

For a deep dive into the 36+ tools available and how to wire them, see MCP Integration.

Design Principles (See Good MCP Design)

3. How to Utilize Tools: The Agentic Strategy

Effective tool use requires the agent to be "MCP-aware"—knowing which tools to reach for and when.

Selection Strategy (See Finding the Right MCP Tool)

Error Handling & Hallucination Mitigation

A robust agentic loop does not crash on a malformed tool call; it uses the error as feedback.

Security: Human-in-the-Loop (HITL)

For high-stakes environments, mutating tools require explicit user approval. The orchestrator pauses the execution, presents the proposed arguments to the human, and only proceeds upon confirmation.


See Also: