Skip to content

Commit b40820b

Browse files
Fix Java SDK documentation where it's incosistent to API (modelcontextprotocol#154)
1 parent 111d51d commit b40820b

File tree

1 file changed

+36
-10
lines changed

1 file changed

+36
-10
lines changed

sdk/java/mcp-server.mdx

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,25 @@ Supported logging levels (in order of increasing severity): DEBUG (0), INFO (1),
259259
<Tab title="Sync">
260260
```java
261261
// Sync tool registration
262+
var schema = """
263+
{
264+
"type" : "object",
265+
"id" : "urn:jsonschema:Operation",
266+
"properties" : {
267+
"operation" : {
268+
"type" : "string"
269+
},
270+
"a" : {
271+
"type" : "number"
272+
},
273+
"b" : {
274+
"type" : "number"
275+
}
276+
}
277+
}
278+
""";
262279
var syncToolRegistration = new McpServerFeatures.SyncToolRegistration(
263-
new Tool("calculator", "Basic calculator", Map.of(
264-
"operation", "string",
265-
"a", "number",
266-
"b", "number"
267-
)),
280+
new Tool("calculator", "Basic calculator", schema),
268281
arguments -> {
269282
// Tool implementation
270283
return new CallToolResult(result, false);
@@ -276,12 +289,25 @@ var syncToolRegistration = new McpServerFeatures.SyncToolRegistration(
276289
<Tab title="Async">
277290
```java
278291
// Async tool registration
292+
var schema = """
293+
{
294+
"type" : "object",
295+
"id" : "urn:jsonschema:Operation",
296+
"properties" : {
297+
"operation" : {
298+
"type" : "string"
299+
},
300+
"a" : {
301+
"type" : "number"
302+
},
303+
"b" : {
304+
"type" : "number"
305+
}
306+
}
307+
}
308+
""";
279309
var asyncToolRegistration = new McpServerFeatures.AsyncToolRegistration(
280-
new Tool("calculator", "Basic calculator", Map.of(
281-
"operation", "string",
282-
"a", "number",
283-
"b", "number"
284-
)),
310+
new Tool("calculator", "Basic calculator", schema),
285311
arguments -> {
286312
// Tool implementation
287313
return Mono.just(new CallToolResult(result, false));

0 commit comments

Comments
 (0)