Closed RamAlapure closed 3 weeks ago
You don't need to configure the message endpoint, the server sends the client that URL during the initialization
See https://modelcontextprotocol.io/specification/2024-11-05/basic/transports#http-with-sse
When a client connects, the server MUST send an endpoint event containing a URI for the client to use for sending messages. All subsequent client messages MUST be sent as HTTP POST requests to this endpoint.
I have a spring-boot based microservice and trying to use same code base with service as MCP Server. The app context path is configured with spring property server.servlet.context-path causing an issue identifying the MCP server endpoints (Not found).
But if I remove this property server.servlet.context-path it works.
There is issue building a postUrl in HttpMcpTransport startSseChannel method from /sse response, it doesn't create valid url with base path (context-path)
Why it Fails
When Spring Boot app has server.servlet.context-path=/mcp-server, all endpoints are effectively served under:
http://localhost:8080/mcp-server/**
HttpMcpTransport uses the response to /sse to infer the message endpoint, assuming it's at /mcp/message (without context path). So it ends up calling:
http://localhost:8080/mcp/message ❌ (Wrong - 404)
Instead of:
http://localhost:8080/mcp-server/mcp/message ✅ (Correct)
And what are you using as the server library? Spring AI? If the server tells the client that the URL is /mcp/message
instead of /mcp-server/mcp/message
, then this is an issue of the server library, not the client.
@jmartisk you are correct, it was a spring ai issue. Thank you for a help. I'm active user of Langchain4j and it's a great.
@RamAlapure then I will close this issue, but feel free to reopen if needed.
/I have a MCP server running with SSE transport on http://localhost:8080/mcp-server Now the SSE Endpoint= http://localhost:8080/mcp-server/sse This can be configured using MCP transport
SSE Message Endpoint= http://localhost:8080/mcp-server/mcp/message Not found an option to configure/change this.
Please help if any option to configure message endpoint with the server.servlet.context-path