Skip to content

Commit 9744c06

Browse files
committed
chore: add mcp Message
Signed-off-by: He-Pin <[email protected]>
1 parent 7ee2cca commit 9744c06

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package io.modelcontextprotocol.spec;
2+
3+
import java.util.Map;
4+
import java.util.Optional;
5+
6+
/**
7+
* An MCP message base class for message driven architecture.
8+
*
9+
*/
10+
public sealed interface McpMessage {
11+
12+
/**
13+
* @return additional metadata related to this resource.
14+
* @see <a href=
15+
* "https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta">Specification</a>
16+
* for notes on _meta usage
17+
*/
18+
Map<String, Object> meta();
19+
20+
sealed interface McpEvent extends McpMessage {
21+
22+
record TaskCreated(McpSchema.Task task, Map<String, Object> meta) implements McpEvent {
23+
}
24+
25+
record TaskStatusUpdated(McpSchema.Task task, Map<String, Object> meta) implements McpEvent {
26+
}
27+
28+
record TaskProgressUpdated(String taskId, Object progressToken, Map<String, Object> meta) implements McpEvent {
29+
}
30+
31+
record TaskResultRetrieved(Optional<String> taskId, McpSchema.CallToolResult result,
32+
Map<String, Object> meta) implements McpEvent {
33+
}
34+
35+
record TaskFailed(Optional<String> taskId, McpError error, Map<String, Object> meta) implements McpEvent {
36+
}
37+
38+
}
39+
40+
}

0 commit comments

Comments
 (0)