Skip to content

mcp: Implement subscriptions/listen rpc (SEP-2575)#1007

Merged
guglielmo-san merged 21 commits into
mainfrom
guglielmoc/SEP-2575_subscriptions_listen
Jun 22, 2026
Merged

mcp: Implement subscriptions/listen rpc (SEP-2575)#1007
guglielmo-san merged 21 commits into
mainfrom
guglielmoc/SEP-2575_subscriptions_listen

Conversation

@guglielmo-san

Copy link
Copy Markdown
Contributor

Fixes #966

@jba

jba commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

subscrptions/listen

nit: subscriptions

Fixes #966

There are many parts to that SEP. Is this the last one to be implemented?

Comment thread mcp/server.go
Comment thread mcp/server.go Outdated
Comment thread mcp/server.go Outdated
Comment thread mcp/client.go Outdated
@guglielmo-san guglielmo-san changed the title mcp: Implement subscrptions/listen rpc (SEP-2575) mcp: Implement subscriptions/listen rpc (SEP-2575) Jun 21, 2026
@guglielmo-san guglielmo-san marked this pull request as ready for review June 21, 2026 12:15
@guglielmo-san guglielmo-san requested a review from jba June 22, 2026 13:08
Comment thread internal/jsonrpc2/conn.go Outdated
OnInternalError func(error) // optional
}

type IsSubscriptionsListenContextKey struct{}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have two objections to this approach: first, the name is specific to a particular transport-level use case. It should be more general. Second, using a context to pass the information should be a last resort. Can we instead have a different constructor?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You wrote in your message to me "that's what lets the listen handler observe HTTP disconnect on stateless streamable HTTP. Without this, the handler would never see the client going away." Document that here (but remove references to the specific protocol). And while you're at it, maybe you can document why the default is to wrap with notDone. A lot of this package is mysterious to me and if you understand it, drop some knowledge where you can.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, I added a parameter on the ConnectionConfig to signal the need to propagate the request cancellation, and added some explanation around it

Comment thread internal/jsonrpc2/conn.go Outdated
c.updateInFlight(func(s *inFlightState) {
err = s.shuttingDown(ErrServerClosing)
req, ok := msg.(*Request)
if !ok || req.Method != "notifications/cancelled" {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's unfortunate that this general package is referring to a specific MCP feature. We should be treating it as if we can some day move it somewhere else and export it. Can you think of another way to do this? What if there were a list of methods that

Maybe we can add a list of methods that can succeed during shutdown to ConnectionConfig. And also add a bool there to replace IsSubscriptionsListenContextKey.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right, I updated to follow the same logic of Conn.Notify(), if a notification reaches write will be allowed to pass

Comment thread mcp/client.go Outdated
Comment thread mcp/server.go Outdated
@guglielmo-san guglielmo-san requested a review from jba June 22, 2026 15:39

@jba jba left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice, thanks for those last changes.

@guglielmo-san guglielmo-san merged commit cd7d80c into main Jun 22, 2026
9 checks passed
@guglielmo-san guglielmo-san deleted the guglielmoc/SEP-2575_subscriptions_listen branch June 22, 2026 16:57
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.

Implement SEP-2575: Make MCP Stateless

2 participants