はじめに
AI環境の準備
FastMCPというのを初めて知ったので、少し触ってみました。
Get Startedを動かしてみただけです。
内容
準備
FastMCPの知識をclaude で使うために
(1) MCP サーバをclaude で登録する。最初、自分は何を登録していませんでした。
$ claude mcp list
と問い合わせると
claude.ai Claude Docs: https://api.anthropic.com/v1/pages/mcp - ✔ Connected
とデフォルトと思われるものしかありません。下記で登録しました。すべてのプロジェクトで使う場合(user スコープ)に対応しています。
$ claude mcp add --transport http --scope user fastmcp-docs https://gofastmcp.com/mcp
✔ Added HTTP MCP server fastmcp-docs with URL: https://gofastmcp.com/mcp to user config
File modified: /home/xtkd/.claude.json
確認するとリストが増えています。
$ claude mcp list
claude.ai Claude Docs: https://api.anthropic.com/v1/pages/mcp - ✔ Connected
fastmcp-docs: https://gofastmcp.com/mcp (HTTP) - ✔ Connected
(2) SKILLの取得
Node.jsを使ってインストールしました。このプロジェクトだけか、どのAIで使うか、を答えました。
$ npx skills add https://gofastmcp.com --skill fastmcp-server
Need to install the following packages:
skills@1.10.1
Ok to proceed? (y)
npm notice run npx
npm notice run 'skills' add https://gofastmcp.com --skill fastmcp-server
███████╗██╗ ██╗██╗██╗ ██╗ ███████╗
██╔════╝██║ ██╔╝██║██║ ██║ ██╔════╝
███████╗█████╔╝ ██║██║ ██║ ███████╗
╚════██║██╔═██╗ ██║██║ ██║ ╚════██║
███████║██║ ██╗██║███████╗███████╗███████║
╚══════╝╚═╝ ╚═╝╚═╝╚══════╝╚══════╝╚══════╝
┌ skills
│
◇ Source: https://gofastmcp.com
│
◇ Found 2 skills
│
● Skill: fastmcp-client-cli
│
│ Query and invoke tools on MCP servers using fastmcp list and fastmcp call. Use when you need to discover what tools a server offers, call tools, or integrate MCP servers into workflows.
│
● Skill: fastmcp-server
│
│ Build, extend, or review MCP servers with Python FastMCP, using documentation matched to the project's version.
│
◇ Downloaded skill files
│
◇ Detected 2 of 79 supported agents: Claude Code, GitHub Copilot
│
◇ Installation scope
│ Project
◇ Which agents do you want to install to?
│ Amp, Cline, Codex, Cursor, Droid, fx, Gemini CLI, GitHub Copilot, Kilo Code, Kimi Code CLI, OpenCode, Pi, Warp, Zed
│
◇ Installation Summary ───────────────────────────────────╮
│ │
│ ~/torupati/learn_fastmcp/.agents/skills/fastmcp-server │
│ copy → Amp, Cline, Codex, Cursor, Droid +9 more │
│ │
├──────────────────────────────────────────────────────────╯
│
◇ Proceed with installation?
│ Yes
│
◇ Installation complete
│
◇ Installed 1 skill ──────────────────────────────────────────╮
│ │
│ ✓ fastmcp-server (copied) │
│ → ~/torupati/learn_fastmcp/.agents/skills/fastmcp-server │
│ │
├──────────────────────────────────────────────────────────────╯
│
└ Done! Review skills before use; they run with full agent permissions.
インストール
uv initのあと uv add fastmcpでトラブルなくインストールされました。
$ uv run fastmcp version
FastMCP version: 4.2.6
MCP version: 2.3.0
Python version: 3.13.6
Platform: Linux-5.15.146.1-microsoft-standard-WSL2-x86_64-with-glibc2.39
FastMCP root path: /home/xtkd/torupati/learn_fastmcp/.venv/lib/python3.13/site-packages
MCP サーバとMCPクライアントの起動
サーバを実装します。Toolを登録します。
from fastmcp import FastMCP
mcp = FastMCP("My MCP Server")
@mcp.tool
def greet(name: str) -> str:
return f"Hello, {name}!"
if __name__ == "__main__":
mcp.run()
サーバの起動にはstdio transport と HTTP transportがあるそうです。ローカル環境での開発ではstdio が便利だそうですが、複数のMCPサーバを扱う実際の環境ではHTTPが必要なようです。
$ uv run fastmcp run my_server.py:mcp --transport http --port 8000
╭──────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ ▄▀▀ ▄▀█ █▀▀ ▀█▀ █▀▄▀█ █▀▀ █▀█ │
│ █▀ █▀█ ▄▄█ █ █ ▀ █ █▄▄ █▀▀ │
│ │
│ │
│ │
│ FastMCP 4.2.6 │
│ https://gofastmcp.com │
│ │
│ 🖥 Server: My MCP Server, 4.2.6 │
│ 🚀 Deploy free: https://horizon.prefect.io │
│ │
╰──────────────────────────────────────────────────────────────────────────────╯
[12/04/26 21:23:27] INFO Starting MCP server 'My MCP Server' with transport 'http' on http://127.0.0.1:8000/mcp transport.py:358
INFO: Started server process [12710]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
問題なく起動しました。
クライアントもQuickstart から持ってきます。非同期で実行するそうです。
import asyncio
from fastmcp import Client
client = Client("http://localhost:8000/mcp")
async def call_tool(name: str):
async with client:
result = await client.call_tool("greet", {"name": name})
print(result)
asyncio.run(call_tool("Ford"))
実行すると応答がありました。
$ uv run python my_client.py
CallToolResult(content=[TextContent(type='text', text='Hello, Ford!', annotations=None, meta=None)], structured_content={'result': 'Hello, Ford!'}, meta={'fastmcp': {'wrap_result': True}, 'io.modelcontextprotocol/serverInfo': {'name': 'My MCP Server', 'version': '4.2.6'}}, data='Hello, Ford!', is_error=False)
サーバー側も
INFO: 127.0.0.1:50170 - "POST /mcp HTTP/1.1" 200 OK
INFO: 127.0.0.1:50170 - "POST /mcp HTTP/1.1" 200 OK
と応答していました。
テキストだけでなくUIも使う
Toolはテキストを返しましたが、実はインタラクティブなUIもprefab_uicomponent として使えるそうです。
from prefab_ui.app import PrefabApp
from prefab_ui.components import Column, Heading, Text, Badge, Row
from fastmcp import FastMCP
mcp = FastMCP("My MCP Server")
@mcp.tool(app=True)
def greet(name: str) -> PrefabApp:
"""Greet someone with a visual card."""
with Column(gap=4, css_class="p-6") as view:
Heading(f"Hello, {name}!")
with Row(gap=2, align="center"):
Text("Status")
Badge("Greeted", variant="success")
return PrefabApp(view=view)
実行するには、追加でパッケージをインストールする必要があります。
$ uv add "fastmcp[apps]"
UIをブラウザで見る、つまり、client も用意されています。
下記でサーバを起動すると、同時にブラウザでアクセスできるようになります。
$ uv run fastmcp dev apps my_server.py
[12/04/26 21:58:52] INFO Starting user server on port 8000… apps_dev.py:1757
INFO Fetching app-bridge.js from npm… apps_dev.py:1758
FastMCP dev UI: http://127.0.0.1:8080/?token=...............................
すごいなー。
PrefabはPythonで使えるUI framework のようです。
まとめ
今回、特にAIにも聞かず、サーバとクラアントが動くところだけ確認しました。
ドキュメントページでは、GetStarted の後に、Servers/Apps/Clients/Integrations/Moreと続いています。
AWSやGithubなどのクラウドにデプロイし認証をつけるための環境もしっかり用意してくれているようです。
とりあえず調査の第一歩でした。
公式サイト以外の参考情報
(2026/12/4)
