Skip to content

Commit 651a670

Browse files
committed
merge: Merged the main branch code and resolved the conflicts.
Signed-off-by: Sun Yuhan <[email protected]>
1 parent aadea40 commit 651a670

File tree

3 files changed

+6
-24
lines changed

3 files changed

+6
-24
lines changed

mcp/common/src/main/java/org/springframework/ai/mcp/McpToolUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ public static McpStatelessServerFeatures.SyncToolSpecification toStatelessSyncTo
231231
private static SharedSyncToolSpecification toSharedSyncToolSpecification(ToolCallback toolCallback,
232232
MimeType mimeType) {
233233
boolean returnDirect = Optional.ofNullable(toolCallback.getToolMetadata())
234-
.map(ToolMetadata::returnDirect)
235-
.orElse(false);
234+
.map(ToolMetadata::returnDirect)
235+
.orElse(false);
236236
McpSchema.ToolAnnotations toolAnnotations = new McpSchema.ToolAnnotations(null, null, null, null, null,
237237
returnDirect);
238238

mcp/common/src/test/java/org/springframework/ai/mcp/AsyncMcpToolCallbackTest.java

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -48,27 +48,6 @@ class AsyncMcpToolCallbackTest {
4848
@Mock
4949
private McpSchema.Tool tool;
5050

51-
@Test
52-
void getToolDefinitionShouldReturnCorrectDefinition() {
53-
54-
var clientInfo = new McpSchema.Implementation("testClient", "1.0.0");
55-
var toolAnnotations = new McpSchema.ToolAnnotations(null, false, false, false, false, true);
56-
57-
when(this.mcpClient.getClientInfo()).thenReturn(clientInfo);
58-
when(this.tool.name()).thenReturn("testTool");
59-
when(this.tool.description()).thenReturn("Test tool description");
60-
when(this.tool.annotations()).thenReturn(toolAnnotations);
61-
62-
AsyncMcpToolCallback callback = new AsyncMcpToolCallback(this.mcpClient, this.tool);
63-
64-
var toolDefinition = callback.getToolDefinition();
65-
var toolMetadata = callback.getToolMetadata();
66-
67-
assertThat(toolDefinition.name()).isEqualTo(clientInfo.name() + "_testTool");
68-
assertThat(toolDefinition.description()).isEqualTo("Test tool description");
69-
assertThat(toolMetadata.returnDirect()).isEqualTo(true);
70-
}
71-
7251
@Test
7352
void callShouldThrowOnError() {
7453
when(this.tool.name()).thenReturn("testTool");
@@ -225,6 +204,8 @@ void getToolDefinitionShouldReturnCorrectDefinition() {
225204
when(this.tool.description()).thenReturn("Test tool description");
226205
var jsonSchema = mock(McpSchema.JsonSchema.class);
227206
when(this.tool.inputSchema()).thenReturn(jsonSchema);
207+
var toolAnnotations = new McpSchema.ToolAnnotations(null, false, false, false, false, true);
208+
when(this.tool.annotations()).thenReturn(toolAnnotations);
228209

229210
// Act
230211
var callback = AsyncMcpToolCallback.builder()
@@ -234,11 +215,13 @@ void getToolDefinitionShouldReturnCorrectDefinition() {
234215
.build();
235216

236217
ToolDefinition definition = callback.getToolDefinition();
218+
var toolMetadata = callback.getToolMetadata();
237219

238220
// Assert
239221
assertThat(definition.name()).isEqualTo("prefix_testTool");
240222
assertThat(definition.description()).isEqualTo("Test tool description");
241223
assertThat(definition.inputSchema()).isNotNull();
224+
assertThat(toolMetadata.returnDirect()).isEqualTo(true);
242225
}
243226

244227
@Test

mcp/common/src/test/java/org/springframework/ai/mcp/SyncMcpToolCallbackTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ void getToolDefinitionShouldReturnCorrectDefinition() {
5858
when(this.tool.description()).thenReturn("Test tool description");
5959
when(this.tool.annotations()).thenReturn(toolAnnotations);
6060

61-
6261
SyncMcpToolCallback callback = SyncMcpToolCallback.builder()
6362
.mcpClient(this.mcpClient)
6463
.tool(this.tool)

0 commit comments

Comments
 (0)