npm package: @recursorsdk/mcp-server
Description: Recursor MCP (Model Context Protocol) Server for Node.js - Connect AI assistants (Claude Desktop, Cursor) to your Recursor project's memory
Author: Recursor
Latest version: 1.0.3

# Recursor MCP Server (Node.js)

[![npm version](https://img.shields.io/npm/v/@recursorsdk/mcp-server)](https://www.npmjs.com/package/@recursorsdk/mcp-server)
[![Node.js Version](https://img.shields.io/node/v/@recursorsdk/mcp-server)](https://www.npmjs.com/package/@recursorsdk/mcp-server)
[![License](https://img.shields.io/npm/l/@recursorsdk/mcp-server)](https://github.com/recursor/middleware/blob/main/mcp-server-node/LICENSE)

Connect your AI coding assistant (Claude Desktop, Cursor, etc.) to your Recursor project's memory and learnings using Node.js.

## What is This?

The Recursor MCP (Model Context Protocol) server allows AI assistants to:

- **Search your memory**: Query past corrections and coding patterns
- **Learn from you**: Save new corrections when you fix the AI's output
- **Access project context**: Pull information specific to your project

## Installation

```bash
npm install -g @recursorsdk/mcp-server
```

Or use locally:

```bash
npm install @recursorsdk/mcp-server
```

## Quick Start

### 1. Get Your Configuration

1. Log into your [Recursor Dashboard](https://recursor.dev/dashboard)
2. Select your project
3. Find the "MCP Server Configuration" section
4. Click "Copy Config"

### 2. Set Environment Variables

```bash
export RECURSOR_API_KEY="your-api-key"
export RECURSOR_API_URL="https://api.recursor.dev/api/v1"
```

### 3. (Optional) Project Isolation - Hybrid Strategy
If you work on multiple projects in the same IDE window or just want strict isolation:

1.  In the Recursor Dashboard, select **"Project Config (.env)"**.
2.  Copy the generated `.env` content.
3.  Create a `.env` file in your **local project root**.
4.  The MCP server will automatically detect this and switch to that project's context for all operations in that folder.

### 3. Configure Your AI Tool

#### Claude Desktop

1. Open your config file:
   - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
   - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`

2. Paste the configuration from your dashboard (update command to `recursor-mcp`)

3. Restart Claude Desktop

#### Cursor

1. Open Settings (Cmd/Ctrl + ,)
2. Search for "MCP"
3. Add your configuration
4. Restart Cursor

### 4. Run the Server

**Stdio Mode (for Claude Desktop/Cursor):**
```bash
recursor-mcp
```

**HTTP Bridge Mode (for Docker, n8n, etc.):**
```bash
recursor-mcp --http
```

The HTTP bridge will be available at `http://localhost:8001` by default.

## Available Tools

Once connected, your AI assistant has access to:

### Corrections
- `search_memory(query, limit)` - Search for relevant past corrections
- `add_correction(original_code, fixed_code, explanation)` - Record a correction
- `list_corrections(page, page_size)` - List corrections with pagination
- `get_correction_stats()` - Get correction statistics

### Code Intelligence
- `detect_intent(user_request, current_file)` - Detect user intent
- `correct_code(code, language)` - Get AI-suggested corrections
- `get_coding_patterns()` - Get learned coding patterns
- `get_analytics(user_id, period)` - Get analytics dashboard

### Projects
- `create_project(name, description)` - Create a project
- `list_projects()` - List projects
- `get_project(project_id)` - Get project details
- `get_mcp_config(project_id)` - Get MCP configuration


### Authentication
- `login(email, password)` - Login and get access token
- `get_profile()` - Get user profile

### Memory
- `query_rotatable_memory(domain, pattern_type, limit)` - Query learned patterns
- `get_memory_stats()` - Get memory statistics

### Gateway
- `gateway_chat(messages, provider, model)` - Send messages through LLM gateway

## HTTP Bridge API

When running in HTTP bridge mode (`--http`), the server exposes REST endpoints:

### Health Check
```bash
GET http://localhost:8001/
```

### Search Corrections
```bash
POST http://localhost:8001/search
Headers: X-API-Key: your-api-key
Body: { "query": "authentication", "limit": 5 }
```

### Add Correction
```bash
POST http://localhost:8001/corrections
Headers: X-API-Key: your-api-key
Body: {
  "original_code": "def func(): pass",
  "fixed_code": "def func() -> None: pass",
  "explanation": "Add type hints"
}
```

## Environment Variables

- `RECURSOR_API_KEY` - Your Recursor API key (required)
- `RECURSOR_API_URL` - Recursor API URL (default: `https://api.recursor.dev/api/v1`)
- `RECURSOR_ACCESS_TOKEN` - Alternative to API key (for user authentication)
- `MCP_HTTP_PORT` - HTTP bridge port (default: `8001`)
- `MCP_HTTP_HOST` - HTTP bridge host (default: `0.0.0.0`)
- `CORS_ORIGINS` - Comma-separated list of allowed CORS origins

## Development

```bash
# Clone the repository
git clone https://github.com/luvbird32/recursor.git
cd recursor/mcp-server-node

# Install dependencies
npm install

# Build
npm run build

# Run in development mode
npm run dev

# Run in HTTP bridge mode
npm run dev -- --http
```

## License

MIT

## Support

- [Documentation](https://docs.recursor.dev/mcp)
- [Issues](https://github.com/luvbird32/recursor/issues)
- [Discord](https://discord.gg/recursor)