Repository navigation
Feature/plugin multi tenancy with per tool plugin config - #4068
Merged
jonpspri merged 17 commits intoApr 7, 2026
Merged
Conversation
cafalchio
force-pushed
the
feature/plugin-multi-tenancy-with-per-tool-plugin-config
branch
from
April 7, 2026 18:49
17c9fa3 to
3afa5b8
Compare
cafalchio
marked this pull request as ready for review
April 7, 2026 18:49
cafalchio
requested review from
araujof,
crivetimihai,
jonpspri,
kevalmahajan,
madhav165 and
terylt
as code owners
April 7, 2026 18:49
Introduce context-scoped plugin isolation via a new TenantPluginManagerFactory singleton. Each virtual server/tenant receives its own TenantPluginManager with an independently merged plugin config, while the __global__ manager continues to serve non-context-aware call sites. - Add TenantPluginManager (disables Borg state sharing) and TenantPluginManagerFactory (async-safe, deduplicating cache/factory) - Update framework __init__ accessors: init_plugin_manager_factory(), get_plugin_manager(server_id), shutdown/reset helpers - Wire services (tool, prompt, resource, classification) to pass server_id when resolving plugin managers - Update main.py lifespan to initialize factory eagerly at startup - Add PluginConfigOverride model and shallow config merge logic - Add architecture doc and 756-line test suite for tenant-scoped plugin execution Signed-off-by: cafalchio <[email protected]>
Signed-off-by: cafalchio <[email protected]>
Signed-off-by: cafalchio <[email protected]>
Signed-off-by: cafalchio <[email protected]>
Signed-off-by: cafalchio <[email protected]>
Signed-off-by: Madhu Mohan Jaishankar <[email protected]>
Signed-off-by: Madhu Mohan Jaishankar <[email protected]>
…eads Signed-off-by: Madhu Mohan Jaishankar <[email protected]>
Signed-off-by: Madhu Mohan Jaishankar <[email protected]>
Signed-off-by: Madhu Mohan Jaishankar <[email protected]>
…team guard Signed-off-by: Madhu Mohan Jaishankar <[email protected]>
Signed-off-by: Madhu Mohan Jaishankar <[email protected]>
Signed-off-by: Madhu Mohan Jaishankar <[email protected]>
Signed-off-by: cafalchio <[email protected]>
Signed-off-by: cafalchio <[email protected]>
Signed-off-by: cafalchio <[email protected]>
Signed-off-by: Jonathan Springer <[email protected]>
jonpspri
force-pushed
the
feature/plugin-multi-tenancy-with-per-tool-plugin-config
branch
from
April 7, 2026 20:27
5312b42 to
4df392a
Compare
jonpspri
deleted the
feature/plugin-multi-tenancy-with-per-tool-plugin-config
branch
April 7, 2026 20:55
3 of 10 tasks
4 of 10 tasks
4 tasks done
4 tasks done
1 of 10 tasks
1 of 10 tasks
crivetimihai
added a commit
that referenced
this pull request
Apr 8, 2026
…C, tests Review fixes for the OAuth access token verification feature (#3715): Security: - Validate issuer URL and discovered jwks_uri against SSRF protections before outbound fetches (validate_core_url on both paths) - Validate discovered metadata issuer matches queried issuer (RFC 8414 §3.3) - Persist oauth_client_id from admin UI into oauth_config for audience validation; log warning when audience check is skipped Correctness: - Fall through to verify_credentials on jwt.DecodeError instead of early-rejecting (fixes 7 broken existing tests) - Wrap _get_user_by_email_sync and _resolve_teams_from_db in try/except returning 503 on DB failures (parity with _auth_jwt path) - Distinguish infra failures (503) from auth failures (401) via OAUTH_VERIFY_UNAVAILABLE sentinel in verify_oauth_access_token - Fix internal MCP RPC RBAC to enable check_any_team for oauth_access_token (non-admin team-scoped users were denied) - Add auth_method and set_trace_context_from_teams for observability - Add TOOLS_MANAGE_PLUGINS to Permissions class (fixes team_admin bootstrap failure from #4068, see #4085) - Fix DAR101 flake8 docstring issue in observability.py Tests: - 30+ new unit tests covering _auth_jwt OAuth routing, _try_oauth_access_token branches, verify_oauth_access_token edge cases, SSRF rejection, issuer mismatch, 503 vs 401 classification, DB error handling, and trace context Signed-off-by: Mihai Criveti <[email protected]>
4 of 10 tasks
crivetimihai
added a commit
that referenced
this pull request
Apr 8, 2026
…C, tests Review fixes for the OAuth access token verification feature (#3715): Security: - Validate issuer URL and discovered jwks_uri against SSRF protections before outbound fetches (validate_core_url on both paths) - Validate discovered metadata issuer matches queried issuer (RFC 8414 §3.3) - Persist oauth_client_id from admin UI into oauth_config for audience validation; log warning when audience check is skipped Correctness: - Fall through to verify_credentials on jwt.DecodeError instead of early-rejecting (fixes 7 broken existing tests) - Wrap _get_user_by_email_sync and _resolve_teams_from_db in try/except returning 503 on DB failures (parity with _auth_jwt path) - Distinguish infra failures (503) from auth failures (401) via OAUTH_VERIFY_UNAVAILABLE sentinel in verify_oauth_access_token - Fix internal MCP RPC RBAC to enable check_any_team for oauth_access_token (non-admin team-scoped users were denied) - Add auth_method and set_trace_context_from_teams for observability - Add TOOLS_MANAGE_PLUGINS to Permissions class (fixes team_admin bootstrap failure from #4068, see #4085) - Fix DAR101 flake8 docstring issue in observability.py Tests: - 30+ new unit tests covering _auth_jwt OAuth routing, _try_oauth_access_token branches, verify_oauth_access_token edge cases, SSRF rejection, issuer mismatch, 503 vs 401 classification, DB error handling, and trace context Signed-off-by: Mihai Criveti <[email protected]>
jonpspri
added a commit
that referenced
this pull request
Apr 10, 2026
* add per-context plugin manager with TenantPluginManagerFactory Introduce context-scoped plugin isolation via a new TenantPluginManagerFactory singleton. Each virtual server/tenant receives its own TenantPluginManager with an independently merged plugin config, while the __global__ manager continues to serve non-context-aware call sites. - Add TenantPluginManager (disables Borg state sharing) and TenantPluginManagerFactory (async-safe, deduplicating cache/factory) - Update framework __init__ accessors: init_plugin_manager_factory(), get_plugin_manager(server_id), shutdown/reset helpers - Wire services (tool, prompt, resource, classification) to pass server_id when resolving plugin managers - Update main.py lifespan to initialize factory eagerly at startup - Add PluginConfigOverride model and shallow config merge logic - Add architecture doc and 756-line test suite for tenant-scoped plugin execution Signed-off-by: cafalchio <[email protected]> * ran pre-commit to update secrets Signed-off-by: cafalchio <[email protected]> * Update architecture, linted and secrets Signed-off-by: cafalchio <[email protected]> * updated secrets Signed-off-by: cafalchio <[email protected]> * audited and scan secrets Signed-off-by: cafalchio <[email protected]> * feat: add per-tool plugin binding API with validation and tests Signed-off-by: Madhu Mohan Jaishankar <[email protected]> * test: improve router and service test quality for tool plugin bindings Signed-off-by: Madhu Mohan Jaishankar <[email protected]> * fix: rebase migration onto cbedf4e580e0 to resolve multiple Alembic heads Signed-off-by: Madhu Mohan Jaishankar <[email protected]> * chore: update secrets baseline with migration revision IDs Signed-off-by: Madhu Mohan Jaishankar <[email protected]> * chore: mark migration revision IDs as non-secrets in baseline Signed-off-by: Madhu Mohan Jaishankar <[email protected]> * feat: grant tools.manage_plugins to team_admin; fix service UUID and team guard Signed-off-by: Madhu Mohan Jaishankar <[email protected]> * chore: add migration revision IDs to secrets baseline Signed-off-by: Madhu Mohan Jaishankar <[email protected]> * feat: wire per-tool plugin bindings into tool invocation pipeline Signed-off-by: Madhu Mohan Jaishankar <[email protected]> * Added dynamic plugin for rust endpoitns Signed-off-by: cafalchio <[email protected]> * Updated secrets and lint Signed-off-by: cafalchio <[email protected]> * fixed linter Signed-off-by: cafalchio <[email protected]> * test: Fix mocking problem in test_main_sighup Signed-off-by: Jonathan Springer <[email protected]> --------- Signed-off-by: cafalchio <[email protected]> Signed-off-by: Madhu Mohan Jaishankar <[email protected]> Signed-off-by: Jonathan Springer <[email protected]> Co-authored-by: cafalchio <[email protected]> Co-authored-by: Jonathan Springer <[email protected]>
claudia-gray
pushed a commit
that referenced
this pull request
Apr 13, 2026
* add per-context plugin manager with TenantPluginManagerFactory Introduce context-scoped plugin isolation via a new TenantPluginManagerFactory singleton. Each virtual server/tenant receives its own TenantPluginManager with an independently merged plugin config, while the __global__ manager continues to serve non-context-aware call sites. - Add TenantPluginManager (disables Borg state sharing) and TenantPluginManagerFactory (async-safe, deduplicating cache/factory) - Update framework __init__ accessors: init_plugin_manager_factory(), get_plugin_manager(server_id), shutdown/reset helpers - Wire services (tool, prompt, resource, classification) to pass server_id when resolving plugin managers - Update main.py lifespan to initialize factory eagerly at startup - Add PluginConfigOverride model and shallow config merge logic - Add architecture doc and 756-line test suite for tenant-scoped plugin execution Signed-off-by: cafalchio <[email protected]> * ran pre-commit to update secrets Signed-off-by: cafalchio <[email protected]> * Update architecture, linted and secrets Signed-off-by: cafalchio <[email protected]> * updated secrets Signed-off-by: cafalchio <[email protected]> * audited and scan secrets Signed-off-by: cafalchio <[email protected]> * feat: add per-tool plugin binding API with validation and tests Signed-off-by: Madhu Mohan Jaishankar <[email protected]> * test: improve router and service test quality for tool plugin bindings Signed-off-by: Madhu Mohan Jaishankar <[email protected]> * fix: rebase migration onto cbedf4e580e0 to resolve multiple Alembic heads Signed-off-by: Madhu Mohan Jaishankar <[email protected]> * chore: update secrets baseline with migration revision IDs Signed-off-by: Madhu Mohan Jaishankar <[email protected]> * chore: mark migration revision IDs as non-secrets in baseline Signed-off-by: Madhu Mohan Jaishankar <[email protected]> * feat: grant tools.manage_plugins to team_admin; fix service UUID and team guard Signed-off-by: Madhu Mohan Jaishankar <[email protected]> * chore: add migration revision IDs to secrets baseline Signed-off-by: Madhu Mohan Jaishankar <[email protected]> * feat: wire per-tool plugin bindings into tool invocation pipeline Signed-off-by: Madhu Mohan Jaishankar <[email protected]> * Added dynamic plugin for rust endpoitns Signed-off-by: cafalchio <[email protected]> * Updated secrets and lint Signed-off-by: cafalchio <[email protected]> * fixed linter Signed-off-by: cafalchio <[email protected]> * test: Fix mocking problem in test_main_sighup Signed-off-by: Jonathan Springer <[email protected]> --------- Signed-off-by: cafalchio <[email protected]> Signed-off-by: Madhu Mohan Jaishankar <[email protected]> Signed-off-by: Jonathan Springer <[email protected]> Co-authored-by: cafalchio <[email protected]> Co-authored-by: Jonathan Springer <[email protected]>
This was referenced Apr 15, 2026
This was referenced Apr 15, 2026
msureshkumar88
pushed a commit
that referenced
this pull request
May 13, 2026
* add per-context plugin manager with TenantPluginManagerFactory Introduce context-scoped plugin isolation via a new TenantPluginManagerFactory singleton. Each virtual server/tenant receives its own TenantPluginManager with an independently merged plugin config, while the __global__ manager continues to serve non-context-aware call sites. - Add TenantPluginManager (disables Borg state sharing) and TenantPluginManagerFactory (async-safe, deduplicating cache/factory) - Update framework __init__ accessors: init_plugin_manager_factory(), get_plugin_manager(server_id), shutdown/reset helpers - Wire services (tool, prompt, resource, classification) to pass server_id when resolving plugin managers - Update main.py lifespan to initialize factory eagerly at startup - Add PluginConfigOverride model and shallow config merge logic - Add architecture doc and 756-line test suite for tenant-scoped plugin execution Signed-off-by: cafalchio <[email protected]> * ran pre-commit to update secrets Signed-off-by: cafalchio <[email protected]> * Update architecture, linted and secrets Signed-off-by: cafalchio <[email protected]> * updated secrets Signed-off-by: cafalchio <[email protected]> * audited and scan secrets Signed-off-by: cafalchio <[email protected]> * feat: add per-tool plugin binding API with validation and tests Signed-off-by: Madhu Mohan Jaishankar <[email protected]> * test: improve router and service test quality for tool plugin bindings Signed-off-by: Madhu Mohan Jaishankar <[email protected]> * fix: rebase migration onto cbedf4e580e0 to resolve multiple Alembic heads Signed-off-by: Madhu Mohan Jaishankar <[email protected]> * chore: update secrets baseline with migration revision IDs Signed-off-by: Madhu Mohan Jaishankar <[email protected]> * chore: mark migration revision IDs as non-secrets in baseline Signed-off-by: Madhu Mohan Jaishankar <[email protected]> * feat: grant tools.manage_plugins to team_admin; fix service UUID and team guard Signed-off-by: Madhu Mohan Jaishankar <[email protected]> * chore: add migration revision IDs to secrets baseline Signed-off-by: Madhu Mohan Jaishankar <[email protected]> * feat: wire per-tool plugin bindings into tool invocation pipeline Signed-off-by: Madhu Mohan Jaishankar <[email protected]> * Added dynamic plugin for rust endpoitns Signed-off-by: cafalchio <[email protected]> * Updated secrets and lint Signed-off-by: cafalchio <[email protected]> * fixed linter Signed-off-by: cafalchio <[email protected]> * test: Fix mocking problem in test_main_sighup Signed-off-by: Jonathan Springer <[email protected]> --------- Signed-off-by: cafalchio <[email protected]> Signed-off-by: Madhu Mohan Jaishankar <[email protected]> Signed-off-by: Jonathan Springer <[email protected]> Co-authored-by: cafalchio <[email protected]> Co-authored-by: Jonathan Springer <[email protected]>
This was referenced Jun 11, 2026
brian-hussey
pushed a commit
to brian-hussey/mcp-context-forge
that referenced
this pull request
Oct 20, 2026
…C, tests Review fixes for the OAuth access token verification feature (IBM#3715): Security: - Validate issuer URL and discovered jwks_uri against SSRF protections before outbound fetches (validate_core_url on both paths) - Validate discovered metadata issuer matches queried issuer (RFC 8414 §3.3) - Persist oauth_client_id from admin UI into oauth_config for audience validation; log warning when audience check is skipped Correctness: - Fall through to verify_credentials on jwt.DecodeError instead of early-rejecting (fixes 7 broken existing tests) - Wrap _get_user_by_email_sync and _resolve_teams_from_db in try/except returning 503 on DB failures (parity with _auth_jwt path) - Distinguish infra failures (503) from auth failures (401) via OAUTH_VERIFY_UNAVAILABLE sentinel in verify_oauth_access_token - Fix internal MCP RPC RBAC to enable check_any_team for oauth_access_token (non-admin team-scoped users were denied) - Add auth_method and set_trace_context_from_teams for observability - Add TOOLS_MANAGE_PLUGINS to Permissions class (fixes team_admin bootstrap failure from IBM#4068, see IBM#4085) - Fix DAR101 flake8 docstring issue in observability.py Tests: - 30+ new unit tests covering _auth_jwt OAuth routing, _try_oauth_access_token branches, verify_oauth_access_token edge cases, SSRF rejection, issuer mismatch, 503 vs 401 classification, DB error handling, and trace context Signed-off-by: Mihai Criveti <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 Related Issue
Closes #
📝 Summary
This PR combines two related pieces of work that together form the foundation of plugin multi-tenancy in ContextForge.
1. Per-tool plugin binding API (
/v1/tools/plugin_bindings)Adds four new endpoints for configuring per-tool plugin policies on a per-team basis:
POST /v1/tools/plugin_bindings— create or update bindings (upsert)GET /v1/tools/plugin_bindings— list all bindingsGET /v1/tools/plugin_bindings/{team_id}— list bindings for a specific teamDELETE /v1/tools/plugin_bindings/{id}— delete a binding by IDEach binding is a
(team_id, tool_name, plugin_id)triple stored in a newtool_plugin_bindingstable. POSTing an existing triple performs an in-place upsert, preserving the originalidandcreated_*fields. A single request can configure multiple teams and multiple tools at once.Supported plugin types:
OUTPUT_LENGTH_GUARD,RATE_LIMITER,SECRETS_DETECTION.Security:
is_admin: true, teams: null) bypass the team guard and can configure any team.tools.manage_pluginspermission is required for write operations;tools.readfor reads.tools.manage_pluginsis seeded into theteam_adminrole on new installations and backfilled via migration for existing ones.Performance: a single
team_id IN (...)prefetch replaces the previous per-triple SELECT loop, and all inserts/updates are flushed in a singledb.flush()call after the loop.2. Tenant plugin manager (
TenantPluginManagerFactory)Adds a per-context plugin manager that dynamically loads and routes plugins per tenant/team at tool execution time. The
TenantPluginManagerFactoryresolves the correct plugin pipeline for the calling team rather than applying a single global plugin stack. The tool service, resource service, and prompt service are updated to use the tenant-aware manager when executing MCP operations.Key changes:
plugins/framework/manager.py—TenantPluginManagerFactorywith per-team plugin loading and lifecycle managementplugins/framework/__init__.py— factory registration and context propagationplugins/framework/models.py— tenant-scoped plugin model additionsservices/tool_service.py,resource_service.py,prompt_service.py— use tenant plugin manager at execution timeservices/base_service.py— base plumbing for tenant context propagationTogether these two pieces form a complete multi-tenancy plugin system: the API lets teams declare which plugins apply to which tools, and the tenant manager enforces those policies at runtime.
🏷️ Type of Change
🧪 Verification
make lintmake testmake coverage✅ Checklist
make black isort pre-commit)📓 Notes (optional)
New Alembic migrations (applied in order):
b1c2d3e4f5a6— creates thetool_plugin_bindingstablec2d3e4f5a6b7— backfillstools.manage_pluginsinto theteam_adminrole for existing installationsFor sidecar/automated processes that need to configure bindings across all teams in a single request, use an API token with
is_admin: true, teams: nulland assign theplatform_adminrole.