feat: Added the annotations attribute to McpSchema.Tool (#313)
Signed-off-by: Sun Yuhan <sunyuhan1998@users.noreply.github.com>
This commit is contained in:
parent
fce7a6bad3
commit
ba5bc94963
1 changed files with 52 additions and 5 deletions
|
|
@ -682,6 +682,36 @@ public class McpSchemaTests {
|
|||
assertThat(deserializedTool.inputSchema().defs()).containsKey("Address");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToolWithAnnotations() throws Exception {
|
||||
String schemaJson = """
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"value": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"required": ["name"]
|
||||
}
|
||||
""";
|
||||
McpSchema.ToolAnnotations annotations = new McpSchema.ToolAnnotations("A test tool", false, false, false, false,
|
||||
false);
|
||||
|
||||
McpSchema.Tool tool = new McpSchema.Tool("test-tool", "A test tool", schemaJson, annotations);
|
||||
|
||||
String value = mapper.writeValueAsString(tool);
|
||||
assertThatJson(value).when(Option.IGNORING_ARRAY_ORDER)
|
||||
.when(Option.IGNORING_EXTRA_ARRAY_ITEMS)
|
||||
.isObject()
|
||||
.isEqualTo(
|
||||
json("""
|
||||
{"name":"test-tool","description":"A test tool","inputSchema":{"type":"object","properties":{"name":{"type":"string"},"value":{"type":"number"}},"required":["name"]},"annotations":{"title":"A test tool","readOnlyHint":false,"destructiveHint":false,"idempotentHint":false,"openWorldHint":false,"returnDirect":false}}"""));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCallToolRequest() throws Exception {
|
||||
Map<String, Object> arguments = new HashMap<>();
|
||||
|
|
|
|||
Loading…
Reference in a new issue