spring-projects / spring-projects/spring-ai

Pluggable Java-method tool-definition strategies & typed inputSchema in MCP

Open
#3,317 1 comment 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

Hi @ThomasVitale,

I’ve tried to expose the REST methods of my application using MCP, but I haven’t
found an easy way to do so. I’d like to leverage Swagger v3 annotations for
tool definitions, but MethodToolCallbackProvider doesn’t support this
approach. The main issues are:

  • Only @Tool annotations are considered. There’s no way to plug in an
    alternative strategy for creating tool definitions.
  • Parameter names are extracted from the bytecode. Without the -parameters
    compiler flag, descriptive names aren’t available.

I propose the following enhancements:

  1. Allow injection of alternative strategies for generating tool definitions
    from different kinds of method metadata. The strategy based on
    @Tool annotations could remain one of the built-in options.
  2. Introduce a clear mapping between tool-definition parameter names and the
    original Java method parameters.

Moreover, implementing this parameter mapping would be much simpler if
ToolDefinition.inputSchema were a typed object (as defined in the
MCP specification)
instead of a raw JSON string. This would allow implementations to assume that
parameters in the tool definition appear in the same order as in the bytecode.

Would it be feasible to introduce these backward-incompatible changes to
ToolDefinition, MethodToolCallbackProvider, and MethodToolCallback?

Thanks!

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 reading the ToolDefinition, MethodToolCallbackProvider, and MethodToolCallback APIs, then compare inputSchema with the linked MCP specification. Define how alternative method-metadata strategies and parameter-name mappings should work, including the proposed typed inputSchema; the issue is done when those compatibility and design questions are resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.