GregoireSauvage/MCP-demo
3.2
If you are the rightful owner of MCP-demo and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
This repository demonstrates a simple Model Context Protocol (MCP) server and client setup using FastAPI and Python.
Tools
2
Resources
0
Prompts
0
MCP
Simple client and server MCP demo
Setup
Clone repo:
git clone https://github.com/GregoireSauvage/MCP-demo.git
cd MCP-demo
Create and activate venv:
uv venv
uv sync --all-groups
source .venv/bin/activate # or .venv\Scripts\activate with Windows
Run MCP server with:
uvicorn mcp_server:app --reload --port 8000
Test MCP client with:
uv run main.py
File architecture
mcp/
│
├── main.py
├── mcp_client.py
│
└── mcp_server/
├── __init__.py
├── api.py # Entrée FastAPI (point d’entrée uvicorn)
├── registry.py # Déclaration et exécution des tools
├── models.py # Schémas Pydantic
└── tools/
├── __init__.py
└── calculator.py # Implémente les fonctions "add" et "mul"
Tools
Add
"add": {
"description": "Additionne deux nombres.",
"fn": add,
"input_schema": {
"type": "object",
"properties": {"a": {"type": "number"}, "b": {"type": "number"}},
"required": ["a", "b"],
},
"output_schema": {
"type": "object",
"properties": {"result": {"type": "number"}},
},
}
Mul
"mul": {
"description": "Multiplie deux nombres.",
"fn": mul,
"input_schema": {
"type": "object",
"properties": {"a": {"type": "number"}, "b": {"type": "number"}},
"required": ["a", "b"],
},
"output_schema": {
"type": "object",
"properties": {"result": {"type": "number"}},
},
}