File tree Expand file tree Collapse file tree 3 files changed +42
-3
lines changed
deployment/src/test/java/io/quarkus/devui/devmcp
runtime/src/main/java/io/quarkus/devui/runtime Expand file tree Collapse file tree 3 files changed +42
-3
lines changed Original file line number Diff line number Diff line change @@ -175,6 +175,36 @@ public void testToolsCall() {
175
175
176
176
}
177
177
178
+ @ Test
179
+ public void testToolsCallWithEmptyArgs () {
180
+ String jsonBody = """
181
+ {
182
+ "jsonrpc": "2.0",
183
+ "id": 4,
184
+ "method": "tools/call",
185
+ "params": {
186
+ "name": "devui-logstream_getLoggers",
187
+ "arguments": {}
188
+ }
189
+ }
190
+ """ ;
191
+
192
+ RestAssured
193
+ .given ()
194
+ .contentType (ContentType .JSON )
195
+ .body (jsonBody )
196
+ .when ()
197
+ .post ("/q/dev-mcp" )
198
+ .then ()
199
+ .statusCode (200 )
200
+ .log ().all ()
201
+ .body ("id" , CoreMatchers .equalTo (4 ))
202
+ .body ("jsonrpc" , CoreMatchers .equalTo ("2.0" ))
203
+ .body ("result.content.type" , CoreMatchers .hasItem ("text" ))
204
+ .body ("result.content.text" , CoreMatchers .notNullValue ());
205
+
206
+ }
207
+
178
208
@ Test
179
209
public void testResourcesList () {
180
210
String jsonBody = """
Original file line number Diff line number Diff line change @@ -55,7 +55,8 @@ private JsonRpcRequest remap(JsonRpcRequest jsonRpcRequest) {
55
55
mapped .setId (jsonRpcRequest .getId ());
56
56
mapped .setJsonrpc (jsonRpcRequest .getJsonrpc ());
57
57
mapped .setMethod (mappedName );
58
- mapped .setParams (mappedParams );
58
+ if (mappedParams != null && !mappedParams .isEmpty ())
59
+ mapped .setParams (mappedParams );
59
60
60
61
return mapped ;
61
62
}
Original file line number Diff line number Diff line change @@ -110,9 +110,17 @@ private void handleMCPJsonRPCRequest(RoutingContext ctx) {
110
110
// This is a MCP notification
111
111
this .routeToMCPNotification (jsonRpcRequest , codec , writer );
112
112
} else if (methodName .equalsIgnoreCase (McpBuiltinMethods .TOOLS_LIST ) ||
113
- methodName .equalsIgnoreCase (McpBuiltinMethods .RESOURCES_LIST ) ||
114
- methodName .equalsIgnoreCase (McpBuiltinMethods .RESOURCES_READ )) {
113
+ methodName .equalsIgnoreCase (McpBuiltinMethods .RESOURCES_LIST )) {
115
114
jsonRpcRequest .setMethod (methodName .replace (SLASH , UNDERSCORE ));
115
+ // Make sure that parameters is empty as expected.
116
+ jsonRpcRequest .setParams (null );
117
+ jsonRpcRouter .route (jsonRpcRequest , writer );
118
+ } else if (methodName .equalsIgnoreCase (McpBuiltinMethods .RESOURCES_READ )) {
119
+ jsonRpcRequest .setMethod (methodName .replace (SLASH , UNDERSCORE ));
120
+ // Make sure that the only parameter is uri (as expected).
121
+ String uri = jsonRpcRequest .getParam ("uri" , String .class );
122
+ jsonRpcRequest .getParams ().clear ();
123
+ jsonRpcRequest .setParams (Map .of ("uri" , uri ));
116
124
jsonRpcRouter .route (jsonRpcRequest , writer );
117
125
} else {
118
126
// This is a normal extension method
You can’t perform that action at this time.
0 commit comments