Skip to content

doc(asgi): Change custom route example to PlainTextResponse #477

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 4 commits into from
May 16, 2025

Conversation

mcw0933
Copy link
Contributor

@mcw0933 mcw0933 commented May 16, 2025

What

Updates the doc examples of custom routes to use PlainTextResponse instead of JSONResponse

Why

streamable_http expects the client to connect with a header for text/event-stream - so if you actually use the old example, you'll fail when trying to return JSON from Starlette/FastAPI with this error message:

{
  "jsonrpc": "2.0",
  "id": "server-error",
  "error": {
    "code": -32600,
    "message": "Not Acceptable: Client must accept text/event-stream"
  }
}

which makes it seem like a client issue, but it's actually just the response body not being plain text.

Copy link
Owner

@jlowin jlowin left a comment

Choose a reason for hiding this comment

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

Good catch, thank you!

@jlowin jlowin added the documentation Improvements or additions to documentation label May 16, 2025
@jlowin jlowin merged commit 3ab1ee7 into jlowin:main May 16, 2025
3 checks passed
@mcw0933
Copy link
Contributor Author

mcw0933 commented May 16, 2025

No prob! Love your documentation! ❤️ We're out here rolling our MCP server now and FastMCP has been a godsend 😁

Any chance you will be at PyCon this weekend?

@jlowin
Copy link
Owner

jlowin commented May 16, 2025

Unfortunately not this one but maybe we’ll meet another time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants