StreamableHttp - GET request standalone SSE (#561)

This commit is contained in:
ihrpr
2025-05-02 13:52:27 +01:00
committed by GitHub
parent 72b66a58b1
commit 46523afe30
3 changed files with 186 additions and 17 deletions

View File

@@ -11,6 +11,7 @@ from mcp.server.streamableHttp import (
MCP_SESSION_ID_HEADER,
StreamableHTTPServerTransport,
)
from pydantic import AnyUrl
from starlette.applications import Starlette
from starlette.requests import Request
from starlette.responses import Response
@@ -92,6 +93,9 @@ def main(
if i < count - 1: # Don't wait after the last notification
await anyio.sleep(interval)
# This will send a resource notificaiton though standalone SSE
# established by GET request
await ctx.session.send_resource_updated(uri=AnyUrl("http:///test_resource"))
return [
types.TextContent(
type="text",