NPE when using MCP streamable transport: ServerSentEvent.id(null) with Spring Boot 3.5.x (Spring 6.2)
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 62/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- java, spring, spring-boot
Research direction
Start in WebFluxStreamableServerTransportProvider.java around sendMessage, line 394, and reproduce the failure with the provided streamable MCP configuration and curl request. Trace how the response reaches ServerSentEvent.Builder.id and verify the endpoint returns a valid SSE stream without an exception when the message has no ID.
Written by the indexing model from the issue text.
Description
Bug description
When using MCP Server with streamable HTTP transport (SSE),
the /mcp endpoint returns:
`500 Server Error
java.lang.NullPointerException:
Cannot invoke "String.indexOf(int)" because "content" is null
java.lang.NullPointerException: Cannot invoke "String.indexOf(int)" because "content" is null
at org.springframework.http.codec.ServerSentEvent$BuilderImpl.checkEvent(ServerSentEvent.java:270)
at org.springframework.http.codec.ServerSentEvent$BuilderImpl.id(ServerSentEvent.java:257)
at io.modelcontextprotocol.server.transport.WebFluxStreamableServerTransportProvider$WebFluxStreamableMcpSessionTransport.lambda$sendMessage$1(WebFluxStreamableServerTransportProvider.java:394)
...
`
Environment
Spring Boot: 3.5.13
Spring Framework: 6.2.17
JDK: 21
Spring AI: 1.1.7
MCP Server: mcp-spring-webflux 0.18.2
Config:
spring.ai.mcp.server.protocol=streamable
Steps to reproduce
- Start MCP server
ai:
mcp:
server:
protocol: streamable
- Simple MCP Tool
@McpTool(name = "test")
public Mono<String> test() {
return Mono.just("ok");
}
- Call API
curl -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}'
Expected behavior
MCP should return valid SSE stream
No exception even if message has no ID
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 5
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from spring-projects/spring-ai
-
status: waiting-for-triage
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
spring-projects/spring-ai#7000 ·
-
status: waiting-for-triage
Difficulty 1/5 Under an hour Newbie friendliness 90/100
spring-projects/spring-ai#6998 ·
-
[Bug - MCP server] @McpTool error messages are emitted twice when the thrown exception has no cause Openstatus: waiting-for-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
spring-projects/spring-ai#6948 · 1 comment · 1 reaction ·
-
status: waiting-for-triage
Difficulty 1/5 Under an hour Newbie friendliness 90/100
spring-projects/spring-ai#6940 · 1 comment ·
-
status: waiting-for-triage
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
spring-projects/spring-ai#6928 · 1 comment ·
All issues in spring-projects/spring-ai
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 1/5 Under an hour Newbie friendliness 94/100
objectionary/hone-maven-plugin#1061 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
spring-projects/spring-modulith#1895 ·