-
Notifications
You must be signed in to change notification settings - Fork 891
Closed
Description
[Feature Request] Upgrade MCP to >=1.10.1 and Use mcp_server.request_context.request
Description
We need to upgrade the mcp package to version >=1.10.1 to utilize the new mcp_server.request_context.request feature. This will allow us to retrieve request information directly from the context. The current implementation lacks this capability, and upgrading will provide a more streamlined way to access HTTP request details.
Example Code
Here is an example of how we can implement this change:
@mcp_server.call_tool()
async def handle_call_tool(
name: str,
arguments: Dict[str, Any],
http_request_info: Optional[HTTPRequestInfo] = None
) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
request = self.server.request_context.request
http_request_info = None
if request:
body = await request.body()
http_request_info = HTTPRequestInfo(
method=request.method,
path=request.url.path,
headers=dict(request.headers),
cookies=request.cookies,
query_params=dict(request.query_params),
body=body.decode(),
)Metadata
Metadata
Assignees
Labels
No labels