Skip to content

Commit fab6de3

Browse files
committed
.
Signed-off-by: He-Pin <[email protected]>
1 parent 9174b21 commit fab6de3

File tree

4 files changed

+136
-10
lines changed

4 files changed

+136
-10
lines changed

mcp-core/src/main/java/io/modelcontextprotocol/client/McpClientFeatures.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ public Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
106106
: new McpSchema.ClientCapabilities(null,
107107
!Utils.isEmpty(roots) ? new McpSchema.ClientCapabilities.RootCapabilities(false) : null,
108108
samplingHandler != null ? new McpSchema.ClientCapabilities.Sampling() : null,
109-
elicitationHandler != null ? new McpSchema.ClientCapabilities.Elicitation() : null);
109+
elicitationHandler != null ? new McpSchema.ClientCapabilities.Elicitation() : null, null // TODO
110+
// task
111+
// management
112+
// capabilities
113+
);
110114
this.roots = roots != null ? new ConcurrentHashMap<>(roots) : new ConcurrentHashMap<>();
111115

112116
this.toolsChangeConsumers = toolsChangeConsumers != null ? toolsChangeConsumers : List.of();
@@ -256,7 +260,11 @@ public Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities cl
256260
: new McpSchema.ClientCapabilities(null,
257261
!Utils.isEmpty(roots) ? new McpSchema.ClientCapabilities.RootCapabilities(false) : null,
258262
samplingHandler != null ? new McpSchema.ClientCapabilities.Sampling() : null,
259-
elicitationHandler != null ? new McpSchema.ClientCapabilities.Elicitation() : null);
263+
elicitationHandler != null ? new McpSchema.ClientCapabilities.Elicitation() : null, null // TODO
264+
// task
265+
// management
266+
// capabilities
267+
);
260268
this.roots = roots != null ? new HashMap<>(roots) : new HashMap<>();
261269

262270
this.toolsChangeConsumers = toolsChangeConsumers != null ? toolsChangeConsumers : List.of();

mcp-core/src/main/java/io/modelcontextprotocol/server/McpServerFeatures.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ record Async(McpSchema.Implementation serverInfo, McpSchema.ServerCapabilities s
8080
!Utils.isEmpty(prompts) ? new McpSchema.ServerCapabilities.PromptCapabilities(false) : null,
8181
!Utils.isEmpty(resources)
8282
? new McpSchema.ServerCapabilities.ResourceCapabilities(false, false) : null,
83-
!Utils.isEmpty(tools) ? new McpSchema.ServerCapabilities.ToolCapabilities(false) : null);
83+
!Utils.isEmpty(tools) ? new McpSchema.ServerCapabilities.ToolCapabilities(false) : null,
84+
null // TODO Task management
85+
);
8486

8587
this.tools = (tools != null) ? tools : List.of();
8688
this.resources = (resources != null) ? resources : Map.of();
@@ -195,7 +197,9 @@ record Sync(McpSchema.Implementation serverInfo, McpSchema.ServerCapabilities se
195197
!Utils.isEmpty(prompts) ? new McpSchema.ServerCapabilities.PromptCapabilities(false) : null,
196198
!Utils.isEmpty(resources)
197199
? new McpSchema.ServerCapabilities.ResourceCapabilities(false, false) : null,
198-
!Utils.isEmpty(tools) ? new McpSchema.ServerCapabilities.ToolCapabilities(false) : null);
200+
!Utils.isEmpty(tools) ? new McpSchema.ServerCapabilities.ToolCapabilities(false) : null,
201+
null // TODO Task management
202+
);
199203

200204
this.tools = (tools != null) ? tools : new ArrayList<>();
201205
this.resources = (resources != null) ? resources : new HashMap<>();

mcp-core/src/main/java/io/modelcontextprotocol/server/McpStatelessServerFeatures.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ record Async(McpSchema.Implementation serverInfo, McpSchema.ServerCapabilities s
7474
!Utils.isEmpty(prompts) ? new McpSchema.ServerCapabilities.PromptCapabilities(false) : null,
7575
!Utils.isEmpty(resources)
7676
? new McpSchema.ServerCapabilities.ResourceCapabilities(false, false) : null,
77-
!Utils.isEmpty(tools) ? new McpSchema.ServerCapabilities.ToolCapabilities(false) : null);
77+
!Utils.isEmpty(tools) ? new McpSchema.ServerCapabilities.ToolCapabilities(false) : null,
78+
null // TODO task management
79+
);
7880

