Skip to main content
Learn how MCPKit handles authentication, manages browser contexts, and secures your credentials.

How Authentication Works

MCPKit uses Browserbase’s persistent context feature to save and reuse authentication sessions:
1

Initial Authentication

When you first create an MCP server for an authenticated site, MCPKit opens a live browser session where you can log in normally.
2

Context Storage

The browser context ID is saved to ~/.mcpkit/contexts/<domain>.txt
3

Context Reuse

Future MCP server executions load the saved context, so you don’t need to log in again.

Authentication Flow

For End Users

When using an MCPKit generated MCP server:

For Developers

In generated servers (src/index.ts):

Managing Contexts

View Saved Contexts

Create New Context

Delete Context

Show Context Details

Security Best Practices

Authentication contexts contain sensitive session data. Follow these practices to keep them secure.

1. Protect Context Files

2. Use Separate Accounts

For automation, create dedicated service accounts:

3. Rotate Contexts Regularly

4. Never Commit Contexts

Add to .gitignore:

Common Authentication Types

OAuth / SSO

Many modern tools use OAuth or SSO:
Supported:
  • Google OAuth
  • GitHub OAuth
  • Microsoft OAuth
  • SAML SSO
  • Custom OAuth providers

Username & Password

Traditional login forms:

API Keys

Some tools use API key authentication:
For API-first tools, you might not need browser automation at all. Consider using the native API directly.

Multi-Factor Authentication (2FA)

MCPKit fully supports 2FA:

Troubleshooting Authentication

If your saved context stops working:
Why it happens:
  • Session tokens have expiration dates
  • Password changes invalidate sessions
  • Security policies force re-authentication
If the browser keeps asking you to log in:
  1. Complete all authentication steps - Don’t press Enter until fully logged in
  2. Check for redirects - Wait for final landing page
  3. Verify cookies - Some sites use complex cookie setups
  4. Try incognito - Clear any conflicting sessions
If two-factor authentication fails:
  1. Use authenticator apps over SMS when possible
  2. Complete before pressing Enter - Don’t rush the process
  3. Check for “remember this device” - Enable if available
  4. Verify time sync - TOTP codes require accurate system time
If tools fail with permission errors:
  1. Check account permissions - Verify you have necessary access rights
  2. Try different account - Use an admin account if needed
  3. Review workspace settings - Some features may be restricted
  4. Contact admin - Request necessary permissions

Advanced Patterns

Context Sharing (Team Use)

For authorized internal tools only:
Only share contexts for authorized service accounts on internal tools. Never share personal account contexts.

Conditional Authentication

Check if authentication is needed:

Session Refresh

Automatically refresh sessions:

Environment Variables

Store sensitive data in environment variables:

Next Steps

Manage Contexts

Learn about the contexts command

Custom Tools

Customize authentication in generated servers