Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate "type" field in JSON output of McpSchema.TextContent #2350

Open
deemkeen opened this issue Feb 28, 2025 · 0 comments
Open

Duplicate "type" field in JSON output of McpSchema.TextContent #2350

deemkeen opened this issue Feb 28, 2025 · 0 comments

Comments

@deemkeen
Copy link

Description

When converting an instance of McpSchema.TextContent to JSON using Jackson's ObjectMapper, the resulting JSON contains a duplicate "type" field. This is incorrect and could lead to parsing issues or unexpected behavior in systems consuming this JSON.

Steps to Reproduce

  1. Create an instance of McpSchema.TextContent
  2. Serialize it to JSON using Jackson's ObjectMapper
  3. Observe the output contains a duplicate "type" field
@Test
void testContent() throws Exception {
  McpSchema.TextContent test = new McpSchema.TextContent("XXX");
  String value = new ObjectMapper().writeValueAsString(test);
  assertEquals(
      """
      {"type":"text","type":"text","text":"XXX"}""",
      value);
}

Expected Behavior

The JSON output should have only one "type" field:

{"type":"text","text":"XXX"}

Actual Behavior

The JSON output contains a duplicate "type" field:

{"type":"text","type":"text","text":"XXX"}

Possible Cause

This is likely due to a field and a getter method both being annotated with @JsonProperty("type") in the McpSchema.TextContent class, or the field might be defined twice in the class hierarchy.

Environment

  • Java version: 21.0.5
  • Spring AI version: 1.0.0-M6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant