java-sdk/mcp-transport/mcp-webflux-sse-transport/README.md
Christian Tzolov 3112e5ede7 Refactor package structure and dependencies
- Updated package prefix: `org.springframework.ai.mcp` → `org.modelcontextprotocol`
- Changed POM groupId: `org.springframework.experimental` → `org.modelcontextprotocol.sdk`
- Update all dependecies and BOM
- Updated documentation references accordingly

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-01-24 22:14:44 +01:00

55 lines
1.5 KiB
Markdown

# WebFlux SSE Transport
```xml
<dependency>
<groupId>org.modelcontextprotocol.sdk</groupId>
<artifactId>mcp-webflux-sse-transport</artifactId>
</dependency>
```
```java
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;
}
// ...
}
```