Skip to content

Add examples of server and client for streamable http transport #294

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 11 commits into from
Apr 9, 2025

Conversation

ihrpr
Copy link
Contributor

@ihrpr ihrpr commented Apr 8, 2025

When adding new features to the transport it's quite useful to have e2e flow to test on. Introducing the examples folder where we can have examples of mcp clients and servers with different features. Adding a very simple example of:

  • server with basic state management and tools, resources and prompts.
  • client to list available tools, resources and prompts

Follow ups

  • Refactor oauth to be shared with sse client
  • Integration tests using examples
  • Resumability
  • Session management
  • Server and client to handle requests returning not only streams but also JSON

@ihrpr ihrpr changed the title Ihrpr/examples Add examples of server and client for streamable http transport Apr 8, 2025
@ihrpr ihrpr requested a review from jspahrsummers April 8, 2025 15:19
@ihrpr ihrpr marked this pull request as ready for review April 8, 2025 15:20
Copy link
Member

@jspahrsummers jspahrsummers left a comment

Choose a reason for hiding this comment

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

Example looks good, but highlights a probable issue in the SDK itself.

oops

Comment on lines +98 to +104
// After handling the request, if we get a session ID back, store the transport
await transport.handleRequest(req, res, req.body);

// Store the transport by session ID for future requests
if (transport.sessionId) {
transports[transport.sessionId] = transport;
}
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, there's a race condition here AFAICT. I believe this sequence of events is possible:

  1. Client sends initialization request to server
  2. Server handles the request, assigns a session ID, and sends an initialization response
  3. Before line 102 is reached, the client sends another request
  4. Server can't find the session matching its ID

This might be something we have to fix in the interfaces we offer—for example, maybe a callback like onsessioncreated or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, good point, the session management is still in the follow ups, I'll address it there if that's okay

Base automatically changed from ihrpr/fix-streamable-connection-close to main April 9, 2025 11:59
@ihrpr ihrpr merged commit 0fa46aa into main Apr 9, 2025
2 checks passed
@ihrpr ihrpr deleted the ihrpr/examples branch April 9, 2025 12:05
@apryiomka
Copy link

Does anyone have a Python SDK link where the work might have started? We can't use TypeScript unfortunately :(

Pizzaface pushed a commit to RewstApp/mcp-inspector that referenced this pull request May 2, 2025
add support for Streamable HTTP server
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.

3 participants