Backend Development 6 min read

Implementing MCP over SSE/HTTP in a SpringBoot Backend

This article explains how to extend an open‑source smart production management system with MCP support by creating SSE/HTTP endpoints, a token‑based MAP, and a McpService that scans, executes, and pushes results, and demonstrates client configuration using CherryStudio.

Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Implementing MCP over SSE/HTTP in a SpringBoot Backend

We previously built the SPMS smart production management system with ERP, WMS, and MES modules. To add support for the popular MCP protocol, we integrated several MCP tools using an SSE/HTTP communication model.

Implementation Idea

In the SSE/HTTP mode, the MCP server pushes messages to the client, so we need an SSE endpoint that announces the POST address for client connections.

2.1 SSE/HTTP Controller

Using SpringBoot, the MCP server only requires a single Controller to expose the SSE endpoint and an HTTP endpoint for receiving client data, which is later forwarded through SSE.

2.1.1 Create SSE Endpoint

This endpoint accepts client connections and sends an initial message indicating the address for further communication.

2.1.2 Create HTTP Endpoint

The HTTP endpoint receives client requests; after processing, the results are pushed to the client via the SSE endpoint.

2.1.3 Create a Token MAP

A MAP stores each client’s AccessToken , which is a private token used for authentication and authorization of MCP tools.

3 McpService Implementation

3.1 Scanning MCP Tools

During initialization, scanMcpMethods scans for methods annotated with @McpMethod , registers them in a permission list, and makes the tool list available at tools/list for MCP clients.

3.2 Executing MCP Tools

When a client calls a tool, the service retrieves the method by methodName , invokes it via reflection, and returns the result, after verifying the token’s permissions.

3.3 SSE Message Push

Instead of returning a normal HTTP response , the result is sent to the client through an SSE push, complying with the MCP protocol.

4 Using the MCP Client

We demonstrate configuration in CherryStudio: add an MCP server, set the SSE address, and obtain the token from the backend system.

5 Testing the Service

We show a simple backend implementation for creating a purchase order, then test the "Create Purchase Order" tool both in unauthorized and authorized states, illustrating permission handling.

6 Full Code

All source code is open‑source; see the GitHub repository at https://github.com/s-pms .

7 Conclusion

The article walks through adding MCP support to an open‑source admin system, covering SSE/HTTP controller design, token management, tool scanning/execution, client setup, and testing, and hints at future voice‑assistant integrations.

backendMCPHTTPSpringBoottokenSSE
Rare Earth Juejin Tech Community
Written by

Rare Earth Juejin Tech Community

Juejin, a tech community that helps developers grow.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.