
A directory listing describing a cancellation-letter and mailing-address service. The configured public GitHub repository returned 404 during source verification.

A step-by-step guide to building a simple MCP server in Python with the MCP Python SDK, exposing an addition tool, a dynamic greeting resource, and a code review prompt.
Tutorial MCP server with a calculator tool, greeting resource, and code review prompt is cataloged as an MCP server attributed to ruslanmv. A step-by-step guide to building a simple MCP server in Python with the MCP Python SDK, exposing an addition tool, a dynamic greeting resource, and a code review prompt. It is categorized under developer tools. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.
Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.
Catalog license label: Not specified. Check the source repository's current license and terms before using, modifying or distributing this software.
Capability definitions are not reviewed. Unreviewed imports are not exposed as trusted interfaces.
No reviewed records to display. This does not establish that upstream lacks this capability.
No reviewed records to display. This does not establish that upstream lacks this capability.
No reviewed records to display. This does not establish that upstream lacks this capability.
Email delivery is not connected. This page does not collect email addresses or create subscriptions.
Browse the registry for current listings instead.
Reviews for Tutorial MCP server with a calculator tool, greeting resource, and code review prompt are not available yet
Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.
It demonstrates tools, resources, and prompts, specifically an addition tool, a dynamic greeting resource, and a code review prompt.
It can be launched with the mcp dev command, which starts the server and opens the browser-based MCP Inspector for testing.
README.md · f84ff758a62b · Fetched 2026-11-13 11:49:43 UTC
Original upstream text, without AI rewriting. Scripts, forms and unsafe links are filtered for safety.
Showing the last retrieved documentation snapshot; check the source for current changes.
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 modular fashion. In this tutorial, we’ll build a simple MCP server in Python step by step.
The Model Context Protocol (MCP) standardizes the interface between applications and LLMs. With MCP, you can separate the concerns of providing context, executing code, and managing user interactions. The MCP Python SDK implements the full MCP specification, allowing you to:
Every MCP server can implement three core primitives. These define who controls the invocation and what role each primitive plays:
| Primitive | Control | Description | Example Use |
|---|---|---|---|
| Prompts | User‑controlled | Interactive templates invoked by user choice | Slash commands, menu options |
| Resources | Application‑controlled | Contextual data managed by the client application | File contents, API responses |
| Tools | Model‑controlled | Functions exposed to the LLM to take actions | API calls, data updates |
During initialization, an MCP server advertises which features it supports. Clients (and front‑ends) can adapt dynamically based on these flags:
| Capability | Feature Flag | Description |
|---|---|---|
| prompts | listChanged | Prompt template management |
| resources | subscribelistChanged | Resource exposure and live updates |
| tools | listChanged | Tool discovery and execution |
| logging | – | Server logging configuration |
| completion | – | Argument completion suggestions |
listChanged signals that the set of available prompts/resources/tools can change at runtime.subscribe lets clients register for updates when resource data changes.logging and completion are simple toggles for debug output and autocomplete help.This tutorial will guide you through creating a simple MCP server using the MCP Python SDK.
Before you begin, ensure you have the following installed:
You will also need to install the MCP Python SDK. You have two options:
Using pip directly:
pip install "mcp[cli]"
Using uv:
If you are managing your project with uv, initialize your project and add MCP as a dependency.
uv init mcp-server
cd mcp-server
uv add "mcp[cli]"
For more detailed installation instructions, please check the MCP Python SDK documentation.
This section details how to set up your development environment on Ubuntu 22.04 using Python 3.11, ensuring you have the correct Python version and the MCP Python SDK installed.
Option 1: Manual Installation
If you prefer a step-by-step approach, follow these instructions:
Add the deadsnakes PPA: This repository provides more recent Python versions for Ubuntu.
sudo add-apt-repository ppa:deadsnakes/ppa -y
Update package lists:
sudo apt update
Install Python 3.11 and essential tools:
sudo apt install -y python3.11 python3.11-venv python3.11-distutils python3-apt
python3.11: The Python 3.11 interpreter.python3.11-venv: The virtual environment module for Python 3.11.python3.11-distutils: Essential tools for building and installing Python packages.python3-apt: A Python interface to the APT package management system (helps resolve potential dependency issues).Set Python 3.11 as the default python3 (optional but recommended): This simplifies using Python 3.11 without needing to specify python3.11 every time.
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 2
sudo update-alternatives --config python3
You will be prompted to select the default Python 3 version. Choose Python 3.11.
Install pip for Python 3.11: pip is the package installer for Python.
curl -sS https://bootstrap.pypa.io/get-pip.py | sudo python3.11
Verify Python and pip versions:
python3 --version
python3 -m pip --version
Confirm that the output shows Python 3.11 and a recent version of pip.
Setting up NodeSource for Node.js 18.x…
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
Installing Node.js (with npm & npx)…"
sudo apt-get update
sudo apt-get install -y nodejs
Create and activate a virtual environment: Using a virtual environment isolates your project's dependencies.
python3 -m venv .venv
source .venv/bin/activate
A .venv directory will be created in your project, and your terminal prompt will change to (.venv), indicating that the environment is active.
Upgrade pip within the virtual environment:
pip install --upgrade pip
Install the MCP Python SDK: Create a file named requirements.txt in your project directory with the following content:
mcp[cli]
Then, install the SDK using pip:
pip install -r requirements.txt
Option 2: Using the install.sh Script
For a more automated setup, you can use the provided install.sh script.
Save the script: Ensure the script you provided earlier is saved as install.sh in your project directory.
Make the script executable: Open your terminal, navigate to your project directory, and run:
chmod +x install.sh
Run the script: Execute the script:
bash install.sh
The install.sh script automates the manual installation steps:
deadsnakes PPA and updates package lists.python3.pip for Python 3.11..venv.pip within the virtual environment.requirements.txt (if the file exists).

