Skip to content

Commit 253e360

Browse files
committed
fix: add backwards compat shims for old annotations
1 parent d55d404 commit 253e360

File tree

1 file changed

+49
-4
lines changed

1 file changed

+49
-4
lines changed

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

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
package io.modelcontextprotocol.spec;
66

77
import java.io.IOException;
8-
import java.util.ArrayList;
9-
import java.util.HashMap;
10-
import java.util.List;
11-
import java.util.Map;
8+
import java.util.*;
129

1310
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
1411
import com.fasterxml.jackson.annotation.JsonInclude;
@@ -1291,6 +1288,22 @@ public TextContent(String content) {
12911288
public TextContent(List<Role> audience, Double priority, String content) {
12921289
this(audience != null || priority != null ? new Annotations(audience, priority) : null, content);
12931290
}
1291+
1292+
/**
1293+
* @deprecated Only exists for backwards-compatibility purposes. Use
1294+
* {@link TextContent#annotations()} instead.
1295+
*/
1296+
public List<Role> audience() {
1297+
return annotations == null ? null : annotations.audience();
1298+
}
1299+
1300+
/**
1301+
* @deprecated Only exists for backwards-compatibility purposes. Use
1302+
* {@link TextContent#annotations()} instead.
1303+
*/
1304+
public Double priority() {
1305+
return annotations == null ? null : annotations.priority();
1306+
}
12941307
}
12951308

12961309
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@@ -1307,6 +1320,22 @@ public record ImageContent( // @formatter:off
13071320
public ImageContent(List<Role> audience, Double priority, String data, String mimeType) {
13081321
this(audience != null || priority != null ? new Annotations(audience, priority) : null, data, mimeType);
13091322
}
1323+
1324+
/**
1325+
* @deprecated Only exists for backwards-compatibility purposes. Use
1326+
* {@link ImageContent#annotations()} instead.
1327+
*/
1328+
public List<Role> audience() {
1329+
return annotations == null ? null : annotations.audience();
1330+
}
1331+
1332+
/**
1333+
* @deprecated Only exists for backwards-compatibility purposes. Use
1334+
* {@link ImageContent#annotations()} instead.
1335+
*/
1336+
public Double priority() {
1337+
return annotations == null ? null : annotations.priority();
1338+
}
13101339
}
13111340

13121341
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@@ -1323,6 +1352,22 @@ public record EmbeddedResource( // @formatter:off
13231352
public EmbeddedResource(List<Role> audience, Double priority, ResourceContents resource) {
13241353
this(audience != null || priority != null ? new Annotations(audience, priority) : null, resource);
13251354
}
1355+
1356+
/**
1357+
* @deprecated Only exists for backwards-compatibility purposes. Use
1358+
* {@link EmbeddedResource#annotations()} instead.
1359+
*/
1360+
public List<Role> audience() {
1361+
return annotations == null ? null : annotations.audience();
1362+
}
1363+
1364+
/**
1365+
* @deprecated Only exists for backwards-compatibility purposes. Use
1366+
* {@link EmbeddedResource#annotations()} instead.
1367+
*/
1368+
public Double priority() {
1369+
return annotations == null ? null : annotations.priority();
1370+
}
13261371
}
13271372

13281373
// ---------------------------

0 commit comments

Comments
 (0)