File tree 4 files changed +33
-3
lines changed
mcp/src/main/java/io/modelcontextprotocol/spec
4 files changed +33
-3
lines changed Original file line number Diff line number Diff line change
1
+ package io .modelcontextprotocol .spec ;
2
+
3
+ import reactor .core .publisher .Mono ;
4
+
5
+ /**
6
+ * Interface for close operations that are asynchronous.
7
+ */
8
+ public interface AsyncCloseable {
9
+
10
+ /**
11
+ * Begins the process of closing the resource gracefully, if there is one in progress,
12
+ * return the existing one.
13
+ * @return A {@link Mono} that completes when the resource has been closed.
14
+ */
15
+ Mono <Void > closeGracefully ();
16
+
17
+ /**
18
+ * Immediately closes the resource gracefully.
19
+ */
20
+ default void close () {
21
+ this .closeGracefully ().subscribe ();
22
+ }
23
+
24
+ }
Original file line number Diff line number Diff line change 29
29
*
30
30
* @author Dariusz Jędrzejczyk
31
31
*/
32
- public interface McpServerTransportProvider {
32
+ public interface McpServerTransportProvider extends AsyncCloseable {
33
33
34
34
/**
35
35
* Sets the session factory that will be used to create sessions for new clients. An
@@ -52,6 +52,7 @@ public interface McpServerTransportProvider {
52
52
* Immediately closes all the transports with connected clients and releases any
53
53
* associated resources.
54
54
*/
55
+ @ Override
55
56
default void close () {
56
57
this .closeGracefully ().subscribe ();
57
58
}
@@ -61,6 +62,7 @@ default void close() {
61
62
* associated resources asynchronously.
62
63
* @return a {@link Mono<Void>} that completes when the connections have been closed.
63
64
*/
65
+ @ Override
64
66
Mono <Void > closeGracefully ();
65
67
66
68
}
Original file line number Diff line number Diff line change 23
23
* @author Christian Tzolov
24
24
* @author Dariusz Jędrzejczyk
25
25
*/
26
- public interface McpSession {
26
+ public interface McpSession extends AsyncCloseable {
27
27
28
28
/**
29
29
* Sends a request to the model counterparty and expects a response of type T.
@@ -72,11 +72,13 @@ default Mono<Void> sendNotification(String method) {
72
72
* Closes the session and releases any associated resources asynchronously.
73
73
* @return a {@link Mono<Void>} that completes when the session has been closed.
74
74
*/
75
+ @ Override
75
76
Mono <Void > closeGracefully ();
76
77
77
78
/**
78
79
* Closes the session and releases any associated resources.
79
80
*/
81
+ @ Override
80
82
void close ();
81
83
82
84
}
Original file line number Diff line number Diff line change 35
35
* @author Christian Tzolov
36
36
* @author Dariusz Jędrzejczyk
37
37
*/
38
- public interface McpTransport {
38
+ public interface McpTransport extends AsyncCloseable {
39
39
40
40
/**
41
41
* Closes the transport connection and releases any associated resources.
@@ -45,6 +45,7 @@ public interface McpTransport {
45
45
* needed. It should handle the graceful shutdown of any active connections.
46
46
* </p>
47
47
*/
48
+ @ Override
48
49
default void close () {
49
50
this .closeGracefully ().subscribe ();
50
51
}
@@ -54,6 +55,7 @@ default void close() {
54
55
* asynchronously.
55
56
* @return a {@link Mono<Void>} that completes when the connection has been closed.
56
57
*/
58
+ @ Override
57
59
Mono <Void > closeGracefully ();
58
60
59
61
/**
You can’t perform that action at this time.
0 commit comments