AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

Configuring Model Context Protocol (MCP) in Cursor: The Architectural Guide for Engineering Teams

장은미 · 365Finds Editorial
Indexed 88,650 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

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).

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.


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 ScopeFile PathVersion Control StrategyIntended Use Cases
Workspace (Per-Repo)<project-root>/.cursor/mcp.jsonCommitted to GitStandard 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 PrivatePersonal 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)
  1. Team Admin Dashboard: If enterprise administrators define global policies, they lock down settings and cannot be overridden locally.
  2. permissions.json: When present, the mcpAllowlist array defined in .cursor/permissions.json completely replaces the allowlist in Cursor's visual Settings UI, making the UI read-only.
  3. 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:

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:

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

DimensionLocal stdio (e.g., PostgreSQL MCP)Containerized stdio (Docker/Podman)Remote SSE / HTTP (Corporate Gateway)
Primary TargetLocal development databases and CLI utilitiesSandboxed test instances with mock dataShared internal documentation, vector search, staging databases
Network DependencyNone; operates over local Unix/Windows pipesNone; strictly local loopback container networkRequires corporate intranet, VPN, or reverse proxy access
Secret ManagementLocal environment variables (${env:VAR})Docker env-files or container secretsCentralized secret vault at gateway; client holds short-lived token
Execution Latency< 10ms< 25ms50ms – 250ms (network-dependent)
Blast RadiusRestricted by OS user and database role privilegesIsolated to container file system and network namespaceGoverned by API Gateway rate limits and RBAC policies
Team MaintenanceEach engineer runs local database daemonShared docker-compose.yml across repositoryMaintained 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:

  1. 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).
  2. Layer permissions.json over IDE Settings: Eliminate "modal fatigue" by explicitly allowlisting idempotent introspection tools (postgres:describe_table, postgres:read_query). Never use wildcard *:* rules in shared projects.
  3. Isolate Environment Secrets: Ensure .cursor/mcp.json is checked into source control with ${env:...} variables, and add .env or local secret stores to .gitignore.
  4. Standardize on stdio for Development, SSE for 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.


References