When engineering teams adopt Cursor Composer and Agent Mode for complex backend and full-stack development, they quickly encounter an annoying productivity bottleneck: context starvation. While the model understands the local repository codebase with high precision, it remains completely blind to running runtime infrastructure. When building an API endpoint or refactoring an ORM entity, developers find themselves constantly alt-tabbing to terminal sessions, running psql or curl, copying schema dumps and JSON responses, and pasting them back into the chat window.
This manual bridging breaks developer flow and introduces costly errors: truncated clipboard pastes miss subtle foreign key constraints, schemas drift between local migrations and the prompt, and LLMs hallucinate non-existent column names.
Model Context Protocol (MCP)—the open standard initiated by Anthropic and adopted natively by Cursor—solves this problem at the protocol level. Instead of treating the AI as an isolated text predictor, Cursor acts as an MCP host that connects directly to local databases, internal microservices, and specialized developer tooling.
At 365Finds, our research indicates that configuring MCP properly transforms Cursor from a sophisticated autocompleter into an autonomous technical collaborator. However, misconfiguring MCP can easily introduce severe security vulnerabilities, credential leaks in shared repositories, or paralyzing approval fatigue. This guide provides engineering managers, systems architects, and backend engineers with the production blueprint for configuring .cursor/mcp.json, securing connections via .cursor/permissions.json, and governing database access.
The Core Architecture: Understanding Cursor MCP Transports
Cursor's MCP client communicates with external tools using standardized JSON-RPC 2.0 messages over two distinct transport mechanisms: stdio and SSE (Server-Sent Events) / Streamable HTTP. Choosing the right transport depends strictly on where the resource lives and how credentials are maintained.
flowchart TD
subgraph CursorIDE["Cursor IDE & Cursor CLI"]
Agent["Cursor Agent (Composer / CLI)"]
PermEngine["Permissions Engine (.cursor/permissions.json)"]
Agent --> PermEngine
end
subgraph LocalMachine["Local Developer Machine"]
PermEngine -->|stdio: command + args + env| PostgresMCP["PostgreSQL MCP Server (npx / uvx)"]
PostgresMCP -->|Local Socket / TCP| LocalDB[(Local PostgreSQL DB)]
PermEngine -->|stdio| LocalCLI["Custom Dev Tools / Git CLI"]
end
subgraph CorporateInfra["Enterprise Cloud Infrastructure"]
PermEngine -->|SSE / HTTP: Bearer Token| RemoteMCP["Internal API Gateway / MCP Service"]
RemoteMCP --> VectorDB[(Internal Vector Knowledge Base)]
RemoteMCP --> ProductionDocs[(Private API Catalog)]
end
1. The stdio Transport (Local Execution)
For developer databases, filesystem tools, or local CLI wrappers, Cursor spawns the MCP server as a subprocess on the host machine. Cursor communicates with this process via standard input (stdin) and standard output (stdout).
- Execution Overhead: Near zero. There are no extra network hops or DNS resolutions.
- Security Surface: Highly isolated. The tool runs under the developer's local OS user account and can only access loopback resources or local sockets.
- Engineering Caveat: If you build custom MCP servers for internal tooling, never emit diagnostic logs to
stdout. Any unsolicited string written to standard output corrupts Cursor's JSON-RPC parser and causes silent connection failures. All server logs and debug outputs must be directed exclusively tostderr.
2. The SSE / Streamable HTTP Transport (Remote Endpoints)
For centralized team resources—such as private API catalogs, staging observability endpoints, or company-wide vector search engines—Cursor connects over HTTPS using Server-Sent Events for server-to-client streaming and standard HTTP POST requests for client-to-server tool invocation.
- Execution Overhead: Dependent on corporate network latency; requires robust retry logic and SSL certificate trust.
- Security Surface: Requires token authentication via custom HTTP headers, zero-trust network access (ZTNA), or VPN gateways.
- Engineering Advantage: The MCP server is maintained centrally by platform engineering. Tool upgrades, schema modifications, and credential rotations happen upstream without requiring every developer to update local packages.
Workspace Scope vs. User Scope: File Placement Strategy
Cursor checks for MCP configurations at two distinct levels. Engineering teams must establish a strict separation between team-shared definitions and individual developer overrides:
| Configuration Scope | File Path | Version Control Strategy | Intended Use Cases |
|---|---|---|---|
| Workspace (Per-Repo) | <project-root>/.cursor/mcp.json | Committed to Git | Standard project dependencies: local dev database, Prisma schema inspector, repo linting tools |
| User (Global) | ~/.cursor/mcp.json (macOS/Linux) or %USERPROFILE%\.cursor\mcp.json (Windows) | Gitignored / Kept Private | Personal productivity tools: personal GitHub CLI, localized notes search, private test harness |
365Finds Institutional Judgment: Never Commit Plaintext Secrets
A frequent error in engineering teams is checking database connection strings containing passwords directly into <project-root>/.cursor/mcp.json. Because this file is committed to Git to synchronize tooling across the engineering org, hardcoded secrets instantly pollute the repository history.
Cursor provides first-class variable substitution. Teams must mandate the use of ${env:VARIABLE_NAME} inside mcp.json or leverage local .env references via "envFile".
Step-by-Step: Connecting a PostgreSQL Database
Connecting a PostgreSQL database allows Cursor Agent to inspect table schemas, verify foreign key relationships, review enum values, and test queries before generating migration code or application queries.
Step 1: Create a Dedicated Read-Only Database Role
Never point Cursor Agent to an administrative superuser account (postgres) or an application user with destructive DROP TABLE or TRUNCATE rights. Always provision a least-privilege role on your database:
-- Create an isolated role for Cursor Agent
CREATE ROLE cursor_agent WITH LOGIN PASSWORD 'strong_dev_password';
-- Grant connection rights
GRANT CONNECT ON DATABASE ecommerce_dev TO cursor_agent;
-- Grant schema access
GRANT USAGE ON SCHEMA public TO cursor_agent;
-- Grant SELECT-only privileges on existing and future tables
GRANT SELECT ON ALL TABLES IN SCHEMA public TO cursor_agent;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO cursor_agent;
Step 2: Configure .cursor/mcp.json in the Project Root
Create or edit .cursor/mcp.json at the root of your repository. Using the official PostgreSQL MCP server (@modelcontextprotocol/server-postgres), configure the stdio transport:
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://cursor_agent:${env:DEV_DB_PASSWORD}@127.0.0.1:5432/ecommerce_dev"
],
"env": {
"NODE_ENV": "development"
}
}
}
}
If your team uses Python environments via uv, you can configure the Python alternative:
{
"mcpServers": {
"postgres-python": {
"command": "uvx",
"args": ["postgres-mcp", "--access-mode=restricted"],
"env": {
"DATABASE_URI": "postgresql://cursor_agent:${env:DEV_DB_PASSWORD}@127.0.0.1:5432/ecommerce_dev"
}
}
}
}
Step 3: Connecting Remote Corporate APIs via SSE
To connect Cursor to an internal documentation index or company microservice catalog running in the corporate intranet, configure an HTTP/SSE block:
{
"mcpServers": {
"enterprise-docs": {
"url": "https://mcp-gateway.internal.acme.corp/sse",
"headers": {
"Authorization": "Bearer ${env:INTERNAL_MCP_TOKEN}",
"X-Team-ID": "backend-core"
}
}
}
}
Tool Governance: Hardening Security with permissions.json
When an MCP server exposes tools to Cursor, the model can invoke them during Composer or Agent sessions. By default, Cursor prompts the developer with an approval modal for every tool execution. In active coding sessions where the agent queries the database multiple times to trace a complex relationship, constant modal prompts destroy velocity.
Conversely, enabling unrestricted execution without boundaries exposes the environment to prompt injection attacks or accidental destructive actions.
Cursor resolves this via .cursor/permissions.json.
Precedence and Merging Hierarchy
Cursor evaluates tool allowlists through a three-tier priority hierarchy:
Team Admin Dashboard (Highest) > permissions.json (Per-User ∪ Per-Repo) > IDE Settings UI (Lowest)
- Team Admin Dashboard: If enterprise administrators define global policies, they lock down settings and cannot be overridden locally.
permissions.json: When present, themcpAllowlistarray defined in.cursor/permissions.jsoncompletely replaces the allowlist in Cursor's visual Settings UI, making the UI read-only.- Merge Behavior: Cursor automatically concatenates arrays from
~/.cursor/permissions.json(per-user) and<workspace>/.cursor/permissions.json(per-repo).
Formatting mcpAllowlist
Each entry in mcpAllowlist strictly follows the server:tool format and is case-insensitive. Wildcards (*) are supported:
postgres:describe_table— Matches exactly one specific tool on thepostgresserver.postgres:*— Matches all tools provided by thepostgresserver.*:read_query— Matchesread_queryacross every connected MCP server.postgres:list_*— Matches all tools starting withlist_on thepostgresserver (e.g.,list_tables,list_views).*:*— Unconditional authorization across all tools and servers (365Finds strongly advises against this in production).
Steer the Agent with autoRun
In addition to static tool matching, teams operating in Auto-review mode can provide natural-language instructions to the internal LLM classifier using the autoRun block.
Here is the production-grade .cursor/permissions.json configuration recommended by 365Finds:
{
// MCP tools that execute without manual confirmation prompts
"mcpAllowlist": [
"postgres:read_query",
"postgres:describe_table",
"postgres:list_tables",
"enterprise-docs:search",
"enterprise-docs:fetch_spec"
],
// Terminal commands permitted without prompting
"terminalAllowlist": [
"git status",
"git diff",
"npm test",
"cargo check"
],
// Guidance for the Auto-review classifier
"autoRun": {
"allow_instructions": [
"Allow read-only SQL queries and schema introspection tools automatically.",
"Allow running unit tests and checking Git diffs."
],
"block_instructions": [
"Never execute write, update, delete, or schema alteration queries without explicit developer confirmation.",
"Never permit Git push, Git commit, or remote branch manipulations."
]
}
}
Verifying Tool Connectivity via the Cursor CLI
Before engaging Cursor Composer in extensive code refactoring, engineering teams should verify tool registration and inspect schema exposure using the Cursor CLI (agent).
1. Inspect Configured Servers
Run the agent mcp discovery command in your terminal:
agent mcp list
This interactive output displays all detected MCP servers, showing:
- Server Identifier: The key defined in
mcp.json(e.g.,postgres,enterprise-docs). - Connection Status:
connected(green) orerror/disconnected(red). - Configuration Origin: Project-level (
<workspace>/.cursor/mcp.json) vs. Global (~/.cursor/mcp.json). - Active Transport:
stdio,HTTP, orSSE.
2. Audit Available Tool Signatures
To verify which tools the PostgreSQL or custom server exposes to the model, run:
agent mcp list-tools postgres
The output outlines tool names, human-readable descriptions, and JSON schema parameter requirements (e.g., query: string, table_name: string). Reviewing this ensures the LLM receives clean, well-annotated parameters rather than ambiguous inputs.
3. Test Invocations in Non-Interactive Agent Runs
You can test the end-to-end integration by running a targeted prompt through the CLI:
# Verify the agent uses the postgres tool to retrieve schema details
agent -p "Query the postgres MCP tool to inspect the columns in the orders table and summarize its indexing structure."
# Run with temporary automated MCP approvals for headless script verification
agent --approve-mcps "Verify connectivity to enterprise-docs and retrieve the auth spec"
Production Architecture Comparison
| Dimension | Local stdio (e.g., PostgreSQL MCP) | Containerized stdio (Docker/Podman) | Remote SSE / HTTP (Corporate Gateway) |
|---|---|---|---|
| Primary Target | Local development databases and CLI utilities | Sandboxed test instances with mock data | Shared internal documentation, vector search, staging databases |
| Network Dependency | None; operates over local Unix/Windows pipes | None; strictly local loopback container network | Requires corporate intranet, VPN, or reverse proxy access |
| Secret Management | Local environment variables (${env:VAR}) | Docker env-files or container secrets | Centralized secret vault at gateway; client holds short-lived token |
| Execution Latency | < 10ms | < 25ms | 50ms – 250ms (network-dependent) |
| Blast Radius | Restricted by OS user and database role privileges | Isolated to container file system and network namespace | Governed by API Gateway rate limits and RBAC policies |
| Team Maintenance | Each engineer runs local database daemon | Shared docker-compose.yml across repository | Maintained centrally by DevOps/Platform team |
365Finds Institutional Evaluation & Operational Checklist
Model Context Protocol is not merely an optional convenience feature; it represents the definitive interface between generative AI models and engineering runtime environments. At 365Finds, we evaluate Cursor's native MCP implementation as industry-leading in developer experience due to its seamless coexistence across both the graphical IDE (Composer) and the command line (agent).
However, implementing MCP without rigorous architectural standards introduces technical debt and security risks. We recommend all engineering teams implement the following four operational rules:
- Enforce Read-Only at the Database Engine: Never rely exclusively on Cursor's prompt or LLM alignment to prevent database mutations. An AI model can misinterpret instructions or hallucinate a write query. Security must be enforced at the PostgreSQL role level (
GRANT SELECT ONLY). - Layer
permissions.jsonover IDE Settings: Eliminate "modal fatigue" by explicitly allowlisting idempotent introspection tools (postgres:describe_table,postgres:read_query). Never use wildcard*:*rules in shared projects. - Isolate Environment Secrets: Ensure
.cursor/mcp.jsonis checked into source control with${env:...}variables, and add.envor local secret stores to.gitignore. - Standardize on
stdiofor Development,SSEfor Enterprise Knowledge: Use local subprocesses for immediate, zero-latency feedback loops on developer laptops. Reserve SSE endpoints for company-wide knowledge platforms where token revocation and auditing must be monitored centrally.
By implementing this architecture, engineering organizations remove the friction of manual clipboard transfers, maintain rigorous zero-trust security postures, and allow Cursor Agent to write code with complete structural fidelity to the real-world system.