Skip to content

fix(plugins): preserve virtual server context for tool calls - #6474

Open
Tethys0 wants to merge 1 commit into
IBM:mainfrom
Tethys0:fix/virtual-server-plugin-context-6233-tethys
Open

fix(plugins): preserve virtual server context for tool calls#6474
Tethys0 wants to merge 1 commit into
IBM:mainfrom
Tethys0:fix/virtual-server-plugin-context-6233-tethys

Conversation

@Tethys0

@Tethys0 Tethys0 commented Aug 29, 2026

Copy link
Copy Markdown

Summary

Fixes #6233.

Tool plugin GlobalContext.server_id was not reliable for virtual-server calls. The normal invocation fallback discarded the explicit virtual-server ID, while the existing-context path could overwrite it with the tool's gateway ID. That made PluginCondition.server_ids and custom server-scoped plugin logic silently miss every call routed through a virtual server.

This patch:

  • preserves the explicit virtual-server server_id through both tool-context construction paths;
  • keeps an existing middleware context ID when no virtual-server scope is present;
  • uses the tool gateway ID only as the fallback when no virtual-server ID exists.

Testing

  • uv run --frozen pytest -q tests/unit/mcpgateway/services/test_tool_service_tenant_id.py tests/unit/mcpgateway/services/test_tool_service_coverage.py - 383 passed, 1 skipped (intentional pre-existing coverage marker)
  • uv run --frozen ruff check mcpgateway/services/tool_service.py tests/unit/mcpgateway/services/test_tool_service_tenant_id.py tests/unit/mcpgateway/services/test_tool_service_coverage.py - passed
  • uv run --frozen ruff format --check mcpgateway/services/tool_service.py tests/unit/mcpgateway/services/test_tool_service_tenant_id.py tests/unit/mcpgateway/services/test_tool_service_coverage.py - passed
  • git diff --check - passed

The full make test target was also started locally but did not complete within the available run window; no full-suite result is claimed here.

Signed-off-by: Bo Zhang <187063395+Tethys0@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: GlobalContext.server_id never carries the virtual-server ID — plugin server_ids scoping never matches

1 participant