Connecting Cursor AI to MCP Servers for External Tool Access
If you have been using Cursor AI for a while, you might have noticed that the assistant is great at reading and writing code, but it can only work with what you give it. It cannot peek into your database, check your API documentation, or inspect live logs on its own. MCP (Model Context Protocol) is an open protocol that connects an AI assistant to external tools, APIs, and data sources through controlled server endpoints — solving exactly this problem.
In this post, I walk through what MCP servers are, how to configure them in Cursor, and how to write a simple one from scratch in Python.
Why MCP Matters
Without MCP, a typical debugging session looks roughly like this:
- Check the code in your editor.
- Read the logs in a terminal.
- Query the database in a separate client.
- Look up the API schema in a browser tab.
- Jump back to the editor to make changes.
All that context switching is tiring and slow. MCP brings that external information directly into the AI assistant, so you can stay in one place and ask questions that span all of those sources at once.
More precisely, instead of manually explaining your project’s structure to the AI on every session, you register MCP servers that give it live, up-to-date access to your tools. The AI then decides which server to call based on what you ask.
How MCP Servers Communicate with Cursor: JSON-RPC and Transport Mechanisms
An MCP server is a process that exposes a set of tools — named functions the language model can invoke automatically when your prompt calls for them. Under the hood, communication uses JSON-RPC 2.0, and Cursor supports several transport mechanisms:
- stdio — the server runs as a local subprocess; Cursor talks to it via standard input/output. Simple to set up, great for development.
- Streamable HTTP — the server listens on an HTTP endpoint and supports multiple concurrent connections. Better suited for remote or shared servers.
- SSE (Server-Sent Events) — an older HTTP-based transport that is now deprecated in the MCP specification. Prefer Streamable HTTP for new integrations.
You configure an MCP server by adding a JSON block to a mcp.json file — either globally in ~/.cursor/mcp.json (available across all your projects) or locally in .cursor/mcp.json inside a specific project directory. The configuration tells Cursor the server’s name, how to start or reach it, and any environment variables it needs (such as API keys).
For security, the protocol keeps a human in the loop: Cursor shows a visual indicator whenever a tool is about to be called, and may ask you to confirm before executing sensitive operations. MCP servers run with whatever credentials you give them, so treat each one as a trusted integration and be careful about what permissions you grant.
Cursor MCP Server Setup Examples: Apidog, Stripe, and Figma Dev Mode
Here are three practical examples of MCP servers you can plug into Cursor today.
1. Apidog MCP Server for API Documentation
This server gives the AI real-time access to your API documentation, which is useful for generating typed clients, writing validation logic, or adding field-level comments based on your actual schema.
To install:
- Generate an API access token and locate your Project ID inside Apidog.
- Add the following to your Cursor
mcp.json. The example below is for Windows; on macOS/Linux replace"cmd", "/c"with"npx"directly:
{
"mcpServers": {
"API specification": {
"command": "cmd",
"args": [
"/c",
"npx",
"-y",
"apidog-mcp-server@latest",
"--project-id=<project-id>"
],
"env": {
"APIDOG_ACCESS_TOKEN": "<access-token>"
}
}
}
}
After saving and restarting Cursor, you can use prompts like:
- “Generate TypeScript interfaces for all data models in our API documentation.”
- “Create a Python client for the authentication endpoints according to our API documentation.”
- “Add comments for each field in the Product class based on the API documentation.”
2. Stripe MCP Server for Payment Processing
The Stripe MCP server exposes tools that wrap the Stripe API — things like listing invoices, creating payment links, or triggering refunds — so you can build and test payment features using natural language.
You can install it with a one-click deep-link from Stripe’s docs, or manually add it to mcp.json. For the remote (Streamable HTTP) variant:
{
"mcpServers": {
"stripe": {
"url": "https://mcp.stripe.com"
}
}
}
Once configured, Cursor’s agent automatically discovers the available tools — such as list_invoices or create_payment_link — and calls them when your prompt warrants it.
3. Figma Dev Mode MCP Server for Design-to-Code Workflows
This server connects Cursor to Figma’s Dev Mode, giving the AI access to design tokens, component specs, and layout data. It is particularly handy for generating code that faithfully matches your designs.
To install:
- In the Figma desktop app, enable “Dev Mode MCP Server” under Preferences.
- Add the server to your global
mcp.json. Because it runs locally, it uses the stdio transport:
{
"mcpServers": {
"figma-dev-mode": {
"command": "npx",
"args": ["-y", "figma-dev-mode-mcp-server"]
}
}
}
With the server running, you can ask Cursor to generate code from a selected Figma frame, extract design variables and component names, or use Code Connect to tie design components to your existing implementation.
Key Benefits of MCP Servers in Cursor AI
- Real-time context. The AI works with live data from your APIs, databases, and design files — not a stale snapshot you pasted into the chat.
- Less context switching. Your entire workflow stays inside the IDE. No more jumping between browser tabs and terminals to gather information.
- Automated multi-step workflows. The agent can chain tool calls — for example, query the database, cross-reference the API docs, and propose a fix — all from a single prompt.
- Controlled access. The
mcp.jsonconfiguration and the human-in-the-loop confirmation step let you decide exactly which tools the AI can reach and when.
A Simple MCP Server in Python
Want to write your own? The official MCP Python SDK makes it straightforward. Below is a minimal database query tool built with FastMCP, the high-level interface from the SDK.
First, install the SDK:
pip install "mcp[cli]"
Then create the server:
# tools/db_query_server.py
import sqlite3
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("Database Query Server")
@mcp.tool()
def query_database(query: str) -> dict:
"""Execute a read-only SQL query against app.db and return the results."""
conn = sqlite3.connect("app.db")
cursor = conn.cursor()
try:
cursor.execute(query)
columns = [desc[0] for desc in cursor.description]
rows = cursor.fetchall()
return {
"status": "success",
"data": [dict(zip(columns, row)) for row in rows],
}
except Exception as e:
return {"status": "error", "message": str(e)}
finally:
conn.close()
if __name__ == "__main__":
mcp.run() # defaults to stdio transport
Register it in your project’s .cursor/mcp.json:
{
"mcpServers": {
"database-query": {
"command": "python",
"args": ["tools/db_query_server.py"]
}
}
}
Now you can ask:
Use the database-query tool to show me all users created today, then check if there were authentication errors for these users
Cursor invokes the tool, gets the results back as structured JSON, and weaves them into its response. It works surprisingly well once you try it!
One important note: for stdio-based servers, never write to stdout outside of the MCP protocol itself — doing so corrupts the JSON-RPC message stream. Use sys.stderr or a logging library for any debug output.
Cursor AI MCP Servers: Frequently Asked Questions
What transport should I use for a local MCP server in Cursor?
Use stdio for a server that runs as a local subprocess — it is simple to set up and ideal for development. Use Streamable HTTP for remote or shared servers that support multiple concurrent connections. SSE (Server-Sent Events) is deprecated in the MCP specification and should not be used for new integrations.
Where do I configure MCP servers in Cursor — globally or per project?
Add a JSON block to ~/.cursor/mcp.json for a server available across all your projects, or to .cursor/mcp.json inside a specific project directory for a server scoped to that project only.
Why shouldn’t an MCP server write to stdout?
For stdio-based servers, writing anything to stdout outside of the MCP protocol itself corrupts the JSON-RPC message stream. Send debug output to sys.stderr or a logging library instead.
Does Cursor ask for confirmation before an MCP tool runs a sensitive operation?
Yes. MCP keeps a human in the loop: Cursor shows a visual indicator whenever a tool is about to be called and may ask you to confirm before executing sensitive operations.
How do I write a minimal MCP tool in Python?
Install the official MCP Python SDK with pip install “mcp[cli]”, then use FastMCP to decorate a function with @mcp.tool(). Register the script in .cursor/mcp.json with the command and args needed to run it.
One MCP server is a good start — connecting Cursor, Codex CLI, and Antigravity to a shared hub of them is the natural next step, and I walk through that setup in Connecting Codex CLI, Cursor, and Antigravity via MCP.
Did you like this post? Please let me know if you have any comments or suggestions about your experience with AI-powered development tools. I am always happy to learn from your experiences, too!
References
Enjoyed this? Get more like it.
Weekly notes on AI tools, Python, and what I'm actually building — plus two free gifts: the 15-page Fantastic AI: The 2026 Toolkit and a Git Commands & Contribution Workflow Cheatsheet.