Class McpToolExecutor
java.lang.Object
dev.langchain4j.mcp.McpToolExecutor
- All Implemented Interfaces:
ToolExecutor
- Since:
- 1.4.0
-
Constructor Summary
ConstructorsConstructorDescriptionMcpToolExecutor(McpClient mcpClient) McpToolExecutor(McpClient mcpClient, String fixedToolName) -
Method Summary
Modifier and TypeMethodDescriptionexecute(ToolExecutionRequest executionRequest, Object memoryId) Executes a tool request.executeWithContext(ToolExecutionRequest executionRequest, InvocationContext context) Executes a tool request.
-
Constructor Details
-
McpToolExecutor
-
McpToolExecutor
-
-
Method Details
-
execute
Description copied from interface:ToolExecutorExecutes a tool request.- Specified by:
executein interfaceToolExecutor- Parameters:
executionRequest- The tool execution request. Contains tool name and arguments.memoryId- The ID of the chat memory. .- Returns:
- The result of the tool execution that will be sent to the LLM.
-
executeWithContext
public ToolExecutionResult executeWithContext(ToolExecutionRequest executionRequest, InvocationContext context) Description copied from interface:ToolExecutorExecutes a tool request. Override this method if you wish to:- access the
InvocationParameterswhen passing extra data into the tool - propagate the tool result object (ToolExecutionResult.result()) into theToolExecution- Specified by:
executeWithContextin interfaceToolExecutor- Parameters:
executionRequest- The tool execution request. Contains tool name and arguments.context- The AI Service invocation context, containsChatMemoryID (seeMemoryIdfor more details), andInvocationParameters.- Returns:
- The result of the tool execution that will be sent to the LLM.
-