Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Should McpTransportContextExtractor contain default methods for protocol version, lastEventId and sessionId

Open
#492 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
java

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.

Description

waiting for triage

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.

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

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.

More from modelcontextprotocol/java-sdk

All issues in modelcontextprotocol/java-sdk

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.