# Cursor Integration Guide

This guide explains how to integrate the Developer Onboarding MCP Server with Cursor IDE.

## Setup Instructions

### 1. Build the MCP Server

First, ensure the MCP server is built and ready:

```bash
cd developer-onboarding-mcp
npm install
npm run build
```

### 2. Configure Cursor MCP Settings

Create or edit the MCP configuration file in your Cursor settings directory:

**Windows**: `%APPDATA%\Cursor\User\mcp_servers.json`
**macOS**: `~/Library/Application Support/Cursor/User/mcp_servers.json`
**Linux**: `~/.config/Cursor/User/mcp_servers.json`

Add the following configuration:

```json
{
  "servers": {
    "developer-onboarding": {
      "command": "node",
      "args": [
        "C:\\Trimble Projects 2025\\Onboarding MCP\\dist\\index.js"
      ],
      "env": {
        "LOG_LEVEL": "info"
      }
    }
  }
}
```

**Note**: Replace the path with the actual path to your built MCP server.

### 3. Restart Cursor

After adding the configuration, restart Cursor IDE to load the MCP server.

### 4. Verify Connection

1. Open the Command Palette (`Ctrl+Shift+P` or `Cmd+Shift+P`)
2. Look for MCP-related commands
3. Check that the Developer Onboarding tools are available

## Available Tools in Cursor

Once connected, you'll have access to the following tools:

### Core Onboarding Tools

1. **identify-user-role**
   - Help developers select their role and capture profile information
   - Required for personalized onboarding

2. **analyze-project**
   - Scan and understand project structure, tech stack, and components
   - Automatically identifies role-specific areas

3. **track-progress**
   - Monitor and update onboarding progress and milestones
   - Tracks individual learning achievements

4. **manage-user**
   - Manage user profiles, sessions, and preferences
   - View progress summaries and activity history

5. **generate-documentation**
   - Generate role-specific onboarding documentation and guides
   - Creates personalized learning materials

6. **analyze-code**
   - Analyze code patterns, best practices, and provide role-specific insights
   - Identifies key learning opportunities

7. **setup-environment**
   - Guide developers through role-specific environment setup
   - Validates development environment

## Available Resources

The MCP server provides several resource schemes:

### project://
- `project://{projectId}/overview` - Project overview and metadata
- `project://{projectId}/structure` - File and directory structure
- `project://{projectId}/techstack` - Technology stack and dependencies

### onboarding://
- `onboarding://overview` - Overall onboarding statistics
- `onboarding://{sessionId}/progress` - Individual session progress
- `onboarding://{sessionId}/milestones` - Learning milestones

### user://
- `user://{userId}/profile` - User profile and preferences
- `user://{userId}/dashboard` - Personal dashboard with progress

### knowledge://
- `knowledge://guides/getting-started` - General getting started guide
- `knowledge://guides/{role}` - Role-specific guides
- `knowledge://best-practices/general` - Development best practices
- `knowledge://troubleshooting/common-issues` - Troubleshooting guide

## Usage Workflow

### 1. Initial Setup

Start by identifying the user's role:

```
Please use the identify-user-role tool to begin the onboarding process. 
I need to know:
- Your name
- Your primary role (frontend, backend, testing, devops, etc.)
- Your experience level
- The project path you're working on
```

### 2. Project Analysis

Analyze the project structure:

```
Use the analyze-project tool with the project path to understand:
- Technology stack
- Project architecture
- Role-specific components
- Complexity assessment
```

### 3. Start Onboarding Session

Begin tracking progress:

```
Use track-progress with action="start_session" to:
- Create a new onboarding session
- Initialize role-specific milestones
- Begin progress tracking
```

### 4. Generate Learning Materials

Create personalized documentation:

```
Use generate-documentation to create:
- Role-specific overview
- Setup guides
- Learning paths
- Reference materials
```

### 5. Track Progress

Monitor learning progress:

```
Use track-progress to:
- Update milestone completion
- Record time spent
- Mark milestones as completed
- Get personalized recommendations
```

## Troubleshooting

### MCP Server Not Connecting

1. **Check the path**: Ensure the path in `mcp_servers.json` is correct
2. **Verify build**: Make sure `npm run build` completed successfully
3. **Check logs**: Look for error messages in Cursor's developer console
4. **Restart Cursor**: Sometimes a restart is needed after configuration changes

### Tools Not Appearing

1. **Verify configuration**: Check that the JSON syntax is correct
2. **Check permissions**: Ensure Cursor has permission to execute the Node.js process
3. **Update Cursor**: Make sure you're using a recent version that supports MCP

### Performance Issues

1. **Reduce analysis depth**: Use smaller `depth` parameters for project analysis
2. **Limit file content analysis**: Set `includeFileContent: false` for faster analysis
3. **Check system resources**: Large projects may require more memory

## Example Usage

Here's a complete example of using the onboarding system:

```typescript
// 1. Identify user role
await tools.identifyUserRole({
  action: "select_role",
  projectPath: "/path/to/project",
  userName: "John Doe",
  role: "frontend",
  experienceLevel: "intermediate",
  email: "john@example.com"
});

// 2. Analyze project
await tools.analyzeProject({
  projectPath: "/path/to/project",
  focusRoles: ["frontend"],
  includeFileContent: false
});

// 3. Start onboarding session
await tools.trackProgress({
  action: "start_session",
  userName: "John Doe",
  projectPath: "/path/to/project",
  role: "frontend"
});

// 4. Generate documentation
await tools.generateDocumentation({
  projectPath: "/path/to/project",
  role: "frontend",
  documentType: "learning_path",
  experienceLevel: "intermediate"
});
```

## Advanced Configuration

For advanced users, you can customize the MCP server behavior:

### Environment Variables

```json
{
  "servers": {
    "developer-onboarding": {
      "command": "node",
      "args": ["path/to/dist/index.js"],
      "env": {
        "LOG_LEVEL": "debug",
        "DATABASE_PATH": "custom/path/to/database.db"
      }
    }
  }
}
```

### Project-Specific Configuration

Create `.onboarding-config.json` in your project root:

```json
{
  "projectType": "web",
  "customRoles": ["data", "security"],
  "skipSteps": ["environment_setup"],
  "estimatedTime": 480,
  "customMilestones": [
    {
      "role": "frontend",
      "milestoneId": "custom-setup",
      "name": "Custom Setup Task",
      "description": "Project-specific setup requirements"
    }
  ]
}
```

## Best Practices

1. **Start with role identification**: Always begin by identifying the user's role and experience level
2. **Analyze before onboarding**: Run project analysis before starting the onboarding session
3. **Track progress regularly**: Update milestone progress frequently for accurate tracking
4. **Use appropriate depth**: Adjust analysis depth based on project size and performance needs
5. **Leverage resources**: Make use of the knowledge base resources for comprehensive guidance

## Support

If you encounter issues:

1. Check the troubleshooting section in this guide
2. Review the server logs for error messages
3. Consult the main README for additional setup information
4. Create an issue in the project repository with detailed error information
