Simple-Tool-Server-Fastapi
🚀 FastAPI を使用したシンプルなツールサーバー
REST API エンドポイントを通じてシンプルなユーティリティ関数を公開する、FastAPI ベースのツールサーバー。
このプロジェクトは、Python 関数を FastAPI エンドポイントの背後にラップし、HTTP リクエストを通じてアクセスする方法を示しています。また、将来的に同様のツールを Model Context Protocol(MCP) を通じて公開する方法を理解するための基礎も提供します。
📌 特徴
➕ 2つの数値の加算
🕐 現在の日時を取得
📝 指定されたテキスト内の単語数をカウント
⚡ FastAPI を使用した高速な API 開発
✅ Pydantic を使用したリクエスト検証
📦 JSON ベースの API レスポンス
📖 自動対話型 API ドキュメント
🔌 後で MCP ベースのツールアーキテクチャに拡張可能なシンプルな設計
Related MCP server: SENTRA MCP
🏗️ プロジェクト構造
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🔄 動作の仕組み
このプロジェクトはシンプルなフローに従います:
Client
↓
FastAPI Endpoint
↓
Python Tool Function
↓
JSON Response例:
GET /add
↓
add_numbers()
↓
JSON response同じコンセプトは、後で MCP アーキテクチャに向けて拡張できます:
AI Assistant
↓
MCP Client
↓
MCP Server
↓
Python Tools🛠️ 使用技術
Python
FastAPI
Pydantic
Uvicorn
REST API
JSON
Model Context Protocol(MCP)のコンセプト
⚙️ インストール
1. リポジトリのクローン
git clone https://github.com/sejalpatole/simple-tool-server-fastapi.git2. プロジェクトディレクトリへ移動
cd simple-tool-server-fastapi3. 仮想環境の作成
python -m venv venv4. 仮想環境の有効化
Windows
venv\Scripts\activatemacOS / Linux
source venv/bin/activate5. 依存関係のインストール
pip install -r requirements.txt▶️ アプリケーションの実行
Uvicorn を使用して FastAPI サーバーを起動します:
uvicorn main:app --reloadサーバーは次の場所で起動します:
http://127.0.0.1:8000📖 API ドキュメント
FastAPI は対話型の API ドキュメントを自動的に提供します。
Swagger UI
開く:
http://127.0.0.1:8000/docsReDoc
開く:
http://127.0.0.1:8000/redoc🔌 API エンドポイント
1. ホーム
エンドポイント
GET /利用可能なエンドポイントに関する情報を返します。
レスポンス例
{
"message": "Welcome to the Simple Tool Server",
"available_endpoints": [
"/add",
"/time",
"/wordcount"
]
}2. 2つの数値の加算
エンドポイント
GET /addパラメータ
パラメータ | 型 | 説明 |
| float | 1つ目の数値 |
| float | 2つ目の数値 |
例
http://127.0.0.1:8000/add?a=10&b=20レスポンス例
{
"operation": "Addition",
"a": 10,
"b": 20,
"result": 30
}3. 現在時刻の取得
エンドポイント
GET /time例
http://127.0.0.1:8000/timeレスポンス例
{
"current_time": "2026-08-20 21:00:00"
}4. 単語数のカウント
エンドポイント
POST /wordcountリクエストボディ
{
"text": "FastAPI is easy to use"
}レスポンス例
{
"text": "FastAPI is easy to use",
"word_count": 5
}🧩 プロジェクトコンポーネント
main.py
FastAPI アプリケーションと API ルートを含みます。
以下のエンドポイントを定義しています:
//add/time/wordcount
tools.py
コアとなる Python ユーティリティ関数を含みます:
add_numbers()
get_current_time()
word_count()ツールのロジックを API 層から分離することで、プロジェクトの保守と拡張が容易になります。
model.py
/wordcount リクエストを検証するために使用される Pydantic モデルを含みます。
class WordCountRequest(BaseModel):
text: strこれにより、API が期待通りのリクエスト構造を受け取ることが保証されます。
🧪 テスト
API は以下を使用してテストできます:
Swagger UI
Postman
ブラウザ
cURL
任意の REST API クライアント
Swagger UI は次の場所で利用可能です:
http://127.0.0.1:8000/docs🌱 今後の改善案
考えられる拡張には以下が含まれます:
より多くのユーティリティツールの追加
認証の追加
ロギングの追加
Pytest を使用した自動テストの追加
Docker サポートの追加
MCP プロトコルサポートの追加
MCP サーバーを通じた Python ツールの公開
データベース対応ツールの追加
クラウドプラットフォームへのサーバーデプロイ
🎯 学習成果
このプロジェクトを通じて、以下のコンセプトを学ぶことができます:
FastAPI を使用した API の構築
GET および POST エンドポイントの作成
Pydantic を使用したリクエスト検証
API ロジックとビジネスロジックの分離
JSON リクエストとレスポンスの処理
Uvicorn を使用したアプリケーションの実行
ツールベースの AI システムの基礎の理解
API、ツール、MCP の関係の理解
👩💻 著者
Sejal Patole
⭐ 謝辞
このプロジェクトは、FastAPI、REST API、Python ユーティリティツール、および MCP ベースのツールアーキテクチャの基礎を学ぶための演習として開発されました。
このプロジェクトが役に立ったと思われた場合は、リポジトリに ⭐ を付けることをご検討ください。
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