mcpField
M
MCP Server Tutorial

MCP Server Tutorial

Local
github.com/cthuaungDeveloper Tools0Updated 80w ago

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

  1. 01Basic arithmetic operations
  2. 02Powers, roots, factorials, and logarithms
  3. 03Sine, cosine, and tangent
  4. 04Remainder calculation
  5. 05Personalized greeting resource

Use cases

  1. 01Perform arithmetic through an MCP client
  2. 02Evaluate roots, powers, and logarithms
  3. 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.

No install method listed yet

We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.

Repository

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

MCP 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

  1. Clone this repository
  2. Create and activate a virtual environment:
    uv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  3. 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
  1. Open MCP Inspector
npx @modelcontextprotocol/inspector

  1. Choose SSE Transport Type
  2. Connect to the server URL (typically http://localhost:8000/sse)
  3. You can now interact with the mathematical tools and resources defined in the server

Available Tools

  • add(a, b): Adds two numbers
  • subtract(a, b): Subtracts two numbers
  • multiply(a, b): Multiplies two numbers
  • divide(a, b): Divides two numbers
  • power(a, b): Calculates a raised to the power of b
  • sqrt(a): Calculates the square root of a number
  • cbrt(a): Calculates the cube root of a number
  • factorial(a): Calculates the factorial of a number
  • log(a): Calculates the natural logarithm of a number
  • remainder(a, b): Calculates the remainder when a is divided by b
  • sin(a): Calculates the sine of a number
  • cos(a): Calculates the cosine of a number
  • tan(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:

  1. To add a new tool, use the @mcp.tool() decorator
  2. 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

Markdown supported

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.