Important: MCP tools only activate in Cursor's Agent mode. Ask mode and Plan mode do not invoke MCP servers. Make sure you are working in Agent mode for PrePrompt to intercept prompts automatically.

How PrePrompt Works in Cursor

When you submit a prompt in Cursor's Agent mode with PrePrompt installed, the following happens:

  1. The UserPromptSubmit hook fires before the prompt reaches the LLM.
  2. PrePrompt's heuristic classifier scores the prompt locally in under 1ms — no API call.
  3. If the score is below 38, the prompt passes through untouched.
  4. If the score is 38 or above, Claude Haiku rewrites the prompt to be more specific and actionable.
  5. Cursor sends the (possibly rewritten) prompt to the LLM.
  6. The interaction is logged locally to ~/.preprompt/history.db.

Stack memory compounds over time: as PrePrompt sees more of your prompts, it learns your preferred language, framework, and conventions, injecting them into future rewrites automatically.

Installation

  1. Install PrePrompt
    pip install preprompt
  2. Run the setup wizard

    This saves your Anthropic API key and registers PrePrompt with the IDEs it detects on your system.

    preprompt-install

    Alternatively, register Cursor specifically:

    python -c "from scripts.install_cursor import main; main()"
  3. Verify the Cursor config was written
    cat ~/.cursor/mcp.json

    You should see a preprompt entry in the mcpServers object.

  4. Restart Cursor

    MCP servers are loaded at startup. Restart Cursor to pick up the new configuration.

  5. Test the integration

    In Cursor Agent mode, send a vague prompt like "write middleware that validates tokens and handles refresh". You should see a PrePrompt annotation in the terminal output, and Cursor will receive the rewritten prompt.

The MCP Configuration Entry

preprompt-install writes the following to ~/.cursor/mcp.json:

{
  "mcpServers": {
    "preprompt": {
      "command": "python",
      "args": ["-m", "mcp_server.server"],
      "env": {
        "ANTHROPIC_API_KEY": "your-api-key-here"
      }
    }
  }
}

If you need to configure this manually, add the above entry to your existing ~/.cursor/mcp.json. If the file does not exist, create it with the full content above.

What Gets Optimized

PrePrompt's classifier routes each prompt through one of three paths:

Frequently Asked Questions

Q: Does PrePrompt work in Cursor's Ask mode?

A: No. MCP tools only activate in Cursor's Agent mode. Ask and Plan modes do not invoke MCP servers at all. For those modes, you can use the preprompt-optimize "your prompt here" CLI command to optimize manually and paste the result.

Q: Where is Cursor's MCP configuration file?

A: ~/.cursor/mcp.json. Running preprompt-install writes the correct entry automatically, detecting whether Cursor is installed on your system.

Q: Does PrePrompt slow down Cursor?

A: No. The heuristic classifier adds under 1ms to every prompt — imperceptible. Simple prompts (questions, short commands) pass through untouched at zero cost. Only complex prompts above the quality threshold trigger a Haiku rewrite, adding approximately 1–2 seconds.

Get started in two commands

Install PrePrompt and register it with Cursor (and any other compatible IDEs you have installed).

View full install guide →

See Also