Class McpToolProvider.Builder

java.lang.Object
dev.langchain4j.mcp.McpToolProvider.Builder
Enclosing class:
McpToolProvider

public static class McpToolProvider.Builder extends Object
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • mcpClients

      public McpToolProvider.Builder mcpClients(List<McpClient> mcpClients)
      The list of MCP clients to use for retrieving tools.
    • mcpClients

      public McpToolProvider.Builder mcpClients(McpClient... mcpClients)
      The list of MCP clients to use for retrieving tools.
    • filter

      public McpToolProvider.Builder filter(BiPredicate<McpClient,dev.langchain4j.agent.tool.ToolSpecification> mcpToolsFilter)
      The predicate to filter MCP provided tools.
    • filterToolNames

      public McpToolProvider.Builder filterToolNames(String... toolNames)
      Filter MCP provided tools with a specific name.
    • failIfOneServerFails

      public McpToolProvider.Builder failIfOneServerFails(boolean failIfOneServerFails)
      If this is true, then the tool provider will throw an exception if it fails to list tools from any of the servers. If this is false (default), then the tool provider will ignore the error and continue with the next server.
    • toolWrapper

      public McpToolProvider.Builder toolWrapper(Function<dev.langchain4j.service.tool.ToolExecutor,dev.langchain4j.service.tool.ToolExecutor> toolWrapper)
      Provide a wrapper around the ToolExecutor that can be used to implement tracing for example.
    • build

      public McpToolProvider build()