Skip to content

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ record Async(McpSchema.Implementation serverInfo, McpSchema.ServerCapabilities s
!Utils.isEmpty(prompts) ? new McpSchema.ServerCapabilities.PromptCapabilities(false) : null,
!Utils.isEmpty(resources)
? new McpSchema.ServerCapabilities.ResourceCapabilities(false, false) : null,
!Utils.isEmpty(tools) ? new McpSchema.ServerCapabilities.ToolCapabilities(false) : null);
!Utils.isEmpty(tools) ? new McpSchema.ServerCapabilities.ToolCapabilities(false) : null,
null // TODO Task management
);

this.tools = (tools != null) ? tools : List.of();
this.resources = (resources != null) ? resources : Map.of();
Expand Down Expand Up @@ -195,7 +197,9 @@ record Sync(McpSchema.Implementation serverInfo, McpSchema.ServerCapabilities se
!Utils.isEmpty(prompts) ? new McpSchema.ServerCapabilities.PromptCapabilities(false) : null,
!Utils.isEmpty(resources)
? new McpSchema.ServerCapabilities.ResourceCapabilities(false, false) : null,
!Utils.isEmpty(tools) ? new McpSchema.ServerCapabilities.ToolCapabilities(false) : null);
!Utils.isEmpty(tools) ? new McpSchema.ServerCapabilities.ToolCapabilities(false) : null,
null // TODO Task management
);

this.tools = (tools != null) ? tools : new ArrayList<>();
this.resources = (resources != null) ? resources : new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ record Async(McpSchema.Implementation serverInfo, McpSchema.ServerCapabilities s
!Utils.isEmpty(prompts) ? new McpSchema.ServerCapabilities.PromptCapabilities(false) : null,
!Utils.isEmpty(resources)
? new McpSchema.ServerCapabilities.ResourceCapabilities(false, false) : null,
!Utils.isEmpty(tools) ? new McpSchema.ServerCapabilities.ToolCapabilities(false) : null);
!Utils.isEmpty(tools) ? new McpSchema.ServerCapabilities.ToolCapabilities(false) : null,
null // TODO task management
);

this.tools = (tools != null) ? tools : List.of();
this.resources = (resources != null) ? resources : Map.of();
Expand Down Expand Up @@ -175,7 +177,9 @@ record Sync(McpSchema.Implementation serverInfo, McpSchema.ServerCapabilities se
!Utils.isEmpty(prompts) ? new McpSchema.ServerCapabilities.PromptCapabilities(false) : null,
!Utils.isEmpty(resources)
? new McpSchema.ServerCapabilities.ResourceCapabilities(false, false) : null,
!Utils.isEmpty(tools) ? new McpSchema.ServerCapabilities.ToolCapabilities(false) : null);
!Utils.isEmpty(tools) ? new McpSchema.ServerCapabilities.ToolCapabilities(false) : null,
null // TODO task management
);

this.tools = (tools != null) ? tools : new ArrayList<>();
this.resources = (resources != null) ? resources : new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package io.modelcontextprotocol.spec;

import java.util.Map;
import java.util.Optional;

/**
* An MCP message base class for message driven architecture.
*
*/
public sealed interface McpMessage {

/**
* @return additional metadata related to this resource.
* @see <a href=
* "https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta">Specification</a>
* for notes on _meta usage
*/
Map<String, Object> meta();

sealed interface McpEvent extends McpMessage {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are these in the spec? I don't find them.

Copy link
Contributor Author

@He-Pin He-Pin Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My current implementation at work is Flux<McpMessage> callToolStream(CallToolRequest request) to support streaming responses. We also have callTool(CallToolRequest request) built upon this implementation.

I specifically plan to support streaming responses in the future. However, because my implementation at work is far more complex than a memory-based implementation, it's not yet ready for open-source development.

modelcontextprotocol/modelcontextprotocol#1905


record TaskCreated(McpSchema.Task task, Map<String, Object> meta) implements McpEvent {
}

record TaskStatusUpdated(McpSchema.Task task, Map<String, Object> meta) implements McpEvent {
}

record TaskProgressUpdated(String taskId, Object progressToken, Map<String, Object> meta) implements McpEvent {
}

record TaskResultRetrieved(Optional<String> taskId, McpSchema.CallToolResult result,
Map<String, Object> meta) implements McpEvent {
}

record TaskFailed(Optional<String> taskId, McpError error, Map<String, Object> meta) implements McpEvent {
}

}

}
Loading
Loading