-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
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