# VS Code Copilot Configuration

This file shows how to configure the PDF MCP Server for use with VS Code Copilot.

## Prerequisites

1. **VS Code** with GitHub Copilot extension installed
2. **MCP support** in VS Code Copilot (ensure you have a recent version)

## Configuration Location

Add the configuration to your VS Code `settings.json`:

- **macOS/Linux**: `~/.config/Code/User/settings.json`
- **Windows**: `%APPDATA%\Code\User\settings.json`

Or use VS Code's settings UI:
1. Press `Cmd+,` (macOS) or `Ctrl+,` (Windows/Linux)
2. Click the "Open Settings (JSON)" icon in the top right
3. Add the configuration below

## Configuration Content

Add the following to your `settings.json`:

```json
{
  "github.copilot.mcp.servers": {
    "pdf-operations": {
      "command": "node",
      "args": [
        "/absolute/path/to/pdf-mcp-server/dist/index.js"
      ]
    }
  }
}
```

## Important Notes

1. **Replace the path**: Change `/absolute/path/to/pdf-mcp-server` to the actual absolute path where you installed this project.

2. **Get absolute path**: To find the absolute path, run this in the project directory:
   ```bash
   pwd
   ```
   Then append `/dist/index.js` to the result.

3. **Example for macOS**:
   ```json
   {
     "github.copilot.mcp.servers": {
       "pdf-operations": {
         "command": "node",
         "args": [
           "/Users/yourname/Documents/pdf-mcp-server/dist/index.js"
         ]
       }
     }
   }
   ```

4. **Example for Windows**:
   ```json
   {
     "github.copilot.mcp.servers": {
       "pdf-operations": {
         "command": "node",
         "args": [
           "C:\\Users\\yourname\\Documents\\pdf-mcp-server\\dist\\index.js"
         ]
       }
     }
   }
   ```

## Multiple MCP Servers

If you already have other MCP servers configured, add the `pdf-operations` entry to the existing object:

```json
{
  "github.copilot.mcp.servers": {
    "existing-server": {
      "command": "...",
      "args": ["..."]
    },
    "pdf-operations": {
      "command": "node",
      "args": [
        "/absolute/path/to/pdf-mcp-server/dist/index.js"
      ]
    }
  }
}
```

## Verification

After adding the configuration:

1. **Save settings.json**
2. **Reload VS Code** (Cmd+Shift+P → "Developer: Reload Window")
3. **Open the Copilot Chat panel**
4. **Test with a PDF file**:
   ```
   @workspace How many pages are in /path/to/test.pdf?
   ```

If configured correctly, Copilot will use the `count-pdf-pages` tool to answer.

## Usage in VS Code

### Via Copilot Chat

Open Copilot Chat and ask questions about PDFs:

```
Count the pages in /Users/yourname/Documents/report.pdf
```

```
Extract the text from ~/Downloads/invoice.pdf
```

```
What's the metadata of /path/to/document.pdf?
```

```
Summarize the main points of /path/to/research-paper.pdf
```

```
Based on /path/to/manual.pdf, how do I configure the system?
```

### Via Inline Chat

You can also use inline chat in the editor:
1. Press `Cmd+I` (macOS) or `Ctrl+I` (Windows/Linux)
2. Ask questions about PDF files
3. Copilot will use the MCP tools to answer

## Troubleshooting

### Server not loading

1. **Check the path**: Ensure it's absolute and points to `dist/index.js`
2. **Rebuild the project**: Run `npm run build` in the project directory
3. **Check Node.js**: Ensure Node.js 18+ is installed: `node --version`
4. **Check VS Code version**: Ensure you have the latest VS Code and Copilot extension
5. **Check output panel**: View "Output" → "GitHub Copilot" for error messages

### MCP setting not available

If the `github.copilot.mcp.servers` setting is not recognized:
- Update VS Code to the latest version
- Update the GitHub Copilot extension
- Ensure MCP support is enabled in your Copilot subscription

### Tool calls not working

- **Use absolute paths**: Provide absolute paths to PDF files
- **Check file permissions**: Ensure PDFs are readable
- **Check file size**: Default limit is 50MB
- **Check PDF format**: File must be a valid PDF (not password-protected)

## Advanced Configuration

### Using workspace-specific settings

You can also add this to `.vscode/settings.json` in your workspace for project-specific configuration:

```json
{
  "github.copilot.mcp.servers": {
    "pdf-operations": {
      "command": "node",
      "args": [
        "/absolute/path/to/pdf-mcp-server/dist/index.js"
      ]
    }
  }
}
```

### Environment variables

Add environment variables if needed:

```json
{
  "github.copilot.mcp.servers": {
    "pdf-operations": {
      "command": "node",
      "args": [
        "/absolute/path/to/pdf-mcp-server/dist/index.js"
      ],
      "env": {
        "NODE_ENV": "production"
      }
    }
  }
}
```

## Example Workflows

### Document Analysis
```
Copilot Chat: Analyze the structure of /path/to/document.pdf and tell me about its key sections
```

### Data Extraction
```
Copilot Chat: Extract all the email addresses mentioned in /path/to/contacts.pdf
```

### Research Summary
```
Copilot Chat: Read /path/to/paper.pdf and summarize the methodology section
```

---

**Need help?** Check the main [README.md](README.md) for more information.
