Skip to content

Add example for stateless server with JSON response #704

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 3 commits into from
May 15, 2025

Conversation

5enxia
Copy link
Contributor

@5enxia 5enxia commented May 13, 2025

Add example for stateless server with JSON response

Motivation and Context

There was no documentation on how to use it.

How Has This Been Tested?

I haven not tested due to only changes in documentation.

Breaking Changes

No

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

ihrpr
ihrpr previously approved these changes May 14, 2025
Copy link
Contributor

@ihrpr ihrpr left a comment

Choose a reason for hiding this comment

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

thank you!

@ihrpr
Copy link
Contributor

ihrpr commented May 14, 2025

The test needs to be fixed before merging:

____________________ test_docs_examples[README.md:394-408] _____________________
black failed:
  --- before
  +++ after
  @@ -398,404 +398,404 @@
   mcp = FastMCP("StatefulServer")
 
   # Stateless server (no session persistence)
   mcp = FastMCP("StatelessServer", stateless_http=True)
 
  -# Stateless server (no session persistence, no sse stream with supported client) 
  +# Stateless server (no session persistence, no sse stream with supported client)
   mcp = FastMCP("StatelessServer", stateless_http=True, json_response=True)
 
   # Run server with streamable_http transport
   mcp.run(transport="streamable-http")

                              Summary of Failures                               
┏━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━┓
┃  File           ┃  Function       ┃  Function Line  ┃  Error Line  ┃  Error  ┃
┡━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━┩
│  tests/test_e…  │  test_docs_ex…  │  [76](https://github.com/modelcontextprotocol/python-sdk/actions/runs/14996876491/job/42133173327?pr=704#step:5:77)             │              │         │
└─────────────────┴─────────────────┴─────────────────┴──────────────┴─────────┘
Results (9.18s):
         1 failed
       297 passed
         1 skipped

@5enxia
Copy link
Contributor Author

5enxia commented May 14, 2025

Thank you for your review!
Sorry, I didn't know tests for docs.
I fixed it!

Copy link
Contributor

@ihrpr ihrpr left a comment

Choose a reason for hiding this comment

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

thank you!

@ihrpr ihrpr merged commit 0a388b6 into modelcontextprotocol:main May 15, 2025
19 of 20 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