Skip to content

Commit 859b50c

Browse files
committed
Skip waiting for a response from the server if message was a notification
1 parent 96b4be3 commit 859b50c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/mcp_grafana/transports/http.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from pydantic import ValidationError
1212
from starlette.datastructures import Headers
1313
from starlette.requests import Request
14-
from starlette.responses import JSONResponse, Response
14+
from starlette.responses import JSONResponse, PlainTextResponse, Response
1515
from starlette.types import ASGIApp, Receive, Scope, Send
1616

1717
from ..client import GrafanaClient, grafana_client
@@ -156,6 +156,12 @@ async def handle_post_message():
156156
logger.debug("Sending client message")
157157
await read_stream_writer.send(client_message)
158158

159+
if isinstance(client_message.root, types.JSONRPCNotification):
160+
# Notifications don't have a response, so we don't need to wait for one.
161+
response = PlainTextResponse("Accepted", status_code=202)
162+
await response(scope, receive, send)
163+
return
164+
159165
# Wait for the server's response, and forward it to the client.
160166
server_message = await write_stream_reader.receive()
161167
obj = server_message.model_dump(

0 commit comments

Comments
 (0)