MCP Authentication
Secure your Kubiya MCP server with OAuth/OIDC authentication
MCP Authentication
The Kubiya MCP server supports multiple authentication methods to secure your workflows and protect API access.
Why Authentication Matters
The MCP authentication system serves a critical purpose: identity delegation. When users interact with Kubiya through various interfaces (Composer UI, API, CLI), the MCP server ensures that:
- User Identity is Preserved - The authenticated user’s identity flows through to workflow execution
- Workflows Run on User’s Behalf - All actions are performed with the user’s permissions and API key
- Audit Trail is Maintained - Every workflow execution is tied to the user who initiated it
- Multi-tenant Security - Different users can safely share the same MCP server with isolated execution contexts
How Identity Delegation Works
When a user accesses Kubiya through the Composer UI or any other interface:
- They authenticate with your organization’s identity provider
- The identity provider issues a JWT containing the user’s identity AND their Kubiya API key
- This JWT is passed to the MCP server with each request
- The MCP server extracts the user’s API key and executes workflows on their behalf
- All workflow executions are tied to the authenticated user in Kubiya’s audit logs
Authentication Methods
1. Simple API Key (Default)
The simplest approach - pass your Kubiya API key directly:
This approach works well for:
- Development and testing
- Simple integrations
- Single-user scenarios
⚠️ Note: With this method, all workflows execute with the same identity (the API key owner).
2. OAuth/OIDC Authentication (Production)
For production deployments, use OAuth 2.0 or OpenID Connect authentication with the mcpauth
library. This enables proper user identity delegation.
Setting Up OAuth/OIDC Authentication
Installation
Basic Configuration
Running with Authentication
Supported Auth Providers
The MCP server works with any OAuth 2.0 or OpenID Connect provider:
Popular Providers
- Auth0: Full OIDC support
- Okta: Enterprise SSO
- Google: Google Workspace integration
- Microsoft Azure AD: Enterprise Microsoft integration
- Keycloak: Open-source identity management
Provider Configuration
Each provider needs to support:
- OAuth 2.0 Authorization Server Metadata (RFC 8414)
- OpenID Connect Discovery (for OIDC)
- JWT tokens with standard claims
API Key in JWT Claims
When using OAuth/OIDC, include the Kubiya API key in JWT claims:
Standard Locations
The server checks these claim locations:
kubiya_api_key
- Custom claimapi_key
- Generic API key claimmetadata.kubiya_api_key
- Nested in metadata
Example JWT Payload
User-Specific API Keys
For proper identity delegation, each user should have their own Kubiya API key. This ensures:
- Individual Accountability - Each action is traceable to a specific user
- Granular Permissions - Different users can have different access levels
- Security Isolation - Compromised keys affect only one user
- Usage Tracking - Monitor and limit usage per user
Setting Up User API Keys
-
During User Onboarding:
-
In JWT Token Claims:
Scope-Based Authorization
Define required scopes for different operations:
Common Scope Patterns
Scope | Permissions |
---|---|
read | List and view workflows |
write | Create and modify workflows |
execute | Execute workflows |
admin | Full access including deletion |
Testing Authentication
1. Check Metadata Endpoint
2. Test with Bearer Token
3. Using MCP Client
Security Best Practices
- Always use HTTPS in production
- Rotate API keys regularly
- Use short-lived JWT tokens (1 hour or less)
- Implement proper scope restrictions
- Monitor authentication logs
- Use environment variables for sensitive data
- Assign unique API keys to each user
- Audit workflow executions by user identity
Troubleshooting
”No API token provided” Error
The server couldn’t find an API key. Check:
- JWT claims include
kubiya_api_key
- Environment variable
KUBIYA_API_KEY
is set - API key parameter is passed correctly
”Invalid token” Error
JWT validation failed. Verify:
- Token hasn’t expired
- Token signature is valid
- Required scopes are present
- Auth server URL is correct
”Insufficient permissions” Error
User lacks required scopes. Ensure:
- JWT includes all required scopes
- Auth provider grants necessary permissions
- Scope names match exactly
Migration Guide
From Simple to OAuth
- Install
mcpauth
:pip install mcpauth
- Set up auth provider (Auth0, Okta, etc.)
- Configure provider to include
kubiya_api_key
in claims - Update server startup to use
server_auth
- Update clients to obtain JWT tokens
- Test thoroughly before switching production