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() {
175175
176176 }
177177
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+
178208 @ Test
179209 public void testResourcesList () {
180210 String jsonBody = """
Original file line number Diff line number Diff line change @@ -55,7 +55,8 @@ private JsonRpcRequest remap(JsonRpcRequest jsonRpcRequest) {
5555 mapped .setId (jsonRpcRequest .getId ());
5656 mapped .setJsonrpc (jsonRpcRequest .getJsonrpc ());
5757 mapped .setMethod (mappedName );
58- mapped .setParams (mappedParams );
58+ if (mappedParams != null && !mappedParams .isEmpty ())
59+ mapped .setParams (mappedParams );
5960
6061 return mapped ;
6162 }
Original file line number Diff line number Diff line change @@ -110,9 +110,17 @@ private void handleMCPJsonRPCRequest(RoutingContext ctx) {
110110 // This is a MCP notification
111111 this .routeToMCPNotification (jsonRpcRequest , codec , writer );
112112 } 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 )) {
115114 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 ));
116124 jsonRpcRouter .route (jsonRpcRequest , writer );
117125 } else {
118126 // This is a normal extension method
You can’t perform that action at this time.
0 commit comments