modelcontextprotocol / modelcontextprotocol/java-sdk
Should McpTransportContextExtractor contain default methods for protocol version, lastEventId and sessionId
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 3.7k
- Forks
- 1.1k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 9
Description
I am defining my McpTransportContextExtractor implementation as:
@Internal
@Singleton
class DefaultMcpTransportContextExtractor implements McpTransportContextExtractor<HttpRequest<?>> {
public static final String HTTP_HEADER_MCP_PROTOCOL_VERSION = "MCP-Protocol-Version";
public static final String DEFAULT_PROTOCOL_VERSION = "2025-03-26";
public static final String HTTP_HEADER_MCP_SESSION_ID = "Mcp-Session-Id";
public static final String HTTP_HEADER_DEFAULT_LAST_EVENT_ID = "Last-Event-ID";
@Override
public McpTransportContext extract(HttpRequest<?> request, McpTransportContext transportContext) {
transportContext.put(HTTP_HEADER_MCP_PROTOCOL_VERSION,
request.getHeaders().get(HTTP_HEADER_MCP_PROTOCOL_VERSION, String.class)
.orElse(DEFAULT_PROTOCOL_VERSION));
request.getHeaders().get(HTTP_HEADER_MCP_SESSION_ID, String.class)
.ifPresent(v -> transportContext.put(HTTP_HEADER_MCP_SESSION_ID, v));
request.getHeaders().get(HTTP_HEADER_DEFAULT_LAST_EVENT_ID, String.class)
.ifPresent(v -> transportContext.put(HTTP_HEADER_DEFAULT_LAST_EVENT_ID, v));
return transportContext;
}
}
But given that the specification defines session id, last event and protocol version. I think it would be good if the McpTransportContextExtractor contained default methods:
default String getSessionId() {
return null;
}
default String getLastEventId() {
return null;
}
default String getProtocolVersion() {
return "2025-03-26";
}
I can submit a PR if you think it is a good idea. With this change the TransportContext will have a clear API for those spec defined concepts.
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.
Research direction
Locate McpTransportContextExtractor and review its existing implementations alongside McpTransportContext usage. Check whether default accessors for protocol version, session ID, and last event ID fit the current API and protocol concepts; done means the interface exposes a consistent, compatible API.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100