Skip to content

Commit cb93d9e

Browse files
committed
Add migration notes
Signed-off-by: Dariusz Jędrzejczyk <2554306+chemicL@users.noreply.github.com>
1 parent 47bf2ae commit cb93d9e

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

MIGRATION-2.0.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,24 @@ The `Tool` record now models `inputSchema` (and `outputSchema`) as arbitrary JSO
7777
- Java code that used `Tool.inputSchema()` as a `JsonSchema` must switch to `Map<String, Object>` (or copy into your own schema wrapper).
7878
- `Tool.Builder.inputSchema(JsonSchema)` remains as a **deprecated** helper that maps the old record into a map; prefer `inputSchema(Map)` or `inputSchema(McpJsonMapper, String)`.
7979

80+
### Required MCP spec fields are now guarded against `null` at construction time
81+
82+
The following records now assert that their required fields (as mandated by the MCP specification) are non-null at construction time. Passing `null` for any of these fields throws `IllegalArgumentException` immediately, rather than producing a structurally invalid object that fails later during serialization or protocol handling.
83+
84+
| Record | Required (non-null) fields |
85+
|--------|---------------------------|
86+
| `JSONRPCResponse.JSONRPCError` | `code`, `message` |
87+
| `CallToolResult` | `content` |
88+
| `SamplingMessage` | `role`, `content` |
89+
| `CreateMessageRequest` | `messages`, `maxTokens` |
90+
| `ElicitRequest` | `message`, `requestedSchema` |
91+
| `ProgressNotification` | `progressToken`, `progress` |
92+
| `LoggingMessageNotification` | `level`, `data` |
93+
94+
**Action:** Audit any code that constructs these records with potentially-null values and provide valid, non-null arguments. Code paths that previously silently produced malformed wire messages will now fail fast at the construction site.
95+
96+
**Note on `LoggingMessageNotification.level`:** Because `LoggingLevel` deserialization is lenient (unknown strings produce `null` — see the section above), inbound notifications with an unrecognized level will fail to deserialize into a `LoggingMessageNotification`. Ensure clients and servers send only recognized level strings.
97+
8098
### Optional JSON Schema validation on `tools/call` (server)
8199

82100
When a `JsonSchemaValidator` is available (including the default from `McpJsonDefaults.getSchemaValidator()` when you do not configure one explicitly) and `validateToolInputs` is left at its default of `true`, the server validates incoming tool arguments against `tool.inputSchema()` before invoking the tool. Failed validation produces a `CallToolResult` with `isError` set and a textual error in the content.

0 commit comments

Comments
 (0)