Class HttpMcpTransport

java.lang.Object
dev.langchain4j.mcp.client.transport.http.HttpMcpTransport
All Implemented Interfaces:
McpTransport, Closeable, AutoCloseable

public class HttpMcpTransport extends Object implements McpTransport
  • Constructor Details

  • Method Details

    • start

      public void start(McpOperationHandler messageHandler)
      Description copied from interface: McpTransport
      Creates a connection to the MCP server (runs the server as a subprocess if needed). This does NOT yet send the "initialize" message to negotiate capabilities.
      Specified by:
      start in interface McpTransport
    • initialize

      public CompletableFuture<com.fasterxml.jackson.databind.JsonNode> initialize(McpInitializeRequest operation)
      Description copied from interface: McpTransport
      Sends the "initialize" message to the MCP server to negotiate capabilities, supported protocol version etc. When this method returns successfully, the transport is fully initialized and ready to be used. This has to be called AFTER the "start" method.
      Specified by:
      initialize in interface McpTransport
    • listTools

      public CompletableFuture<com.fasterxml.jackson.databind.JsonNode> listTools(McpListToolsRequest operation)
      Description copied from interface: McpTransport
      Requests a list of available tools from the MCP server.
      Specified by:
      listTools in interface McpTransport
    • executeTool

      public CompletableFuture<com.fasterxml.jackson.databind.JsonNode> executeTool(McpCallToolRequest operation)
      Description copied from interface: McpTransport
      Executes a tool on the MCP server.
      Specified by:
      executeTool in interface McpTransport
      Parameters:
      operation - the tool execution request
    • cancelOperation

      public void cancelOperation(long operationId)
      Description copied from interface: McpTransport
      Cancels a running operation on the server (sends a 'notifications/cancelled' message to the server). This does not expect any response from the server.
      Specified by:
      cancelOperation in interface McpTransport
      Parameters:
      operationId - The ID of the operation to be cancelled.
    • close

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