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

# Authentication

> Set up API key authentication for the CLI

# CLI Authentication

Authenticate the LeanMCP CLI with your API key to access your projects and deployments.

## Get Your API Key

1. Go to [LeanMCP Dashboard](https://leanmcp.com)
2. Navigate to **Settings** → **API Keys**
3. Create a new API key with appropriate permissions
4. Copy the API key (starts with `airtrain_`)

## Login Command

```bash theme={null}
leanmcp login
```

The CLI will prompt you interactively for your API key:

```
LeanMCP Login

? Enter your LeanMCP API key: airtrain_xxxx...

Validating API key...
API key validated successfully!
Logged in successfully!
```

## Verify Authentication

Check if you're logged in:

```bash theme={null}
leanmcp whoami
```

**Example Output:**

```
LeanMCP Authentication Status

Logged in
  API Key: airtrain_2ef4da...
  API URL: https://api.leanmcp.com
  Last updated: 12/18/2025, 4:38:05 PM
```

## Logout

Remove stored credentials:

```bash theme={null}
leanmcp logout
```

**Example Output:**

```
Logged out successfully!
```

## Credential Storage

The CLI stores your credentials securely in:

* **macOS/Linux**: `~/.leanmcp/config.json`

<Warning>
  Keep your API key secure. Do not share it or commit it to version control.
</Warning>

## Troubleshooting

### Not Authenticated

```
Not authenticated
Run 'leanmcp login' to authenticate.
```

**Solutions:**

* Run `leanmcp login` and enter your API key
* Verify your API key is correct

### API Key Invalid

```
API key validation failed
Please check your API key and try again.
```

**Solutions:**

* Verify your API key is correct
* Check if the API key has expired
* Create a new API key in the dashboard

## Next Steps

<Card title="Project Management" icon="folder" href="/cli/projects">
  Start creating and managing MCP projects
</Card>
