17
17
package org .springframework .ai .mcp .client .common .autoconfigure .properties ;
18
18
19
19
import java .time .Duration ;
20
+ import java .util .Set ;
20
21
21
22
import org .junit .jupiter .api .Test ;
22
23
@@ -47,6 +48,9 @@ void defaultValues() {
47
48
assertThat (properties .getRequestTimeout ()).isEqualTo (Duration .ofSeconds (20 ));
48
49
assertThat (properties .getType ()).isEqualTo (McpClientCommonProperties .ClientType .SYNC );
49
50
assertThat (properties .isRootChangeNotification ()).isTrue ();
51
+ assertThat (properties .getToolcallback ().isEnabled ()).isTrue ();
52
+ assertThat (properties .getToolcallback ().getExcludedToolContextKeys ())
53
+ .containsExactlyElementsOf (Set .of ("TOOL_CALL_HISTORY" ));
50
54
});
51
55
}
52
56
@@ -56,7 +60,9 @@ void customValues() {
56
60
.withPropertyValues ("spring.ai.mcp.client.enabled=false" , "spring.ai.mcp.client.name=custom-client" ,
57
61
"spring.ai.mcp.client.version=2.0.0" , "spring.ai.mcp.client.initialized=false" ,
58
62
"spring.ai.mcp.client.request-timeout=30s" , "spring.ai.mcp.client.type=ASYNC" ,
59
- "spring.ai.mcp.client.root-change-notification=false" )
63
+ "spring.ai.mcp.client.root-change-notification=false" ,
64
+ "spring.ai.mcp.client.toolcallback.enabled=false" ,
65
+ "spring.ai.mcp.client.toolcallback.excluded-tool-context-keys=foo,bar" )
60
66
.run (context -> {
61
67
McpClientCommonProperties properties = context .getBean (McpClientCommonProperties .class );
62
68
assertThat (properties .isEnabled ()).isFalse ();
@@ -66,6 +72,9 @@ void customValues() {
66
72
assertThat (properties .getRequestTimeout ()).isEqualTo (Duration .ofSeconds (30 ));
67
73
assertThat (properties .getType ()).isEqualTo (McpClientCommonProperties .ClientType .ASYNC );
68
74
assertThat (properties .isRootChangeNotification ()).isFalse ();
75
+ assertThat (properties .getToolcallback ().isEnabled ()).isFalse ();
76
+ assertThat (properties .getToolcallback ().getExcludedToolContextKeys ())
77
+ .containsExactlyInAnyOrderElementsOf (Set .of ("foo" , "bar" ));
69
78
});
70
79
}
71
80
@@ -101,6 +110,14 @@ void setterGetterMethods() {
101
110
// Test rootChangeNotification property
102
111
properties .setRootChangeNotification (false );
103
112
assertThat (properties .isRootChangeNotification ()).isFalse ();
113
+
114
+ // Test toolcallback property
115
+ properties .getToolcallback ().setEnabled (false );
116
+ assertThat (properties .getToolcallback ().isEnabled ()).isFalse ();
117
+
118
+ properties .getToolcallback ().setExcludedToolContextKeys (Set .of ("foo" , "bar" ));
119
+ assertThat (properties .getToolcallback ().getExcludedToolContextKeys ())
120
+ .containsExactlyInAnyOrderElementsOf (Set .of ("foo" , "bar" ));
104
121
}
105
122
106
123
@ Test
@@ -125,7 +142,9 @@ void propertiesFileBinding() {
125
142
.withPropertyValues ("spring.ai.mcp.client.enabled=false" , "spring.ai.mcp.client.name=test-mcp-client" ,
126
143
"spring.ai.mcp.client.version=0.5.0" , "spring.ai.mcp.client.initialized=false" ,
127
144
"spring.ai.mcp.client.request-timeout=45s" , "spring.ai.mcp.client.type=ASYNC" ,
128
- "spring.ai.mcp.client.root-change-notification=false" )
145
+ "spring.ai.mcp.client.root-change-notification=false" ,
146
+ "spring.ai.mcp.client.toolcallback.enabled=false" ,
147
+ "spring.ai.mcp.client.toolcallback.excluded-tool-context-keys=foo,bar" )
129
148
.run (context -> {
130
149
McpClientCommonProperties properties = context .getBean (McpClientCommonProperties .class );
131
150
assertThat (properties .isEnabled ()).isFalse ();
@@ -135,6 +154,9 @@ void propertiesFileBinding() {
135
154
assertThat (properties .getRequestTimeout ()).isEqualTo (Duration .ofSeconds (45 ));
136
155
assertThat (properties .getType ()).isEqualTo (McpClientCommonProperties .ClientType .ASYNC );
137
156
assertThat (properties .isRootChangeNotification ()).isFalse ();
157
+ assertThat (properties .getToolcallback ().isEnabled ()).isFalse ();
158
+ assertThat (properties .getToolcallback ().getExcludedToolContextKeys ())
159
+ .containsExactlyInAnyOrderElementsOf (Set .of ("foo" , "bar" ));
138
160
});
139
161
}
140
162
@@ -165,7 +187,9 @@ void yamlConfigurationBinding() {
165
187
.withPropertyValues ("spring.ai.mcp.client.enabled=false" , "spring.ai.mcp.client.name=test-mcp-client-yaml" ,
166
188
"spring.ai.mcp.client.version=0.6.0" , "spring.ai.mcp.client.initialized=false" ,
167
189
"spring.ai.mcp.client.request-timeout=60s" , "spring.ai.mcp.client.type=ASYNC" ,
168
- "spring.ai.mcp.client.root-change-notification=false" )
190
+ "spring.ai.mcp.client.root-change-notification=false" ,
191
+ "spring.ai.mcp.client.toolcallback.enabled=false" ,
192
+ "spring.ai.mcp.client.toolcallback.excluded-tool-context-keys=foo,bar" )
169
193
.run (context -> {
170
194
McpClientCommonProperties properties = context .getBean (McpClientCommonProperties .class );
171
195
assertThat (properties .isEnabled ()).isFalse ();
@@ -175,6 +199,9 @@ void yamlConfigurationBinding() {
175
199
assertThat (properties .getRequestTimeout ()).isEqualTo (Duration .ofSeconds (60 ));
176
200
assertThat (properties .getType ()).isEqualTo (McpClientCommonProperties .ClientType .ASYNC );
177
201
assertThat (properties .isRootChangeNotification ()).isFalse ();
202
+ assertThat (properties .getToolcallback ().isEnabled ()).isFalse ();
203
+ assertThat (properties .getToolcallback ().getExcludedToolContextKeys ())
204
+ .containsExactlyInAnyOrderElementsOf (Set .of ("foo" , "bar" ));
178
205
});
179
206
}
180
207
@@ -201,6 +228,9 @@ void disabledProperties() {
201
228
assertThat (properties .getRequestTimeout ()).isEqualTo (Duration .ofSeconds (20 ));
202
229
assertThat (properties .getType ()).isEqualTo (McpClientCommonProperties .ClientType .SYNC );
203
230
assertThat (properties .isRootChangeNotification ()).isTrue ();
231
+ assertThat (properties .getToolcallback ().isEnabled ()).isTrue ();
232
+ assertThat (properties .getToolcallback ().getExcludedToolContextKeys ())
233
+ .containsExactlyInAnyOrderElementsOf (Set .of ("TOOL_CALL_HISTORY" ));
204
234
});
205
235
}
206
236
@@ -216,6 +246,9 @@ void notInitializedProperties() {
216
246
assertThat (properties .getRequestTimeout ()).isEqualTo (Duration .ofSeconds (20 ));
217
247
assertThat (properties .getType ()).isEqualTo (McpClientCommonProperties .ClientType .SYNC );
218
248
assertThat (properties .isRootChangeNotification ()).isTrue ();
249
+ assertThat (properties .getToolcallback ().isEnabled ()).isTrue ();
250
+ assertThat (properties .getToolcallback ().getExcludedToolContextKeys ())
251
+ .containsExactlyInAnyOrderElementsOf (Set .of ("TOOL_CALL_HISTORY" ));
219
252
});
220
253
}
221
254
@@ -231,6 +264,9 @@ void rootChangeNotificationDisabled() {
231
264
assertThat (properties .isInitialized ()).isTrue ();
232
265
assertThat (properties .getRequestTimeout ()).isEqualTo (Duration .ofSeconds (20 ));
233
266
assertThat (properties .getType ()).isEqualTo (McpClientCommonProperties .ClientType .SYNC );
267
+ assertThat (properties .getToolcallback ().isEnabled ()).isTrue ();
268
+ assertThat (properties .getToolcallback ().getExcludedToolContextKeys ())
269
+ .containsExactlyInAnyOrderElementsOf (Set .of ("TOOL_CALL_HISTORY" ));
234
270
});
235
271
}
236
272
@@ -246,6 +282,9 @@ void customRequestTimeout() {
246
282
assertThat (properties .isInitialized ()).isTrue ();
247
283
assertThat (properties .getType ()).isEqualTo (McpClientCommonProperties .ClientType .SYNC );
248
284
assertThat (properties .isRootChangeNotification ()).isTrue ();
285
+ assertThat (properties .getToolcallback ().isEnabled ()).isTrue ();
286
+ assertThat (properties .getToolcallback ().getExcludedToolContextKeys ())
287
+ .containsExactlyInAnyOrderElementsOf (Set .of ("TOOL_CALL_HISTORY" ));
249
288
});
250
289
}
251
290
@@ -261,6 +300,9 @@ void asyncClientType() {
261
300
assertThat (properties .isInitialized ()).isTrue ();
262
301
assertThat (properties .getRequestTimeout ()).isEqualTo (Duration .ofSeconds (20 ));
263
302
assertThat (properties .isRootChangeNotification ()).isTrue ();
303
+ assertThat (properties .getToolcallback ().isEnabled ()).isTrue ();
304
+ assertThat (properties .getToolcallback ().getExcludedToolContextKeys ())
305
+ .containsExactlyInAnyOrderElementsOf (Set .of ("TOOL_CALL_HISTORY" ));
264
306
});
265
307
}
266
308
@@ -278,6 +320,9 @@ void customNameAndVersion() {
278
320
assertThat (properties .getRequestTimeout ()).isEqualTo (Duration .ofSeconds (20 ));
279
321
assertThat (properties .getType ()).isEqualTo (McpClientCommonProperties .ClientType .SYNC );
280
322
assertThat (properties .isRootChangeNotification ()).isTrue ();
323
+ assertThat (properties .getToolcallback ().isEnabled ()).isTrue ();
324
+ assertThat (properties .getToolcallback ().getExcludedToolContextKeys ())
325
+ .containsExactlyInAnyOrderElementsOf (Set .of ("TOOL_CALL_HISTORY" ));
281
326
});
282
327
}
283
328
0 commit comments