mcp-server
# mcp tutorial
In this repo, I will show how to use [FastMCP](https://gofastmcp.com) 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 |
## Run the MCP server
Transport stdio (par défaut, pour les clients MCP locaux) :
```powershell
uv run mcp-server
```
Transport HTTP (point d'accès `http://127.0.0.1:8000/mcp`) :
```powershell
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.
```json
{"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.
```shell
# 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
```shell
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
```shell
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
```shell
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) :
```powershell
uv run fastmcp dev inspector src/mcp_server/server.py
```
## Configuration d'un client MCP (ex. Claude Desktop / Claude Code)
```json
{
"mcpServers": {
"mcp-server": {
"command": "uv",
"args": ["--directory", "C:/chemin/vers/le/projet", "run", "mcp-server"]
}
}
}
```
## Tests
```powershell
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
```
TDQS
Scored across 3 tools
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.
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.
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.
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.