Class McpClientWrapper

java.lang.Object
org.noear.solon.ai.mcp.client.McpClientWrapper
All Implemented Interfaces:
Closeable, AutoCloseable

public class McpClientWrapper extends Object implements Closeable
Mcp 客户端简化版
Since:
3.1
Author:
noear
  • Constructor Details

    • McpClientWrapper

      public McpClientWrapper(io.modelcontextprotocol.client.McpSyncClient client)
    • McpClientWrapper

      public McpClientWrapper(io.modelcontextprotocol.spec.McpClientTransport clientTransport)
    • McpClientWrapper

      public McpClientWrapper(String baseUri, String sseEndpoint)
    • McpClientWrapper

      public McpClientWrapper(Properties properties)
  • Method Details

    • callToolAsText

      public String callToolAsText(String name, Map<String,Object> args)
      调用工具并转为文本
      Parameters:
      name - 工具名
      args - 调用参数
    • callToolAsImage

      public org.noear.solon.ai.image.Image callToolAsImage(String name, Map<String,Object> args)
      调用工具并转为图像
      Parameters:
      name - 工具名
      args - 调用参数
    • callTool

      public io.modelcontextprotocol.spec.McpSchema.CallToolResult callTool(String name, Map<String,Object> args)
      调用工具
      Parameters:
      name - 工具名
      args - 调用参数
    • toTools

      public Collection<org.noear.solon.ai.chat.tool.FunctionTool> toTools()
      转为聊天函数(用于模型绑定)
    • toTools

      public Collection<org.noear.solon.ai.chat.tool.FunctionTool> toTools(boolean cached)
      转为聊天函数(用于模型绑定)
    • buildTools

      protected Collection<org.noear.solon.ai.chat.tool.FunctionTool> buildTools()
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException