Package dev.langchain4j.mcp.client
Class DefaultMcpClient
java.lang.Object
dev.langchain4j.mcp.client.DefaultMcpClient
- All Implemented Interfaces:
McpClient
,AutoCloseable
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
executeTool
(dev.langchain4j.agent.tool.ToolExecutionRequest executionRequest) Executes a tool on the MCP server and returns the result as a String.Obtains the current list of resources available on the MCP server.Obtains the current list of resource templates (dynamic resources) available on the MCP server.List
<dev.langchain4j.agent.tool.ToolSpecification> Obtains a list of tools from the MCP server.readResource
(String uri) Retrieves the contents of the resource with the specified URI.
-
Constructor Details
-
DefaultMcpClient
-
-
Method Details
-
listTools
Description copied from interface:McpClient
Obtains a list of tools from the MCP server. -
executeTool
Description copied from interface:McpClient
Executes a tool on the MCP server and returns the result as a String. Currently, this expects a tool execution to only contain text-based results.- Specified by:
executeTool
in interfaceMcpClient
-
listResources
Description copied from interface:McpClient
Obtains the current list of resources available on the MCP server.- Specified by:
listResources
in interfaceMcpClient
-
readResource
Description copied from interface:McpClient
Retrieves the contents of the resource with the specified URI. This also works for dynamic resources (templates).- Specified by:
readResource
in interfaceMcpClient
-
listResourceTemplates
Description copied from interface:McpClient
Obtains the current list of resource templates (dynamic resources) available on the MCP server.- Specified by:
listResourceTemplates
in interfaceMcpClient
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-