# myCompiler MCP Server

This directory contains a Model Context Protocol (MCP) server integration for `myCompiler`.
It exposes Prompt Compiler tools to MCP clients such as Claude Code, Claude Desktop, and Cursor.

## Setup

1.  **Install Dependencies**:
    ```bash
    pip install -r requirements.txt
    ```

2.  **Start the API Server**:
    Ensure the main `myCompiler` API is running:
    ```bash
    # From project root
    uvicorn api.main:app --port 8000
    ```

## Configuration

Environment variables (optional; align with the Chrome extension’s `/compile` request):

| Variable | Purpose |
|----------|---------|
| `PROMPTC_BACKEND_URL` | API origin (default `http://localhost:8000`); the tool posts to `{origin}/compile`. |
| `PROMPTC_API_URL` | Full compile URL if set (overrides backend + `/compile`). |
| `PROMPTC_API_KEY` | Sent as `x-api-key` when the API requires optional key verification. |
| `PROMPTC_PROMPT_MODE` | `conservative` (default) or `default`; sent as `X-Prompt-Mode` and in the JSON body `mode`. |

The request body matches the extension: `v2`, `render_v2_prompts`, `diagnostics`, and `mode`.

### Claude Desktop

Add the following to your `claude_desktop_config.json` (usually in `%APPDATA%\Claude\` on Windows or `~/Library/Application Support/Claude/` on macOS):

```json
{
  "mcpServers": {
    "myCompiler": {
      "command": "python",
      "args": [
        "C:\\Users\\User\\Desktop\\myCompiler\\integrations\\mcp-server\\server.py"
      ]
    }
  }
}
```

> **Note**: Verify the path to `server.py`.

### Cursor

1.  Go to **Settings > Features > MCP**.
2.  Click **Add New MCP Server**.
3.  **Name**: `myCompiler`
4.  **Type**: `stdio`
5.  **Command**: `python C:\Users\User\Desktop\myCompiler\integrations\mcp-server\server.py`

## Exposed Tools

- `optimize_prompt(text)` — returns the compiled prompt string
- `compile_prompt(text)` — returns the full `/compile` payload
- `generate_agent(description, multi_agent=false)` — returns generated agent markdown
- `generate_skill(description)` — returns generated skill markdown
- `export_claude_pack(system_prompt)` — returns a Claude Code project-pack manifest
- `benchmark_prompt(text, model?)` — returns the benchmark comparison payload

## Usage

Once configured, you can ask Claude or Cursor:
> "Optimize this prompt for me: 'write a snake game in python'"

Or:

> "Generate an agent for reviewing React performance and export it as a Claude project pack."

The MCP server will call the corresponding Prompt Compiler backend route and return the result in the same session.
