An MCP server is a small program that gives AI apps such as Claude, ChatGPT and Cursor a standard set of tools and data to use. It speaks the Model Context Protocol, so any MCP client can connect without a custom integration.
To write this, we built a working MCP server in 50 lines of Python, connected to it locally and over HTTP, and timed every call. Below are the code, the real results, and how servers differ from APIs and plugins.
What an MCP server does
MCP, the Model Context Protocol, is an open standard for connecting AI apps to outside systems. Our explainer on what MCP is covers the protocol as a whole. This article is about the server side: the part you install or build.
An MCP server sits between an AI app and something useful, such as a database, a file system, a website or a SaaS product. It tells the AI app what it offers, accepts requests, does the work and returns results in a standard format.
| Part | What it is | Example |
|---|---|---|
| Host | The AI app you use | Claude Desktop, Cursor, ChatGPT |
| Client | The connector inside the host that talks to one server | One per connected server |
| Server | The program that offers tools and data | A GitHub, database or WordPress MCP server |
| Model | The AI that decides which tool to call | Claude, GPT, Gemini |
The client and host are often the same app. When you add a server to Claude Desktop, Claude Desktop is the host, it runs an MCP client for each server, and the model decides when to call the tools.
MCP server vs MCP client
The two words get mixed up because they always appear together. The server offers capabilities; the client consumes them on behalf of an AI app.
| MCP server | MCP client | |
|---|---|---|
| Role | Offers tools, resources and prompts | Connects to a server and uses them |
| Lives in | Its own process or web service | The AI app, one per connected server |
| Starts the conversation | No; it waits for requests | Yes; it sends initialize |
| Who builds it | Service owners and developers | AI app makers |
| Example | Our droidcrunch-posts server | The connector inside Claude Desktop or Cursor |
In our test, the “client” was a 30-line Python script using the SDK’s Client class. It connected, listed tools, called them 20 times and measured the timings. In everyday use, the client is built into the app you already use, and you never see it.
The three things a server can offer
Every MCP server exposes some combination of three building blocks, which the protocol calls primitives.
| Primitive | What it is | Who decides to use it | Our test server |
|---|---|---|---|
| Tools | Functions the AI can call to do something or fetch data | The model | search_posts, count_posts |
| Resources | Read-only data the app can load as context | The app or user | posts://all, the full list |
| Prompts | Reusable prompt templates with parameters | The user | related_reading(topic) |
Most servers are mostly tools. Our test server offers all three so you can see each one working.
How an MCP server works, step by step
The steps at a glance
-
Step 1 of 6
The client connects
The AI app launches a local server or opens an HTTP connection to a remote one.
-
Step 2 of 6
They agree on a version
The client sends initialize; the server replies with its protocol version, name and what it supports.
-
Step 3 of 6
The client asks what's available
It requests the list of tools, resources and prompts, each with a description and input schema.
-
Step 4 of 6
The model picks a tool
When your request needs it, the model chooses a tool and fills in the arguments.
-
Step 5 of 6
The server does the work
It validates the input, runs the function and returns text and structured results, or an error.
-
Step 6 of 6
The model uses the result
The answer goes back into the conversation, and the model may call more tools before replying.
Under the hood, every message is JSON-RPC 2.0: a small JSON object with a method name, parameters and an ID. Here’s the real initialize response our test server sent back when we connected with curl:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"protocolVersion": "2025-11-25",
"capabilities": {
"prompts": { "listChanged": false },
"resources": { "listChanged": false, "subscribe": false },
"tools": { "listChanged": false }
},
"instructions": "Search DroidCrunch article titles.",
"serverInfo": { "name": "droidcrunch-posts", "version": "" }
}
}
And here’s a real tool call and its result. The server returns both plain text, which any model can read, and structured content, which code can use directly:
// request
{ "jsonrpc": "2.0", "id": 2, "method": "tools/call",
"params": { "name": "count_posts", "arguments": {} } }
// response
{ "jsonrpc": "2.0", "id": 2,
"result": {
"content": [ { "type": "text", "text": "300" } ],
"isError": false,
"structuredContent": { "result": 300 }
} }
We built an MCP server in 50 lines
The plan for this article asked for a small server built from scratch. Ours searches a list of 300 DroidCrunch article titles. It uses the official Python SDK, version 2.3.0, installed with pip install "mcp[cli]".
"""A small MCP server: searches a list of DroidCrunch posts."""
import sys
from pathlib import Path
from mcp.server.mcpserver import MCPServer
POSTS = Path(__file__).with_name("posts.txt")
server = MCPServer("droidcrunch-posts", instructions="Search DroidCrunch article titles.")
def load_posts() -> list[tuple[str, str]]:
rows = []
for line in POSTS.read_text().splitlines():
slug, _, title = line.partition("|")
rows.append((slug, title))
return rows
@server.tool()
def search_posts(query: str, limit: int = 5) -> list[dict]:
"""Find articles whose title contains every word in the query."""
words = query.lower().split()
hits = [
{"slug": s, "title": t, "url": f"https://droidcrunch.com/{s}/"}
for s, t in load_posts()
if all(w in t.lower() for w in words)
]
return hits[:limit]
@server.tool()
def count_posts() -> int:
"""Return how many articles are in the list."""
return len(load_posts())
@server.resource("posts://all")
def all_posts() -> str:
"""The full list of slugs and titles, one per line."""
return POSTS.read_text()
@server.prompt()
def related_reading(topic: str) -> str:
"""A prompt template that asks for related DroidCrunch reading."""
return f"Use search_posts to find three DroidCrunch articles about {topic}, then explain why each is relevant."
if __name__ == "__main__":
transport = sys.argv[1] if len(sys.argv) > 1 else "stdio"
server.run(transport)
A few details are worth pointing out:
- The decorators do the protocol work.
@server.tool()reads the function’s name, type hints and docstring and turns them into a tool definition with a JSON schema. We never wrote a schema by hand. - Docstrings matter. The model only sees the tool name, description and input schema. “Find articles whose title contains every word in the query” tells it when and how to use the tool.
- One file, two transports. The same code runs over STDIO for local apps or Streamable HTTP for remote clients, chosen by one argument.
A version gotcha we hit
Most tutorials still import FastMCP from mcp.server.fastmcp. In version 2 of the Python SDK, that import fails with a clear error: FastMCP was renamed to MCPServer and moved to mcp.server.mcpserver. If you follow an older guide, either change the import or pin mcp<2.
What the client saw
We connected with the SDK’s own client, listed the tools and called them. The search for “vpn” with a limit of 3 returned three real articles, including our guide to how a VPN works, as both text and structured JSON.
We also sent bad input on purpose: a call missing the required query field, with limit set to the word “five”. The server didn’t crash. It returned a result flagged isError: true with a validation message the model can read and correct.

