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 TypeMethodDescriptionvoidclose()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:McpClientObtains a list of tools from the MCP server. -
executeTool
Description copied from interface:McpClientExecutes 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:
executeToolin interfaceMcpClient
-
listResources
Description copied from interface:McpClientObtains the current list of resources available on the MCP server.- Specified by:
listResourcesin interfaceMcpClient
-
readResource
Description copied from interface:McpClientRetrieves the contents of the resource with the specified URI. This also works for dynamic resources (templates).- Specified by:
readResourcein interfaceMcpClient
-
listResourceTemplates
Description copied from interface:McpClientObtains the current list of resource templates (dynamic resources) available on the MCP server.- Specified by:
listResourceTemplatesin interfaceMcpClient
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-