IA que trabaja

What is MCP and how to use it: a practical guide with Claude Code, Claude Desktop and Cursor

MCP is how you give an AI real tools: a browser, your database, your calendar. What it is, how to add it to Claude Code, Claude Desktop and Cursor, how to build your own in Python, and how not to open a security hole.

By David García Published: October 17, 20264 min read

MCP (Model Context Protocol) is an open standard, created by Anthropic and now adopted across the industry, for connecting an AI application to external tools and data.

Think of it as a universal plug. Instead of every AI app inventing its own way to talk to Google Drive or your database, someone writes an "MCP server" once and it works in Claude Code, Claude Desktop, Cursor and any other compatible app.

Diagram: you, the AI app with its MCP client, the MCP server with tools, resources and prompts, and your service
You talk to the app; the app uses the MCP server; the server talks to your service.
  • The AI application contains an MCP client.
  • The MCP server is a small program offering tools (actions), resources (data to read) and prompts (templates).
  • Your service is the database, API or files behind it.

Ask "what appointments do I have tomorrow?" and the AI sees a appointments_for_day tool, calls it, gets the data and answers with it. (The screenshots below come from a Spanish-language practice project.)

Your first MCP in Claude Code

Three commands do everything: claude mcp add, claude mcp list and claude mcp remove. Inside a session, /mcp shows connected servers and their tools.

python -m venv .venv
.venv\Scripts\python.exe -m pip install mcp-server-fetch
claude mcp add fetch -- .venv\Scripts\python.exe -m mcp_server_fetch
claude mcp list
Real output of claude mcp list with fetch connected
fetch connected. If it says Failed, check the Python path.

The first time a tool is used, Claude Code asks for permission.

Real permission prompt: fetch with url https://example.com and the options Yes, Yes and don't ask again, No
Every MCP tool asks before running, until you say otherwise.

Scopes

ScopeOptionWhere it applies
Local (default)no --scopeOnly you, only this folder
Project--scope projectSaved in .mcp.json in the folder, shared through Git
User--scope userYou, across all your projects

When a project ships a .mcp.json, Claude Code asks before enabling it, defaulting to no, so a downloaded project cannot sneak a server in.

Claude Desktop, Cursor and VS Code

AppFileKey
Claude Code.mcp.json or ~/.claude.jsonmcpServers
Claude DesktopWindows: %APPDATA%\Claude\claude_desktop_config.json · Mac: ~/Library/Application Support/Claude/claude_desktop_config.jsonmcpServers
Cursor.cursor/mcp.json or ~/.cursor/mcp.jsonmcpServers
VS Code.vscode/mcp.jsonservers
{
  "mcpServers": {
    "fetch": {
      "command": "C:/Users/you/mcp-practice/.venv/Scripts/python.exe",
      "args": ["-m", "mcp_server_fetch"]
    }
  }
}

MCP servers worth using

  • Playwright: a browser the AI controls, for testing sites, screenshots and forms.
  • GitHub: issues, pull requests and repos.
  • Databases (Postgres, SQLite...): query without copy-pasting.
  • Notion, Linear, Google Drive: remote servers that need you to log in.
claude mcp add --scope project playwright -- npx -y @playwright/mcp@latest

Not every server in those "awesome MCP" lists works: some are archived or broken with newer versions. Test before you trust.

Build your own MCP server in Python

With the official Python SDK, a server with two read-only tools is about 30 lines:

import csv
from pathlib import Path

from mcp.server.mcpserver import MCPServer

DATA = Path(__file__).parent / "data"
mcp = MCPServer("garage")


def read(name: str) -> list[dict]:
    with open(DATA / name, encoding="utf-8", newline="") as f:
        return list(csv.DictReader(f))


@mcp.tool()
def appointments_for_day(date: str) -> list[dict]:
    """Garage appointments on a date (YYYY-MM-DD), sorted by time."""
    rows = [r for r in read("appointments.csv") if r["date"] == date]
    return sorted(rows, key=lambda r: r["time"])


if __name__ == "__main__":
    mcp.run()

The docstring is what the AI reads to decide when to use the tool, so write it clearly. In version 2 of the SDK the class is MCPServer; tutorials using FastMCP are from the previous version.

Test it with the official MCP Inspector before connecting it:

npx @modelcontextprotocol/inspector .venv\Scripts\python.exe garage.py
Real MCP Inspector showing the result of the tool and the tools/list and tools/call messages
The Inspector lets you call each tool by hand and see exactly what it returns.

Security

  1. Read by default, write with confirmation. Tools that create, send or delete should ask first.
  2. Watch out for injected instructions. Data can contain text like "IGNORE PREVIOUS INSTRUCTIONS". In my test Claude spotted it, but the real defence is that tools cannot do anything serious without your confirmation.
  3. Keys in environment variables, never hard-coded in .mcp.json.
Real output: an appointment note containing IGNORE PREVIOUS INSTRUCTIONS
An instruction hidden in a piece of data. It can arrive in an email, a web page or a review.

If you want an agent connected to your company's tools without dealing with all this, see the services. And for the agent itself, the Claude Code guide.

Frequently asked questions

What is MCP in AI?

An open standard for connecting AI applications to external tools and data. An MCP server exposes tools the AI can call, and it works in any compatible app.

Which apps support MCP?

Claude Code, Claude Desktop, Cursor, VS Code with Copilot, Codex and many more. Each has its own config file, but the server is the same.

Is it hard to build an MCP server?

No. With the official Python SDK a small server is about 30 lines. The hard part is designing it safely.

Keep reading

Guides

Claude Code: the complete hands-on guide, from installing it to leaving it working alone

Installation, daily commands, permissions, CLAUDE.md, skills, MCP, subagents and scheduled tasks.

Read · 6 min
Automation

What is AI automation (and what it is not): a practical guide for small businesses

AI vs automation, real examples, tools, costs and mistakes to avoid.

Read · 3 min