Static codebase indexing has hit a hard architectural ceiling. When debugging distributed microservices, investigating data corruption, or implementing features against live APIs, Cursor's local vector index and Abstract Syntax Tree (AST) parser cannot see beyond the files on disk. If an engineer asks Cursor Composer to write a database migration, diagnose an orphaned record, or reproduce a production incident logged in GitHub Issues, the agent is forced to guess table structures, assume API payloads, and hallucinate foreign key relationships.
The Model Context Protocol (MCP) eliminates this boundary. By exposing external databases, internal developer tools, and SaaS APIs directly to Cursor's Agent and Composer workflows, MCP turns an AI code generator into a contextual execution agent.
At 365Finds, our research and deployment across engineering teams lead to a definitive judgment: MCP is essential for high-velocity software engineering, but unconstrained MCP deployment is an operational hazard. Relying on human rubber-stamping to catch destructive SQL executions (DROP TABLE, unindexed UPDATE, accidental TRUNCATE) fails in practice due to approval fatigue. A production-grade Cursor MCP architecture requires a multi-layered security gate combining repository-scoped configurations, read-only database credentials, strict tool allowlists in permissions.json, and semantic auto-review classifiers.
This guide provides the complete blueprint for software engineers, DevOps leads, and system architects configuring native MCP in Cursor.
1. Architecture: How Cursor Integrates MCP
Cursor implements the open Model Context Protocol standard developed by Anthropic, functioning as an MCP Host. When configured, Cursor connects to one or more MCP Servers, interrogates their capabilities, and exposes their primitives—primarily Tools, Resources, and Prompts—to the agent runtime.
+-------------------------------------------------------------+
| Cursor IDE |
| +--------------------+ +--------------------+ |
| | Agent / Composer |<----------->| permissions.json | |
| | (Model Reasoning) | | Security Gate | |
| +---------+----------+ +--------------------+ |
| | |
| | JSON-RPC 2.0 (Tool Invocations & Resources) |
+------------|------------------------------------------------+
|
+------------+---------------------------+
| |
v v
[ STDIO Transport ] [ HTTP / SSE Transport ]
Local Process Lifecycle Remote Stateless / Stateful
| |
+---------+---------+ +--------+--------+
| Postgres / SQLite | | Internal DevAPI |
| Local CLI Tools | | GitHub / Linear |
+-------------------+ +-----------------+
Transport Mechanisms: STDIO vs. SSE / HTTP
Cursor supports two primary communication transports for MCP servers:
| Feature | STDIO Transport | Remote SSE / Streamable HTTP |
|---|---|---|
| Execution Location | Local workstation process | Remote server or container |
| Lifecycle Management | Managed directly by Cursor | Self-hosted or third-party cloud |
| Performance / Latency | Sub-millisecond IPC | Network-dependent |
| Configuration Syntax | command, args, env, envFile | url, headers, auth |
| Authentication | Environment variables, local files | Bearer tokens, Static OAuth, PKCE |
| Security Perimeter | Local machine process boundary | TLS, corporate VPN, OAuth scopes |
| Best For | Local dev DBs, ad-hoc Python/Node scripts | Team-shared microservices, cloud telemetry |
Configuration Scopes: Global vs. Project-Level
Cursor searches for MCP definitions across two distinct configuration tiers:
- Project-Level (
<workspace>/.cursor/mcp.json): Dedicated to the active repository. 365Finds strongly recommends committing.cursor/mcp.jsonto version control. It guarantees that every developer on the team shares the identical set of database tools, migration scripts, and documentation servers without manual setup. - Global (
~/.cursor/mcp.json): Applies universally across all workspaces on the user's operating system. Reserved for personal utility servers (such as a local note-taking index, clipboard manager, or personal developer scratchpad).
Cursor evaluates both files. For variable interpolation, Cursor supports dynamic expansion directly within command, args, env, url, and headers:
${env:VARIABLE_NAME}: Resolves environment variables from the user's shell.${workspaceFolder}: Resolves to the absolute path of the root directory containing.cursor/mcp.json.${userHome}: Resolves to the user's home directory.
2. Configuring mcp.json for External Databases
To connect relational databases to Cursor Agent, engineers configure specialized MCP servers that translate database metadata and query capabilities into structured JSON schemas.
Connecting PostgreSQL via STDIO
The official @modelcontextprotocol/server-postgres package provides schema inspection and query execution over a standard connection string.
Create or edit .cursor/mcp.json in your repository root:
{
"mcpServers": {
"postgres-staging": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"${env:STAGING_DATABASE_URL}"
],
"env": {
"PGCONNECT_TIMEOUT": "10"
}
}
}
}
[!IMPORTANT] Never hardcode plain-text database credentials in
.cursor/mcp.json. Use${env:STAGING_DATABASE_URL}combined with an untracked.envfile or exported shell variables. For STDIO servers, Cursor also supports"envFile": "${workspaceFolder}/.env".
Connecting SQLite for Local Application Development
For projects utilizing SQLite (e.g., local prototypes, desktop apps, embedded databases), the SQLite MCP server provides zero-dependency introspection:
{
"mcpServers": {
"sqlite-local": {
"command": "uvx",
"args": [
"mcp-server-sqlite",
"--db-path",
"${workspaceFolder}/storage/development.sqlite3"
]
}
}
}
3. Connecting Custom Developer Tools & Remote Endpoints
Engineers frequently require Cursor Agent to interact with proprietary internal services, CI/CD pipelines, or incident tracking systems.
Building a Custom Internal Tool via Python (FastMCP)
Creating a project-specific MCP server requires minimal code using Python's fastmcp or the official @modelcontextprotocol/sdk.
Create tools/service_inspector.py:
#!/usr/bin/env python3
import json
import os
import urllib.request
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("ServiceInspector")
@mcp.tool()
def get_service_health(environment: str) -> str:
"""Fetch health checks and error rates for backend microservices.
Args:
environment: Target environment ('staging' or 'production').
"""
if environment not in ["staging", "production"]:
return "Invalid environment requested."
# Example logic querying internal diagnostic endpoint
url = f"https://internal-telemetry.corp.internal/{environment}/status"
req = urllib.request.Request(
url,
headers={"Authorization": f"Bearer {os.getenv('CORP_API_TOKEN', '')}"}
)
try:
with urllib.request.urlopen(req, timeout=5) as resp:
data = json.loads(resp.read().decode())
return json.dumps(data, indent=2)
except Exception as e:
return f"Error connecting to internal telemetry: {str(e)}"
if __name__ == "__main__":
mcp.run()
Register this local script in .cursor/mcp.json:
{
"mcpServers": {
"internal-telemetry": {
"command": "python",
"args": ["${workspaceFolder}/tools/service_inspector.py"],
"env": {
"CORP_API_TOKEN": "${env:INTERNAL_DEV_TOKEN}"
}
}
}
}
Remote SSE Endpoints with Static OAuth
For centralized developer platforms hosted on corporate infrastructure (or integrations with Linear, Jira, GitHub), remote Server-Sent Events (SSE) or Streamable HTTP endpoints avoid distributing local binaries to every developer's machine:
{
"mcpServers": {
"enterprise-gateway": {
"url": "https://mcp.devops.enterprise.internal/sse",
"headers": {
"X-Organization-ID": "eng-platform"
},
"auth": {
"CLIENT_ID": "${env:MCP_OAUTH_CLIENT_ID}",
"CLIENT_SECRET": "${env:MCP_OAUTH_CLIENT_SECRET}",
"scopes": ["read:telemetry", "query:staging"]
}
}
}
}
When authenticating remote OAuth MCP servers in Cursor:
- Desktop clients use the callback:
http://localhost:8787/callback - Web and Cloud Agent instances use:
https://www.cursor.com/agents/mcp/oauth/callback
4. Guiding Cursor Agent: Discovery and Structured Invocations
Once mcp.json is saved, Cursor establishes background connections with the declared servers.
Tool Verification
- Navigate to File > Preferences > Cursor Settings > Tools & MCP (or the Customize panel).
- Verify that the registered servers display green active status indicators.
- Expanding a server shows the list of dynamically detected tools, schemas, and descriptions.
[Installed MCP Servers]
✓ postgres-staging (Connected - 3 tools discovered)
- query (Execute read-only SQL query)
- list_tables (List relational schemas and tables)
- describe_table (Inspect columns, types, and foreign keys)
✓ internal-telemetry (Connected - 1 tool discovered)
- get_service_health (Fetch health checks and error rates)
Structured Prompting Workflow in Composer
In Cursor Composer or Agent Chat (Cmd + L or Ctrl + L), prompt the agent naturally with explicit context. Cursor's reasoning model inspects available tool definitions, selects the appropriate tool, and constructs valid JSON parameters conforming to the tool's schema:
Prompt:
"Investigate why user authentication failed for team_id 492 in staging.
Check the schema of the `accounts` and `sessions` tables using our postgres server,
query the latest 5 session records for this team, and cross-reference with our service health."
During execution, Cursor displays an interactive tool call chip showing:
- The target server (
postgres-staging). - The specific function (
query). - The exact structured arguments (
{"sql": "SELECT session_id, user_id, status, expires_at FROM sessions WHERE team_id = 492 ORDER BY created_at DESC LIMIT 5;"}). - The output returned by the external system.
5. Security Authorization Gates: Gating Destructive Operations
Giving an autonomous agent unrestricted access to real-world database connections introduces severe operational risk:
- An LLM may attempt schema migrations using unindexed columns on multimillion-row tables.
- A hallucinated query could issue
DELETE FROM users WHERE status = 'inactive'without a transaction or safety limit. - An innocent query on an unpartitioned table could trigger connection starvation and lock active databases.
The 365Finds 4-Tier Security Defense
To achieve velocity without compromising data integrity, implement this defense-in-depth framework:
+--------------------------------------------------------------+
| Tier 1: Database Engine Role Isolation (SELECT-only User) |
+--------------------------------------------------------------+
|
v
+--------------------------------------------------------------+
| Tier 2: MCP Tool Separation (Distinct read vs write tools) |
+--------------------------------------------------------------+
|
v
+--------------------------------------------------------------+
| Tier 3: Cursor permissions.json Allowlist (mcpAllowlist) |
+--------------------------------------------------------------+
|
v
+--------------------------------------------------------------+
| Tier 4: Auto-Review Semantic Classifier (autoRun Guardrails) |
+--------------------------------------------------------------+
1. Database Role Isolation (Non-Negotiable)
Never configure an MCP database server with superuser or general admin privileges. Provision a dedicated database user restricted strictly to read privileges:
-- PostgreSQL Security Provisioning
CREATE ROLE cursor_analyst WITH LOGIN PASSWORD 'strong_random_password';
GRANT CONNECT ON DATABASE staging_app TO cursor_analyst;
GRANT USAGE ON SCHEMA public TO cursor_analyst;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO cursor_analyst;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO cursor_analyst;
-- Explicitly revoke write permissions
REVOKE INSERT, UPDATE, DELETE, TRUNCATE, DROP ON ALL TABLES IN SCHEMA public FROM cursor_analyst;
2. Gating Approvals via permissions.json
Cursor features an explicit permissions configuration system that controls which MCP tools can execute automatically and which demand human approval.
Cursor resolves permissions using strict priority:
- Team Admin Dashboard (Enterprise policy)
permissions.json(~/.cursor/permissions.jsonconcatenated with<workspace>/.cursor/permissions.json)- IDE Settings UI (Cursor settings)
Create <workspace>/.cursor/permissions.json in your repository:
{
// Explicitly allow safe read tools to run without UI popups
"mcpAllowlist": [
"postgres-staging:list_tables",
"postgres-staging:describe_table",
"postgres-staging:read_query",
"internal-telemetry:*"
],
// Auto-review classifier steering for Auto-review run mode
"autoRun": {
"allow_instructions": [
"Allow read-only database queries, schema inspections, and GET requests to internal telemetry.",
"Allow querying staging databases for table metadata and row counts."
],
"block_instructions": [
"Block any database operations that execute INSERT, UPDATE, DELETE, ALTER, DROP, or TRUNCATE statements.",
"Block any database queries directed toward production hosts.",
"Block tool calls that expose unhashed passwords, private tokens, or secret keys."
]
}
}
How the Authorization Gate Behaves:
- Whitelisted Tool Calls (
postgres-staging:read_query): Cursor Agent executes the query immediately, returning schema context to Composer with zero friction. - Unwhitelisted / Mutation Calls (
postgres-staging:execute_dmlor any unapproved tool): Cursor halts execution, flashes an interactive review modal, and displays the exact SQL query or payload to the engineer. The operation cannot execute until the user clicks Run or rejects the invocation. - Auto-Review Classifier Guidance: If the project runs in Auto-review mode, the classifier checks the tool call against
block_instructions. Even if a tool is technically permitted, detecting destructive SQL keywords triggers an immediate stop and requests human intervention.
6. Operational Trade-Offs and Enterprise Recommendations
365Finds recommends the following institutional policies when adopting MCP in engineering teams:
- Commit Configuration, Exclude Secrets: Check
.cursor/mcp.jsonand.cursor/permissions.jsoninto the repository. Add.envand connection strings to.gitignore. This standardizes the developer experience across your organization on day one. - Favor STDIO for Local Dev, Remote SSE for Centralized Teams: STDIO requires developers to install runtimes (Node, Python, uv) locally. For larger engineering organizations, deploy a shared, containerized MCP gateway over SSE that enforces company-wide RBAC and centralized audit logging.
- Audit Token Usage: External database schemas and query results consume LLM context window tokens. Restrict custom MCP tools to return concise, structured summaries rather than raw
SELECT *dumps containing thousands of rows. - Never Rely on Model Prompting as a Security Boundary: Telling Cursor in
.cursorrules"Do not delete data" is advisory; models hallucinate. Hard security boundaries must be enforced via database role grants andpermissions.jsongates.
By combining the expressive reach of the Model Context Protocol with the defensive rigors of permissions.json and role isolation, engineering teams transform Cursor into an indispensable operational copilot capable of querying live data without putting production stability at risk.