Making Spring Boot Ready for Model Context Protocol

August 20, 2025

Even though RheinInsights is a software generalist, the RheinInsights Retrieval Suite is a Java enterprise application. It brings enterprise search connectors for leading search engines, all with security trimming and everything, you need to implement grounding with permissions.

In the last year, Model Context Protocol (MCP) evolved. MCP is a protocol which is used in agent to agent communication. This means that generalized agents can use this protocol to perform actions or get answers from MCP Servers. Since organizational knowledge is more than important in task solving, the RheinInsights Retrieval Suite now supports MCP.

Laptop with VS Code

Spring Boot and MCP

Fortunately, Java applications which are based on Spring Boot can easily be extended towards Model Context Protocol. For an introduction, we refer to https://github.com/modelcontextprotocol/java-sdk. In order to get started, you can use one of the examples given in the SDK.

After you started your favorite MCP example, you can use the MCP inspector and check if you can access the server and if you can call actions. If one of the examples works for you, you can start integrating the approach in your existing application framework.

For existing frameworks, such as the RheinInsights Retrieval Suite, you might need a specific integration approach. The two major variables are to implement

  • Streamable HTTP,

  • Server-Sent Events or

  • Stdio

and to use

  • WebFlux or

  • MVC.

Stdio, SSE vs. Streamable HTTP

MCP actually supports three communication protocols: Stdio, Server-Sent Events (SSE) and Streamable HTTP. However, SSE already is deprecated and you might have a hard time if agents stop supporting this protocol. Therefore, you might want to consider directly going for Streamable HTTP. For Microsoft Copilot integrations, for instance, Streamable HTTP is supported whereas SSE is in public preview and according to the documentation might never become fully supported.

WebFlux and MVC

If you have an existing Spring application which you like to turn into an MCP server, you likely already have Spring MVC in use. In such a case, going for WebFlux might not work. However, in such a case, you can take any of the examples and simply configure

WebMvcStreamableServerTransportProvider

as your transport provider. This way, you easily integrate the MCP examples into your existing MVC application.

Custom Endpoints

Last but not least, when extending an existing application, you might not want to have your MCP endpoints at the root level. This means that instead of

https://yourserver:port/mcp

you might want to implement a custom endpoint. In our case, the endpoint is

https://application:port/api/v1/mcp

So how do you implement this with Spring MVC or WebFlux? The key the transport provider, too. In the builder method, you can define your custom mcpEndpoint as follows:

return WebMvcStreamableServerTransportProvider
        .builder()
        .objectMapper(new ObjectMapper())
        .mcpEndpoint("/api/v1/mcp")                
        .build();