fix: 修复 SSE 模式下的 TypeError 异常 + 更新README#4
Open
eggylan wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修复 SSE 模式下的 TypeError 异常
问题描述
在启动SSE服务器后,客户端调用
/messages端点时出现以下错误:错误发生在 Starlette 路由处理过程中,导致 MCP 客户端无法正常通信。
错误原因
Route包装sse.handle_post_message,但该方法本身是 ASGI 应用,直接返回None,导致 Starlette 尝试调用None作为响应对象handle_sse函数在 SSE 连接结束后没有返回Response对象修复内容
1. 按 MCP 官方示例正确集成 SSE 路由
2. 在 SSE 处理函数中返回空响应
3. 统一消息端点路径
测试结果
✅ 服务正常启动
✅ POST
/messages/?session_id=xxx返回预期响应(无效 session 返回 400)✅ GET
/sse正常建立 SSE 连接✅ GET
/health返回{"status":"ok","server":"netease-modsdk-mcp"}✅ 不再出现
TypeError: 'NoneType' object is not callable异常参考文档