Skip to content

Conversation

@sdelamo
Copy link
Contributor

@sdelamo sdelamo commented Aug 13, 2025

Type Keyword:

The type keyword can take two forms:

  • A single string. When it is a single string, it must be one of the types mentioned above (array, boolean, integer, number, null, object, regular expressions, or string). This specifies that the instance data is only valid when it matches that specific type.
  • An array of strings. When type is used as an array, it contains more than one string specifying the types mentioned above. In this case, the instance data is valid if it matches any of the given types.

This pull-request serializes type as a single string instead of an array. That it is to say, instead of [“object]” it uses ”object”.

I am working on the Micronaut MCP Server implementation. To implement tools, you have to provide a JSON Schema of the Tool. Under the hood, we use the MCP Java SDK which requires type to be a single string.

> The type keyword can take two forms:
> A single string. When it is a single string, it must be one of the types mentioned above (array, boolean, integer, number, null, object, regular expressions, or string). This specifies that the instance data is only valid when it matches that specific type.
> An array of strings. When type is used as an array, it contains more than one string specifying the types mentioned above. In this case, the instance data is valid if it matches any of the given types.

This pull-request serializes type as a single string instead of an array. That it is to say, instead of `[“object]”` it uses `”object”`.

I am working on the [Micronaut MCP Server](https://github.com/micronaut-projects/micronaut-mcp) implementation. To implement tools, you have to provide a [JSON Schema of the Tool](https://modelcontextprotocol.io/specification/2025-06-18/server/tools#listing-tools). Under the hood, we use the MCP Java SDK which [requires type to be a single string](https://github.com/modelcontextprotocol/java-sdk/blob/main/mcp/src/main/java/io/modelcontextprotocol/spec/McpSchema.java#L1218).
@sdelamo sdelamo requested a review from andriy-dmytruk August 13, 2025 12:09
@sdelamo sdelamo added the type: enhancement New feature or request label Aug 13, 2025
@sdelamo sdelamo changed the title feature. display type as a single string Display type as a single string Aug 13, 2025
@sdelamo sdelamo changed the title Display type as a single string Render type as a single string Aug 13, 2025
@sonarqubecloud
Copy link

sonarqubecloud bot commented Aug 13, 2025

Copy link
Collaborator

@andriy-dmytruk andriy-dmytruk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks Sergio!

@sdelamo sdelamo merged commit f814a19 into 1.7.x Aug 13, 2025
12 checks passed
@sdelamo sdelamo deleted the remove-brackets-if-only-one-type branch August 13, 2025 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants