spring-projects / spring-projects/spring-ai

Mcptool outputSchema Missing field description

Open
#4,772 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

my code

public record CityPopulation(
        @JsonPropertyDescription("城市的名称,例如:北京") String city,
        @JsonPropertyDescription("城市的人口,单位为:万人") int population
) {
}


# tool
@Service
public class PopulationService {
    @McpTool(name = "getCityPopulation",
            description = "获取城市的人口情况. ",
            generateOutputSchema = true
    )
    public Mono<CityPopulation> getCityPopulation(@McpToolParam(description = "城市的名称,如:北京,上海") String city) {
        // 使用 Mono.fromCallable 来包装同步逻辑,使其在异步环境中安全执行

        McpSchema.CallToolResult build = McpSchema.CallToolResult.builder()
                .addTextContent("")
                .build();


        return Mono.fromCallable(() -> {
            // 在这里可以执行任何耗时的操作,比如查询数据库
            return new CityPopulation(city, 100);
        });
    }
}


use fastmcp list tool get tool info

name='getCityPopulation' title='getCityPopulation' description='获取城市的人口情况. ' inputSchema={'type': 'object', 'properties': {'city': {'type': 'string', 'description': '城市的名称,如:北京,上海'}}, 'required': ['city']} outputSchema={'$schema': 'https://json-schema.org/draft/2020-12/schema', 'type': 'object', 'properties': {'city': {'type': 'string'}, 'population': {'type': 'integer', 'format': 'int32'}}} icons=None annotations=ToolAnnotations(title='', readOnlyHint=False, destructiveHint=True, idempotentHint=False, openWorldHint=True) meta=None

Outputschema is missing a field description, how can you add a field description

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 reproducing the Java record and @JsonPropertyDescription annotations shown in the issue, then compare the generated outputSchema with the expected field descriptions. Done means the city and population properties in the generated schema include their annotation descriptions, while the existing tool metadata remains intact.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.