Skip to content

Elicitation Schema Invalid #4993

@jamesward

Description

@jamesward

Spring AI 1.1

I have:

record UserRandomNumber(int number) { }

@McpTool(description = "generate a random number")
public int random(McpSyncRequestContext context) {
    Random rand = new Random();
    Integer maybeNumber = null;

    if (rand.nextBoolean() && context.elicitEnabled()) {
        var elicitResult = context.elicit(UserRandomNumber.class);
        if (elicitResult.action() == McpSchema.ElicitResult.Action.ACCEPT) {
            maybeNumber = elicitResult.structuredContent().number();
        }
    }

    return maybeNumber != null ? maybeNumber : rand.nextInt(100);
}

In MCP Inspector when I provide the elicited value I get:

Validation Error: unknown format "int32" is used in schema at path "#/properties/number"

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions