# Cursor IDE Setup Guide

Quick setup guide for using the WebRTC MCP Chat Server with Cursor IDE.

## 🚀 Quick Setup (5 minutes)

### Step 1: Install & Start the Chat Server
```bash
# Clone or navigate to the project directory
cd webrtc-mcp-chat

# Install dependencies
npm install

# Start both servers
npm start
```

Keep this terminal running! You should see:
```
🚀 Starting WebRTC MCP Chat Server...
📡 Starting main chat server...
🔧 Starting MCP server...
✅ Both servers started successfully!
🌐 Web interface: http://localhost:3000
```

### Step 2: Configure Cursor

1. **Open Cursor Settings**
   - Press `Cmd/Ctrl + ,`
   - Search for "MCP" or navigate to Extensions → MCP

2. **Add MCP Server Configuration**
   - Click "Add MCP Server" or edit your MCP settings
   - Paste this configuration:

```json
{
  "mcpServers": {
    "webrtc-chat": {
      "command": "node",
      "args": ["/FULL/PATH/TO/webrtc-mcp-chat/mcp-server.js"],
      "env": {
        "CHAT_SERVER_URL": "http://localhost:3000"
      }
    }
  }
}
```

3. **Update Path**
   - Replace `/FULL/PATH/TO/webrtc-mcp-chat/` with your actual project path
   - Example: `/Users/john/projects/webrtc-mcp-chat/mcp-server.js`

4. **Restart Cursor**

### Step 3: Test It!

Ask Cursor any of these questions:
- "Join the general chat room as [YourName]"
- "Send a message saying 'Hello from Cursor!' to the general room"
- "What users are currently in the general room?"
- "Create a new chat room for testing"

## 💬 Usage Examples

### Join a Chat Room
```
You: "Join the tech-talk room as Alice and say hello"
```
Cursor will use the `join_chat` tool to join the room and send your message.

### Send Messages
```
You: "Send 'How is everyone doing?' to the general room as Alice"
```
Cursor will use the `send_message` tool.

### Check Room Status
```
You: "Who's in the general chat room?"
```
Cursor will use the `get_room_info` tool.

### Create New Rooms
```
You: "Create a new chat room for our team meeting"
```
Cursor will use the `create_room` tool and give you the room ID.

## 🌐 Connect with Web Users

1. **Open the web interface**: `http://localhost:3000`
2. **Join the same room** that you're using in Cursor
3. **Chat together!** Web users get video/audio, MCP users get text

## 🔧 Troubleshooting

### Common Issues

**"MCP server not found"**
- Check that your file path is correct and absolute
- Make sure `mcp-server.js` exists at that location

**"Connection refused"**
- Ensure `npm start` is running
- Check that you see "✅ Both servers started successfully!"

**"Tools not available"**
- Restart Cursor completely
- Check that MCP configuration was saved properly

**Windows Path Issues**
Use forward slashes in JSON:
```json
"args": ["C:/Users/YourName/projects/webrtc-mcp-chat/mcp-server.js"]
```

### Getting Your Full Path

**macOS/Linux:**
```bash
cd webrtc-mcp-chat
pwd
# Copy the output and add '/mcp-server.js'
```

**Windows:**
```cmd
cd webrtc-mcp-chat
cd
# Copy the output and add '/mcp-server.js'
```

## 🎯 What's Happening?

When you ask Cursor to interact with chat:

1. **Cursor** receives your request
2. **MCP Server** (`mcp-server.js`) processes the request  
3. **Chat Server** (`server.js`) handles the actual chat functionality
4. **Web Users** see your messages in real-time
5. **You** get responses back through Cursor

It's like having a bridge between Cursor and the chat system!

## 📚 More Info

- **Full Documentation**: See `README.md`
- **MCP Tools Available**: `join_chat`, `send_message`, `get_room_info`, `create_room`
- **Web Interface**: `http://localhost:3000`

Happy chatting! 🚀 