Skip to content

mcp: add stream type #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 28, 2025
Merged

mcp: add stream type #171

merged 2 commits into from
Jul 28, 2025

Conversation

jba
Copy link
Contributor

@jba jba commented Jul 24, 2025

Consolidate several maps into a single struct.

Simplifies the code, for the most part.

Consolidate several maps into a single struct.

Simplifies the code, for the most part.
@jba jba requested review from samthanawalla and Copilot July 24, 2025 11:27
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR consolidates the streamable server transport implementation by introducing a single stream struct to replace multiple separate maps. The main purpose is to simplify the code structure and improve maintainability by grouping related stream data together.

  • Replaces three separate maps (outgoing, signals, streamRequests) with a single streams map containing stream structs
  • Introduces a new stream type that encapsulates all stream-related state and behavior
  • Updates all stream-related operations to work with the consolidated structure

t.mu.Unlock()

for _, data := range outgoing {
if err := t.opts.EventStore.Append(req.Context(), t.id, id, data); err != nil {
if err := t.opts.EventStore.Append(req.Context(), t.SessionID(), stream.id, data); err != nil {
Copy link
Preview

Copilot AI Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent method call: using t.SessionID() here but t.id was used in the original code. This may cause incorrect session identification in the event store.

Suggested change
if err := t.opts.EventStore.Append(req.Context(), t.SessionID(), stream.id, data); err != nil {
if err := t.opts.EventStore.Append(req.Context(), t.SessionID(), t.SessionID(), data); err != nil {

Copilot uses AI. Check for mistakes.

Copy link
Contributor

@samthanawalla samthanawalla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice LGTM!

@jba jba enabled auto-merge (squash) July 25, 2025 18:21
@jba jba merged commit 86f71fc into modelcontextprotocol:main Jul 28, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants