Simple-Tool-Server-Fastapi
🚀 Einfacher Tool-Server mit FastAPI
Ein leichtgewichtiger FastAPI-basierter Tool-Server, der einfache Hilfsfunktionen über REST-API-Endpunkte bereitstellt.
Dieses Projekt zeigt, wie Python-Funktionen hinter FastAPI-Endpunkten gekapselt und über HTTP-Anfragen aufgerufen werden können. Es bietet außerdem eine Grundlage, um zu verstehen, wie ähnliche Tools später über das Model Context Protocol (MCP) bereitgestellt werden können.
📌 Funktionen
➕ Zwei Zahlen addieren
🕐 Aktuelles Datum und Uhrzeit abrufen
📝 Wörter in einem vorgegebenen Text zählen
⚡ Schnelle API-Entwicklung mit FastAPI
✅ Anfragevalidierung mit Pydantic
📦 JSON-basierte API-Antworten
📖 Automatische interaktive API-Dokumentation
🔌 Einfache Architektur, die zu einem MCP-basierten Tool-Server erweitert werden kann
Related MCP server: SENTRA MCP
🏗️ Projektstruktur
simple-tool-server-fastapi/
│
├── main.py # FastAPI application and API endpoints
├── model.py # Pydantic request models
├── tools.py # Core utility functions
├── requirements.txt # Project dependencies
├── .gitignore # Files excluded from Git
└── README.md # Project documentation🔄 Funktionsweise
Das Projekt folgt einem einfachen Ablauf:
Client
↓
FastAPI Endpoint
↓
Python Tool Function
↓
JSON ResponseZum Beispiel:
GET /add
↓
add_numbers()
↓
JSON responseDasselbe Konzept kann später zu einer MCP-Architektur erweitert werden:
AI Assistant
↓
MCP Client
↓
MCP Server
↓
Python Tools🛠️ Verwendete Technologien
Python
FastAPI
Pydantic
Uvicorn
REST API
JSON
Konzepte des Model Context Protocol (MCP)
⚙️ Installation
1. Repository klonen
git clone https://github.com/sejalpatole/simple-tool-server-fastapi.git2. In das Projekt wechseln
cd simple-tool-server-fastapi3. Virtuelle Umgebung erstellen
python -m venv venv4. Virtuelle Umgebung aktivieren
Windows
venv\Scripts\activatemacOS / Linux
source venv/bin/activate5. Abhängigkeiten installieren
pip install -r requirements.txt▶️ Anwendung ausführen
Starten Sie den FastAPI-Server mit Uvicorn:
uvicorn main:app --reloadDer Server startet unter:
http://127.0.0.1:8000📖 API-Dokumentation
FastAPI stellt automatisch eine interaktive API-Dokumentation bereit.
Swagger UI
Öffnen Sie:
http://127.0.0.1:8000/docsReDoc
Öffnen Sie:
http://127.0.0.1:8000/redoc🔌 API-Endpunkte
1. Home
Endpunkt
GET /Gibt Informationen über die verfügbaren Endpunkte zurück.
Beispielantwort
{
"message": "Welcome to the Simple Tool Server",
"available_endpoints": [
"/add",
"/time",
"/wordcount"
]
}2. Zwei Zahlen addieren
Endpunkt
GET /addParameter
Parameter | Typ | Beschreibung |
| float | Erste Zahl |
| float | Zweite Zahl |
Beispiel
http://127.0.0.1:8000/add?a=10&b=20Beispielantwort
{
"operation": "Addition",
"a": 10,
"b": 20,
"result": 30
}3. Aktuelle Uhrzeit abrufen
Endpunkt
GET /timeBeispiel
http://127.0.0.1:8000/timeBeispielantwort
{
"current_time": "2026-08-20 21:00:00"
}4. Wörter zählen
Endpunkt
POST /wordcountAnfrage-Body
{
"text": "FastAPI is easy to use"
}Beispielantwort
{
"text": "FastAPI is easy to use",
"word_count": 5
}🧩 Projektkomponenten
main.py
Enthält die FastAPI-Anwendung und die API-Routen.
Es definiert Endpunkte für:
//add/time/wordcount
tools.py
Enthält die zentralen Python-Hilfsfunktionen:
add_numbers()
get_current_time()
word_count()Die Tool-Logik von der API-Ebene getrennt zu halten, macht das Projekt einfacher zu warten und zu erweitern.
model.py
Enthält das Pydantic-Modell zur Validierung der /wordcount-Anfrage.
class WordCountRequest(BaseModel):
text: strDadurch wird sichergestellt, dass die API die erwartete Anfragestruktur erhält.
🧪 Testen
Die APIs können mit Folgendem getestet werden:
Swagger UI
Postman
Browser
cURL
einen beliebigen REST-API-Client
Swagger UI ist verfügbar unter:
http://127.0.0.1:8000/docs🌱 Zukünftige Verbesserungen
Mögliche zukünftige Erweiterungen:
Weitere Hilfstools Hinzufügen
Authentifizierung hinzufügen
Protokollierung hinzufügen
Automatisierte Tests mit Pytest hinzufügen
Docker-Unterstützung hinzufügen
Unterstützung für das MCP-Protokoll hinzufügen
Expose the Python tools through an
Die Python-Tools über einen MCP-Server bereitstellen
Datenbankgestützte Tools hinzufügen
Den Server auf einer Cloud-Plattform bereitstellen
🎯 Lernergebnisse
In diesem Projekt werden die folgenden Konzepte demonstriert:
Erstellen von APIs mit FastAPI
Erstellen von GET- und POST-Endpunkten
Anfragevalidierung mit Pydantic
Trennung von API-Logik und Geschäftslogik
Arbeiten mit JSON-Anfragen und -Antworten
Ausführen von Anwendungen mit Uvicorn
Verständnis der Grundlagen tool-basierter KI-Systeme
Verstehen der Beziehung zwischen APIs, Tools und MCP
👩💻 Autorin
Sejal Patitole
⭐ Danksagung
Dieses Projekt wurde als Lernübung entwickelt, um FastAPI, REST-APIs, Python-Hilfstools und die Grundlagen einer MCP-basierten Tool-Architektur zu verstehen.
Wenn Ihnen dieses Projekt nützlich erscheint, geben Sie dem Repository gerne einen ⭐.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA basic educational MCP server that provides simple tools for mathematical calculations, text manipulation, and time retrieval. Designed for learning MCP implementation patterns and development purposes.
- AlicenseNot gradedqualityDmaintenanceA minimal FastAPI-based MCP server that provides basic utility tools like ping and time functions. Designed for easy deployment with Docker support, authentication, and extensible architecture for future tool additions.MIT
- AlicenseNot gradedqualityDmaintenanceA 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
- FlicenseNot gradedqualityDmaintenanceA simple educational MCP server providing basic math operations, string manipulation, and greeting functionality. Demonstrates how to implement MCP tools for learning purposes.
Related MCP Connectors
MCP server exposing the Backtest360 engine API as tools for AI agents.
MCP server providing access to the Scorecard API to evaluate and optimize LLM systems.
Hosted MCP server for LLM cost estimation, model comparison, and budget-aware routing.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/sejalpatole/Simple-Tool-Server-Fastapi'
If you have feedback or need assistance with the MCP directory API, please join our Discord server