swapi_mcp
swapi_mcp
可観測な AI エージェントを構築するための、小規模なエンドツーエンドのリファレンスプロジェクトです。Star Wars API をラップする MCP サーバー、それを操作する Claude エージェント、そして Web チャット UI で構成され、すべて OpenTelemetry と Grafana Cloud(分散トレース、RED メトリクス、フロントエンド RUM、AI/エージェント可観測性)で計装されています。
このプロジェクトは、1つの実行可能なコードベースで各構成要素がどのように組み合わさるかを示すために存在します。すなわち、MCP ツール境界、エージェントのツール使用ループ、そしてブラウザのクリックから上流の HTTP 呼び出しに到達して再び戻ってくるまでのフルスタックトレーシングです。
このリポジトリの内容
MCP(stdio)を介して相互に通信する2つの部分で構成されています:
MCP サーバー(src/index.ts、src/tools/)— Star Wars API を6つのリソース(people、planets、films、species、vehicles、starships)にわたる18のツールとしてラップします。各リソースにつき search_、get-all、get-by-id を1つずつ提供します。これは単純なツールプロバイダーであり、意思決定は行いません。
エージェント(src/agent/)— 意思決定を行う側です:
mcpClient.ts— ビルド済みサーバーを stdio 経由で起動し、MCP クライアントとして接続します。agent.ts— 手動のツール使用ループです。質問とサーバーのツールを Claude に送信し、要求された各ツールを MCP 経由で実行して結果をフィードバックし、完了するまで繰り返します。main.ts— CLI エントリーポイントです。server.ts+public/index.html— HTTP サーバーとシングルページのチャット UI です。
Related MCP server: SWAPI MCP Server
可観測性
以下はすべてオプションであり、環境変数によって有効化されます。これらがなくてもエージェントは問題なく動作します。
分散トレーシング(OpenTelemetry → Tempo):1つのトレースが
browser → POST /ask → agent.turn → llm.request / tool.call → tool.execute → swapi.fetchという一連の流れを3つのサービス(swapi-web、swapi-agent、swapi-mcp-server)にわたってカバーします。トレースコンテキストは、リクエストの_metaを介して MCP 境界を越えて伝播されます。RED メトリクス(→ Mimir):ツールごと・LLM 呼び出しごとの rate/errors/duration ヒストグラムに加え、コスト用のトークン使用量カウンターを提供し、
model、error、error.typeのタグが付きます。フロントエンド RUM(Grafana Faro):Web Vitals、JS エラー、ブラウザ→バックエンドのトレース伝播。
AI/エージェント可観測性(
@grafana/agent-o11y):正規化された LLM ジェネレーションとツール実行。デモ用フォールトインジェクション(
src/chaos.ts):オプションで、1つのリソースにシミュレートされた 503 を返させ、別のリソースの実行を50%遅くします。これにより、ダッシュボードに実際のエラーとレイテンシのシグナルが表示されます。
前提条件
Node.js 22+(
--env-fileを使用)Yarn 4(Corepack 経由)
Anthropic API キー(エージェント用)
Grafana Cloud アカウント(オプション — 可観測性機能のみに必要)
セットアップ
yarn install
yarn buildMCP サーバーを直接使用する(例:Claude Desktop)
ビルド済みサーバーを MCP クライアントに指定します:
{
"mcpServers": {
"swapi": { "command": "node", "args": ["/absolute/path/to/swapi_mcp/build/index.js"] }
}
}エージェントを実行する
.env ファイル(git で無視されます)を作成し、少なくとも Anthropic のキーを設定します:
ANTHROPIC_API_KEY=sk-ant-...次に:
yarn dev # build + serve the web UI at http://localhost:8787
yarn ask "Who is Luke's homeworld?" # one-shot CLI環境変数
環境変数 | 目的 |
| エージェントに必須です。 |
| モデルの上書き(デフォルトは |
| Web サーバーのポート(デフォルトは |
| Grafana Cloud への OTLP トレースとメトリクスを有効にします。 |
| Grafana Faro フロントエンド RUM を有効にします(コレクター URL は設計上公開されています)。 |
| Grafana Agent Observability を有効にします(トークンには |
| デモ用フォールトインジェクション(デフォルトではオフ)。 |
注記
これは学習用/デモ用のプロジェクトです。データは SWAPI の静的ミラーから取得しています。SWAPI はアクションではなく関連(キャラクターが映画に「登場する」など)をモデル化しているため、回答もそれに合わせた表現になっています。
ライセンス
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
- AlicenseBqualityDmaintenanceEnables searching characters, planets, and films from the Star Wars universe via the SWAPI API.4121ISC
- AlicenseNot gradedqualityBmaintenanceEnables LLMs and clients to search for Star Wars characters, planets, and films by exposing SWAPI as MCP tools.1MIT
- AlicenseNot gradedqualityDmaintenanceMCP server for querying the Star Wars universe via the SWAPI API, providing access to characters, films, starships, vehicles, species, and planets.ISC
- FlicenseBqualityBmaintenanceA Model Context Protocol server that exposes Star Wars API data as MCP tools. It enables users to list available categories and retrieve character information.3140
Related MCP Connectors
SWAPI MCP — wraps the Star Wars API (swapi.dev, free, no auth)
Star Wars API (SWAPI) as a remote MCP server: films, people, planets, species, starships, vehicles.
Rick and Morty MCP — wraps the Rick and Morty API (free, no auth)
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/jasonwarta/swapi_mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server