Protocol basics · FastMCP · Tools/Resources/Prompts · HTTP deployment · Knowledge-base project
LLMs feel "not smart enough" because they cannot reach external tools or live data. If you want Claude or GPT to query databases, call APIs, and read files, Model Context Protocol (MCP) is the open standard answer. This guide targets backend and AI developers with Python or TypeScript experience. You will go from protocol fundamentals through environment setup, Tools, Resources, and Prompts registration, MCP Inspector debugging, HTTP+SSE remote deployment, and a personal knowledge-base project — and ship a production-ready MCP Server.
Tool-calling evolved from Function Calling → Plugins → MCP. Anthropic designed MCP to standardize how AI talks to external systems — write one Server, reuse it across Clients.
MCP Client (Claude Desktop, Cursor) talks to MCP Server (your code) over JSON-RPC 2.0. Servers expose Tools (callable functions), Resources (readable data), and Prompts (reusable templates). Transport: stdio (local, low latency) or HTTP + SSE (remote, multi-client). Lifecycle: handshake → capability negotiation → request/response → shutdown.
No live data: Training cutoffs block stock prices and ticket status — external APIs are mandatory.
Vendor lock-in: Plugins, Function Calling, and Tool Use each need separate adapters.
IDE fragmentation: Cursor, VS Code, and Claude Desktop cannot share tool assets.
Framework binding: LangChain Tools do not port to CrewAI without rewrite.
N×M cost: N models × M systems explodes maintenance; MCP collapses this to one Server.
| Dimension | MCP | OpenAI Function Calling | LangChain Tools |
|---|---|---|---|
| Standardization | Open protocol | Vendor-specific | Framework-bound |
| Transport | stdio / HTTP | HTTP | HTTP |
| Cross-model | Yes | No | Partial |
| Resources / Prompts | Native | Not supported | Not supported |
| Ecosystem | 10,000+ Servers (2026) | Mature | Mature |
Python (mcp + FastMCP) is best for beginners. TypeScript (@modelcontextprotocol/sdk) suits full-stack teams. This guide uses Python with TypeScript notes where relevant.
python -m venv .venv && source .venv/bin/activate && pip install mcp npm init -y && npm install @modelcontextprotocol/sdk
Suggested layout: server.py, tools/, resources/, prompts/, tests/. Debug with MCP Inspector, Claude Desktop config, and Cursor MCP settings. Docs: modelcontextprotocol.io.
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("my-first-server")
@mcp.tool()
def say_hello(name: str) -> str:
"""Greet a person by name"""
return f"Hello, {name}! This is your first MCP tool."
if __name__ == "__main__":
mcp.run()
Create venv and install mcp (Python ≥ 3.10).
Register say_hello with @mcp.tool(); docstring becomes the tool description.
Debug in Inspector: npx @modelcontextprotocol/inspector python server.py.
Configure Cursor MCP with command and absolute path to server.py.
Configure Claude Desktop via claude_desktop_config.json.
Verify: Ask Cursor to greet VpsMesh via say_hello and confirm the tool is invoked.
Use verb-first names (search_web). Model complex inputs with Pydantic. Build: calculator, file read/write (allowlist paths), HTTP client, read-only SQL, and timezone utilities. Use async for network IO:
@mcp.tool()
async def fetch_url(url: str) -> str:
async with httpx.AsyncClient(timeout=30.0) as client:
return (await client.get(url)).text
Return structured errors for expected failures. Set timeouts. Audit write operations.
Resources are read-only data via URI (file://, config://, user://{id}/profile). Tools execute actions. Static and dynamic resource examples:
@mcp.resource("config://app-settings")
def get_app_settings() -> str:
return json.dumps({"version": "1.0", "env": "production"})
Prompts inject parameters into multi-turn templates — code review, interview simulation, debug assistant. Supports user and assistant roles in one template.
| Feature | stdio | HTTP + SSE |
|---|---|---|
| Deploy | Local process | Remote server |
| Latency | Very low | Network-dependent |
| Multi-client | No | Yes |
| Use case | Local tools | SaaS / team sharing |
mcp = FastMCP("remote-server", transport="streamable-http")
mcp.run(host="0.0.0.0", port=8000)
Secure remote servers with Bearer tokens, API key middleware, CORS, and rate limits. Test with MCP Inspector and pytest + ClientSession. Common fixes: wrong config path, non-serializable returns, slow tools (use async + timeout), file permission denials (allowlist directories).
Containerize with Docker (Python 3.12-slim). Deploy to Railway, Render, Cloud Run, or VPS behind Nginx. Add structured logs, Prometheus metrics, Sentry, and health checks. Declare MCP protocol version for compatibility.
Knowledge-base MCP Server: Index local Markdown with ChromaDB/Qdrant, text-embedding-3-small, and watchfiles. Expose semantic search, note creation, and file resources. Ask Cursor: "What did I write about MCP last week?"
Recommended community Servers: filesystem, GitHub, Brave Search, Postgres, Slack. 2026 trend: major clients support MCP; Marketplace and enterprise security standards are maturing. SDKs: Python, TypeScript, Inspector.
tools/list.Laptops work for POC but sleep kills 24/7 uptime. Linux VPS runs HTTP+SSE but struggles with Keychain and Xcode-dependent tools. For teams treating MCP Servers as always-on infrastructure, VpsMesh Mac Mini M4 cloud rental delivers predictable OpEx. See pricing and help center.
Python + FastMCP is fastest for backend/AI teams. TypeScript SDK fits Node full-stack shops. Both are protocol-compatible.
Tools execute actions. Resources serve read-only data by URI. Read with Resources; act with Tools.
HTTP+SSE on Railway or Cloud Run works for many cases. For macOS-native toolchains and uninterrupted Cursor sessions, Mac Mini M4 rental is more reliable. See pricing and order page.