Skip to content

feat: add SSE client demo example #598

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

Conversation

Vinisha-projects
Copy link

@Vinisha-projects Vinisha-projects commented Apr 28, 2025

SSE Client Example for MCP SDK

Motivation and Context

This PR provides a minimal Server-Sent Events (SSE) client example, as requested in issue #584.

The goal was to add a WORKING demonstration of how an MCP-compatible client would handle streamed responses using standard HTTP and Server-Sent Events logic.
No public MCP server was available; therefore, a simple local mock server was used to simulate behavior.

What Does This PR Do?

  • Adds examples/sse_client_demo.py — a basic working SSE client demo.
  • Adds examples/README.md — documentation on running the demo.
  • Adds examples/images/demo_screenshot.png — a screenshot showing the working output.
  • Simulates an MCP-compatible server locally via Flask for demonstration purposes.

How Has This Been Tested?

  • Manually tested by running the SSE client against a local mock Flask server.
  • Client successfully received multiple streamed updates (data: {}) in real-time.
  • Screenshot proof (demo_screenshot.png) attached.
  • All GitHub Actions checks passed (formatting, linting, build verification).
  • Code style validated via ruff and testing methods.

Breaking Changes

This PR introduces a new example only and does not modify the core SDK or any existing functionality.


Types of Changes

  • ✅New Example (non-breaking addition to examples directory)
  • ✅Documentation and Screenshot addition
  • ✅Local Testing Verified

Checklist

  • ✅ I have read the MCP Documentation.
  • ✅ My example follows the repository's coding style and structure.
  • ✅ I tested locally using a mock server and verified event streaming.
  • ✅I included a README with instructions and a Screenshot.
  • ✅No breaking changes introduced to the SDK.

Additional Context

  • Discussed in issue #584.
  • If a public MCP server becomes available in the future, this demo can be easily updated to point to the real server endpoint instead of a mock.
  • Future improvements could include retry logic and automatic reconnection handling if desired.

Screenshot

  • ✅Screenshot proof (demo_screenshot.png) attached.

@Vinisha-projects
Copy link
Author

Update: Successfully tested full SSE client with mock server. Added README and new demo screenshot after confirming 3 streamed events. PR ready for final review

@Vinisha-projects Vinisha-projects deleted the add-sse-client-demo branch April 29, 2025 18:10
Vinisha-projects added a commit to Vinisha-projects/python-sdk that referenced this pull request May 5, 2025
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.

1 participant