Skip to content

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

Description

@yunlong-song-awx

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions