Sitemap

Spring AI Recipe: Streamable HTTP MCP Server

3 min readApr 29, 2026

--

Press enter or click to view image in full size

In the previous recipe, we created an MCP server using the STDIO transport. STDIO is ideal for local development and tight integrations where the MCP server runs as a subprocess and communicates over standard input and output.

But in many real-world scenarios, that’s not enough.

What if your MCP server needs to:

  • run remotely
  • be accessed by multiple agents
  • or be deployed in a production environment?

For those cases, MCP provides Streamable HTTP, a modern transport designed to replace the older SSE-based approach and better align with real-world deployment patterns.

NOTE: This recipe has been updated since it’s original publication to reflect changes in Spring AI 2.0.0.

From STDIO to HTTP

Conceptually, very little changes when moving from STDIO to HTTP:

  • You still define tools using @McpTool
  • You still expose those tools through an MCP server
  • The main difference is how clients connect and communicate

With HTTP, communication happens over standard web protocols instead of STDIN/STDOUT.

Creating the Project

Start by creating a Spring Boot project with the following dependencies:

implementation 'org.springframework.boot:spring-boot-starter-webmvc'
implementation 'org.springframework.ai:spring-ai-starter-mcp-server-webmvc'

By using the MVC variety of MCP server starter, you are configuring your MCP server to operate over HTTP instead of STDIO.

Defining Tools

Tool definitions remain exactly the same:

@Service
public class WeatherTools {
@McpTool(name = "get-weather-for-zipcode", description = "")
public Weather getWeatherForZipcode(
@McpToolParam(description = "The zipcode to get weather for") String zipcode) {
return new Weather(zipcode, "Raining cats and dogs", "78F");
}
}

And the supporting domain type:

public record Weather(
String zipcode,
String conditions,
String temperature) {}

Configuring Streamable HTTP

As of Spring AI 2.0.0-M7, Spring AI’s HTTP-based MCP server defaults to Streamable HTTP. But if you’re still using an older 2.0.0 milestone, it will default to SSE, which has been deprecated in the MCP specification. To use the modern Streamable HTTP transport, set:

spring.ai.mcp.server.protocol=streamable

By default, the server will listen on port 8080. But you may also want to configure the port to something else. Port 3000 is commonly used for MCP servers:

server.port=3000

Unlike STDIO, there’s no need to suppress logging or disable the Spring Boot banner, since communication happens over HTTP.

Running and Testing

Start the application and then connect using a tool such as:

  • MCP Inspector
  • MCPJam

Use the following connection details:

Once connected:

  • Navigate to the Tools tab
  • List available tools
  • Select get-weather-for-zipcode
  • Provide a zipcode
  • Execute the tool

You should see the response returned from your MCP server.

STDIO vs. Streamable HTTP

TransportBest ForSTDIOLocal integrations, CLI tools, subprocess communicationStreamable HTTPRemote services, shared APIs, production deployment

Key Takeaway

Moving from STDIO to HTTP doesn’t change how you define tools — it changes how those tools are exposed and consumed.

With Streamable HTTP, your MCP server becomes:

  • network-accessible
  • easier to integrate
  • suitable for real-world deployment

What’s more, in a future recipe, you’ll see how to secure Streamable HTTP MCP servers.

What’s Next

Now that we can expose MCP tools over HTTP, the next step is to build a client that can discover and invoke those tools.

In the next recipe, we’ll create an MCP client to bring it all together.

Get the code for this and other Spring AI recipes at https://github.com/habuma/spring-ai-recipes.

If you’re exploring Spring AI, I’ve written a book (Spring AI in Action) that covers the core foundations — and I’ll continue sharing newer patterns like this here as the ecosystem evolves. You can find my book on the publisher’s website, at Amazon, or anywhere you buy technical books.

--

--

Craig Walls
Craig Walls

Written by Craig Walls

Author Spring AI in Action, Spring in Action, and Build Talking Apps for Alexa