> ## Documentation Index
> Fetch the complete documentation index at: https://mcpkit.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# contexts

> Manage saved authentication contexts

The `contexts` command helps you manage saved browser authentication contexts. This allows you to reuse login sessions across multiple MCP server generations without having to authenticate every time.

## Usage

```bash theme={null}
mcpkit contexts <subcommand> [domain]
```

### Subcommands

**list** `string`

Show all saved authentication contexts

**show \<domain>** `string`

Display details for a specific domain's context

**create \<domain>** `string`

Create a new authentication context for a domain

**delete \<domain>** `string`

Remove a saved context for a domain

## Examples

### List All Contexts

View all saved authentication contexts:

```bash theme={null}
mcpkit contexts list
```

Output:

```
Saved Authentication Contexts
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📦 mcpkit.sh
   Created: 2024-01-15 14:30:00
   Size: 2.3 KB

📦 github.com
   Created: 2024-01-14 10:15:00
   Size: 4.1 KB

Total: 2 contexts
```

### Show Context Details

View details for a specific domain:

```bash theme={null}
mcpkit contexts show mcpkit.sh
```

Output:

```
Context: mcpkit.sh
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Domain: mcpkit.sh
Created: 2024-01-15 14:30:00
Last Used: 2024-01-15 16:45:00
Size: 2.3 KB
Cookies: 12
Local Storage Items: 5

Status: ✓ Valid
```

### Create New Context

Create an authentication context for a domain:

```bash theme={null}
mcpkit contexts create mcpkit.sh
```

This will:

1. Launch a live browser session
2. Navigate to the domain
3. Wait for you to complete authentication
4. Save the browser state (cookies, local storage, etc.)

```
🌐 Opening live browser session for mcpkit.sh...

Complete authentication in your browser.
Press Enter when done...

✓ Context saved successfully!
```

> [!TIP]
>
> Complete all authentication steps including 2FA before pressing Enter.

### Delete Context

Remove a saved authentication context:

```bash theme={null}
mcpkit contexts delete mcpkit.sh
```

Output:

```
✓ Context for mcpkit.sh deleted successfully
```

> [!WARNING]
>
> This action cannot be undone. You'll need to authenticate again to create a
> new context.

## How Contexts Work

Authentication contexts store browser state to avoid repeated logins:

**1. Context Creation**

When you authenticate during `mcpkit create` or run `mcpkit contexts create`, the browser state is captured including:

* Cookies
* Local storage
* Session storage
* IndexedDB data

**2. Context Storage**

The context is saved to your local machine:

```
~/.mcpkit/contexts/
├── mcpkit.sh.json
├── github.com.json
└── notion.com.json
```

Each file contains the serialized browser context.

**3. Context Reuse**

When creating an MCP server for a domain with a saved context:

```bash theme={null}
mcpkit create https://mcpkit.sh --skip-auth
```

The saved context is loaded, so you don't need to log in again.

**4. Context Expiry**

Contexts can expire based on the website's session policies. If a context is invalid, you'll be prompted to authenticate again.

## Context Files

### Location

> [tab] macOS/Linux
>
> ```
> ~/.mcpkit/contexts/
> ```

> [tab] Windows
>
> ```
> %USERPROFILE%\.mcpkit\contexts\
> ```

### File Format

Context files are JSON containing browser state:

```json theme={null}
{
  "domain": "mcpkit.sh",
  "created": "2024-01-15T14:30:00.000Z",
  "cookies": [
    {
      "name": "session_token",
      "value": "encrypted_value",
      "domain": ".mcpkit.sh",
      "path": "/",
      "expires": 1737820200
    }
  ],
  "localStorage": {
    "user_id": "user_123",
    "theme": "dark"
  }
}
```

> [!WARNING]
>
> Context files contain sensitive authentication data. Never share these files
> or commit them to version control.

## Use Cases

### Multi-Site Workflow

Save contexts for multiple sites you frequently use:

```bash theme={null}
# Set up contexts once
mcpkit contexts create mcpkit.sh
mcpkit contexts create github.com
mcpkit contexts create notion.com

# Generate servers without re-authenticating
mcpkit create https://mcpkit.sh --skip-auth
mcpkit create https://github.com --skip-auth
mcpkit create https://notion.com --skip-auth
```

### Context Refresh

If your session expires, refresh the context:

```bash theme={null}
# Delete old context
mcpkit contexts delete mcpkit.sh

# Create new context
mcpkit contexts create mcpkit.sh
```

### Team Sharing (Advanced)

For authorized internal tools, you can share contexts (use caution):

```bash theme={null}
# Export context
cp ~/.mcpkit/contexts/internal-tool.com.json ~/shared/

# Team member imports
cp ~/shared/internal-tool.com.json ~/.mcpkit/contexts/
```

> [!WARNING]
>
> Only share contexts for authorized internal tools where you have permission.
> Never share personal account contexts.

