Skip to main content
Glama

mcp tutorial

In this repo, I will show how to use FastMCP and uv to build an MCP server

Content of the MCP server

Suppose we want to provide the below content in the MCP server.

Type

Nom

Description

Outil

add

Additionne deux nombres

Outil

multiply

Multiplie deux nombres

Outil

current_time

Date et heure UTC (ISO 8601)

Ressource

config://version

Version du serveur

Ressource

greeting://{name}

Message de bienvenue paramétré

Invite

summarize

Demande de résumé d'un texte

Related MCP server: MCPServer (FastMCP)

Run the MCP server

Transport stdio (par défaut, pour les clients MCP locaux) :

uv run mcp-server

Transport HTTP (point d'accès http://127.0.0.1:8000/mcp) :

uv run mcp-server --transport http --port 8000

Test the MCP server

If you open http://127.0.0.1:8000/mcp via a browser, you will receive the below error message.

{"jsonrpc":"2.0","id":null,"error":{"code":-32600,"message":"Bad Request: Missing session ID"}}

This is because the browser does not understand the MCP protocol. So we need an MCP client which can understand the MCP server.

The FastMCP package provide an MCP client. So open a new terminal and run the below command to launch a client command.

# list all available resources of a MCP server
uv run fastmcp list http://127.0.0.1:8000/mcp --resources --prompts

# expected output
Tools (3)

  add(a: float, b: float) -> dict
    Additionne deux nombres.

  multiply(a: float, b: float) -> dict
    Multiplie deux nombres.

  current_time() -> dict
    Renvoie la date et l'heure actuelles (UTC, format ISO 8601).

Resources (1)

  config://version
    version — Version du serveur.

Prompts (1)

  summarize(text)
    Invite demandant un résumé concis du texte fourni.

In the output, you can notice an MCP server can provide three kind of services:

  • tools: function which runs code locally(on the MCP server) and return a result to client

  • resources: return data based on the request

  • prompt:

Use MCP client to call a tool

uv run fastmcp call http://127.0.0.1:8000/mcp multiply a=2 b=3
# expected output
{
  "result": 6.0
}

# the space is the separator
uv run fastmcp call http://127.0.0.1:8000/mcp add a=2 b=3
# expected output
{
  "result": 5.0
}

uv run fastmcp call http://127.0.0.1:8000/mcp current_time
# expected output
{
  "result": "2026-12-03T15:22:12.481875+00:00"
}

Use MCP client to call a resource

uv run fastmcp call http://127.0.0.1:8000/mcp config://version

uv run fastmcp call http://127.0.0.1:8000/mcp greeting://Alice

Use MCP client to call a prompt

uv run fastmcp call http://127.0.0.1:8000/mcp summarize --prompt text="MCP est un protocole ouvert. This is a long story of a young man trying to get in the best school of the USa."

Inspecteur MCP (nécessite Node.js) :

uv run fastmcp dev inspector src/mcp_server/server.py

Configuration d'un client MCP (ex. Claude Desktop / Claude Code)

{
  "mcpServers": {
    "mcp-server": {
      "command": "uv",
      "args": ["--directory", "C:/chemin/vers/le/projet", "run", "mcp-server"]
    }
  }
}

Tests

uv run pytest

Structure

src/mcp_server/
  __init__.py   # point d'entrée CLI (main)
  server.py     # définition du serveur FastMCP
tests/
  test_server.py

Available Tools

3 tools
addAddB

Additionne deux nombres.

Inputs: a (required), b (required). Returns: result

current_timeCurrent TimeA

Renvoie la date et l'heure actuelles (UTC, format ISO 8601).

Inputs: no named parameters. Returns: result

multiplyMultiplyB

Multiplie deux nombres.

Inputs: a (required), b (required). Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 3 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: add performs addition, multiply performs multiplication, and current_time returns the current timestamp. There is no overlap in functionality, so an agent can select the right tool unambiguously.

    Naming Consistency4/5

    All names use lowercase snake_case, which is consistent. However, add and multiply are verbs while current_time is a noun phrase, so get_current_time would have made the pattern fully uniform.

    Tool Count3/5

    Three tools is a borderline-thin surface; it is not unreasonable for a tiny utility server, but the arithmetic and time domains naturally suggest additional operations. Each tool earns its place, but the set feels minimal rather than well-scoped.

    Completeness2/5

    The arithmetic surface omits core operations such as subtraction, division, and modulo, which will force agents into awkward workarounds or failures. The time tool is also limited to UTC, and there is no subtract or divide counterpart to add and multiply.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A minimal FastMCP server implementation that provides basic mathematical and greeting tools. Enables users to perform simple operations like adding numbers and greeting people by name through a lightweight MCP interface.
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      A minimal Model Context Protocol server built with FastMCP that provides basic utility tools including user greetings, number addition, and file listing operations. Includes examples of exposing tools, resources, and prompts for MCP-aware clients.
      -
    • F
      license
      Not graded
      quality
      C
      maintenance
      A basic MCP server implementation using the FastMCP framework that provides utility tools for greetings and mathematical calculations. It is designed to demonstrate tool integration for AI-assisted development workflows like Cline.
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      A foundational Model Context Protocol server demonstrating core functionality through basic arithmetic tools and personalized greeting resources. It serves as a template for developers learning to build and deploy MCP-enabled AI applications.
      GPL 3.0