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

# Using Cursor with Unkey

> Configure Cursor with Unkey documentation context to generate accurate key issuance, rate limiting, and verification code in your projects.

Cursor is an AI-powered code editor that can help you build applications faster. When combined with Unkey's APIs, you can quickly generate secure, scalable applications with API keys and rate limiting.

## Prerequisites

## Getting Started

### 1. Set Up Your Unkey Workspace

First, create your Unkey workspace and get your API keys:

<Steps>
  <Step title="Create a keyspace" stepNumber={1}>
    Navigate to the [Unkey Dashboard](https://app.unkey.com/apis) and create a new keyspace for your project.
  </Step>

  <Step title="Get Your Root Key" stepNumber={2}>
    Go to [Settings > Root Keys](https://app.unkey.com/settings/root-keys) and create a new root key with the necessary permissions.
  </Step>

  <Step title="Note Your API ID" stepNumber={3}>
    Copy your API ID from the dashboard - you'll need this for generating API keys.
  </Step>
</Steps>

### 2. Set Up Unkey MCP Server (Optional)

Cursor supports the Model Context Protocol (MCP) which allows you to connect directly to Unkey's APIs. This gives Cursor access to your Unkey workspace for more intelligent suggestions.

#### Install Unkey MCP Server

1. **Configure the MCP Server**

   Create or update your Cursor configuration file with the Unkey MCP server:

   ```json theme={"theme":"kanagawa-wave"}
   {
     "mcpServers": {
       "Unkey": {
         "command": "npx",
         "args": [
           "mcp-remote",
           "https://mcp.unkey.com/mcp/v2",
           "--header",
           "MCP-UNKEY-BEARER-AUTH:${UNKEY_ROOT_KEY}"
         ]
       }
     }
   }
   ```

   For ratelimiting specific operations, you can also add:

   ```json theme={"theme":"kanagawa-wave"}
   {
     "mcpServers": {
       "UnkeyRateLimiting": {
         "command": "npx",
         "args": [
           "mcp-remote",
           "https://mcp.unkey.com/mcp/ratelimits/",
           "--header",
           "MCP-UNKEY-V2-ROOT-KEY:${UNKEY_ROOT_KEY}"
         ]
       }
     }
   }
   ```

2. **Set Environment Variable**

   ```bash theme={"theme":"kanagawa-wave"}
   export UNKEY_ROOT_KEY="your_root_key_here"
   ```

3. **Restart Cursor**

   Restart Cursor to load the MCP server configuration.

## Tips and Tricks for Cursor with Unkey

### 1. Keep Your Requests Small

When working with Cursor, break down complex tasks into smaller, focused requests:

**Good:**

```text theme={"theme":"kanagawa-wave"}
Create a function to verify an API key with Unkey that returns a boolean
```

**Better:**

```text theme={"theme":"kanagawa-wave"}
Create a TypeScript function that:
- Takes an API key string as input
- Uses @unkey/api to verify the key
- Returns a boolean indicating if the key is valid
- Includes proper error handling
```

### 2. Update and Reference Your README.md

Keep your project's README.md updated with Unkey-specific information. Cursor uses this context to provide better suggestions:

```markdown theme={"theme":"kanagawa-wave"}
# My Project

This project uses Unkey for API authentication and ratelimiting.

## Environment Variables

- `UNKEY_ROOT_KEY`: Your Unkey root key
- `UNKEY_API_ID`: Your API ID from the Unkey dashboard

## API Routes

- `/api/protected` - Requires valid API key
- `/api/keys` - Manage API keys (admin only)

## Rate Limiting

- Free tier: 100 requests/hour
- Pro tier: 1000 requests/hour
```

## Add Unkey Documentation Context

Adding Unkey docs can let you specifically refer to Unkey features when building your app.

From Cursor Settings > Features > Docs add new doc, use the URL "[https://unkey.com/docs](https://unkey.com/docs)"
