Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions nostr-java-mcp/src/test/java/nostr/mcp/NostrMcpServerStdioIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
import io.modelcontextprotocol.spec.McpSchema.Tool;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.time.Duration;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -270,6 +273,7 @@ private McpSyncClient launchServerWithEnvironment(Map<String, String> environmen
ServerParameters.builder("java")
.args(
"-Dnostr.mcp.relays.read=" + UNREACHABLE_RELAY,
isolatedUserHome(),
"-cp",
runtimeClasspath(),
NostrMcpApplication.class.getName())
Expand All @@ -284,6 +288,7 @@ private McpSyncClient launchServerWithEnvironment(Map<String, String> environmen
private McpSyncClient launchServer(String... extraProperties) {
List<String> arguments = new java.util.ArrayList<>();
arguments.add("-Dnostr.mcp.relays.read=" + UNREACHABLE_RELAY);
arguments.add(isolatedUserHome());
arguments.addAll(List.of(extraProperties));
arguments.add("-cp");
arguments.add(runtimeClasspath());
Expand All @@ -297,6 +302,18 @@ private McpSyncClient launchServer(String... extraProperties) {
.build();
}

/**
* Points the server at an empty home directory, so identities the developer running the build
* has created (indexed under {@code ~/.nostr-java}) do not leak into what the server reports.
*/
private String isolatedUserHome() {
try {
return "-Duser.home=" + Files.createTempDirectory("nostr-mcp-it-home");
} catch (IOException e) {
throw new UncheckedIOException("Could not create an isolated home directory", e);
}
}

/** The classpath this test is running with, which already contains the module and the SDK. */
private String runtimeClasspath() {
return System.getProperty("java.class.path");
Expand Down