Software engineers using Cursor often encounter a hard context ceiling: while Cursor Agent and Composer navigate local files, generate diffs, and refactor codebases with high precision, they remain blind to live runtime state. An agent editing an ORM schema cannot verify whether a database migration matches the actual PostgreSQL schema, inspect live table indexes, or fetch payload specs from an internal microservice gateway.
Cursor solves this context-silo problem through native support for the Model Context Protocol (MCP). By configuring MCP servers, developers grant Cursor’s AI models direct, programmatic access to databases, cloud infrastructure, and private APIs through standardized tool calls.
The Core Problem: Breaking Beyond Local File Boundaries
Modern software engineering requires continuous interaction with systems outside the file tree:
- Database Schema Drift: Developers manually copy table definitions, query results, or migration diffs into chat prompts to verify ORM models.
- Private API & Microservice Disconnect: Large internal services lack public API documentation, forcing engineers to switch back and forth between Postman, terminal curl commands, and Cursor.
- Static vs. Dynamic Context: Static code files cannot reveal live row counts, runtime performance metrics, or third-party error traces.
MCP establishes a universal, JSON-RPC-based protocol between Cursor (the client) and external tools (the servers). When configured, Cursor Agent autonomously inspects available MCP tools, decides when to trigger them, executes queries or API requests, and incorporates structured JSON responses directly into its multi-step reasoning.
Configuration Architecture: Global vs. Project-Level Scope
Cursor supports two distinct configuration locations for MCP servers:
| Scope | File Path | Target Use Case | Version Control Strategy |
|---|---|---|---|
| Project-Level | .cursor/mcp.json (Repository root) | Team-wide shared databases; project-specific microservices; custom CI/CD scripts | Commit to Git; reference credentials via ${env:VARIABLE} |
| Global | ~/.cursor/mcp.json (User home directory) | Personal developer utilities; local shell scripts; cross-project tools (e.g., GitHub, Slack) | Exclude from Git; keep on individual developer workstation |
365Finds Institutional Recommendation
365Finds strongly advises technical teams to standardize on project-level .cursor/mcp.json for database connectors and workspace APIs. Global UI configurations create invisible drift across engineering teams: one engineer's Cursor Agent effortlessly verifies database schemas while a teammate's agent fails because the local configuration is absent. By checking .cursor/mcp.json into repository version control and resolving sensitive keys through environment variables, the entire engineering team shares identical agent capabilities without leaking credentials.
Standard JSON Syntax: Local stdio vs. Remote sse
Cursor handles two primary transport mechanisms:
stdio(Standard Input/Output): Cursor launches a local subprocess (vianpx,uvx,python, ornode) and communicates over standard I/O streams.sse(Server-Sent Events / HTTP): Cursor connects over HTTP/HTTPS to a running daemon or remote server endpoint.
1. Connecting a Custom Database via Local stdio
To connect a PostgreSQL instance, declare an entry inside the mcpServers object using the official PostgreSQL MCP server. You can use Node's npx or Python's uvx:
{
"mcpServers": {
"postgres-dev": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://app_user:${env:DEV_DB_PASSWORD}@localhost:5432/app_development"
]
}
}
}
If your tool requires dedicated runtime variables rather than inline CLI arguments, pass them in the env block:
{
"mcpServers": {
"postgres-staging": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres"
],
"env": {
"POSTGRES_CONNECTION_STRING": "postgresql://readonly_user:${env:STAGING_DB_PASSWORD}@db.staging.internal:5432/analytics"
}
}
}
}
2. Connecting Custom API Microservices via Remote sse / HTTP
When connecting Cursor to an organization-wide API tool, internal documentation daemon, or remote service, use the url property with authentication headers:
{
"mcpServers": {
"internal-api-gateway": {
"url": "https://api-mcp.internal.company.net/sse",
"headers": {
"Authorization": "Bearer ${env:INTERNAL_MCP_TOKEN}",
"X-Environment": "staging"
}
}
}
}
3. Running Custom In-Repo Tools
If your team maintains internal automation scripts in Python or TypeScript, expose them directly from the project directory using Cursor's variable interpolation:
{
"mcpServers": {
"repo-debugger": {
"command": "python3",
"args": [
"${workspaceFolder}/scripts/mcp_inspect_service.py"
],
"env": {
"API_ENDPOINT": "http://127.0.0.1:8080/api/v1"
}
}
}
}
Security Guardrails: Safeguarding Secrets and Data Integrity
Connecting autonomous coding agents to live infrastructure introduces significant operational risks. 365Finds establishes two mandatory technical guardrails for teams implementing MCP in Cursor:
1. Never Hardcode Raw Credentials
Do not write raw database passwords or API keys directly into .cursor/mcp.json. Cursor natively interpolates environment variables from your shell session or local .env setup:
${env:VARIABLE_NAME}: Resolves the variable from the developer's local shell environment.${workspaceFolder}: Expands to the root path of the opened project.${userHome}: Expands to the operating system user home directory.
Add .env and any local credential files to your .gitignore.
2. Enforce Read-Only Database Connections
Cursor Agent and Composer possess autonomous execution loops. If an agent receives write permissions to a database, a hallucinated migration or troubleshooting prompt could trigger unexpected UPDATE or DROP TABLE statements.
- Rule: Always configure database MCP servers with dedicated read-only database credentials (or restrict permissions to
SELECTandpg_catalog/schema inspection tables). - Isolation: For transactional testing, connect Cursor exclusively to ephemeral Docker containers, test fixtures, or staging read-replicas. Never attach an MCP server with write privileges to a production cluster.
Activating and Interacting with MCP in Cursor Agent & Composer
Once .cursor/mcp.json is saved in your repository:
Step 1: Verify Server Status
- Open Cursor and navigate to Cursor Settings (
Cmd + ,orCtrl + ,). - Select Features > MCP Servers (or Customize > Tools & MCP).
- Confirm that your declared server appears in the list with a green status indicator.
- Click the refresh icon to reload server tools or inspect the exact list of available tool schemas (such as
query,list_tables, ordescribe_table).
Step 2: Prompting Composer and Chat
Cursor's Agent Mode automatically identifies when an MCP tool is relevant. You do not need complex manual syntax to trigger it. Simply prompt the agent with natural language:
"Check the schema of the
userstable viapostgres-devand generate an updated Prisma schema and TypeScript interface matching the actual column types."
When the agent decides to invoke an MCP tool:
- Cursor displays a tool call card in the Composer / Chat feed indicating the action and parameters.
- If human approval is required by your security policy, review the SQL statement or API payload and click Run.
- The server executes the request, returns the raw JSON payload to Cursor, and the agent synthesizes the code edits directly into your active workspace.
Operational Comparison
| Architecture Pattern | Transport | Setup Overhead | Collaboration Fit | Security Posture |
|---|---|---|---|---|
Local Stdio (npx / uvx) | stdio via subprocess | Low (zero server infrastructure required) | High when using .cursor/mcp.json and ${env:VAR} | Tied to local machine process; requires strict local DB permission isolation |
Remote Gateway (sse) | HTTP / Server-Sent Events | Medium (requires hosting an MCP daemon) | Exceptional (centralized access control for entire org) | Centralized token rotation and backend audit logging; zero client secret exposure |
Custom Script (python / ts) | stdio via local interpreter | Low to Medium | High (scripts versioned directly in repo) | Depends on in-house script validation and sanitization |