Important Notes:
source .venv/bin/activate) every time you work on your project in a new terminal session. This ensures you are using the correct Python version and have access to the installed MCP SDK.install.sh script is designed for Ubuntu 22.04. If you are using a different operating system or distribution, you might need to adjust the script accordingly.requirements.txt file is crucial for managing your project's dependencies. Always keep it updated with the necessary packages.With your environment set up, you're ready to create your MCP server!
Create a new directory for your project and navigate into it. Then, create a file called server.py in the root of your project.
Your project structure should look like this:
mcp-server/
├── server.py
└── (other files such as .env, README.md, etc. as needed)
In this section, we will create a simple MCP server that exposes a calculator tool and a dynamic greeting resource. You can later extend this to add more functionality using prompts or additional tools.
Tools are functions that perform computations or side effects. In this example, we’ll define a simple addition tool.
Open server.py and add the following code:
# server.py
from mcp.server.fastmcp import FastMCP
# Create an MCP server instance with a custom name.
mcp = FastMCP("Demo Server")
# Add a calculator tool: a simple function to add two numbers.
@mcp.tool()
def add(a: int, b: int) -> int:
"""
Add two numbers together.
:param a: First number.
:param b: Second number.
:return: Sum of the numbers.
"""
return a + b
Resources provide data that can be loaded into an LLM’s context. Here, we define a resource that returns a personalized greeting.
Add the following code to server.py:
# Expose a greeting resource that dynamically constructs a personalized greeting.
@mcp.resource("greeting://{name}")
def get_greeting(name: str) -> str:
"""
Return a greeting for the given name.
:param name: The name to greet.
:return: A personalized greeting.
"""
return f"Hello, {name}!"
Prompts allow you to supply reusable templates for interactions. For example, you can add a prompt to review code.
Add the following code if desired:
from mcp.server.fastmcp.prompts import base
@mcp.prompt()
def review_code(code: str) -> str:
"""
Provide a template for reviewing code.
:param code: The code to review.
:return: A prompt that asks the LLM to review the code.
"""
return f"Please review this code:\n\n{code}"
First, make sure your Python virtual environment is activated by running:
source .venv/bin/activate
This should be done in the root directory of your project. Then, change into your MCP server folder:
cd mcp-server
With your server defined in server.py, you can now run it. There are several ways to run an MCP server depending on your goals — development, debugging, integration, or deployment.
mcp devThe easiest way to interact with your MCP server is using the built-in MCP Inspector, which gives you a visual UI in the browser.
For development and testing, the MCP Development Inspector provides an intuitive web interface to interact with your server.
In your terminal, run:
mcp dev server.py
This command launches your MCP server and typically opens the Inspector in your web browser. You'll see your "Demo Server" and the exposed tools (add), resources (greeting), and prompts (review_code).
Start your server with the Inspector:
mcp dev server.py
It performs several important tasks:
http://localhost:6274/, where you can explore and test all the functionalities of your server.After running the command, your terminal output should resemble:

