generated from micronaut-projects/micronaut-project-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Expected Behavior
I tried implementing an MCP tool that returned an enum.
For example, let's say you have a tool that looks like this:
@Tool(name = "sun-state")
public SunState sunState() {
return SunState.TOTAL_ECLIPSE;
}
My enum looks like this:
public enum SunState {
FULL, ANNULAR_ECLIPSE, PARTIAL_ECLIPSE, TOTAL_ECLIPSE
}
Actual Behaviour
In the case above, when using the MCP inspector, the output of that tool will be a string surrounded by quotes, corresponding to the name of the enum:
"\"TOTAL_ECLIPSE\""
Instead of just `"TOTAL_ECLIPSE"`, maybe?
Now if I want to make this enum `@Introspected` and have a `@JsonSchema`, my `enum` becomes:
```java
@JsonSchema(
title = "Sun state",
description = "Sun state",
uri = "/sunState"
)
@Introspected
public enum SunState {
FULL, ANNULAR_ECLIPSE, PARTIAL_ECLIPSE, TOTAL_ECLIPSE;
}
The server runs fine, but then, when I list the tools in the MCP inspector, it tells me:
[
{
"received": "string",
"code": "invalid_literal",
"expected": "object",
"path": [
"tools",
2,
"outputSchema",
"type"
],
"message": "Invalid literal value, expected \"object\""
}
]
However, if I turn the enum
into a similar record
:
@JsonSchema
@Introspected
public record SunState(String state) {
}
It works just fine.
Steps To Reproduce
As stated above, trying to annotate, return, an enum, from an MCP tool.
Environment Information
No response
Example Application
No response
Version
4.9.3
Metadata
Metadata
Assignees
Labels
No labels