Back to all days

Day 20 — Security

Multi-Tenant Auth System

Org-level isolation, role hierarchies, invite flows, and audit trails — the unsexy infrastructure that makes B2B SaaS actually work.

An MCP server that manages multi-tenant authentication. Ask who has access to what, which orgs are MFA-compliant, and whether that pending invite expired. No more digging through admin panels.

Example Queries

“Which organizations have MFA required but users not compliant?”
“Show me the role hierarchy for Acme Corp”
“Are there any pending invitations that are about to expire?”
“What permissions does Marcus Lee have at Acme?”
“Show me failed login attempts in the last 30 days”
“Which orgs have the lowest security scores?”

Tools

6 MCP Tools

ToolWhat It Does
org_lookupSearch organizations by name, plan, or status. Returns org details, member count, seat usage, SSO/MFA config, and current health.
user_permissionsCheck a user's role, permissions, and access within an organization. Shows hierarchy level, granted permissions, and MFA compliance.
invite_statusTrack invitation status across organizations — pending, accepted, expired, or revoked. Shows who invited whom and when.
role_hierarchyView the full role hierarchy and permissions matrix for an org. Shows each role's level, permissions, and assigned members.
audit_logQuery the auth and access audit log. Filter by org, user, action type, or date range. Surfaces logins, permission changes, and security events.
tenant_healthGet health metrics for an org — active users, MFA adoption, seat usage, login frequency, and a security compliance score.

Tenants

6 Organizations

Acme Corp

enterprise plan

75/100
5/100seats
SSO on
MFA required

Bright Studio

business plan

65/100
4/25seats
SSO off
MFA optional

CloudNine Labs

starter plan

65/100
3/5seats
SSO off
MFA optional

Delta Finance

enterprise plan

70/100
4/50seats
SSO on
MFA required

Ember Health

business plan

85/100
2/15seats
SSO off
MFA required

Forge AI

starter plan

0/100
1/5seats
SSO off
MFA optional

Why This Build

Why Multi-Tenant Auth?

The moment your SaaS gets a second customer, everything breaks. Suddenly you need org-level isolation, role hierarchies that actually make sense, and an invite flow that doesn't leak data across tenants.

Most teams bolt multi-tenancy on after the fact. The schema gets messy, the permission checks get scattered across the codebase, and one day someone from Org A sees Org B's data. Nobody writes a blog post about that.

This server models six organizations across three plan tiers, with proper role hierarchies (owner → admin → manager → member → viewer), invite lifecycle tracking, MFA compliance monitoring, and a full audit trail. Ask a question about who has access to what — and get an answer backed by real permissions data, not guesswork.

Demo Data

What's Inside

6

Organizations

18

Users

19

Memberships

30

Roles

8

Invitations

25

Audit Events

Six orgs spanning enterprise, business, and starter tiers. One suspended org with a deactivated user. A freelancer in two orgs simultaneously. Users with MFA disabled in MFA-required orgs. Expired and revoked invitations. Fifteen granular permissions across five role levels. Edge cases that will actually show up in production.

Setup

Try It Locally

cd day20-multi-tenant-auth
npm install && npm run seed && npm run build

Then add the config to Claude Desktop and restart.

Need multi-tenant auth that doesn't fall apart at scale?

If you're bolting on multi-tenancy after the fact or your permission model is a pile of if-statements, let's talk about doing it right.