Building a Simple MCP Server in Python Using the MCP Python SDK
@ruslanmv
About Building a Simple MCP Server in Python Using the MCP Python SDK
The Model Context Protocol (MCP) is a standardized way to supply context to large language models (LLMs). Using the MCP Python SDK, you can build servers that expose data (resources), functionality (tools), and interaction templates (prompts) to LLM applications in a secure and m
Config
Add this server to your MCP-compatible client using the configuration below.
{
"mcpServers": {
"Simple-MCP-Server-with-Python": {
"command": "uv",
"args": [
"init",
"mcp-server"
]
}
}
}Tools
No tools detected
We auto-extract tools from the README. The maintainer can list them under a ## Tools heading to populate this section.
Overview
What is Building a Simple MCP Server in Python Using the MCP Python SDK?
This is a step‑by‑step tutorial for creating a Model Context Protocol (MCP) server in Python using the official MCP Python SDK. It teaches how to expose resources (data), tools (functions), and prompts (templates) that LLM applications can consume in a secure, modular way.
How to use Building a Simple MCP Server in Python Using the MCP Python SDK?
First, ensure Python 3.7+ (preferably 3.11+), pip, and Node.js 18.x are installed. Install the MCP Python SDK with pip install "mcp[cli]" or via uv add "mcp[cli]". Create a project directory with a server.py file, define tools using @mcp.tool(), resources with @mcp.resource(), and optional prompts with @mcp.prompt(). Run the server with mcp dev server.py to open the MCP Inspector at http://localhost:6274/.
Key features of Building a Simple MCP Server in Python Using the MCP Python SDK?
- Uses
FastMCPfrom the MCP Python SDK for easy server creation. - Exposes a calculator tool (
add) that accepts two integers. - Provides a dynamic greeting resource at
greeting://{name}. - Supports an optional
review_codeprompt template. - Includes live reloading during development via
mcp dev.
Use cases of Building a Simple MCP Server in Python Using the MCP Python SDK?
- Supply an addition tool that LLM applications can call to perform calculations.
- Serve personalized greeting data to enrich LLM context.
- Offer reusable code‑review prompts for interactive LLM workflows.
- Demonstrate the three MCP primitives (resources, tools, prompts) in a single server.
FAQ from Building a Simple MCP Server in Python Using the MCP Python SDK?
What is MCP?
The Model Context Protocol (MCP) standardizes the interface between applications and LLMs, separating concerns of providing context, executing code, and managing user interactions.
What are the prerequisites to build and run the server?
Python 3.7+ (preferably 3.11+), pip, Node.js 18.x, and the MCP Python SDK installed via pip install "mcp[cli]" or uv add "mcp[cli]".
How do I run the server and test it?
Activate your virtual environment, then run mcp dev server.py in your project directory. This starts the server using the default STDIO transport and launches the MCP Inspector web UI.
What primitives can an MCP server expose?
Prompts (user‑controlled), resources (application‑controlled), and tools (model‑controlled). The tutorial implements all three.
What transport does the server use by default?
The server uses the STDIO transport when started with mcp dev.
Frequently asked questions
What is MCP?
The Model Context Protocol (MCP) standardizes the interface between applications and LLMs, separating concerns of providing context, executing code, and managing user interactions.
What are the prerequisites to build and run the server?
Python 3.7+ (preferably 3.11+), pip, Node.js 18.x, and the MCP Python SDK installed via `pip install "mcp[cli]"` or `uv add "mcp[cli]"`.
How do I run the server and test it?
Activate your virtual environment, then run `mcp dev server.py` in your project directory. This starts the server using the default STDIO transport and launches the MCP Inspector web UI.
What primitives can an MCP server expose?
Prompts (user‑controlled), resources (application‑controlled), and tools (model‑controlled). The tutorial implements all three.
What transport does the server use by default?
The server uses the STDIO transport when started with `mcp dev`.
Basic information
More Developer Tools MCP servers
MCP-Scan: An MCP Security Scanner
invariantlabs-aiSecurity scanner for AI agents, MCP servers and agent skills.
Unity MCP (Server + Plugin)
IvanMurzakAI Skills, MCP Tools, and CLI for Unity Engine. Full AI develop and test loop. Use cli for quick setup. Efficient token usage, advanced tools. Any C# method may be turned into a tool by a single line. Works with Claude Code, Gemini, Copilot, Cursor and any other absolutely for fr
extentos
Asger mølgaardExtentos is a multi-vendor development platform for adding smart-glasses capabilities to existing iOS and Android apps. The simplest analogy is Stripe for smart glasses:
endoflife.ai
endoflife.aiFree MCP server for software end-of-life intelligence: EOL dates, support status, and the 0-100 EOL Risk Score across 485 tracked products. Agents can check a single version, pull a product's full lifecycle schedule, or
Altronis
sypherinMCP server + CLI for Altronis — Singapore AI consulting. Ask the Lyra consultant, generate a grant-matched AI transformation plan, pull curated SG AI events/news. Read-only, wraps altronis.sg.
Comments