modelcontextprotocol / modelcontextprotocol/go-sdk

Proposal: add StreamableHTTPHandler.Close

Open
#440 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs investigation
Dominant language
Go
Stars
5.1k
Forks
543
Avg merge
1d 17h
Merged PRs (30d)
37

Description

While writing a test for #265, it occurred to me that we probably should expose a StreamableHTTPHandler.Close. Otherwise, there's no way to close the handler while also guaranteeing that no new sessions are subsequently added.

Specifically, I propose the following:

// Close closes the handler, closing and removing all connected sessions,
// and preventing new sessions from being added.
func (*StreamableHTTPHandler) Close() error

I think we didn't do this initially because there was a thought that with #148, perhaps we wouldn't need it if the handler was effectively stateless and only interacted with a session store.

However, I don't think there's much harm in adding Close. Even if we eventually accept a session store, close may be useful.

This is not urgent.

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 by locating StreamableHTTPHandler and read the test context from issue #265. Determine how the handler tracks connected sessions and prevents new sessions during shutdown; done means Close closes and removes all connected sessions and prevents subsequent additions.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.