spring-projects / spring-projects/spring-ai

Support @Hidden on enums and object fields read by @MCPTool

Open
#4,690 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
Dominant language
Java
Stars
9.5k
Forks
2.9k
Avg merge
1d 7h
Merged PRs (30d)
6

Description

Expected Behavior

When adding @Hidden to enum values and fields of objects, the expected behavior is for Spring AI to filter those items from the generated tool inputSchema.

Current Behavior

At the moment, @MCPTool displays all enum values.

Context

The swagger annotation @Hidden is placed on enum values for example to avoid the OpenAPI spec from containing those values. The example below will generated an openapi.json file with currency: USD, CAD.

When viewing the generated tool definition of the below example, it contains all values "enum": ["EUR", "JPY", "USD", "CAD"] exposing fields/values that are not intended to be exposed.

enum Currency {
    @Hidden EUR,
    @Hidden JPY,
            USD,
            CAD
}

@RequireAuthentication
@GetMapping("{currency}")
@Operation(summary = GET_BALANCE_TITLE, description = GET_BALANCE_DESCRIPTION)
@McpTool(title = GET_BALANCE_TITLE, description = GET_BALANCE_DESCRIPTION)
public BalancePayload getBalance(@PathVariable final Currency currency) { ... }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how @McpTool generates its inputSchema, especially enum values and object fields, and compare that path with the existing @Hidden behavior used for OpenAPI. Verify the generated tool schema excludes hidden enum values and fields while retaining visible ones.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.