feat: add AudioContent support to MCP schema (#243)
- Add AudioContent record class implementing Annotated and Content interfaces
- Update Content sealed interface to permit AudioContent
- Add audio type handling in Content.type() method
- Include AudioContent in JsonSubTypes annotation for polymorphic deserialization
- Add comprehensive tests for AudioContent serialization and deserialization
- Update error message test to include audio in known type ids
c87a0da6d8/schema/2025-03-26/schema.ts (L987-L1009)
This commit is contained in:
parent
b539b9889e
commit
9a63538840
1 changed files with 36 additions and 2 deletions
|
|
@ -1359,8 +1359,9 @@ public final class McpSchema {
|
|||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
|
||||
@JsonSubTypes({ @JsonSubTypes.Type(value = TextContent.class, name = "text"),
|
||||
@JsonSubTypes.Type(value = ImageContent.class, name = "image"),
|
||||
@JsonSubTypes.Type(value = AudioContent.class, name = "audio"),
|
||||
@JsonSubTypes.Type(value = EmbeddedResource.class, name = "resource") })
|
||||
public sealed interface Content permits TextContent, ImageContent, EmbeddedResource {
|
||||
public sealed interface Content permits TextContent, ImageContent, AudioContent, EmbeddedResource {
|
||||
|
||||
default String type() {
|
||||
if (this instanceof TextContent) {
|
||||
|
|
@ -1369,6 +1370,9 @@ public final class McpSchema {
|
|||
else if (this instanceof ImageContent) {
|
||||
return "image";
|
||||
}
|
||||
else if (this instanceof AudioContent) {
|
||||
return "audio";
|
||||
}
|
||||
else if (this instanceof EmbeddedResource) {
|
||||
return "resource";
|
||||
}
|
||||
|
|
@ -1398,6 +1402,14 @@ public final class McpSchema {
|
|||
@JsonProperty("mimeType") String mimeType) implements Content { // @formatter:on
|
||||
}
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_ABSENT)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public record AudioContent( // @formatter:off
|
||||
@JsonProperty("annotations") Annotations annotations,
|
||||
@JsonProperty("data") String data,
|
||||
@JsonProperty("mimeType") String mimeType) implements Annotated, Content { // @formatter:on
|
||||
}
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_ABSENT)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public record EmbeddedResource( // @formatter:off
|
||||
|
|
|
|||
Loading…
Reference in a new issue