7981
this.tools = (tools != null) ? tools : List.of();
8082
this.resources = (resources != null) ? resources : Map.of();
@@ -175,7 +177,9 @@ record Sync(McpSchema.Implementation serverInfo, McpSchema.ServerCapabilities se
175177
!Utils.isEmpty(prompts) ? new McpSchema.ServerCapabilities.PromptCapabilities(false) : null,
176178
!Utils.isEmpty(resources)
177179
? new McpSchema.ServerCapabilities.ResourceCapabilities(false, false) : null,
178-
!Utils.isEmpty(tools) ? new McpSchema.ServerCapabilities.ToolCapabilities(false) : null);
180+
!Utils.isEmpty(tools) ? new McpSchema.ServerCapabilities.ToolCapabilities(false) : null,
181+
null // TODO task management
182+
);
179183

180184
this.tools = (tools != null) ? tools : new ArrayList<>();
181185
this.resources = (resources != null) ? resources : new HashMap<>();

mcp-core/src/main/java/io/modelcontextprotocol/spec/McpSchema.java

Lines changed: 114 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,14 +381,16 @@ public InitializeResult(String protocolVersion, ServerCapabilities capabilities,
381381
* @param roots Present if the client supports listing roots
382382
* @param sampling Present if the client supports sampling from an LLM
383383
* @param elicitation Present if the client supports elicitation from the server
384+
* @param tasks Present if the client supports tasks operations
384385
*/
385386
@JsonInclude(JsonInclude.Include.NON_ABSENT)
386387
@JsonIgnoreProperties(ignoreUnknown = true)
387388
public record ClientCapabilities( // @formatter:off
388389
@JsonProperty("experimental") Map<String, Object> experimental,
389390
@JsonProperty("roots") RootCapabilities roots,
390391
@JsonProperty("sampling") Sampling sampling,
391-
@JsonProperty("elicitation") Elicitation elicitation) { // @formatter:on
392+
@JsonProperty("elicitation") Elicitation elicitation,
393+
@JsonProperty("tasks") ClientCapabilities.TaskCapabilities tasks) { // @formatter:on
392394

393395
/**
394396
* Present if the client supports listing roots.
@@ -424,6 +426,57 @@ public record Sampling() {
424426
public record Elicitation() {
425427
}
426428

429+
@JsonInclude(JsonInclude.Include.NON_ABSENT)
430+
public record TaskCapabilities( // @formatter:off
431+
@JsonProperty("list") TaskCapabilities.List list,
432+
@JsonProperty("cancel") TaskCapabilities.Cancel cancel,
433+
@JsonProperty("requests") TaskCapabilities.Requests requests) {// @formatter:on
434+
435+
/**
436+
* Client supports the tasks/list operation
437+
*/
438+
public record List() {
439+
}
440+
441+
/**
442+
* Client supports the tasks/cancel operation
443+
*/
444+
public record Cancel() {
445+
}
446+
447+
/**
448+
* Client supports task-augmented requests
449+
*/
450+
public record Requests( // @formatter:off
451+
@JsonProperty("sampling") Requests.Sampling sampling,
452+
@JsonProperty("elicitation") Requests.Elicitation elicitation) { // @formatter:on
453+
454+
/**
455+
* Client supports task-augmented sampling requests
456+
*/
457+
@JsonInclude(JsonInclude.Include.NON_ABSENT)
458+
public record Sampling(@JsonProperty("createMessage") Sampling.CreateMessage createMessage) {
459+
/**
460+
* Client supports task-augmented sampling/createMessage requests
461+
*/
462+
public record CreateMessage() {
463+
}
464+
}
465+
466+
/**
467+
* Client supports task-augmented elicitation requests
468+
*/
469+
@JsonInclude(JsonInclude.Include.NON_ABSENT)
470+
public record Elicitation(@JsonProperty("elicitation") Elicitation.Create create) {
471+
/**
472+
* Client supports task-augmented elicitation/create requests
473+
*/
474+
public record Create() {
475+
}
476+
}
477+
}
478+
}
479+
427480
public static Builder builder() {
428481
return new Builder();
429482
}
@@ -438,6 +491,8 @@ public static class Builder {
438491

439492
private Elicitation elicitation;
440493

494+
private ClientCapabilities.TaskCapabilities tasks;
495+
441496
public Builder experimental(Map<String, Object> experimental) {
442497
this.experimental = experimental;
443498
return this;
@@ -458,8 +513,13 @@ public Builder elicitation() {
458513
return this;
459514
}
460515

516+
public Builder tasks(ClientCapabilities.TaskCapabilities tasks) {
517+
this.tasks = tasks;
518+
return this;
519+
}
520+
461521
public ClientCapabilities build() {
462-
return new ClientCapabilities(experimental, roots, sampling, elicitation);
522+
return new ClientCapabilities(experimental, roots, sampling, elicitation, tasks);
463523
}
464524

465525
}
@@ -478,6 +538,7 @@ public ClientCapabilities build() {
478538
* @param prompts Present if the server offers any prompt templates
479539
* @param resources Present if the server offers any resources to read
480540
* @param tools Present if the server offers any tools to call
541+
* @param tasks Present if the server supports tasks operations
481542
*/
482543
@JsonInclude(JsonInclude.Include.NON_ABSENT)
483544
@JsonIgnoreProperties(ignoreUnknown = true)
@@ -487,7 +548,8 @@ public record ServerCapabilities( // @formatter:off
487548
@JsonProperty("logging") LoggingCapabilities logging,
488549
@JsonProperty("prompts") PromptCapabilities prompts,
489550
@JsonProperty("resources") ResourceCapabilities resources,
490-
@JsonProperty("tools") ToolCapabilities tools) { // @formatter:on
551+
@JsonProperty("tools") ToolCapabilities tools,
552+
@JsonProperty("tasks") ServerCapabilities.TaskCapabilities tasks) { // @formatter:on
491553

492554
/**
493555
* Present if the server supports argument autocompletion suggestions.
@@ -535,6 +597,47 @@ public record ResourceCapabilities(@JsonProperty("subscribe") Boolean subscribe,
535597
public record ToolCapabilities(@JsonProperty("listChanged") Boolean listChanged) {
536598
}
537599

600+
/**
601+
* Present if the server supports task management operations.
602+
*
603+
* @param list Server supports the tasks/list operation
604+
* @param cancel Server supports the tasks/cancel operation
605+
* @param requests supports task-augmented tools/call requests
606+
*/
607+
@JsonInclude(JsonInclude.Include.NON_ABSENT)
608+
public record TaskCapabilities( // @formatter:off
609+
@JsonProperty("list") TaskCapabilities.List list,
610+
@JsonProperty("cancel") TaskCapabilities.Cancel cancel,
611+
@JsonProperty("requests") TaskCapabilities.Requests requests) { // @formatter:on
612+
613+
/**
614+
* Server supports the tasks/list operation
615+
**/
616+
public record List() {
617+
}
618+
619+
/**
620+
* Server supports the tasks/cancel operation
621+
*/
622+
public record Cancel() {
623+
}
624+
625+
/**
626+
* Server supports task-augmented requests
627+
*/
628+
@JsonInclude(JsonInclude.Include.NON_ABSENT)
629+
public record Requests(@JsonProperty("tools") TaskCapabilities.Requests.Tools tools) {
630+
/**
631+
* Present if the server supports task-augmented tools/call requests
632+
*/
633+
@JsonInclude(JsonInclude.Include.NON_ABSENT)
634+
public record Tools(@JsonProperty("call") Tools.Call call) {
635+
public record Call() {
636+
}
637+
}
638+
}
639+
}
640+
538641
/**
539642
* Create a mutated copy of this object with the specified changes.
540643
* @return A new Builder instance with the same values as this object.
@@ -568,6 +671,8 @@ public static class Builder {
568671

569672
private ToolCapabilities tools;
570673

674+
private TaskCapabilities tasks;
675+
571676
public Builder completions() {
572677
this.completions = new CompletionCapabilities();
573678
return this;
@@ -598,8 +703,13 @@ public Builder tools(Boolean listChanged) {
598703
return this;
599704
}
600705

706+
public Builder tasks(ServerCapabilities.TaskCapabilities tasks) {
707+
this.tasks = tasks;
708+
return this;
709+
}
710+
601711
public ServerCapabilities build() {
602-
return new ServerCapabilities(completions, experimental, logging, prompts, resources, tools);
712+
return new ServerCapabilities(completions, experimental, logging, prompts, resources, tools, tasks);
603713
}
604714

605715
}

0 commit comments

Comments
 (0)