How diogofrj/mcp-turnkey works
MCP Turnkey is both a project scaffold and a Python MCP server template. Its hosted workflow registers an MCP client, obtains user consent for upstream OAuth, stores that user’s credential, then serves tenant-scoped tools using the client’s validated credential. Local stdio login is a separate path. The graph preserves documented security, storage, rate-limit, and deployment capabilities; several internal adapter connections are omitted where the excerpts do not establish their runtime calls.
Main entry points: container.py Composition roots · asgi.py HTTP routes · auth.py Local login · supabase_token_store.py Encrypted token storage
Components 27
Project setup
- Project scaffold
scripts/scaffold.py - Generated server
template/src/mcp_bootstrap
MCP transport
- HTTP routes
template/src/mcp_bootstrap/asgi.py - MCP tools
template/src/mcp_bootstrap/server.py - Composition roots
template/src/mcp_bootstrap/container.py - Server configuration
template/src/mcp_bootstrap/config.py - Request hardening
template/src/mcp_bootstrap/middleware.py - Structured logging
template/src/mcp_bootstrap/observability/logging.py
OAuth and tenancy
- Consent flow
template/src/mcp_bootstrap/application/consent.py - OAuth server rules
template/src/mcp_bootstrap/application/authserver.py - Local login
template/src/mcp_bootstrap/application/auth.py - Token lifecycle
template/src/mcp_bootstrap/application/token_access.py - Identity and token models
template/src/mcp_bootstrap/domain/models.py - Application ports
template/src/mcp_bootstrap/domain/ports.py - Provider OAuth client
template/src/mcp_bootstrap/infrastructure/oauth_client.py - OAuth rate limits
template/src/mcp_bootstrap/application/rate_limit.py
Tools and upstream access
- Example item tools
template/src/mcp_bootstrap/application/items.py - Upstream API adapter
template/src/mcp_bootstrap/infrastructure/upstream_client.py
Infrastructure
- Supabase access
template/src/mcp_bootstrap/infrastructure/supabase_client.py - Encrypted token storage
template/src/mcp_bootstrap/infrastructure/supabase_token_store.py - AES-GCM encryption
template/src/mcp_bootstrap/infrastructure/crypto_aesgcm.py - OAuth state storage
template/src/mcp_bootstrap/infrastructure/authserver_store.py - Rate-limit cache
template/src/mcp_bootstrap/infrastructure/upstash_cache.py
Other components
- Project creator
- MCP client
- User browser
- OAuth provider
Connections 33
- Project creator → Project scaffold: runs scaffold
README.md - Project scaffold → Generated server: copies template
README.md - MCP client → HTTP routes: connects over HTTP
README.md - User browser → HTTP routes: follows OAuth routes
README.md - HTTP routes → Consent flow: routes consent
template/src/mcp_bootstrap/asgi.py - HTTP routes → OAuth server rules: routes OAuth
template/src/mcp_bootstrap/asgi.py - HTTP routes → OAuth rate limits: applies limits
template/src/mcp_bootstrap/asgi.py - HTTP routes → Composition roots: resolves services
template/src/mcp_bootstrap/asgi.py - HTTP routes → MCP tools: serves MCP
template/src/mcp_bootstrap/asgi.py - HTTP routes → Request hardening: installs middleware
template/src/mcp_bootstrap/asgi.py - MCP tools → Example item tools: calls tool logic
template/src/mcp_bootstrap/server.py - Composition roots → Local login: wires local login
template/src/mcp_bootstrap/container.py - Composition roots → Token lifecycle: wires token access
template/src/mcp_bootstrap/container.py - Composition roots → Upstream API adapter: builds API adapter
template/src/mcp_bootstrap/container.py - Composition roots → Provider OAuth client: builds OAuth client
template/src/mcp_bootstrap/container.py - Composition roots → Encrypted token storage: builds token store
template/src/mcp_bootstrap/container.py - Composition roots → AES-GCM encryption: builds cipher
template/src/mcp_bootstrap/container.py - Composition roots → OAuth state storage: builds auth store
template/src/mcp_bootstrap/container.py - Composition roots → Rate-limit cache: builds cache
template/src/mcp_bootstrap/container.py - Example item tools → Upstream API adapter: requests resources
- Upstream API adapter → OAuth provider: calls API
README.md - Provider OAuth client → OAuth provider: exchanges credentials
template/src/mcp_bootstrap/infrastructure/oauth_client.py - Consent flow → OAuth server rules: uses OAuth rules
template/src/mcp_bootstrap/application/authserver.py - Local login → Provider OAuth client: exchanges login
template/src/mcp_bootstrap/application/auth.py - Local login → Identity and token models: updates token model
template/src/mcp_bootstrap/application/auth.py - Token lifecycle → Identity and token models: manages credentials
template/src/mcp_bootstrap/application/token_access.py - Encrypted token storage → Supabase access: reads and writes
template/src/mcp_bootstrap/infrastructure/supabase_token_store.py - Encrypted token storage → AES-GCM encryption: seals credentials
README.md - OAuth state storage → Supabase access: persists OAuth state
template/src/mcp_bootstrap/infrastructure/authserver_store.py - OAuth rate limits → Rate-limit cache: counts requests
template/src/mcp_bootstrap/application/rate_limit.py - HTTP routes → Server configuration: loads settings
template/src/mcp_bootstrap/asgi.py - Request hardening → Structured logging: logs requests
template/src/mcp_bootstrap/middleware.py - OAuth provider → User browser: redirects after login
README.md