Skip to content

Commit b74f6de

Browse files
authored
feat(schema): support Object type for progressToken (#663)
Change progressToken from String to Object throughout McpSchema to allow both String and Number token types. This makes it compliant with the MCP spec. Resolves: #659 Signed-off-by: Christian Tzolov <[email protected]>
1 parent 7385253 commit b74f6de

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,9 @@ public sealed interface Request extends Meta
167167
permits InitializeRequest, CallToolRequest, CreateMessageRequest, ElicitRequest, CompleteRequest,
168168
GetPromptRequest, ReadResourceRequest, SubscribeRequest, UnsubscribeRequest, PaginatedRequest {
169169

170-
default String progressToken() {
170+
default Object progressToken() {
171171
if (meta() != null && meta().containsKey("progressToken")) {
172-
return meta().get("progressToken").toString();
172+
return meta().get("progressToken");
173173
}
174174
return null;
175175
}
@@ -1502,7 +1502,7 @@ public Builder meta(Map<String, Object> meta) {
15021502
return this;
15031503
}
15041504

1505-
public Builder progressToken(String progressToken) {
1505+
public Builder progressToken(Object progressToken) {
15061506
if (this.meta == null) {
15071507
this.meta = new HashMap<>();
15081508
}
@@ -1912,7 +1912,7 @@ public Builder meta(Map<String, Object> meta) {
19121912
return this;
19131913
}
19141914

1915-
public Builder progressToken(String progressToken) {
1915+
public Builder progressToken(Object progressToken) {
19161916
if (this.meta == null) {
19171917
this.meta = new HashMap<>();
19181918
}
@@ -2080,7 +2080,7 @@ public Builder meta(Map<String, Object> meta) {
20802080
return this;
20812081
}
20822082

2083-
public Builder progressToken(String progressToken) {
2083+
public Builder progressToken(Object progressToken) {
20842084
if (this.meta == null) {
20852085
this.meta = new HashMap<>();
20862086
}
@@ -2217,13 +2217,13 @@ public record PaginatedResult(@JsonProperty("nextCursor") String nextCursor) {
22172217
@JsonInclude(JsonInclude.Include.NON_ABSENT)
22182218
@JsonIgnoreProperties(ignoreUnknown = true)
22192219
public record ProgressNotification( // @formatter:off
2220-
@JsonProperty("progressToken") String progressToken,
2220+
@JsonProperty("progressToken") Object progressToken,
22212221
@JsonProperty("progress") Double progress,
22222222
@JsonProperty("total") Double total,
22232223
@JsonProperty("message") String message,
22242224
@JsonProperty("_meta") Map<String, Object> meta) implements Notification { // @formatter:on
22252225

2226-
public ProgressNotification(String progressToken, double progress, Double total, String message) {
2226+
public ProgressNotification(Object progressToken, double progress, Double total, String message) {
22272227
this(progressToken, progress, total, message, null);
22282228
}
22292229
}

0 commit comments

Comments
 (0)