Fix the docker.io/tzolov/mcp-everything-server:v1 url
This commit is contained in:
parent
bc281dee54
commit
0ebb38ce0e
4 changed files with 40 additions and 4 deletions
|
|
@ -48,6 +48,15 @@ public class DefaultMcpSession implements McpSession {
|
||||||
|
|
||||||
private final McpTransport transport;
|
private final McpTransport transport;
|
||||||
|
|
||||||
|
private final ConcurrentHashMap<String, RequestHandler> requestHandlers = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface RequestHandler {
|
||||||
|
|
||||||
|
Mono<Object> handle(Object params);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public DefaultMcpSession(Duration requestTimeout, ObjectMapper objectMapper, McpTransport transport) {
|
public DefaultMcpSession(Duration requestTimeout, ObjectMapper objectMapper, McpTransport transport) {
|
||||||
|
|
||||||
Assert.notNull(objectMapper, "The ObjectMapper can not be null");
|
Assert.notNull(objectMapper, "The ObjectMapper can not be null");
|
||||||
|
|
@ -70,7 +79,13 @@ public class DefaultMcpSession implements McpSession {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (message instanceof McpSchema.JSONRPCRequest request) {
|
else if (message instanceof McpSchema.JSONRPCRequest request) {
|
||||||
logger.info("Client does not yet support server requests");
|
handleIncomingRequest(request).subscribe(response -> transport.sendMessage(response).subscribe(),
|
||||||
|
error -> {
|
||||||
|
var errorResponse = new McpSchema.JSONRPCResponse(McpSchema.JSONRPC_VERSION, request.id(),
|
||||||
|
null, new McpSchema.JSONRPCResponse.JSONRPCError(
|
||||||
|
McpSchema.ErrorCodes.INTERNAL_ERROR, error.getMessage(), null));
|
||||||
|
transport.sendMessage(errorResponse).subscribe();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else if (message instanceof McpSchema.JSONRPCNotification notification) {
|
else if (message instanceof McpSchema.JSONRPCNotification notification) {
|
||||||
logger.info("Notifications not yet supported");
|
logger.info("Notifications not yet supported");
|
||||||
|
|
@ -82,6 +97,27 @@ public class DefaultMcpSession implements McpSession {
|
||||||
this.transport.start();
|
this.transport.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Mono<McpSchema.JSONRPCResponse> handleIncomingRequest(McpSchema.JSONRPCRequest request) {
|
||||||
|
return Mono.defer(() -> {
|
||||||
|
var handler = requestHandlers.get(request.method());
|
||||||
|
if (handler == null) {
|
||||||
|
return Mono.just(new McpSchema.JSONRPCResponse(McpSchema.JSONRPC_VERSION, request.id(), null,
|
||||||
|
new McpSchema.JSONRPCResponse.JSONRPCError(McpSchema.ErrorCodes.METHOD_NOT_FOUND,
|
||||||
|
"Method not found: " + request.method(), null)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return handler.handle(request.params())
|
||||||
|
.map(result -> new McpSchema.JSONRPCResponse(McpSchema.JSONRPC_VERSION, request.id(), result, null))
|
||||||
|
.onErrorResume(error -> Mono.just(new McpSchema.JSONRPCResponse(McpSchema.JSONRPC_VERSION, request.id(),
|
||||||
|
null, new McpSchema.JSONRPCResponse.JSONRPCError(McpSchema.ErrorCodes.INTERNAL_ERROR,
|
||||||
|
error.getMessage(), null))));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerRequestHandler(String method, RequestHandler handler) {
|
||||||
|
requestHandlers.put(method, handler);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> Mono<T> sendRequest(String method, Object requestParams, TypeReference<T> typeRef) {
|
public <T> Mono<T> sendRequest(String method, Object requestParams, TypeReference<T> typeRef) {
|
||||||
// TODO: UUID API is blocking. Consider non-blocking alternatives to generate
|
// TODO: UUID API is blocking. Consider non-blocking alternatives to generate
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ class SseMcpAsyncClientTests extends AbstractMcpAsyncClientTests {
|
||||||
|
|
||||||
// Uses the https://github.com/tzolov/mcp-everything-server-docker-image
|
// Uses the https://github.com/tzolov/mcp-everything-server-docker-image
|
||||||
@SuppressWarnings("resource")
|
@SuppressWarnings("resource")
|
||||||
static GenericContainer<?> container = new GenericContainer<>("tzolov/mcp-everything-server:v1")
|
static GenericContainer<?> container = new GenericContainer<>("docker.io/tzolov/mcp-everything-server:v1")
|
||||||
.withLogConsumer(outputFrame -> System.out.println(outputFrame.getUtf8String()))
|
.withLogConsumer(outputFrame -> System.out.println(outputFrame.getUtf8String()))
|
||||||
.withExposedPorts(3001)
|
.withExposedPorts(3001)
|
||||||
.waitingFor(Wait.forHttp("/").forStatusCode(404));
|
.waitingFor(Wait.forHttp("/").forStatusCode(404));
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ class SseMcpSyncClientTests extends AbstractMcpSyncClientTests {
|
||||||
|
|
||||||
// Uses the https://github.com/tzolov/mcp-everything-server-docker-image
|
// Uses the https://github.com/tzolov/mcp-everything-server-docker-image
|
||||||
@SuppressWarnings("resource")
|
@SuppressWarnings("resource")
|
||||||
static GenericContainer<?> container = new GenericContainer<>("tzolov/mcp-everything-server:v1")
|
static GenericContainer<?> container = new GenericContainer<>("docker.io/tzolov/mcp-everything-server:v1")
|
||||||
.withLogConsumer(outputFrame -> System.out.println(outputFrame.getUtf8String()))
|
.withLogConsumer(outputFrame -> System.out.println(outputFrame.getUtf8String()))
|
||||||
.withExposedPorts(3001)
|
.withExposedPorts(3001)
|
||||||
.waitingFor(Wait.forHttp("/").forStatusCode(404));
|
.waitingFor(Wait.forHttp("/").forStatusCode(404));
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ class SseServerTransportTests {
|
||||||
static String host = "http://localhost:3001";
|
static String host = "http://localhost:3001";
|
||||||
|
|
||||||
@SuppressWarnings("resource")
|
@SuppressWarnings("resource")
|
||||||
static GenericContainer<?> container = new GenericContainer<>("tzolov/mcp-everything-server:v1")
|
static GenericContainer<?> container = new GenericContainer<>("docker.io/tzolov/mcp-everything-server:v1")
|
||||||
.withLogConsumer(outputFrame -> System.out.println(outputFrame.getUtf8String()))
|
.withLogConsumer(outputFrame -> System.out.println(outputFrame.getUtf8String()))
|
||||||
.withExposedPorts(3001)
|
.withExposedPorts(3001)
|
||||||
.waitingFor(Wait.forHttp("/").forStatusCode(404));
|
.waitingFor(Wait.forHttp("/").forStatusCode(404));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue