@@ -243,7 +243,7 @@ public McpAsyncServer build() {
243243 : McpJsonDefaults .getSchemaValidator ();
244244
245245 return new McpAsyncServer (transportProvider , jsonMapper == null ? McpJsonDefaults .getMapper () : jsonMapper ,
246- features , requestTimeout , uriTemplateManagerFactory , jsonSchemaValidator );
246+ features , requestTimeout , uriTemplateManagerFactory , jsonSchemaValidator , validateToolInputs );
247247 }
248248
249249 }
@@ -269,7 +269,7 @@ public McpAsyncServer build() {
269269 var jsonSchemaValidator = this .jsonSchemaValidator != null ? this .jsonSchemaValidator
270270 : McpJsonDefaults .getSchemaValidator ();
271271 return new McpAsyncServer (transportProvider , jsonMapper == null ? McpJsonDefaults .getMapper () : jsonMapper ,
272- features , requestTimeout , uriTemplateManagerFactory , jsonSchemaValidator );
272+ features , requestTimeout , uriTemplateManagerFactory , jsonSchemaValidator , validateToolInputs );
273273 }
274274
275275 }
@@ -293,6 +293,8 @@ abstract class AsyncSpecification<S extends AsyncSpecification<S>> {
293293
294294 boolean strictToolNameValidation = ToolNameValidator .isStrictByDefault ();
295295
296+ boolean validateToolInputs = true ;
297+
296298 /**
297299 * The Model Context Protocol (MCP) allows servers to expose tools that can be
298300 * invoked by language models. Tools enable models to interact with external
@@ -421,6 +423,17 @@ public AsyncSpecification<S> strictToolNameValidation(boolean strict) {
421423 return this ;
422424 }
423425
426+ /**
427+ * Sets whether to validate tool inputs against the tool's input schema.
428+ * @param validate true to validate inputs and return error on validation failure,
429+ * false to skip validation. Defaults to true.
430+ * @return This builder instance for method chaining
431+ */
432+ public AsyncSpecification <S > validateToolInputs (boolean validate ) {
433+ this .validateToolInputs = validate ;
434+ return this ;
435+ }
436+
424437 /**
425438 * Sets the server capabilities that will be advertised to clients during
426439 * connection initialization. Capabilities define what features the server
@@ -818,7 +831,8 @@ public McpSyncServer build() {
818831 var asyncServer = new McpAsyncServer (transportProvider ,
819832 jsonMapper == null ? McpJsonDefaults .getMapper () : jsonMapper , asyncFeatures , requestTimeout ,
820833 uriTemplateManagerFactory ,
821- jsonSchemaValidator != null ? jsonSchemaValidator : McpJsonDefaults .getSchemaValidator ());
834+ jsonSchemaValidator != null ? jsonSchemaValidator : McpJsonDefaults .getSchemaValidator (),
835+ validateToolInputs );
822836 return new McpSyncServer (asyncServer , this .immediateExecution );
823837 }
824838
@@ -849,7 +863,7 @@ public McpSyncServer build() {
849863 : McpJsonDefaults .getSchemaValidator ();
850864 var asyncServer = new McpAsyncServer (transportProvider ,
851865 jsonMapper == null ? McpJsonDefaults .getMapper () : jsonMapper , asyncFeatures , this .requestTimeout ,
852- this .uriTemplateManagerFactory , jsonSchemaValidator );
866+ this .uriTemplateManagerFactory , jsonSchemaValidator , validateToolInputs );
853867 return new McpSyncServer (asyncServer , this .immediateExecution );
854868 }
855869
@@ -872,6 +886,8 @@ abstract class SyncSpecification<S extends SyncSpecification<S>> {
872886
873887 boolean strictToolNameValidation = ToolNameValidator .isStrictByDefault ();
874888
889+ boolean validateToolInputs = true ;
890+
875891 /**
876892 * The Model Context Protocol (MCP) allows servers to expose tools that can be
877893 * invoked by language models. Tools enable models to interact with external
@@ -1004,6 +1020,17 @@ public SyncSpecification<S> strictToolNameValidation(boolean strict) {
10041020 return this ;
10051021 }
10061022
1023+ /**
1024+ * Sets whether to validate tool inputs against the tool's input schema.
1025+ * @param validate true to validate inputs and return error on validation failure,
1026+ * false to skip validation. Defaults to true.
1027+ * @return This builder instance for method chaining
1028+ */
1029+ public SyncSpecification <S > validateToolInputs (boolean validate ) {
1030+ this .validateToolInputs = validate ;
1031+ return this ;
1032+ }
1033+
10071034 /**
10081035 * Sets the server capabilities that will be advertised to clients during
10091036 * connection initialization. Capabilities define what features the server
@@ -1401,6 +1428,8 @@ class StatelessAsyncSpecification {
14011428
14021429 boolean strictToolNameValidation = ToolNameValidator .isStrictByDefault ();
14031430
1431+ boolean validateToolInputs = true ;
1432+
14041433 /**
14051434 * The Model Context Protocol (MCP) allows servers to expose tools that can be
14061435 * invoked by language models. Tools enable models to interact with external
@@ -1530,6 +1559,17 @@ public StatelessAsyncSpecification strictToolNameValidation(boolean strict) {
15301559 return this ;
15311560 }
15321561
1562+ /**
1563+ * Sets whether to validate tool inputs against the tool's input schema.
1564+ * @param validate true to validate inputs and return error on validation failure,
1565+ * false to skip validation. Defaults to true.
1566+ * @return This builder instance for method chaining
1567+ */
1568+ public StatelessAsyncSpecification validateToolInputs (boolean validate ) {
1569+ this .validateToolInputs = validate ;
1570+ return this ;
1571+ }
1572+
15331573 /**
15341574 * Sets the server capabilities that will be advertised to clients during
15351575 * connection initialization. Capabilities define what features the server
@@ -1859,7 +1899,8 @@ public McpStatelessAsyncServer build() {
18591899 this .resources , this .resourceTemplates , this .prompts , this .completions , this .instructions );
18601900 return new McpStatelessAsyncServer (transport , jsonMapper == null ? McpJsonDefaults .getMapper () : jsonMapper ,
18611901 features , requestTimeout , uriTemplateManagerFactory ,
1862- jsonSchemaValidator != null ? jsonSchemaValidator : McpJsonDefaults .getSchemaValidator ());
1902+ jsonSchemaValidator != null ? jsonSchemaValidator : McpJsonDefaults .getSchemaValidator (),
1903+ validateToolInputs );
18631904 }
18641905
18651906 }
@@ -1884,6 +1925,8 @@ class StatelessSyncSpecification {
18841925
18851926 boolean strictToolNameValidation = ToolNameValidator .isStrictByDefault ();
18861927
1928+ boolean validateToolInputs = true ;
1929+
18871930 /**
18881931 * The Model Context Protocol (MCP) allows servers to expose tools that can be
18891932 * invoked by language models. Tools enable models to interact with external
@@ -2013,6 +2056,17 @@ public StatelessSyncSpecification strictToolNameValidation(boolean strict) {
20132056 return this ;
20142057 }
20152058
2059+ /**
2060+ * Sets whether to validate tool inputs against the tool's input schema.
2061+ * @param validate true to validate inputs and return error on validation failure,
2062+ * false to skip validation. Defaults to true.
2063+ * @return This builder instance for method chaining
2064+ */
2065+ public StatelessSyncSpecification validateToolInputs (boolean validate ) {
2066+ this .validateToolInputs = validate ;
2067+ return this ;
2068+ }
2069+
20162070 /**
20172071 * Sets the server capabilities that will be advertised to clients during
20182072 * connection initialization. Capabilities define what features the server
@@ -2360,7 +2414,8 @@ public McpStatelessSyncServer build() {
23602414 var asyncServer = new McpStatelessAsyncServer (transport ,
23612415 jsonMapper == null ? McpJsonDefaults .getMapper () : jsonMapper , asyncFeatures , requestTimeout ,
23622416 uriTemplateManagerFactory ,
2363- this .jsonSchemaValidator != null ? this .jsonSchemaValidator : McpJsonDefaults .getSchemaValidator ());
2417+ this .jsonSchemaValidator != null ? this .jsonSchemaValidator : McpJsonDefaults .getSchemaValidator (),
2418+ validateToolInputs );
23642419 return new McpStatelessSyncServer (asyncServer , this .immediateExecution );
23652420 }
23662421
0 commit comments