Add blocking and logging related tests for MCP streamable HTTP route.

This commit is contained in:
Hemang authored and Hemang Sarkar committed 2025-05-27 23:11:57 +02:00
1 parent 115ae5f36b
commit ab3fb98b67
4 files changed
+177 -82

No files matched your search

+1
View File
@@ -89,6 +89,7 @@ async def hook_tool_call(
guardrails_result = await session.get_guardrails_check_result(
message, action=GuardrailAction.BLOCK
)
print("[hook_tool_call] Guardrails result:", guardrails_result, flush=True)
# If the request is blocked, return a message indicating the block reason.
# If there are new errors, run append_and_push_trace in background.
# If there are no new errors, just return the original request.
+3 -2
View File
@@ -81,8 +81,9 @@ async def mcp_post_streamable_gateway(request: Request) -> StreamingResponse:
# Intercept the request and check for guardrails.
if not is_initialization_request:
if result := await _intercept_request(session_id, request_body) and result: # noqa: F821 pylint: disable=used-before-assignment
return result
request_interception_result = await _intercept_request(session_id, request_body)
if request_interception_result:
return request_interception_result
async with httpx.AsyncClient(timeout=CLIENT_TIMEOUT) as client:
try: