fix(mcp): avoid relying on progress notification root shape

This commit is contained in:
Xubin Ren
2026-06-19 14:59:48 +08:00
parent f9511049c4
commit bbd7bbd7f5
2 changed files with 40 additions and 4 deletions
+18
View File
@@ -36,6 +36,24 @@ def _mcp_notification(method: str, params: dict[str, Any] | None = None) -> Sess
)
def test_mcp_progress_detection_accepts_flattened_sdk_message_shape():
malformed = SimpleNamespace(
message=SimpleNamespace(
method="notifications/progress",
params={"progress": 20, "total": 600},
)
)
valid = SimpleNamespace(
message=SimpleNamespace(
method="notifications/progress",
params={"progressToken": "req-1", "progress": 25},
)
)
assert mcp_runtime._is_malformed_mcp_progress_notification(malformed) is True
assert mcp_runtime._is_malformed_mcp_progress_notification(valid) is False
class _FakeMcpTool(Tool):
def __init__(self, name: str) -> None:
self._name = name