Skip to content

Commit aaffa47

Browse files
fix: propagate app_user_email when global context already exists
When invoke_tool receives an existing plugin_global_context from middleware, the user email was not being propagated to the global context. This caused plugins to receive user: null in their GlobalContext. This fix ensures the user email is always propagated to the global context when available, enabling security plugins to properly track which user made each request. Closes #1550 Supersedes #1551 Co-authored-by: Ilia Manolov <iliamanolov@outlook.com> Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
1 parent cdb373f commit aaffa47

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

mcpgateway/services/tool_service.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,6 +1466,9 @@ async def invoke_tool(
14661466
gateway_id = getattr(tool, "gateway_id", None)
14671467
if gateway_id and isinstance(gateway_id, str):
14681468
global_context.server_id = gateway_id
1469+
# Propagate user email to global context for plugin access
1470+
if app_user_email and isinstance(app_user_email, str):
1471+
global_context.user = app_user_email
14691472
else:
14701473
# Create new context (fallback when middleware didn't run)
14711474
# Use correlation ID from context if available, otherwise generate new one

0 commit comments

Comments
 (0)