Local vs remote MCP servers: our test results
MCP servers run in one of two ways. A local server runs on your computer as a child process of the AI app and talks over standard input and output (STDIO). A remote server runs on a web server and talks over Streamable HTTP. We ran the same server both ways on one machine and timed it.
| Measure | Local (STDIO) | Remote style (Streamable HTTP) |
|---|---|---|
| Connect and handshake | 516 ms | 34 ms |
| List tools | 3 ms | 3 ms |
| First tool call | 41 ms | 37 ms |
| Median of 20 calls | 1.6 ms | 2.4 ms |
| 95th percentile of 20 calls | 2.5 ms | 3.0 ms |
| Bad input | Returned isError with a validation message | Same |
Three findings stood out:
- Starting a local server is the slow part. The STDIO connection took about half a second because the client had to launch a new Python process. After that, calls were faster than over HTTP.
- Individual calls are tiny. Both transports answered simple calls in a few milliseconds. In real use, the tool’s own work, such as a database query or an API call, takes far longer than the protocol.
- HTTP needs a session. A raw request without a session ID got
400 Bad Request: Missing session ID. Clients handle this automatically; it only matters if you’re testing with curl.
Our HTTP test ran on the same machine as the client, so it shows protocol overhead, not internet latency. On a real remote server, add your network round trip to every call.
| Local server (STDIO) | Remote server (HTTP) | |
|---|---|---|
| Where it runs | On your computer, launched by the AI app | On a web server |
| Who can use it | Only you, on that computer | Anyone you give access to |
| Sign-in | Usually none; it runs as you | OAuth, API keys or application passwords |
| Good for | Files, local tools, development | SaaS products, shared team tools, websites |
| Setup on the client | Command and arguments in a config file | A URL and a sign-in |
| Main risk | Runs with your user’s permissions | Exposed to the internet |
MCP server examples
Thousands of MCP servers exist. These are the kinds most people use, with examples:
| Type | What it lets an AI do | Examples |
|---|---|---|
| Files | Read and write files in folders you allow | Filesystem server |
| Code hosting | Read issues, open pull requests, search code | GitHub MCP server |
| Databases | Query tables and inspect schemas | Postgres and Supabase servers |
| Browsers | Open pages, click and take screenshots | Playwright MCP server |
| Websites | Manage posts, SEO and media | WordPress MCP servers |
| Business apps | Read and update records | Notion, Slack and CRM servers |
| Web data | Search and scrape the web | Firecrawl and Apify servers |
A big server next to our small one
We use a remote WordPress MCP server every day to stage DroidCrunch drafts, and its shape is very different from our 50-line test.
| Our test server | DroidCrunch’s WordPress server | |
|---|---|---|
| Runs | Locally or on localhost HTTP | Remote, on the live site |
| Tools shown to the client | 2 | 3 meta tools |
| Actions behind them | 2 tools, 1 resource, 1 prompt | 132 abilities from three plugins |
| Sign-in | None | A dedicated WordPress user |
| Can change things | No | Yes, so we use strict rules |
The WordPress server shows a pattern you’ll see in large servers: instead of listing 132 tools to the model, it exposes three meta tools (discover, get info, execute) and lets the agent look up what it needs. That keeps the tool list short, at the cost of an extra lookup step. Our Novamira review covers that setup in detail.
How to connect an MCP server to Claude, Cursor or ChatGPT
For a local server like ours, most desktop clients use a JSON config file that tells them how to launch it:
{
"mcpServers": {
"droidcrunch-posts": {
"command": "/path/to/venv/bin/python",
"args": ["/path/to/server.py", "stdio"]
}
}
}
Remote servers are simpler on the client side: you paste a URL and sign in, usually with OAuth. Our guide to connecting an MCP server to Claude, Cursor and ChatGPT shows where each app keeps its settings. We didn’t test the config above in Claude Desktop for this article, because our test machine has no desktop client; we tested with the official SDK client and raw HTTP requests.
How to build your own MCP server
The fastest path for most people is the one we took.
| Step | What we did |
|---|---|
| Pick an SDK | Official Python SDK; TypeScript, Java, C#, Go and others also exist |
| Install it | pip install “mcp[cli]” in a virtual environment |
| Write tools | Plain functions with type hints and docstrings, decorated with @server.tool() |
| Add resources and prompts if useful | One of each in our server |
| Run it | STDIO for local use, streamable-http for remote |
| Test it | SDK client, the MCP Inspector or raw HTTP requests |
| Connect a real client | Add it to your AI app’s config or paste the URL |
Adding a write tool safely
Read-only tools are easy. The moment a tool changes something, two details matter: telling clients what kind of change it makes, and returning errors the model can act on. We added a second server with one write tool to test both.
from pathlib import Path
from mcp.server.mcpserver import MCPServer
from mcp.types import ToolAnnotations
from mcp.server.mcpserver.exceptions import ToolError
NOTES = Path(__file__).with_name("notes-out.txt")
server = MCPServer("droidcrunch-notes")
@server.tool(annotations=ToolAnnotations(read_only_hint=False, destructive_hint=False, idempotent_hint=False))
def add_note(slug: str, note: str) -> str:
"""Append an editing note for one article. Does not change the article."""
if len(note) > 500:
raise ToolError("Keep notes under 500 characters.")
with NOTES.open("a") as f:
f.write(f"{slug}\t{note}\n")
return f"Saved a note for {slug}."
if __name__ == "__main__":
server.run("stdio")
The ToolAnnotations showed up in the tool list as readOnlyHint: false, destructiveHint: false and idempotentHint: false, which clients can use to decide when to ask you before running it.
The error handling taught us something. Our first version raised a normal Python ValueError for notes over 500 characters. The client got back only “Error executing tool add_note”, with our message hidden. Switching to the SDK’s ToolError passed the real message through: “Keep notes under 500 characters.” If you want the model to fix its own mistakes, raise ToolError with a clear instruction.
Testing with the MCP Inspector
Before connecting a real AI app, test your server with the official MCP Inspector, a browser-based tool that lists tools and lets you call them by hand. Run npx @modelcontextprotocol/inspector and point it at your server’s command or URL. It’s the quickest way to check schemas and error messages, because you see exactly what the model will see.
Design tips from building ours
- Write tool descriptions for the model. Say what the tool does, when to use it and what each parameter means. Vague descriptions cause wrong calls.
- Keep tools small and specific. “search_posts” beats “do_anything”. Agents choose better between a few clear tools than between many overlapping ones.
- Return structured results. Return lists and objects, not prose. The SDK converts them into both text and structured content.
- Limit output size. Add a limit parameter, like our
limit, so a broad query doesn’t flood the model’s context. - Validate inputs. Type hints give you validation for free. Bad calls come back as readable errors instead of crashes.
- Make write tools explicit. Name them clearly, such as
delete_draft, and mark them as destructive so clients can ask the user first.
Running a remote MCP server
A local server is enough for personal use. To share a server with a team or connect it to web-based AI apps, it needs to run on a server with HTTPS and sign-in.
| Option | Good for | Watch out for |
|---|---|---|
| Small VPS with a reverse proxy | Full control, low cost | You handle updates, HTTPS and sign-in |
| Serverless platforms | Spiky, light traffic | Cold starts and session handling |
| Container platforms | Teams already using Docker | More setup than a single VPS |
| Inside an existing web app | Adding MCP to a product you run | Keep MCP permissions separate from admin rights |
Three things trip people up when they move from local to remote:
- HTTPS is required in practice. Most clients refuse plain HTTP for remote servers. Put the server behind a reverse proxy such as Caddy or Nginx that handles certificates.
- Sign-in is your job. The SDK supports OAuth, but you still decide who can connect and what each user can do. Never expose a remote server with no authentication.
- Sessions need sticky routing. Streamable HTTP uses a session ID. If you run several copies behind a load balancer, send each session to the same copy or use a stateless setup.
For a small team, a single cheap VPS is plenty. Our protocol overhead was a few milliseconds per call, so the server’s real work and your network decide the speed, not MCP.
MCP server vs API vs plugin
People often ask whether MCP replaces APIs. It doesn’t; most MCP servers call an API behind the scenes. The difference is the audience.
| API | MCP server | Plugin | |
|---|---|---|---|
| Built for | Developers writing code | AI apps discovering tools | One specific app |
| Discovery | Read the docs | Ask the server for its tool list | Install from an app store |
| Works with | Any code that can make requests | Any MCP-compatible AI app | Only its own host app |
| Inputs | Endpoint-specific | Typed JSON schema per tool | App-specific |
| Typical relationship | The underlying service | A wrapper that often calls an API | A wrapper tied to one platform |
We built the same tool as both an API and an MCP server in our MCP vs API comparison if you want to see the trade-off in code. For the bigger picture of APIs themselves, see what an API is.

