About MCP Server Tutorial
MCP Server Tutorial is a FastMCP-based server that exposes common and advanced math operations, plus a personalized greeting resource. It suits demonstrations and MCP clients that need calculation tools.
Key features
- 01Basic arithmetic operations
- 02Powers, roots, factorials, and logarithms
- 03Sine, cosine, and tangent
- 04Remainder calculation
- 05Personalized greeting resource
Use cases
- 01Perform arithmetic through an MCP client
- 02Evaluate roots, powers, and logarithms
- 03Retrieve a greeting for a supplied name
MCP support
The server exposes math tools and a dynamic greeting resource to MCP clients. It supports stdio and SSE transports.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEMCP Server Tutorial
This repository contains a simple MCP (Model Context Protocol) server built with FastMCP. The server provides various mathematical operations as tools that can be used through the MCP protocol.
Features
- Basic arithmetic operations (addition, subtraction, multiplication, division)
- Advanced mathematical functions:
- Power
- Square root
- Cube root
- Factorial
- Logarithm
- Trigonometric functions (sin, cos, tan)
- Remainder
- Dynamic greeting resource
Prerequisites
- Python 3.8 or higher
- FastMCP library
Installation
- Clone this repository
- Create and activate a virtual environment:
uv venv source venv/bin/activate # On Windows: venv\Scripts\activate - Install dependencies:
uv install fastmcp
Usage
Running the Server
Run the server using:
python main.py
The server uses SSE (Server-Sent Events) transport by default, which allows you to connect using MCP Inspector.
Connecting with MCP Inspector
- Open MCP Inspector
npx @modelcontextprotocol/inspector
- Choose SSE Transport Type
- Connect to the server URL (typically http://localhost:8000/sse)
- You can now interact with the mathematical tools and resources defined in the server
Available Tools
add(a, b): Adds two numberssubtract(a, b): Subtracts two numbersmultiply(a, b): Multiplies two numbersdivide(a, b): Divides two numberspower(a, b): Calculates a raised to the power of bsqrt(a): Calculates the square root of a numbercbrt(a): Calculates the cube root of a numberfactorial(a): Calculates the factorial of a numberlog(a): Calculates the natural logarithm of a numberremainder(a, b): Calculates the remainder when a is divided by bsin(a): Calculates the sine of a numbercos(a): Calculates the cosine of a numbertan(a): Calculates the tangent of a number
Available Resources
greeting://{name}: Returns a personalized greeting for the given name
Modifying the Server
You can add more tools and resources by following the pattern in main.py:
- To add a new tool, use the
@mcp.tool()decorator - To add a new resource, use the
@mcp.resource()decorator
Transport Options
FastMCP supports two transport protocols:
stdio: Standard input/output (terminal-based)sse: Server-Sent Events (browser-based, compatible with MCP Inspector)
To change the transport protocol, modify the transport parameter in the mcp.run() call.
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.