modelcontextprotocol / modelcontextprotocol/java-sdk

Resolve message endpoint path using request context path

Open Beginner friendly
#400 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

area/server enhancement P2
Dominant language
Java
Stars
3.7k
Forks
1.1k
Avg merge
1d 15h
Merged PRs (30d)
9

Description

When HttpServletSseServerTransportProvider handling the GET request to establish a new SSE connection, the message endpoint is advertised using the immutable field "baseUrl" that's set in the constructor:

// Send initial endpoint event this.sendEvent(writer, ENDPOINT_EVENT_TYPE, this.baseUrl + this.messageEndpoint + "?sessionId=" + sessionId);

This will not work if clients use a different base URL to access this servlet (e.g.: using reverse proxies). The servlet implementation should allow the request context path to be used to produce the endpoint path appropriate for that request:

// Send initial endpoint event this.sendEvent(writer, ENDPOINT_EVENT_TYPE, request.getContextPath() + this.messageEndpoint + "?sessionId=" + sessionId);

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in HttpServletSseServerTransportProvider, at the GET handler that establishes a new SSE connection and sends the initial endpoint event. Trace how the request context path and message endpoint are available there, then verify that the advertised endpoint uses the context path for clients behind a reverse proxy. Done means the endpoint URL is derived from the request rather than the immutable baseUrl.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.