Class McpToolExecutor
java.lang.Object
dev.langchain4j.mcp.McpToolExecutor
- All Implemented Interfaces:
ToolExecutor
- Since:
- 1.4.0
-
Constructor Summary
Constructors -
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
-
-
Method Details
-
execute
Description copied from interface:ToolExecutor
Executes a tool request.- Specified by:
execute
in 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:ToolExecutor
Executes a tool request. Override this method if you wish to:- access the
InvocationParameters
when passing extra data into the tool - propagate the tool result object (ToolExecutionResult.result()
) into theToolExecution
- Specified by:
executeWithContext
in interfaceToolExecutor
- Parameters:
executionRequest
- The tool execution request. Contains tool name and arguments.context
- The AI Service invocation context, containsChatMemory
ID (seeMemoryId
for more details), andInvocationParameters
.- Returns:
- The result of the tool execution that will be sent to the LLM.
-