## Domain Matching

Contexts are matched by domain name:

| URL | Matched Context |
| - | - |
| `https://mcpkit.sh` | `mcpkit.sh` |
| `https://www.mcpkit.sh` | `mcpkit.sh` (or `www.mcpkit.sh` if exists) |
| `https://app.mcpkit.sh` | `mcpkit.sh` (or `app.mcpkit.sh` if exists) |
| `https://mcpkit.sh/team/issue-123` | `mcpkit.sh` |

> [!NOTE]
>
> MCPKit normalizes domains by removing `www.` and subdomains to find the base
> domain context.

## Security Considerations

### What's Stored

Contexts contain:

* ✅ Session cookies
* ✅ Authentication tokens
* ✅ Local storage data
* ✅ Session storage data
* ❌ Passwords (never stored)
* ❌ Credit card information
* ❌ Personal messages

### Best Practices

> [card] Protect Your Contexts
>
> Follow these practices to keep your authentication contexts secure:

1. **Use separate accounts** - Create dedicated accounts for automation when possible
2. **Rotate contexts** - Refresh contexts periodically
3. **Monitor usage** - Check your account activity for unexpected sessions
4. **Delete unused contexts** - Remove contexts you no longer need
5. **Secure your machine** - Use disk encryption and strong passwords

### Permissions

Ensure proper file permissions:

```bash theme={null}
# Check permissions
ls -la ~/.mcpkit/contexts/

# Should be readable only by you (600)
chmod 600 ~/.mcpkit/contexts/*.json
```

## Troubleshooting

> [accordion] Context Not Found
>
> If MCPKit can't find a context:
>
> 1. **List all contexts:**
>    ```bash theme={null}
>    mcpkit contexts list
>    ```
>
> 2. **Check domain spelling:**
>    ```bash theme={null}
>    mcpkit contexts show mcpkit.sh
>    ```
>
> 3. **Create new context:**
>    ```bash theme={null}
>    mcpkit contexts create mcpkit.sh
>    ```

> [accordion] Context Invalid or Expired
>
> If a saved context doesn't work:
>
> 1. **Delete and recreate:**
>    ```bash theme={null}
>    mcpkit contexts delete mcpkit.sh
>    mcpkit contexts create mcpkit.sh
>    ```
>
> 2. **Check website session policies** - Some sites expire sessions quickly
>
> 3. **Verify you're still logged in** to the website manually

> [accordion] Authentication Fails During Creation
>
> If context creation fails:
>
> 1. **Complete all auth steps** - Including 2FA, email verification, etc.
> 2. **Wait for full page load** - Don't press Enter until fully logged in
> 3. **Check browser state** - Make sure cookies are enabled
> 4. **Try manual authentication:**
>    * Open the site in a normal browser
>    * Log in completely
>    * Then run `mcpkit contexts create`

> [accordion] Can't Delete Context
>
> If deletion fails:
>
> 1. **Check file permissions:**
>    ```bash theme={null}
>    ls -la ~/.mcpkit/contexts/
>    ```
>
> 2. **Manually delete:**
>    ```bash theme={null}
>    rm ~/.mcpkit/contexts/mcpkit.sh.json
>    ```
>
> 3. **Verify deletion:**
>    ```bash theme={null}
>    mcpkit contexts list
>    ```

## Advanced Usage

### Bulk Context Management

List and delete multiple contexts:

```bash theme={null}
# List all contexts
mcpkit contexts list

# Delete old contexts
for domain in old-site1.com old-site2.com; do
  mcpkit contexts delete $domain
done
```

### Context Backup

Back up your contexts:

```bash theme={null}
# Create backup directory
mkdir ~/mcpkit-backup

# Copy all contexts
cp ~/.mcpkit/contexts/*.json ~/mcpkit-backup/

# Restore when needed
cp ~/mcpkit-backup/*.json ~/.mcpkit/contexts/
```

### Context Migration

Move contexts to a new machine:

```bash theme={null}
# On old machine
tar -czf mcpkit-contexts.tar.gz -C ~/.mcpkit contexts

# Transfer file to new machine
scp mcpkit-contexts.tar.gz newmachine:~/

# On new machine
mkdir -p ~/.mcpkit
tar -xzf mcpkit-contexts.tar.gz -C ~/.mcpkit
```

## Next Steps

> [card] [Create MCP Server](https://mcpkit.sh/commands/create.md)
>
> Use saved contexts to generate servers

&#x20;

> [card] [Authentication Guide](https://mcpkit.sh/advanced/authentication.md)
>
> Learn more about authentication handling

&#x20;

> [card] [Examples](https://mcpkit.sh/examples/overview.md)
>
> See example workflows using contexts

> [card] [Secrets Management](https://mcpkit.sh/commands/secrets.md)
>
> Configure your API keys


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.