このレポジトリはMCP(Model Context Protocol)をFastAPIで実装するためのワークショップ用のサンプルコードです。
以下のコマンドを実行して、Pythonのパッケージ管理ツールのuv (https://docs.astral.sh/uv/getting-started/installation/) をインストールします。
curl -LsSf https://astral.sh/uv/install.sh | shpowershell -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をインストールします。
uv tool install mcp-proxyClaude 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"]
}
}
}