-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Support for http request injection propagation to tools #816
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
Changes from 6 commits
a86f8f4
4ae633c
3b076be
f1f17f7
567875e
81123c6
5413bca
9268cab
149d8cb
0612dcb
a5e7efe
4da517e
991d855
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,7 +52,8 @@ async def handle_sse(request): | |
| from starlette.types import Receive, Scope, Send | ||
|
|
||
| import mcp.types as types | ||
| from mcp.shared.message import SessionMessage | ||
| from mcp.shared.message import ServerMessageMetadata, SessionMessage | ||
| from mcp.types import RequestData | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
@@ -203,7 +204,19 @@ async def handle_post_message( | |
| await writer.send(err) | ||
| return | ||
|
|
||
| session_message = SessionMessage(message) | ||
| # Extract request headers and other context | ||
| request_context: RequestData = { | ||
| "headers": dict(request.headers), | ||
| "method": request.method, | ||
| "url": str(request.url), | ||
| "client": request.client, | ||
| "path_params": request.path_params, | ||
| "query_params": dict(request.query_params), | ||
| } | ||
|
||
|
|
||
| # Create session message with request context | ||
| metadata = ServerMessageMetadata(request_context=request_context) | ||
| session_message = SessionMessage(message, metadata=metadata) | ||
| logger.debug(f"Sending session message to writer: {session_message}") | ||
| response = Response("Accepted", status_code=202) | ||
| await response(scope, receive, send) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.