-
Notifications
You must be signed in to change notification settings - Fork 270
Feat/860 enterprise multitenancy, role-based access control, JWT revocation and SSO #862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Review Summary:
make serve
- Login with
[email protected]
andchangeme
- Successfully able to add
streamable http
transport server () - Successfully tested the
get pr details
tool

-
Successfully able to add mcp-container-runtime on sse transport
-
Successfully able to test a tool
get current time
-
Able to see metrics for the executed tools
-
Able to export metrics as a
csv
file -
Able to create a team
9. Not able to exit add members when clicking on cancel below.

PR Test Summary:
1. make test
- 1 test failing
FAILED tests/unit/mcpgateway/test_main_extended.py::TestApplicationStartupPaths::test_startup_without_plugin_manager - sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: global_config
=== 1 failed, 2652 passed, 24 skipped, 1069 warnings in 233.88s (0:03:53) ===
make autoflake isort black flake8
- PASS - no errors
3. make pylint
- FAIL - Your code has been rated at 9.71/10
🐛 pylint mcpgateway mcp-servers/python...
************* Module mcpgateway.db
mcpgateway/db.py:1698:13: E1136: Value 'Mapped' is unsubscriptable (unsubscriptable-object)
Your code has been rated at 9.71/10 (previous run: 10.00/10, -0.29)
make: *** [Makefile:723: pylint] Error 2
-
make smoketest
- PASS
✅ Smoketest passed! -
make doctest
- all pass
616 passed, 7 skipped, 69 warnings in 22.10s
Signed-off-by: Mihai Criveti <[email protected]>
mcpgateway/db.py:2358:16: E1136: Value 'Mapped' is unsubscriptable (unsubscriptable-object)The error is occurring because pylint doesn't recognize Mapped[Type] syntax as valid. This is a common issue with SQLAlchemy 2.0's new typing system. The code is actually correct - Mapped is designed to be subscriptable with type parameters. This requires Did you run |
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a massive and very comprehensive PR! The design looks good.
Because the PR is huge, I decided to look for specific things to check in the code.
From code inspection, the token services catalog handles JTI revocation for invalid or expired tokens; on token revocation, it immediately invalidates the JWT token.
In .env.example
, SSO_AUTO_CREATE_USERS=true
while SSO_ENABLED=false
could be confusing. Should we thrown an error or warning during startup if SSO is disabled but auto-create is enabled?
Maybe, for a feature this big, should we have a rollback plan (including db schema) and a flag like MULTI_TENANCY_ENABLED
to allow users to disable, or have this disabled by default?
Overall this is an impressive addition!
- make test
Similar comments as above, but I tried to experiment with the system to probe some corner cases I was interested in checking. Reviewing the design looks pretty comprehensive, but after experimenting a little I noticed a few small things.
|
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Hey @crivetimihai I had a chance to test the changes in this branch locally, and it's looking great – really solid work! As I was going through it, a couple of questions came to mind regarding the architecture, and I was hoping to get your insights:
I'm keen to align my understanding with the intended design. |
Signed-off-by: Mihai Criveti <[email protected]>
Containerfile
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing we did in our SysFlow open source project is use a manifest file to set versions for things in the container. This helped a lot in the CI/CD as we could quickly update versions for new builds. Here's an example: https://github.com/sysflow-telemetry/sf-collector/blob/master/makefile.manifest.inc
Might be useful here cc: @araujof
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment on linting. I've noticed this a bit with other PRs that a bunch of the file changes are linting related from stuff checked in in previous PRs. Are there ways that we might be able to stabilize the linting so that it has to be done during PR check in and remains consistent? I think this might help with the readability of the PRs as we wouldn't get lint changes from code checked in from previous PRs. Just a thought.
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
@@ -173,6 +184,66 @@ | |||
message_ttl=settings.message_ttl, | |||
) | |||
|
|||
|
|||
# Helper function for authentication compatibility | |||
def get_user_email(user): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks to be similar to the get_user_email in the admin.py script
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
🏢 EPIC: Complete Multi-Tenancy System Implementation
🚀 Summary
This massive PR transforms MCP Gateway from a single-tenant system into a production-ready enterprise multi-tenant platform with team-based resource scoping, comprehensive authentication, and enterprise SSO integration.
Impact: Complete architectural transformation enabling secure team collaboration, enterprise SSO integration, and scalable multi-tenant deployments.
🎯 Issues Closed
Primary Epic:
Core Security & Authentication:
SSO Integration:
Future Work:
🔥 Major Features Implemented
🔐 Authentication & Authorization System
👥 Team Management System
🔒 Resource Scoping & Visibility
🏗️ Platform Administration
🗄️ Database & Infrastructure
📐 System Architecture
This implementation introduces a comprehensive multi-tenant architecture:
🗄️ Database Schema Changes
New Multi-Tenant Tables:
Extended Resource Tables:
All existing resource tables (tool, server, resource, prompt, a2a_agent) extended with:
🔧 Configuration Changes
New Environment Variables:
Core Multi-Tenancy:
Authentication:
SSO Integration:
🔐 Security Enhancements
Multi-Tenant Security Model:
Enterprise Security Controls:
🚀 API Changes
New Authentication Endpoints:
POST /auth/email/register
- Email user registrationPOST /auth/email/login
- Email user loginGET /auth/sso/providers
- List available SSO providersGET /auth/sso/login/{provider}
- Initiate SSO loginPOST /auth/sso/callback/{provider}
- Handle SSO callbackNew Team Management Endpoints:
GET /teams
- List user's teamsPOST /teams
- Create new teamGET /teams/{team_id}
- Get team detailsPUT /teams/{team_id}
- Update teamDELETE /teams/{team_id}
- Delete team (non-personal only)POST /teams/{team_id}/invitations
- Invite user to teamGET /teams/{team_id}/members
- List team membersDELETE /teams/{team_id}/members/{user_email}
- Remove team memberEnhanced Resource Endpoints:
All resource endpoints (tools, servers, resources, prompts, a2a agents) now support:
?team_id=uuid
- Filter by team?visibility=private|team|public
- Filter by visibilityteam_id
,owner_email
,visibility
fields in request/response bodies📚 Documentation Added
Complete Documentation Suite:
docs/docs/architecture/multitenancy.md
(934 lines)docs/docs/manage/sso-ibm-tutorial.md
- IBM Security Verify setupdocs/docs/manage/sso-github-tutorial.md
- GitHub SSO setupdocs/docs/manage/sso-google-tutorial.md
- Google SSO setupEnterprise Deployment Guides:
🧪 Testing
Test Coverage:
Test Categories:
⚡ Performance Optimizations
Database Optimizations:
API Performance:
🔄 Migration Strategy
Backward Compatibility:
Upgrade Path:
🏆 Business Impact
Enterprise Readiness:
Scalability Improvements:
🎯 Breaking Changes
Database Schema:
email_users
,email_teams
,email_team_members
,email_team_invitations
team_id
,owner_email
,visibility
columnsAPI Changes:
Configuration:
Note: All changes are backward compatible when multi-tenancy features are disabled.
🚦 Deployment Checklist
Pre-Deployment:
Deployment:
make alembic-upgrade
Post-Deployment:
🎉 Summary
This PR represents a complete architectural transformation of MCP Gateway into a production-ready enterprise multi-tenant platform. The implementation includes:
Result: MCP Gateway now supports multi-tenancy, team collaboration, and SSO integration.