Package io.modelcontextprotocol.spec
Class MissingMcpTransportSession
java.lang.Object
io.modelcontextprotocol.spec.MissingMcpTransportSession
- All Implemented Interfaces:
McpLoggableSession,McpSession
A
McpLoggableSession which represents a missing stream that would allow the
server to communicate with the client. Specifically, it can be used when a Streamable
HTTP client has not opened a listening SSE stream to accept messages for interactions
unrelated with concurrently running client-initiated requests.- Author:
- Dariusz Jędrzejczyk
-
Constructor Summary
ConstructorsConstructorDescriptionMissingMcpTransportSession(String sessionId) Create an instance with the Session ID specified. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the session and releases any associated resources.reactor.core.publisher.Mono<Void>Closes the session and releases any associated resources asynchronously.booleanisNotificationForLevelAllowed(McpSchema.LoggingLevel loggingLevel) Allows checking whether a particular logging level is allowed.reactor.core.publisher.Mono<Void>sendNotification(String method, Object params) Sends a notification to the model client or server with parameters.<T> reactor.core.publisher.Mono<T>sendRequest(String method, Object requestParams, com.fasterxml.jackson.core.type.TypeReference<T> typeRef) Sends a request to the model counterparty and expects a response of type T.voidsetMinLoggingLevel(McpSchema.LoggingLevel minLoggingLevel) Set the minimum logging level for the client.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.modelcontextprotocol.spec.McpSession
sendNotification
-
Constructor Details
-
MissingMcpTransportSession
Create an instance with the Session ID specified.- Parameters:
sessionId- session ID
-
-
Method Details
-
sendRequest
public <T> reactor.core.publisher.Mono<T> sendRequest(String method, Object requestParams, com.fasterxml.jackson.core.type.TypeReference<T> typeRef) Description copied from interface:McpSessionSends a request to the model counterparty and expects a response of type T.This method handles the request-response pattern where a response is expected from the client or server. The response type is determined by the provided TypeReference.
- Specified by:
sendRequestin interfaceMcpSession- Type Parameters:
T- the type of the expected response- Parameters:
method- the name of the method to be called on the counterpartyrequestParams- the parameters to be sent with the requesttypeRef- the TypeReference describing the expected response type- Returns:
- a Mono that will emit the response when received
-
sendNotification
Description copied from interface:McpSessionSends a notification to the model client or server with parameters.Similar to
McpSession.sendNotification(String)but allows sending additional parameters with the notification.- Specified by:
sendNotificationin interfaceMcpSession- Parameters:
method- the name of the notification method to be sent to the counterpartyparams- parameters to be sent with the notification- Returns:
- a Mono that completes when the notification has been sent
-
closeGracefully
Description copied from interface:McpSessionCloses the session and releases any associated resources asynchronously.- Specified by:
closeGracefullyin interfaceMcpSession- Returns:
- a
reactor.core.publisher.Mono<Void>that completes when the session has been closed.
-
close
public void close()Description copied from interface:McpSessionCloses the session and releases any associated resources.- Specified by:
closein interfaceMcpSession
-
setMinLoggingLevel
Description copied from interface:McpLoggableSessionSet the minimum logging level for the client. Messages below this level will be filtered out.- Specified by:
setMinLoggingLevelin interfaceMcpLoggableSession- Parameters:
minLoggingLevel- The minimum logging level
-
isNotificationForLevelAllowed
Description copied from interface:McpLoggableSessionAllows checking whether a particular logging level is allowed.- Specified by:
isNotificationForLevelAllowedin interfaceMcpLoggableSession- Parameters:
loggingLevel- the level to check- Returns:
- whether the logging at the specified level is permitted.
-