Skip to content

Commit aa95c0d

Browse files
committed
Add JSON deserialization test
1 parent 705c70f commit aa95c0d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,24 @@ void testJSONRPCRequest() throws Exception {
186186
{"jsonrpc":"2.0","method":"method_name","id":1,"params":{"key":"value"}}"""));
187187
}
188188

189+
@Test
190+
void testJSONRPCRequestWithMeta() throws Exception {
191+
Map<String, Object> params = new HashMap<>();
192+
params.put("key", "value");
193+
params.put("_meta", Map.of("progressToken", "abc123"));
194+
195+
McpSchema.JSONRPCRequest request = new McpSchema.JSONRPCRequest(McpSchema.JSONRPC_VERSION, "method_name", 1,
196+
params);
197+
198+
String value = mapper.writeValueAsString(request);
199+
assertThatJson(value).when(Option.IGNORING_ARRAY_ORDER)
200+
.when(Option.IGNORING_EXTRA_ARRAY_ITEMS)
201+
.isObject()
202+
.isEqualTo(
203+
json("""
204+
{"jsonrpc":"2.0","method":"method_name","id":1,"params":{"key":"value"},"_meta":{"progressToken":"abc123"}}"""));
205+
}
206+
189207
@Test
190208
void testJSONRPCNotification() throws Exception {
191209
Map<String, Object> params = new HashMap<>();

0 commit comments

Comments
 (0)