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

# secrets

> Manage API keys and configuration

The `secrets` command helps you set up and manage API keys required for MCPKit to function.

## Usage

```bash theme={null}
mcpkit secrets [subcommand]
```

### Subcommands

<ParamField path="(none)" type="default">
  Run the interactive setup wizard to configure or update your API keys.
</ParamField>

<ParamField path="show" type="string">
  Display your current configuration (without revealing full API keys).
</ParamField>

## Examples

### Initial Setup

Run the interactive setup wizard:

```bash theme={null}
mcpkit secrets
```

You'll be prompted for:

1. **Browserbase API Key**

   ```
   ? Enter your Browserbase API key: bb_xxxxxxxxxxxxxxxx
   ```

2. **LLM Provider**

   ```
   ? Select your LLM provider:
   ❯ Google Gemini (recommended)
     OpenAI
     Anthropic
     Azure OpenAI
   ```

3. **LLM API Key**
   ```
   ? Enter your Gemini API key: AIxxxxxxxxxxxxxxxxx
   ```

<Check>
  Your secrets are now configured and saved to `~/.mcpkit/secrets.json`
</Check>

### View Current Configuration

Check what's currently configured:

```bash theme={null}
mcpkit secrets show
```

Output:

```
Current Configuration:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
LLM Provider: google
LLM Model: gemini-2.0-flash-exp
Browserbase API: Configured ✓
LLM API Key: Configured ✓
```

## Configuration Details

### Storage Location

Your secrets are stored in a JSON file at:

<Tabs>
  <Tab title="macOS/Linux">
    ```
    ~/.mcpkit/secrets.json
    ```
  </Tab>

  <Tab title="Windows">
    ```
    %USERPROFILE%\.mcpkit\secrets.json
    ```
  </Tab>
</Tabs>

<Warning>
  Never commit `secrets.json` to version control. This file contains sensitive
  API keys.
</Warning>

### File Format

The secrets file has this structure:

```json theme={null}
{
  "browserbaseApiKey": "bb_xxxxxxxxxxxxxxxx",
  "llmProvider": "google",
  "llmApiKey": "AIxxxxxxxxxxxxxxxxx",
  "llmModel": "gemini-2.0-flash-exp"
}
```

## Supported LLM Providers

MCPKit supports multiple LLM providers for AI-powered action discovery:

### Google Gemini (Recommended)

<Card title="Google Gemini" icon="google">
  Best balance of speed, quality, and cost. Free tier available.
</Card>

