FastAPI MCP Workshop
このレポジトリはMCP(Model Context Protocol)をFastAPIで実装するためのワークショップ用のサンプルコードです。
セットアップ
以下のコマンドを実行して、Pythonのパッケージ管理ツールのuv (https://docs.astral.sh/uv/getting-started/installation/) をインストールします。
MacOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
Windows
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
プロジェクトのセットアップ
以下のコマンドでソースコードをクローンします。
git clone https://github.com/Miura55/fastapi-mcp-workshop
cd fastapi-mcp-workshop
仮想環境を用意します。
uv venv
アプリケーションの起動
以下のコマンドでアプリケーションを起動します。
uv run uvicorn main:api.app --host 0.0.0.0 --reload
mcp-proxyを使って接続
追加でmcp-proxyをインストールします。
uv tool install mcp-proxy
Claude Desktopの設定ファイル( claude_desktop_config.json) を開き、お使いのOSに合わせて以下の設定を行います。
- Windows
{
"mcpServers": {
"my-api-mcp-proxy": {
"command": "mcp-proxy",
"args": ["http://127.0.0.1:8000/mcp"]
}
}
}
- MacOS
MacOSの場合、mcp=proxyのパスをフルパスで指定する必要があります。
which mcp-proxyでフルパスを確認できます。
{
"mcpServers": {
"my-api-mcp-proxy": {
"command": "/Full/Path/To/Your/Executable/mcp-proxy",
"args": ["http://127.0.0.1:8000/mcp"]
}
}
}
Recommend MCP Servers 💡
fdmocho/mcp_server_nasa
An MCP server for integrating with the NASA API to retrieve Near Earth Object (NEO) information by date.
@Panth1823/formula1-mcp
Provides real-time and historical Formula 1 racing data via the Model Context Protocol
term_mcp_deepseek
A MCP‑like server using the DeepSeek API for Terminal
KerolIA98/mcp-sample
An MCP server template integrating Mem0 to provide AI agents with persistent memory management via semantic search.
content-core
Extract what matters from any media source
device-info-mcp
An MCP server that provides information about electronic devices, allowing search by model number and retrieval of detailed information.