✅ (mcp): Fix flaky addAndListIssueCommentTools (write/read race)
Changes
1 file changed, +6 -0
MODIFY
src/test/java/de/workaround/mcp/McpToolsTest.java
+6 -0
@@ -138,12 +138,18 @@
138
138
.setAdditionalHeaders(json -> MultiMap.caseInsensitiveMultiMap().add("Authorization", "Bearer " + token))
139
139
.build().connect();
140
140
141
+ // Add the comment and await its result before listing. Chaining both calls in one when() block
142
+ // dispatches them concurrently (they land on different MCP worker threads), so the list can race
143
+ // the add's commit and come back empty. A real MCP client calls sequentially — await, then list.
141
144
client.when()
142
145
.toolsCall("addIssueComment", Map.of("owner", owner.username, "name", "mcpissuecomments",
143
146
"number", issueNumber, "body", "first thought"), response -> {
144
147
assertFalse(response.isError());
145
148
assertTrue(response.firstContent().asText().text().contains("first thought"));
146
149
})
150
+ .thenAssertResults();
151
+
152
+ client.when()
147
153
.toolsCall("listIssueComments", Map.of("owner", owner.username, "name", "mcpissuecomments",
148
154
"number", issueNumber), response -> {
149
155
assertFalse(response.isError());