少し前に、Model Context Protocol (MCP) が LLM アプリケーションに不足しているコンテキストを補完する方法について、4部構成のブログシリーズで紹介しました。このシリーズでは、AWS リソース管理を支援するカスタムMCPサーバーを構築しました。次に、RAG ナレッジベースとユーティリティをサーバーに追加して、AWS サービスのドメイン固有知識を持たせることで、新しいアプリケーションの学習と開発を迅速に進められるようにしました。最後に、MCP サーバーが提供するツールを利用して Amazon Bedrock を通じて Claude 3.7 Sonnet を呼び出すカスタム MCP クライアントを作成しました。
カスタム MCP クライアントの開発は MCP と Amazon Bedrock について理解を深めるための良い練習になりましたが、実際には私たちの MCP サーバーは MCP プロトコルに対応するどのクライアントとも連携できます。今回は、これまで作成したカスタム MCP サーバーを Amazon Q Developer CLI と連携させる方法をご紹介します。
Amazon Q Developer
まだ Amazon Q Developer をお試しでない方は、ぜひインストールして使ってみることをお勧めします。優れた生成 AI を搭載したコーディング支援ツールとして、お気に入りの IDE と連携し、開発作業を強力にサポートします。また、q chat コマンドで起動できるコマンドラインベースのアシスタント、Amazon Q Developer CLI も含まれています。執筆時点ではちょうど、この Amazon Q Developer CLI がカスタムMCPサーバーに対応するようになりました。この新機能の詳細は発表ブログをご覧いただくとして、ここでは Amazon IVS 用MCPサーバーを実際に追加して試してみましょう!
Amazon Q Developer CLI にカスタム MCP サーバーを追加する
まず、Amazon Qをインストールし、AWS Builder ID で認証を行います。既にインストール済みの場合は、バージョンが 1.9.0 以上であることをご確認ください。
次に、~/.aws/amazonq 配下にある mcp.json というファイルで MCP サーバーを定義しましょう。このファイルに、Amazon Q が MCP サーバーと連携できるように、必要な情報を記述しなければなりません。
{ "mcpServers": { "amazon-ivs-mcp-server": { "command": "node", "args": ["/projects/demos/ivs-mcp/amazon-ivs-mcp-server-demo/index.js"], "env": { } } } } mcpServer オブジェクトの中に、amazon-ivs-mcp-server というキーでオブジェクトを定義します。このキー名自体は好きに書いてもいいのですが、追加するサーバーの概要が伝わるものにすると良いでしょう。このキーに対してバリューとなるオブジェクトでは、実行コマンド (node) と、MCP サーバーに渡すを引数 (args) 配列を指定します。必要に応じて、env オブジェクトでは環境変数を定義することもできます。私の場合は、環境変数をセッションで設定しているので、このファイルでの明示的な定義は不要です。
最後に、q chat コマンドで Amazon Q Developer CLI を起動しましょう。このブログシリーズで作成した Amazon IVS MCP サーバーが正しく設定されていれば、起動時に利用可能なツール一覧に表示されます。
$ q chat To learn more about MCP safety, see https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-mcp-security.html ⚠ amazon_ivs_mcp_server has the following warning: The following tool names are changed: - amazon_ivs_mcp_server___get-logging-configuration -> amazon_ivs_mcp_server___getloggingconfiguration - amazon_ivs_mcp_server___get-playback-restriction-policy -> amazon_ivs_mcp_server___getplaybackrestrictionpolicy ...more warnings ✓ 1 of 1 mcp servers initialized ⚠️の警告は気にしないでください。これは、Amazon Q がツール名を命名規則に合わせて変更したことを通知しているだけです。重要なのは「✓ 1 of 1 mcp servers initialized」という部分です。MCP サーバーとAmazon Q Developer CLI の連携に成功しました!
ツールの管理
ツールを管理するためのコマンドがいくつか用意されています。利用可能なコマンドの一覧は /help コマンドで確認できます。以下はツール関連のコマンド一覧です:
/tools View and manage tools and permissions help Show an explanation for the trust command trust Trust a specific tool or tools for the session untrust Revert a tool or tools to per-request confirmation trustall Trust all tools (equivalent to deprecated /acceptall) reset Reset all tools to default permission levels ツールが「trust (信頼)」されていない場合、Amazon Q Developer CLI がそのツールを使用する必要があると判断したときに、「信頼」するかどうかの確認が表示されます。
Amazon Q Developer CLI から Amazon IVS MCP サーバーを利用する
これで、Amazon IVS があるアカウントについて Amazon Q に質問できるようになりました。例えば:
tell me about the last streaming session on demo-stage
(demo-stageでの最後のストリーミングセッションについて教えて)
と聞くと、次のような応答が返ってきます:
I'll help you find information about the last streaming session on "demo-stage". To do this, I need to first check if this stage exists and then retrieve its session information. Let me first list the available IVS Real-Time stages to find the one named "demo-stage": 🛠️ Using tool: list-stages from mcp server amazon_ivs_mcp_server ⋮ ● Running list-stages with the param: ⋮ { ⋮ "arguments": {}, ⋮ "name": "list-stages" ⋮ } Allow this action? Use 't' to trust (always allow) this tool for the session. [y/n/t]: list-stages ツールを信頼するために「t」と入力すると、ツールが実行されます。Amazon Q は質問に答えるために必要な情報を収集するまで、さまざまなツールを順次実行していきます。
I found the "demo-stage" in the list. Now let me get the stage sessions for this stage to find the last streaming session: 🛠️ Using tool: list-stage-sessions from mcp server amazon_ivs_mcp_server ⋮ ● Running list-stage-sessions with the param: ⋮ { ⋮ "arguments": { ⋮ "arn": "arn:aws:ivs:us-east-1:[redacted]:stage/[redacted]" ⋮ }, ⋮ "name": "list-stage-sessions" ⋮ } 🛠️ Using tool: get-stage-session from mcp server amazon_ivs_mcp_server ⋮ ● Running get-stage-session with the param: ⋮ { ⋮ "arguments": { ⋮ "sessionId": "st-[redacted]", ⋮ "stageArn": "arn:aws:ivs:us-east-1:[redacted]:stage/[redacted]" ⋮ }, ⋮ "name": "get-stage-session" ⋮ } 🛠️ Using tool: list-participants from mcp server amazon_ivs_mcp_server ⋮ ● Running list-participants with the param: ⋮ { ⋮ "arguments": { ⋮ "arn": "arn:aws:ivs:us-east-1:[redacted]:stage/[redacted]", ⋮ "sessionId": "st-[redacted]" ⋮ }, ⋮ "name": "list-participants" ⋮ } 最終的に、ステージセッションの概要が詳細に表示されます:
Based on the information I've gathered, here are the details about the last streaming session on "demo-stage": ## Last Streaming Session Details • **Stage Name**: demo-stage • **Session ID**: st-[redacted] • **Start Time**: April 24, 2025 at 15:50:38 UTC • **End Time**: April 24, 2025 at 16:55:06 UTC • **Duration**: Approximately 1 hour and 5 minutes ### Participant Information: • Total participants: 8 • 6 participants published content during the session • 1 participant was identified with user ID "[redacted]" • All participants are now disconnected The session had multiple participants joining at different times, with the first participant joining at 15:50:37 UTC and the last one joining at 16:41:06 UTC. None of the participants had recording enabled during this session. (このセッションには複数の参加者が異なる時間に参加し、最初の参加者はUTC 15:50:37に参加し、最後の参加者はUTC 16:41:06に参加しました。このセッション中、録画を有効にした参加者はいませんでした。) This was the most recent session on the demo-stage, which ended about 6 days ago. (これがdemo-stageでの最新のセッションで、約6日前に終了しました。) Amazon Q Developer CLIを使った Amazon IVS の迅速なプロトタイピング
前回の記事で作成したカスタム MCP クライアントと同様に、Amazon Q に簡単なプロトタイプアプリケーションを作成してもらうことができ、その際に Amazon IVS の専門知識とツールを活用できるようになります。
using the latest version of the amazon ivs web broadcast sdk, create a simple prototype application to broadcast to an amazon ivs low-latency channel. within the UI, include input elements for ingest endpoint and stream key, and let the user choose their webcam and mic. refer to the latest documentation as necessary: https://aws.github.io/amazon-ivs-web-broadcast/docs/low-latency-sdk-guides/introduction
(最新バージョンの Amazon IVS Web Broadcast SDK を使用して、Amazon IVS 低レイテンシーチャンネルに配信するシンプルなプロトタイプアプリケーションを作成してください。UI内には、インジェストエンドポイントとストリームキーの入力要素を含め、ユーザーがウェブカムとマイクを選択できるようにしてください。必要に応じて最新のドキュメントを参照してください:https://aws.github.io/amazon-ivs-web-broadcast/docs/low-latency-sdk-guides/introduction)
このプロンプトに対して、Amazon IVS 低レイテンシースチャンネルへの配信が可能なシンプルな HTML アプリケーションが生成されます。
まとめ
本記事では、カスタム MCP サーバーを Amazon Q Developer CLI でしようできるように設定する方法を紹介しました。この機能は自作の MCP サーバーだけでなく、信頼できる既存の MCP サーバーを追加して Amazon Q の能力を拡張できるため、開発者にとって非常に強力なツールとなります。ぜひ、インストールして試してみてください!
原文はこちらです。
本ブログは Amazon Web Services Japan Startup Solutions Architect の Torgayev Tamirlan が翻訳しました。


Top comments (0)