java-sdk/mcp-spring/mcp-spring-webflux
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Dariusz Jędrzejczyk 0a8cb1e038
Decouple mcp-test and mcp-spring modules from Jackson implementation (#760)
This is a follow-up to #742.

The `mcp-test`, `mcp-spring-webflux`, and `mcp-spring-webmvc` depended
on `mcp` module which transitively brought in Jackson 3 dependencies.
These modules are now decoupled and only depend on `mcp-core`.

The test dependencies bring in Jackson 2 for the time being.

This is a breaking change but it is required to allow easily exchanging
Jackson2 and Jackson3 modules.

Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
2026-01-27 15:47:28 +01:00
..
src Decouple mcp-test and mcp-spring modules from Jackson implementation (#760) 2026-01-27 15:47:28 +01:00
pom.xml Decouple mcp-test and mcp-spring modules from Jackson implementation (#760) 2026-01-27 15:47:28 +01:00
README.md Module and Package restructoring 2025-01-29 13:40:53 +01:00

WebFlux SSE Transport

<dependency>
    <groupId>io.modelcontextprotocol.sdk</groupId>
    <artifactId>mcp-spring-webflux</artifactId>
</dependency>
String MESSAGE_ENDPOINT = "/mcp/message";

@Configuration
static class MyConfig {

    // SSE transport
	@Bean
	public WebFluxSseServerTransport sseServerTransport() {
		return new WebFluxSseServerTransport(new ObjectMapper(), "/mcp/message");
	}

	// Router function for SSE transport used by Spring WebFlux to start an HTTP
	// server.
	@Bean
	public RouterFunction<?> mcpRouterFunction(WebFluxSseServerTransport transport) {
		return transport.getRouterFunction();
	}

	@Bean
	public McpAsyncServer mcpServer(ServerMcpTransport transport, OpenLibrary openLibrary) {

		// Configure server capabilities with resource support
		var capabilities = McpSchema.ServerCapabilities.builder()
			.resources(false, true) // No subscribe support, but list changes notifications
			.tools(true) // Tool support with list changes notifications
			.prompts(true) // Prompt support with list changes notifications
			.logging() // Logging support
			.build();

		// Create the server with both tool and resource capabilities
		var server = McpServer.using(transport)
			.serverInfo("MCP Demo Server", "1.0.0")
			.capabilities(capabilities)
			.resources(systemInfoResourceRegistration())
			.prompts(greetingPromptRegistration())
			.tools(openLibraryToolRegistrations(openLibrary))
			.async();
		
		return server;
	} 

    // ...

}