Repository navigation
MCP: upgrade framework and test stateless tools/list #2644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
027c386
test: reproduce rejection of stateless MCP 2026-07-28 requests
erichare b2088a9
fix: upgrade MCP runtime for stateless protocol requests
erichare bdc563c
test: expect framework server metadata in MCP responses
erichare 5fb06da
Share MCP HTTP test support and run CI for stacked PRs
erichare d3c2429
ci: restore the original pull request branch filter
erichare c6b4121
Address MCP protocol test review comments
erichare File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/test/java/io/stargate/sgv2/jsonapi/api/v1/mcp/McpHttpTestSupport.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| package io.stargate.sgv2.jsonapi.api.v1.mcp; | ||
|
|
||
| import static io.restassured.RestAssured.given; | ||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| import io.restassured.http.ContentType; | ||
| import io.restassured.response.Response; | ||
| import io.restassured.specification.RequestSpecification; | ||
| import io.vertx.core.json.JsonObject; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| /** Shared wire format for raw HTTP tests that do not initialize an MCP client session. */ | ||
| final class McpHttpTestSupport { | ||
| private static final String CURRENT_PROTOCOL_VERSION = "2026-07-28"; | ||
|
|
||
| private McpHttpTestSupport() {} | ||
|
|
||
| static RequestSpecification request(String method) { | ||
| return given() | ||
| .contentType(ContentType.JSON) | ||
| .accept("application/json, text/event-stream") | ||
| .header("MCP-Protocol-Version", CURRENT_PROTOCOL_VERSION) | ||
| .header("Mcp-Method", method); | ||
| } | ||
|
|
||
| static Map<String, Object> toolPayload(int id, String tool, Map<String, Object> arguments) { | ||
| return rpcPayload(id, "tools/call", Map.of("name", tool, "arguments", arguments)); | ||
| } | ||
|
|
||
| static Map<String, Object> rpcPayload(int id, String method, Map<String, Object> params) { | ||
| var requestParams = new HashMap<>(params); | ||
| requestParams.put( | ||
| "_meta", | ||
| Map.of( | ||
| "io.modelcontextprotocol/protocolVersion", | ||
| CURRENT_PROTOCOL_VERSION, | ||
| "io.modelcontextprotocol/clientCapabilities", | ||
| Map.of())); | ||
| return Map.of("jsonrpc", "2.0", "id", id, "method", method, "params", requestParams); | ||
| } | ||
|
|
||
| static JsonObject assertResponseComplete(Response response, int id) { | ||
| assertThat(response.statusCode()).as(response.asString()).isEqualTo(200); | ||
| var body = new JsonObject(response.asString()); | ||
| assertThat(body.getInteger("id")).isEqualTo(id); | ||
| assertThat(body.containsKey("error")).isFalse(); | ||
| var result = body.getJsonObject("result"); | ||
| assertThat(result.getString("resultType")).isEqualTo("complete"); | ||
| return result; | ||
| } | ||
|
|
||
| static JsonObject assertResultReadable(JsonObject result) { | ||
| var content = result.getJsonArray("content"); | ||
| assertThat(content).hasSize(1); | ||
| assertThat(content.getJsonObject(0).getString("type")).isEqualTo("text"); | ||
| return new JsonObject(content.getJsonObject(0).getString("text")); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/test/java/io/stargate/sgv2/jsonapi/api/v1/mcp/McpProtocolTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package io.stargate.sgv2.jsonapi.api.v1.mcp; | ||
|
|
||
| import static io.stargate.sgv2.jsonapi.api.v1.mcp.McpHttpTestSupport.assertResponseComplete; | ||
| import static io.stargate.sgv2.jsonapi.api.v1.mcp.McpHttpTestSupport.request; | ||
| import static io.stargate.sgv2.jsonapi.api.v1.mcp.McpHttpTestSupport.rpcPayload; | ||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| import io.quarkus.test.junit.QuarkusTest; | ||
| import io.quarkus.test.junit.TestProfile; | ||
| import io.stargate.sgv2.jsonapi.testresource.NoGlobalResourcesTestProfile; | ||
| import java.util.Map; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| /** Exercises the HTTP wire contract without a client that might initialize a session for us. */ | ||
| @QuarkusTest | ||
| @TestProfile(NoGlobalResourcesTestProfile.Impl.class) | ||
| class McpProtocolTest { | ||
| @Test | ||
| void listsToolsWithoutInitializationOrSession() { | ||
| // Each POST is independent. clientInfo, discovery and initialization are deliberately absent. | ||
| for (int id = 1; id <= 2; id++) { | ||
| var response = | ||
| request("tools/list") | ||
| // Header auth checks only that a token is present. Database requests validate it, | ||
| // but tools/list returns metadata without accessing the database. | ||
| .header("Token", "protocol-test-credential") | ||
| .body(rpcPayload(id, "tools/list", Map.of())) | ||
| .post("/v1/mcp"); | ||
| assertResponseComplete(response, id); | ||
| assertThat(response.header("Mcp-Session-Id")).isNull(); | ||
| assertThat(response.jsonPath().getList("result.tools.name")).isNotEmpty(); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.