Skip to content

Commit 962e47b

Browse files
Merge pull request #50320 from phillip-kruger/dev-mcp-params-issue
Dev MCP: Don't set empty params
2 parents 6c3a543 + f68786b commit 962e47b

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

extensions/devui/deployment/src/test/java/io/quarkus/devui/devmcp/DevMcpTest.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff 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 = """

extensions/devui/runtime/src/main/java/io/quarkus/devui/runtime/jsonrpc/JsonRpcRequestCreator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}

extensions/devui/runtime/src/main/java/io/quarkus/devui/runtime/mcp/McpHttpHandler.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)