modelcontextprotocol / modelcontextprotocol/java-sdk
Support running test cases in offline environments
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 3.7k
- Forks
- 1.1k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 9
Description
Description:
Several test cases in mcp-test and other src/test rely on external HTTP endpoints, which cause test failures in offline CI/CD environments.
For example, test case testToolCallSuccess of AbstractStatelessIntegrationTest.java throws an AssertionError if a GET request to raw.githubusercontent.com/modelcontextprotocol/java-sdk/refs/heads/main/README.md has null or empty response.
Goal:
- Support running maven test lifecycle for offline environments.
- Specifically, all test cases shall pass when
-ooption is appended to mvn test command, provided that all required docker images have already been imported (the default container pull policy will allow this to work offline).
Proposed changes:
Instead of sending GET request using an HTTP client, use a mock client that reads README.md from local file.
HttpClient mockClient = mock(HttpClient.class);
HttpResponse<String> mockResponse = mock(HttpResponse.class);
// Relative path of README.md depending on project directory
when(mockResponse.body()).thenReturn(Files.readString(Path.of("../README.md").toAbsolutePath()));
when(mockResponse.statusCode()).thenReturn(200);
when(mockClient.send(any(HttpRequest.class), any(HttpResponse.BodyHandler.class))).thenReturn(mockResponse);
Environment:
- MCP Java SDK: current
mainbranch - JDK: 21
- OS: Linux
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with testToolCallSuccess in AbstractStatelessIntegrationTest.java and inspect the related tests under mcp-test and src/test for external HTTP endpoints. Run the Maven test lifecycle with -o after required Docker images are available. Done means the test suite passes in an offline environment without contacting external endpoints.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, java
- Domain
- build-system, testing-qa
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100