You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: conformance-tests/server-servlet/src/main/java/io/modelcontextprotocol/conformance/server/ConformanceServlet.java
McpTransport transport =newStdioClientTransport(params);
146
+
McpTransport transport =newStdioClientTransport(params, McpJsonDefaults.getMapper());
148
147
```
149
148
150
149
### Streamable HTTP
@@ -184,7 +183,7 @@ McpTransport transport = new StdioClientTransport(params);
184
183
Creates a framework-agnostic (pure Java API) SSE client transport. Included in the core `mcp` module:
185
184
186
185
```java
187
-
McpTransport transport = new HttpClientSseClientTransport("http://your-mcp-server");
186
+
McpTransport transport = HttpClientSseClientTransport.builder("http://your-mcp-server").build();
188
187
```
189
188
=== "SSE WebClient (external)"
190
189
@@ -301,6 +300,17 @@ The `ElicitResult` supports three actions:
301
300
-`DECLINE` - The user declined to provide the information
302
301
-`CANCEL` - The operation was cancelled
303
302
303
+
You can optionally have the client fill in missing values from the schema's `default` declarations before returning an accepted result to the server:
304
+
305
+
```java
306
+
var client =McpClient.sync(transport)
307
+
.applyElicitationDefaults(true) // default is false
308
+
.elicitation(formElicitationHandler)
309
+
.build();
310
+
```
311
+
312
+
When enabled, any keys absent from an accepted `ElicitResult.content` are populated with the `default` values declared in the request's `requestedSchema`.
313
+
304
314
#### URL Elicitation Required Handling
305
315
306
316
When a server requires out-of-band URL elicitation but the client has not negotiated support for it (or the server strictly requires out-of-band handling), the server may return a `URL_ELICITATION_REQUIRED` error during tool execution or prompt retrieval.
CallToolResult result = mcpClient.callTool(newCallToolRequest("logging-test", Map.of()));
352
+
CallToolResult result = mcpClient.callTool(CallToolRequest.builder("logging-test").build());
343
353
```
344
354
345
355
Clients can control the minimum logging level they receive through the `mcpClient.setLoggingLevel(level)` request. Messages below the set level will be filtered out.
@@ -371,11 +381,13 @@ Tools are server-side functions that clients can discover and execute. The MCP c
371
381
372
382
// Call a tool with a CallToolRequest
373
383
CallToolResult result = client.callTool(
374
-
new CallToolRequest("calculator", Map.of(
375
-
"operation", "add",
376
-
"a", 1,
377
-
"b", 2
378
-
))
384
+
CallToolRequest.builder("calculator")
385
+
.arguments(Map.of(
386
+
"operation", "add",
387
+
"a", 1,
388
+
"b", 2
389
+
))
390
+
.build()
379
391
);
380
392
```
381
393
@@ -389,11 +401,13 @@ Tools are server-side functions that clients can discover and execute. The MCP c
0 commit comments