Skip to main content

Overview

Cursor is an AI-powered code editor with built-in support for MCP servers and hooks. The Secure MCP Gateway integrates with Cursor in two ways:
  1. As an MCP Server - Gateway acts as a centralized MCP server proxy
  2. Using Hooks - Direct guardrails for prompts, MCP tool calls, and agent responses

Gateway Installation

Prerequisites

  • Cursor IDE installed
  • Python 3.11 or higher
  • pip or uv package manager

Step 1: Install the Gateway

Step 2: Generate Configuration

Step 3: Install for Cursor

Cursor usually doesn’t require restart, but if you see loading state for too long, restart Cursor.

Configuration Files

Cursor MCP Config

Cursor reads MCP servers from:
  • Global: ~/.cursor/mcp.json (macOS/Linux) or %USERPROFILE%\.cursor\mcp.json (Windows)
  • Project: .cursor/mcp.json in your project directory

Cursor Hooks Integration

Cursor Hooks provide real-time security for prompts, MCP executions, and agent responses.

What Runs When

Installation

Configure Guardrails

Configure Cursor Hooks

Create or edit .cursor/hooks.json in your project:
Windows Users: Replace venv/bin/python with venv\Scripts\python.exe

Guardrails Configuration

Example Configuration

guardrails_config.json

Available Detectors


Blocking vs Observational Hooks

Can prevent actions from occurring:
  • beforeSubmitPrompt: Set "continue": false to block
  • beforeMCPExecution: Set "permission": "deny" to block

How It Works

1. beforeSubmitPrompt

Input:
Output (block):

2. beforeMCPExecution

Output options:
  • "permission": "allow" - Let it run
  • "permission": "deny" - Block it
  • "permission": "ask" - Require user confirmation

3. afterMCPExecution

This hook is observability-only (doesn’t block).

4. afterAgentResponse

Violations logged to security_alerts.jsonl but cannot prevent response.

Audit Logs

All events are logged to ~/cursor/hooks_logs/:

View Logs


Testing

Test Hook Manually

Expected output:

Test with Malicious Prompt

Try this in Cursor:
You should see a block message if beforeSubmitPrompt is enabled.

Troubleshooting

Hooks Not Running

  1. Restart Cursor - Hooks require full restart after config changes
  2. Check Hooks tab - Settings → Features → Hooks
  3. Check Output panel - Select “Hooks” from dropdown for errors

Python Not Found

Ensure correct Python path in .cursor/hooks.json:

API Returning 404

The "Policy not found" error means:
  • The policy_violation detector references a non-existent policy
  • Fix: Disable policy_violation or create the policy in Enkrypt Dashboard

Metrics


Next Steps

Configure Gateway

Set up the gateway with your MCP servers

Guardrails Policies

Create custom security policies

MCP Servers

Add GitHub, Slack, or custom servers

Monitoring

View logs and metrics