Build a Streamable HTTP MCP Server with Java’s New 0.11 SDK (Lesson 10)

The article explains how the Java MCP SDK 0.11 adds Streamable HTTP support, compares it with the traditional HTTP+SSE approach, and walks through adding Maven dependencies, configuring Spring AI, creating custom auto‑configuration classes, implementing a Weibo trending tool, and deploying a fully functional Streamable HTTP MCP server.

Ubiquitous Tech
Ubiquitous Tech
Ubiquitous Tech
Build a Streamable HTTP MCP Server with Java’s New 0.11 SDK (Lesson 10)

The Model Context Protocol (MCP) originally required two separate endpoints—standard HTTP for requests and Server‑Sent Events (SSE) for responses—making agent development complex and resource‑intensive. In the second protocol version, Streamable HTTP was introduced as a single bidirectional endpoint, offering better stability, lower latency, and simpler client code.

Compared with the HTTP+SSE pattern, Streamable HTTP eliminates the need for a dedicated /sse endpoint, reduces long‑living connections, and improves performance under high concurrency. The Java MCP SDK version 0.11.1 (released in the first week of August 2025) officially supports this transport.

Step 1 – Add the new SDK dependency

<dependency>
  <groupId>io.modelcontextprotocol.sdk</groupId>
  <artifactId>mcp-spring-webmvc</artifactId>
  <version>0.11.1</version>
</dependency>

Step 2 – Application configuration (the existing SSE settings are kept for compatibility):

spring:
  ai:
    mcp:
      server:
        enabled: true
        name: xxxxx-mcp-server
        version: 1.0.0
        type: ASYNC  # recommended for reactive apps
        sse-endpoint: /sse
        sse-message-endpoint: /mcp/message
server:
  port: 8001

Step 3 – Implement a tool (here a Weibo trending‑list service). The method fetches the hot‑search JSON, filters ads, builds a list of maps and returns a JSON string.

@Service
@Slf4j
public class WeiboTrendingDataRequestService {
    @Tool(name = "get-weibo-trending",
          description = "获取微博热搜榜,包含时事热点、社会现象、娱乐新闻、明星动态及网络热议话题的实时热门中文资讯")
    public String getWeiboTrending() {
        String url = "https://weibo.com/ajax/side/hotSearch";
        try {
            Connection.Response response = Jsoup.connect(url)
                .ignoreContentType(true)
                .timeout(10000)
                .header("referer", "https://weibo.com")
                .method(Connection.Method.GET)
                .execute();
            if (response.statusCode() != 200) {
                log.warn("请求微博热搜失败,HTTP状态码: {}", response.statusCode());
                return "微博热搜获取失败,请稍后再试";
            }
            // parse and build result list …
            return JSON.toJSONString(resultList);
        } catch (Exception e) {
            log.error("工具调用异常: {}", e.getMessage(), e);
            return "工具调用失败,请稍后再试";
        }
    }
}

Step 4 – Register a Streamable HTTP transport provider . The custom configuration creates a WebMvcStreamableServerTransportProvider bean and exposes its router function.

@ConditionalOnClass({WebMvcStreamableServerTransportProvider.class})
@Configuration
public class CustomStreamableMcpServerConfiguration {
    public static final String MCP = "/mcp";
    @Bean
    public WebMvcStreamableServerTransportProvider webMvcServerTransportProvider(ObjectMapper objectMapper) {
        return WebMvcStreamableServerTransportProvider.builder()
                .objectMapper(objectMapper)
                .mcpEndpoint(MCP)
                .build();
    }
    @Bean
    public RouterFunction<ServerResponse> routerFunction(WebMvcStreamableServerTransportProvider provider) {
        return provider.getRouterFunction();
    }
}

Step 5 – Extend the main MCP auto‑configuration so that the newly created transport provider is used for the async server. The class wires capabilities (tools, resources, prompts, completions) and registers them with the server builder.

@ConditionalOnClass({McpSchema.class, McpSyncServer.class})
@EnableConfigurationProperties(McpServerProperties.class)
@Configuration
public class CustomMcpServerAutoConfiguration {
    @Bean
    public McpAsyncServer mcpAsyncServer(
            McpStreamableServerTransportProvider transportProvider,
            McpSchema.ServerCapabilities.Builder capabilitiesBuilder,
            McpServerProperties serverProperties,
            ObjectProvider<List<ToolCallback>> toolCalls,
            ObjectProvider<List<ToolCallback>> toolCallbackProvider) {
        // build serverInfo, capabilities, tools, resources, prompts, completions …
        McpServer.AsyncSpecification serverBuilder = McpServer.async(transportProvider)
                .serverInfo(new McpSchema.Implementation(serverProperties.getName(), serverProperties.getVersion()));
        // register tools, resources, etc.
        serverBuilder.capabilities(capabilitiesBuilder.build());
        serverBuilder.instructions(serverProperties.getInstructions());
        serverBuilder.requestTimeout(serverProperties.getRequestTimeout());
        return serverBuilder.build();
    }
}

Step 6 – Adjust the Spring Boot entry point to exclude the default auto‑configuration and expose the tool as a ToolCallbackProvider bean.

@SpringBootApplication(exclude = {McpWebMvcServerAutoConfiguration.class, McpServerAutoConfiguration.class})
public class ToolApplication {
    public static void main(String[] args) {
        SpringApplication.run(ToolApplication.class, args);
    }
    @Bean
    public ToolCallbackProvider applicationTools(WeiboTrendingDataRequestService weibo) {
        return MethodToolCallbackProvider.builder()
                .toolObjects(weibo)
                .build();
    }
}

After building and running the application, the author verified the server with the MCP client UI (screenshots omitted). The client successfully invoked the get‑weibo‑trending tool, demonstrating that the Streamable HTTP transport works as intended.

In summary, the article provides a complete migration path from the legacy HTTP+SSE model to the newer Streamable HTTP model for Java‑based MCP servers, highlighting the protocol’s architectural benefits, the exact Maven coordinates, the required Spring‑Boot configuration, and the custom auto‑configuration classes needed to expose the new transport.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaSpring AIServerauto-configurationStreamable HTTPSDK 0.11
Ubiquitous Tech
Written by

Ubiquitous Tech

A ubiquitous public account for pirate enthusiasts, regularly sharing curated experiences, tech learning, and growth insights. Currently publishing articles on AI RAG customer service, AI MCP technology, and open-source design. Personal free Knowledge Planet: Awakening New World Programmer.

0 followers
Reader feedback

How this landed with the community

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.