Class HttpMcpTransport
java.lang.Object
dev.langchain4j.mcp.client.transport.http.HttpMcpTransport
- All Implemented Interfaces:
McpTransport
,Closeable
,AutoCloseable
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
executeOperationWithoutResponse
(McpClientMessage operation) Sends a message that does not expect a response from the server.CompletableFuture
<com.fasterxml.jackson.databind.JsonNode> executeOperationWithResponse
(McpClientMessage operation) Executes an operation that expects a response from the server.CompletableFuture
<com.fasterxml.jackson.databind.JsonNode> initialize
(McpInitializeRequest operation) Sends the "initialize" message to the MCP server to negotiate capabilities, supported protocol version etc.void
start
(McpOperationHandler messageHandler) Creates a connection to the MCP server (runs the server as a subprocess if needed).
-
Constructor Details
-
HttpMcpTransport
-
-
Method Details
-
start
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 interfaceMcpTransport
-
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 interfaceMcpTransport
-
executeOperationWithResponse
public CompletableFuture<com.fasterxml.jackson.databind.JsonNode> executeOperationWithResponse(McpClientMessage operation) Description copied from interface:McpTransport
Executes an operation that expects a response from the server.- Specified by:
executeOperationWithResponse
in interfaceMcpTransport
-
executeOperationWithoutResponse
Description copied from interface:McpTransport
Sends a message that does not expect a response from the server. The 'id' field of the message should be null.- Specified by:
executeOperationWithoutResponse
in interfaceMcpTransport
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-