This output confirms that the Inspector is active and ready for interaction.
add(a, b) toolgreeting://John to test the resourcereview_code prompt
💡 If any packages are missing,
mcp devwill help you install them automatically.
When you open the Inspector in your browser, you will notice several key sections designed to facilitate server testing.
Go to the top of the MCP Inspector interface where it shows:
Transport Type: STDIO
Command: python
Arguments: run --with mcp mcp run server.py
Due to in our server.py is a standalone script using a normal pip-based virtual environment, we need to correct configuration in the MCP Inspector to:
Transport Type: STDIO
Command: python
Arguments: server.py
Then click Connect and our server will be launched properly using the Python interpreter.

add): Navigate to the add tool in the Inspector.Consider the following scenario while working with our example (which registers an addition tool, a greeting resource, and a code review prompt):
Accessing the Tools Tab:
With the MCP Inspector loaded, navigate to the Tools tab. Click List Tools. Here, you will see a list of all registered tools from your server. In our case, one of the entries is the add tool.
Testing the "Add" Functionality:
Click on the add tool from the list. The Inspector displays the input schema for the tool, prompting you for two numbers (for example, parameters a and b).
a = 10 and b = 15.Reviewing the Output:
Once executed, the Inspector immediately displays the result of the operation. You should see that the sum is returned as 25.
This immediate feedback loop shows how you can quickly verify that your tool’s logic is working as expected without leaving the development interface.

review_code Prompt via the MCP Inspectorreview_code listed:
review_code
In the prompt pane you’ll find a form or JSON editor ready to accept arguments.
code parameter.
For example:print(1+1)
Hit Run Tool .
The Inspector will display the output:
{
"messages": [
{
"role": "user",
"content": {
"type": "text",
"text": "Please review this code:\n\nprint(1+1)"
}
}
]
}

greeting://Alice)Once your server is up and running in the Inspector (using the setup from above), you can invoke any registered resource by its URI:
List templates and select
get_greetingAlice
@mcp.resource("greeting://{name}") handler.{
"contents": [
{
"uri": "greeting://Alice",
"mimeType": "text/plain",
"text": "Hello, Alice!"
}
]
}

The MCP Inspector acts as a user-friendly client, handling the underlying protocol communication for you.
python server.pyYour code is correct, but when you run:
python server.py
…it looks like nothing happens. That’s because your server is using stdio (standard input/output) as the default transport, and it just sits silently waiting for a client to connect and send it a request.
This is normal! But you need the right interface to interact with it.
client.py)For programmatic interaction, you can use the mcp Python SDK to create a client. Your provided client.py is a correct example of this:
# client.py
import asyncio
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
async def main():
server_params = StdioServerParameters(
command="python",
args=["server.py"],
)
async with stdio_client(server_params) as (reader, writer):
async with ClientSession(reader, writer) as session:
await session.initialize()
result = await session.call_tool("add", arguments={"a": 3, "b": 4})
print(f"Result of add tool: {result}")
if __name__ == "__main__":
asyncio.run(main())
To run this client:
python server.py
python client.py
The output will be:
[your log output indicating the tool call]
Result of add tool: meta=None content=[TextContent(type='text', text='7', annotations=None)] isError=False
This demonstrates how a Python client can connect to your server and invoke tools programmatically.
In this tutorial, we built a simple MCP server in Python using the MCP Python SDK. We:
The MCP Python SDK empowers you to build robust and modular servers that provide data, functionality, and reusable interaction templates to LLM applications. As you expand your server, consider adding more complex tools, resources, and prompts to fully leverage the power of the Model Context Protocol.
Claim this server with your GitHub account to request manual ownership verification.
Link to the catalog listing for Tutorial MCP server with a calculator tool, greeting resource, and code review prompt from your README. This badge does not certify ownership, compatibility or security.
[](https://awesome-mcp.com/servers/simple-mcp-server-with-python)Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.
Separate sources, scopes and periods. Never combined or treated as installations, active users or security reviews.
No reviewed package or image identity; download statistics are not listed yet.
Alternative and complementary servers in the same category

A directory listing describing a cancellation-letter and mailing-address service. The configured public GitHub repository returned 404 during source verification.

A hosted MCP service for browsing and searching through Singapore mobile-network proxies.

A directory listing describing a Markdown-to-PDF service. The configured public GitHub repository returned 404 during source verification.