**Get an API key:** [Google AI Studio](https://aistudio.google.com/app/apikey)

**Supported models:**

* `gemini-2.0-flash-exp` (recommended)
* `gemini-1.5-pro`
* `gemini-1.5-flash`

**Configuration:**

```json theme={null}
{
  "llmProvider": "google",
  "llmApiKey": "AIxxxxxxxxxxxxxxxxx",
  "llmModel": "gemini-2.0-flash-exp"
}
```

### OpenAI

<Card title="OpenAI" icon="openai">
  High quality but more expensive. Good for complex websites.
</Card>

**Get an API key:** [OpenAI Platform](https://platform.openai.com)

**Supported models:**

* `gpt-4o`
* `gpt-4o-mini`
* `gpt-4-turbo`

**Configuration:**

```json theme={null}
{
  "llmProvider": "openai",
  "llmApiKey": "sk-xxxxxxxxxxxxxxxx",
  "llmModel": "gpt-4o"
}
```

### Anthropic

<Card title="Anthropic" icon="robot">
  Excellent reasoning capabilities for complex page analysis.
</Card>

**Get an API key:** [Anthropic Console](https://console.anthropic.com)

**Supported models:**

* `claude-3-5-sonnet-20241022`
* `claude-3-opus-20240229`

**Configuration:**

```json theme={null}
{
  "llmProvider": "anthropic",
  "llmApiKey": "sk-ant-xxxxxxxxxxxxxxxx",
  "llmModel": "claude-3-5-sonnet-20241022"
}
```

### Azure OpenAI

<Card title="Azure OpenAI" icon="microsoft">
  Enterprise option with compliance and data residency.
</Card>

**Configuration:**

```json theme={null}
{
  "llmProvider": "azure",
  "azureApiKey": "xxxxxxxxxxxxxxxx",
  "azureEndpoint": "https://your-resource.openai.azure.com",
  "azureDeployment": "gpt-4o",
  "llmModel": "gpt-4o"
}
```

## Browserbase Configuration

MCPKit uses [Stagehand](https://docs.stagehand.dev/) and [Browserbase](https://www.browserbase.com) for serverless browser automation.

### Get a Browserbase API Key

<Steps>
  <Step title="Sign up">
    Create a free account at [browserbase.com](https://www.browserbase.com)
  </Step>

  <Step title="Navigate to settings">
    Go to your dashboard and click on Settings
  </Step>

  <Step title="Copy API key">
    Find your API key in the API Keys section
  </Step>

  <Step title="Configure mcpkit">
    Run `mcpkit secrets` and paste your API key when prompted
  </Step>
</Steps>

### Browserbase Pricing

* **Free tier**: 100 hours/month of browser time
* Perfect for development and testing
* Upgrade for production use

## Updating Secrets

To update your configuration, simply run the setup wizard again:

```bash theme={null}
mcpkit secrets
```

Your existing values will be shown as defaults. Press Enter to keep them, or type new values to update.

## Manual Configuration

You can also manually edit the secrets file:

<Tabs>
  <Tab title="macOS/Linux">
    ```bash theme={null}
    # Edit with your preferred editor
    nano ~/.mcpkit/secrets.json

    # Or use vim
    vim ~/.mcpkit/secrets.json
    ```
  </Tab>

  <Tab title="Windows">
    ```powershell theme={null}
    # Edit with notepad
    notepad "$env:USERPROFILE\.mcpkit\secrets.json"
    ```
  </Tab>
</Tabs>

<Warning>
  Make sure the JSON is valid after manual edits, or MCPKit may fail to read the
  configuration.
</Warning>

## Environment Variables

You can also configure secrets via environment variables (useful for CI/CD):

```bash theme={null}
export BROWSERBASE_API_KEY="bb_xxxxxxxxxxxxxxxx"
export LLM_PROVIDER="google"
export LLM_API_KEY="AIxxxxxxxxxxxxxxxxx"
export LLM_MODEL="gemini-2.0-flash-exp"

mcpkit create https://example.com
```

Environment variables take precedence over the secrets file.

## Troubleshooting

<AccordionGroup>
  <Accordion title="Invalid API Key" icon="triangle-exclamation">
    If you get "Invalid API key" errors:

    1. **Verify the key** - Make sure you copied it correctly
    2. **Check provider** - Ensure you're using the right provider
    3. **Test the key** directly with the provider's API
    4. **Regenerate** - Create a new API key if needed
  </Accordion>

  <Accordion title="Secrets File Not Found" icon="file">
    If MCPKit can't find your secrets:

    1. **Run setup again:**
       ```bash theme={null}
       mcpkit secrets
       ```

    2. **Check file permissions:**
       ```bash theme={null}
       ls -la ~/.mcpkit/
       ```

    3. **Create directory manually:**
       ```bash theme={null}
       mkdir -p ~/.mcpkit
       mcpkit secrets
       ```
  </Accordion>

  <Accordion title="Rate Limits or Quota Errors" icon="gauge">
    If you hit rate limits:

    1. **Check your usage** on the provider's dashboard
    2. **Upgrade your plan** if needed
    3. **Switch providers** temporarily:
       ```bash theme={null}
       mcpkit secrets
       # Select a different provider
       ```
  </Accordion>

  <Accordion title="JSON Parse Error" icon="code">
    If your secrets file is corrupted:

    1. **Backup the file:**
       ```bash theme={null}
       cp ~/.mcpkit/secrets.json ~/.mcpkit/secrets.json.bak
       ```

    2. **Delete and recreate:**
       ```bash theme={null}
       rm ~/.mcpkit/secrets.json
       mcpkit secrets
       ```

    3. **Validate JSON:**
       ```bash theme={null}
       cat ~/.mcpkit/secrets.json | python -m json.tool
       ```
  </Accordion>
</AccordionGroup>

## Security Best Practices

<Card title="Protect Your API Keys" icon="shield">
  Your API keys provide access to paid services. Follow these practices to keep
  them secure:
</Card>

* ✅ Never commit secrets files to git
* ✅ Use environment variables in CI/CD
* ✅ Rotate keys regularly
* ✅ Use separate keys for development and production
* ✅ Set spending limits on provider dashboards
* ❌ Don't share secrets files
* ❌ Don't expose keys in logs or screenshots
* ❌ Don't use production keys in public repositories

## Next Steps

<CardGroup cols={2}>
  <Card title="Create MCP Server" icon="wand-magic-sparkles" href="/commands/create">
    Use your configured secrets to create an MCP server
  </Card>

  <Card title="Manage Contexts" icon="database" href="/commands/contexts">
    Learn about authentication contexts
  </Card>
</CardGroup>
