1717package org .springframework .ai .mcp .client .autoconfigure .properties ;
1818
1919import java .time .Duration ;
20+ import java .util .Set ;
2021
2122import org .junit .jupiter .api .Test ;
2223
@@ -47,6 +48,9 @@ void defaultValues() {
4748 assertThat (properties .getRequestTimeout ()).isEqualTo (Duration .ofSeconds (20 ));
4849 assertThat (properties .getType ()).isEqualTo (McpClientCommonProperties .ClientType .SYNC );
4950 assertThat (properties .isRootChangeNotification ()).isTrue ();
51+ assertThat (properties .getToolcallback ().isEnabled ()).isTrue ();
52+ assertThat (properties .getToolcallback ().getExcludedToolContextKeys ())
53+ .containsExactlyElementsOf (Set .of ("TOOL_CALL_HISTORY" ));
5054 });
5155 }
5256
@@ -56,7 +60,9 @@ void customValues() {
5660 .withPropertyValues ("spring.ai.mcp.client.enabled=false" , "spring.ai.mcp.client.name=custom-client" ,
5761 "spring.ai.mcp.client.version=2.0.0" , "spring.ai.mcp.client.initialized=false" ,
5862 "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" )
6066 .run (context -> {
6167 McpClientCommonProperties properties = context .getBean (McpClientCommonProperties .class );
6268 assertThat (properties .isEnabled ()).isFalse ();
@@ -66,6 +72,9 @@ void customValues() {
6672 assertThat (properties .getRequestTimeout ()).isEqualTo (Duration .ofSeconds (30 ));
6773 assertThat (properties .getType ()).isEqualTo (McpClientCommonProperties .ClientType .ASYNC );
6874 assertThat (properties .isRootChangeNotification ()).isFalse ();
75+ assertThat (properties .getToolcallback ().isEnabled ()).isFalse ();
76+ assertThat (properties .getToolcallback ().getExcludedToolContextKeys ())
77+ .containsExactlyInAnyOrderElementsOf (Set .of ("foo" , "bar" ));
6978 });
7079 }
7180
@@ -101,6 +110,14 @@ void setterGetterMethods() {
101110 // Test rootChangeNotification property
102111 properties .setRootChangeNotification (false );
103112 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" ));
104121 }
105122
106123 @ Test
@@ -125,7 +142,9 @@ void propertiesFileBinding() {
125142 .withPropertyValues ("spring.ai.mcp.client.enabled=false" , "spring.ai.mcp.client.name=test-mcp-client" ,
126143 "spring.ai.mcp.client.version=0.5.0" , "spring.ai.mcp.client.initialized=false" ,
127144 "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" )
129148 .run (context -> {
130149 McpClientCommonProperties properties = context .getBean (McpClientCommonProperties .class );
131150 assertThat (properties .isEnabled ()).isFalse ();
@@ -135,6 +154,9 @@ void propertiesFileBinding() {
135154 assertThat (properties .getRequestTimeout ()).isEqualTo (Duration .ofSeconds (45 ));
136155 assertThat (properties .getType ()).isEqualTo (McpClientCommonProperties .ClientType .ASYNC );
137156 assertThat (properties .isRootChangeNotification ()).isFalse ();
157+ assertThat (properties .getToolcallback ().isEnabled ()).isFalse ();
158+ assertThat (properties .getToolcallback ().getExcludedToolContextKeys ())
159+ .containsExactlyInAnyOrderElementsOf (Set .of ("foo" , "bar" ));
138160 });
139161 }
140162
@@ -165,7 +187,9 @@ void yamlConfigurationBinding() {
165187 .withPropertyValues ("spring.ai.mcp.client.enabled=false" , "spring.ai.mcp.client.name=test-mcp-client-yaml" ,
166188 "spring.ai.mcp.client.version=0.6.0" , "spring.ai.mcp.client.initialized=false" ,
167189 "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" )
169193 .run (context -> {
170194 McpClientCommonProperties properties = context .getBean (McpClientCommonProperties .class );
171195 assertThat (properties .isEnabled ()).isFalse ();
@@ -175,6 +199,9 @@ void yamlConfigurationBinding() {
175199 assertThat (properties .getRequestTimeout ()).isEqualTo (Duration .ofSeconds (60 ));
176200 assertThat (properties .getType ()).isEqualTo (McpClientCommonProperties .ClientType .ASYNC );
177201 assertThat (properties .isRootChangeNotification ()).isFalse ();
202+ assertThat (properties .getToolcallback ().isEnabled ()).isFalse ();
203+ assertThat (properties .getToolcallback ().getExcludedToolContextKeys ())
204+ .containsExactlyInAnyOrderElementsOf (Set .of ("foo" , "bar" ));
178205 });
179206 }
180207
@@ -201,6 +228,9 @@ void disabledProperties() {
201228 assertThat (properties .getRequestTimeout ()).isEqualTo (Duration .ofSeconds (20 ));
202229 assertThat (properties .getType ()).isEqualTo (McpClientCommonProperties .ClientType .SYNC );
203230 assertThat (properties .isRootChangeNotification ()).isTrue ();
231+ assertThat (properties .getToolcallback ().isEnabled ()).isTrue ();
232+ assertThat (properties .getToolcallback ().getExcludedToolContextKeys ())
233+ .containsExactlyInAnyOrderElementsOf (Set .of ("TOOL_CALL_HISTORY" ));
204234 });
205235 }
206236
@@ -216,6 +246,9 @@ void notInitializedProperties() {
216246 assertThat (properties .getRequestTimeout ()).isEqualTo (Duration .ofSeconds (20 ));
217247 assertThat (properties .getType ()).isEqualTo (McpClientCommonProperties .ClientType .SYNC );
218248 assertThat (properties .isRootChangeNotification ()).isTrue ();
249+ assertThat (properties .getToolcallback ().isEnabled ()).isTrue ();
250+ assertThat (properties .getToolcallback ().getExcludedToolContextKeys ())
251+ .containsExactlyInAnyOrderElementsOf (Set .of ("TOOL_CALL_HISTORY" ));
219252 });
220253 }
221254
@@ -231,6 +264,9 @@ void rootChangeNotificationDisabled() {
231264 assertThat (properties .isInitialized ()).isTrue ();
232265 assertThat (properties .getRequestTimeout ()).isEqualTo (Duration .ofSeconds (20 ));
233266 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" ));
234270 });
235271 }
236272
@@ -246,6 +282,9 @@ void customRequestTimeout() {
246282 assertThat (properties .isInitialized ()).isTrue ();
247283 assertThat (properties .getType ()).isEqualTo (McpClientCommonProperties .ClientType .SYNC );
248284 assertThat (properties .isRootChangeNotification ()).isTrue ();
285+ assertThat (properties .getToolcallback ().isEnabled ()).isTrue ();
286+ assertThat (properties .getToolcallback ().getExcludedToolContextKeys ())
287+ .containsExactlyInAnyOrderElementsOf (Set .of ("TOOL_CALL_HISTORY" ));
249288 });
250289 }
251290
@@ -261,6 +300,9 @@ void asyncClientType() {
261300 assertThat (properties .isInitialized ()).isTrue ();
262301 assertThat (properties .getRequestTimeout ()).isEqualTo (Duration .ofSeconds (20 ));
263302 assertThat (properties .isRootChangeNotification ()).isTrue ();
303+ assertThat (properties .getToolcallback ().isEnabled ()).isTrue ();
304+ assertThat (properties .getToolcallback ().getExcludedToolContextKeys ())
305+ .containsExactlyInAnyOrderElementsOf (Set .of ("TOOL_CALL_HISTORY" ));
264306 });
265307 }
266308
@@ -278,6 +320,9 @@ void customNameAndVersion() {
278320 assertThat (properties .getRequestTimeout ()).isEqualTo (Duration .ofSeconds (20 ));
279321 assertThat (properties .getType ()).isEqualTo (McpClientCommonProperties .ClientType .SYNC );
280322 assertThat (properties .isRootChangeNotification ()).isTrue ();
323+ assertThat (properties .getToolcallback ().isEnabled ()).isTrue ();
324+ assertThat (properties .getToolcallback ().getExcludedToolContextKeys ())
325+ .containsExactlyInAnyOrderElementsOf (Set .of ("TOOL_CALL_HISTORY" ));
281326 });
282327 }
283328
0 commit comments