Can multiple MCP servers with different endpoints be published in one service? An entry application needs to have a unified capability to implement routing forwarding for multiple MCP servers.

Comment From: flamezhang

+1

Comment From: flamezhang

@alexanderqiu have you found a solution now?

Comment From: apappascs

You can give it a try, but it will likely require some additional setup. Specifically, you'll need to ensure that each MCP server exposes its endpoints under a distinct path or port to avoid conflicts. Also, session management could become a challenge, as the MCP server maintains its own state. This might require a deeper look into the server implementation to fully understand how sessions are handled and whether multiple instances can safely coexist.

Comment From: alexanderqiu

I tried to rewrite McpServerAutoConfiguration and McpWebFluxServerAutoConfiguration and have succeeded

Comment From: sunchangji

+1

Comment From: wuque1024

@alexanderqiu Contribute your code, thank you very much!

Comment From: flamezhang

@alexanderqiu can you contribute your code? spirng-ai-alibaba nocos should be a good choice?but , I didn't use nocos。

Comment From: alexanderqiu

@alexanderqiu Contribute your code, thank you very much!

rewrite McpServerAutoConfiguration and McpWebFluxServerAutoConfiguration

Comment From: alexanderqiu

@alexanderqiu can you contribute your code? spirng-ai-alibaba nocos should be a good choice?but , I didn't use nocos。

rewrite McpServerAutoConfiguration and McpWebFluxServerAutoConfiguration

Comment From: goribun

+1

Comment From: czhcc

I want to create another McpSyncServer through such code after the project starts, but it has no effect.

public void createSyncServer()
    {
        WebMvcSseServerTransportProvider transportProvider =
                new WebMvcSseServerTransportProvider(new ObjectMapper(), "/mcp/message3","/sse3");
        mcpToolsBoot.registerSingletonBean("transportProvider3", transportProvider);
        RouterFunction<ServerResponse> f =  transportProvider.getRouterFunction();
        mcpToolsBoot.registerRouterFunction("dynamicRouterFunctionMapping3", f);
        ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
        WebMvcSseServerTransportProvider transportProvider1 = (WebMvcSseServerTransportProvider)beanFactory.getBean("transportProvider3");

        var capabilities = McpSchema.ServerCapabilities.builder()
                .tools(true) // Tool support with list changes notifications
                .prompts(true)
                .logging() // Logging support
                .build();

        // Create the server with both tool and resource capabilities
        // Add @Tools
//        ToolCallbackProvider provider = MethodToolCallbackProvider.builder().build();
        McpSyncServer syncServer = McpServer.sync(transportProvider1)
                .serverInfo("MCP Demo Weather Server3", "3.0.3")
                .capabilities(capabilities)
//                .tools(McpToolUtils.toSyncToolSpecifications(provider.getToolCallbacks())) // Add @Tools
                .build(); // @formatter:on

        mcpToolsBoot.registerSingletonBean("mcpSyncServer3", syncServer);
    }

Comment From: tzolov

@alexanderqiu, can you please elaborate on your use case.

It looks like you are trying to implement a load balancer with server replication? This will not fly with the existing HTTP/SSE protocol version . The new streamable http protocol provides a server stateless mode that could help with simple replication scenarios. But if you use the fully fledged SSE response modes you will like have to implement a sticky session or server request redirection solution.

But maybe I'm overcomplicating your use case?

Comment From: czhcc

I want to add different tool methods to different sseendpoints. Now different sseendpoints can be generated through bean annotations. But I want to implement it through code.