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:- As an MCP Server - Gateway acts as a centralized MCP server proxy
- 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.jsonin 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:
Guardrails Configuration
Example Configuration
guardrails_config.json
Available Detectors
Blocking vs Observational Hooks
- Blocking Hooks
- Observational Hooks
Can prevent actions from occurring:
beforeSubmitPrompt: Set"continue": falseto blockbeforeMCPExecution: Set"permission": "deny"to block
How It Works
1. beforeSubmitPrompt
2. beforeMCPExecution
"permission": "allow"- Let it run"permission": "deny"- Block it"permission": "ask"- Require user confirmation
3. afterMCPExecution
4. afterAgentResponse
security_alerts.jsonl but cannot prevent response.
Audit Logs
All events are logged to~/cursor/hooks_logs/:
View Logs
Testing
Test Hook Manually
Test with Malicious Prompt
Try this in Cursor:beforeSubmitPrompt is enabled.
Troubleshooting
Hooks Not Running
- Restart Cursor - Hooks require full restart after config changes
- Check Hooks tab - Settings → Features → Hooks
- 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_violationdetector references a non-existent policy - Fix: Disable
policy_violationor 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