feat: support MCP output schemas
All checks were successful
Deploy to OCIWP / deploy (push) Successful in 2m1s

This commit is contained in:
jade
2026-08-04 11:24:59 +09:00
parent 15262d5a0f
commit 31e6fd605d
10 changed files with 192 additions and 5 deletions

View File

@@ -0,0 +1,34 @@
package io.shinhanlife.dap.mcc.biz.cmm.dto;
import io.shinhanlife.dap.lib.annotation.McpOutputSchema;
import io.shinhanlife.dap.lib.annotation.McpParameter;
import io.shinhanlife.dap.lib.annotation.McpValidation;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
/**
* Simple response DTO sample that generates an MCP output schema from annotations.
*/
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@McpOutputSchema
public class ClaimSearchResponse {
@McpParameter(description = "Tool execution result code.")
@McpValidation(required = true, allowedValues = {"SUCCESS", "FAILURE"})
private String resultCode;
@McpParameter(description = "User-readable execution message.")
@McpValidation(required = true, maxLength = 200)
private String message;
@McpParameter(description = "Number of matched claims.")
@McpValidation(minimum = 0)
private Integer totalCount;
}

View File

@@ -17,7 +17,7 @@ public interface ClaimSearchSchemaSampleUseCase {
description = "inputSchemaResource를 사용하는 청구 조회 Tool 샘플입니다.",
prompt = "청구번호 또는 계약번호로 보험금 청구를 조회해줘.",
inputSchemaResource = "classpath:tool-schemas/claim-search-resource-input-schema.json",
readOnlyHint = true,
outputSchemaResource = "classpath:tool-schemas/claim-search-resource-output-schema.json", readOnlyHint = true,
idempotentHint = true
)
Object search(ClaimSearchRequest request);

View File

@@ -0,0 +1,10 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"message": { "type": "string", "description": "Tool execution summary." },
"request": { "type": "object", "description": "Normalized Tool request." }
},
"required": ["message", "request"],
"additionalProperties": false
}

View File

@@ -43,6 +43,16 @@ class ClaimSearchRequestSchemaTest {
assertEquals(50, property(schema, "size").get("maximum"));
}
@Test
void resolvesOutputSchemaFromToolModuleResource() throws Exception {
Method method = ClaimSearchSchemaSampleUseCase.class
.getDeclaredMethod("search", ClaimSearchRequest.class);
McpFunction function = method.getAnnotation(McpFunction.class);
Map<String, Object> schema = new ToolSchemaResolver(new ObjectMapper()).resolveOutput(function);
assertEquals("https://json-schema.org/draft/2020-12/schema", schema.get("$schema"));
assertEquals(List.of("message", "request"), schema.get("required"));
}
@SuppressWarnings("unchecked")
private Map<String, Map<String, Object>> properties(Map<String, Object> schema) {
return (Map<String, Map<String, Object>>) schema.get("properties");