spring-projects / spring-projects/spring-ai

Add `name` attribute to `@McpToolParam` for custom MCP tool argument names

Open
#6,544 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

@McpToolParam should support an optional name attribute to customize the external MCP tool argument name.

  @McpTool(name = "get_weather")
  public String getWeather(@McpToolParam(name = "city_name") String cityName) {
        return cityName;
  }

This should generate an input schema with city_name:

  {
    "type": "object",
    "properties": {
      "city_name": {
        "type": "string"
      }
    },
    "required": ["city_name"]
  }

A tool call using city_name should bind to the Java parameter cityName.

Current Behavior

mcp/mcp-annotations currently uses the Java reflection parameter name for top-level tool input schema properties
and runtime argument binding.

For example:

  @McpTool(name = "get_weather")
  public String getWeather(String cityName) {
        return cityName;
  }

generates and expects cityName.

There is no MCP-specific way to expose city_name while keeping the Java method parameter named cityName.

Context

I want to expose MCP tool arguments using an external naming style such as snake_case while keeping idiomatic Java
camelCase parameter names internally.

A possible API would be:

  public @interface McpToolParam {

        String name() default "";

        boolean required() default true;

        String description() default "";

  }

Since @McpToolParam already targets both PARAMETER and FIELD, the same name attribute could also be honored for
nested object properties in generated schemas.

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 in mcp/mcp-annotations by tracing @McpToolParam handling for top-level schema generation and runtime argument binding. Check how its PARAMETER and FIELD targets are processed, then verify behavior for the city_name example. Done means custom external names work for schema properties and bind back to Java parameters, including nested object properties.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.