Skip to content

Commit da14593

Browse files
committed
Add JSON deserialization test
1 parent 3297830 commit da14593

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

mcp/src/test/java/io/modelcontextprotocol/spec/McpSchemaTests.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,23 @@ void testJSONRPCRequest() throws Exception {
163163
{"jsonrpc":"2.0","method":"method_name","id":1,"params":{"key":"value"}}"""));
164164
}
165165

166+
@Test
167+
void testJSONRPCRequestWithMeta() throws Exception {
168+
Map<String, Object> params = new HashMap<>();
169+
params.put("key", "value");
170+
params.put("_meta", Map.of("progressToken", "abc123"));
171+
172+
McpSchema.JSONRPCRequest request = new McpSchema.JSONRPCRequest(McpSchema.JSONRPC_VERSION, "method_name", 1,
173+
params);
174+
175+
String value = mapper.writeValueAsString(request);
176+
assertThatJson(value).when(Option.IGNORING_ARRAY_ORDER)
177+
.when(Option.IGNORING_EXTRA_ARRAY_ITEMS)
178+
.isObject()
179+
.isEqualTo(json("""
180+
{"jsonrpc":"2.0","method":"method_name","id":1,"params":{"key":"value"},"_meta":{"progressToken":"abc123"}}"""));
181+
}
182+
166183
@Test
167184
void testJSONRPCNotification() throws Exception {
168185
Map<String, Object> params = new HashMap<>();

0 commit comments

Comments
 (0)