When an MCP server is the wrong tool
MCP is useful, but it isn’t always the answer:
- Fixed, repeated jobs. If the same steps run every day with no decisions, a script or an automation tool such as n8n is cheaper and more predictable than an AI choosing tools.
- One app only. If only your own code will ever call a function, a normal API or library call is simpler.
- Huge data transfers. Models read everything a tool returns. Returning thousands of rows wastes tokens; query and summarise on the server first.
- High-risk actions with no review. Payments, deletions and account changes need human confirmation, however good the server is.
Are MCP servers safe?
An MCP server can do whatever its code allows, using whatever credentials you give it. That makes security a real concern, especially for servers you didn’t write.
| Risk | What it looks like | What to do |
|---|---|---|
| Too much access | A server with your admin token can delete things | Use scoped tokens and low-privilege accounts |
| Untrusted code | A local server runs as you on your computer | Use well-known publishers or read the code |
| Prompt injection | Text inside a web page or file tells the model to misuse a tool | Keep write tools behind confirmation |
| Leaked credentials | Tokens pasted into shared config files | Use environment variables and never commit configs |
| Exposed remote servers | An HTTP server with no sign-in | Require OAuth or keys; restrict who can connect |
Our rules for any server we install: read the code or use a well-known publisher, give it the lowest permissions that work, prefer read-only tools until you trust it, and never paste production passwords into a config file you’ll share.
Troubleshooting
| Problem | Likely cause | Fix |
|---|---|---|
| ImportError for FastMCP | Python SDK version 2 renamed it | Import MCPServer from mcp.server.mcpserver, or pin mcp<2 |
| Client shows no tools | Server failed to start | Run the server command in a terminal and read the error |
| 400 Missing session ID | Raw HTTP request without initializing first | Send initialize first and reuse the mcp-session-id header |
| Tool never gets called | Vague name or description | Describe what the tool does and when to use it |
| Model passes wrong arguments | Unclear parameter names | Use descriptive names, types and defaults |
| Huge responses | No limit on results | Add a limit parameter and trim output |
Should you build one?
If you want an AI app to use your own data or tools, yes. A useful read-only server takes an afternoon, and once it exists, every MCP client can use it. If a well-maintained server already exists for the service, such as GitHub, a database or WordPress, install that instead and spend the time on permissions.
For AI agents in general, our explainer on what an AI agent is covers where MCP servers fit into the bigger picture.
Heads-up: this article has no affiliate links. We use MCP servers to run parts of DroidCrunch, and we built the test server ourselves.
Can an MCP server work without the internet?
Yes. A local server that talks over STDIO needs no network at all, and it can work with local files and tools. The AI model itself may still need the internet unless you run a local model, such as one served through Ollama.
Do I need to know how to code to use an MCP server?
Not to use one. Many servers install with a few clicks or a URL and a sign-in. Building your own takes basic programming; our working example is 50 lines of Python using the official SDK.
Are MCP servers free?
The protocol and the official SDKs are free and open source, and many servers are free. Some remote servers belong to paid products, and the AI app you connect may need a paid plan. Hosting your own remote server costs whatever your server costs.
Can one AI app use several MCP servers at once?
Yes. Clients such as Claude Desktop and Cursor can connect to many servers, and the model chooses tools from all of them. Too many overlapping tools can confuse it, so connect the servers you actually need.
What languages can I build an MCP server in?
Official SDKs exist for Python, TypeScript, Java, Kotlin, C#, Go, Ruby, Rust, Swift and PHP, among others. Python and TypeScript have the most examples. Any language works if it implements the protocol’s JSON-RPC messages correctly.
Where can I find MCP servers to install?
Start with the official MCP servers repository and registry, then the integrations listed by the apps you use. Many companies now publish their own official servers. Prefer those over unofficial copies when the server will hold your credentials.
Can an MCP server run on my phone?
Not usually as a local server, because mobile apps can’t launch background processes the way desktop apps do. Mobile AI apps that support MCP connect to remote servers over HTTP instead.



