2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Amazon Q Developer CLI で Strands Agents MCP サーバーを利用する設定

Posted at

はじめに

Strands AgentsのMCPサーバーが提供されていたので、Amazon Q Developer CLIに設定して、Strands Agentsのアプリを簡単に作成できるように設定してみました。

Amazon Q Developer CLI へのMCPサーバー設定

今回の環境

  • OS:Ubuntu(WSL2)
  • Amazon Q Developer: 1.12.2(MCP対応)
  • uv:インストール済み

方法1:mcp.jsonを直接編集

公式の手順にもサンプルが置いてありますが、mcp.jsonに追加するだけで動きます。

プロジェクト固有の場合:/project/.amazonq/mcp.json
グローバル設定の場合:~/.aws/amazonq/mcp.json

{
  "mcpServers": {
    "strands-agents": {
      "command": "uvx",
      "args": [
        "strands-agents-mcp-server"
      ]
    }
  }
}

方法2:Q Developer自体に依頼

Q Developerに設定自体を頼んでしまっても大丈夫でした。
q mcp addコマンドを実行してくれました。

> Strands AgentsのMCPサーバーをワークスペース設定で設定したい(uvx "strands-agents-mcp-server"> Strands AgentsのMCPサーバーをワークスペース設定で追加しましょう。uvxを使用してStrands Agents MCPサーバーを設定します。

🛠️  Using tool: execute_bash (trusted)
 ⋮
 ● I will run the following shell command:
q mcp add --name "strands-agents" --command "uvx" --args "strands-agents-mcp-server" --scope workspace
 ⋮
 ↳ Purpose: Add Strands Agents MCP server to workspace configuration

📁 Created MCP config in '/home/xxxxxx/qdev/.amazonq/mcp.json'

To learn more about MCP safety, see https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-mcp-security.html

✓ Added MCP server 'strands-agents' to 📄 workspace

 ⋮
 ● Completed in 1.389s

> 設定が完了しました!設定内容を確認してみましょう。


🛠️  Using tool: execute_bash (trusted)
 ⋮
 ● I will run the following shell command: q mcp list
 ⋮
 ↳ Purpose: List configured MCP servers


📄 workspace:
  /home/xxxxxx/qdev/.amazonq/mcp.json
    • strands-agents uvx

🌍 global:
  /home/xxxxxx/.aws/amazonq/mcp.json
    (empty)

チャットを再び開くと認識されます。
冒頭の部分でMCPサーバー(strands_agents)が読み込まれています。

$ q chat
✓ strands_agents loaded in 1.15 s


    ⢠⣶⣶⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣶⣿⣿⣿⣶⣦⡀⠀
 ⠀⠀⠀⣾⡿⢻⣿⡆⠀⠀⠀⢀⣄⡄⢀⣠⣤⣤⡀⢀⣠⣤⣤⡀⠀⠀⢀⣠⣤⣤⣤⣄⠀⠀⢀⣤⣤⣤⣤⣤⣤⡀⠀⠀⣀⣤⣤⣤⣀⠀⠀⠀⢠⣤⡀⣀⣤⣤⣄⡀⠀⠀⠀⠀⠀⠀⢠⣿⣿⠋⠀⠀⠀⠙⣿⣿⡆
 ⠀⠀⣼⣿⠇⠀⣿⣿⡄⠀⠀⢸⣿⣿⠛⠉⠻⣿⣿⠛⠉⠛⣿⣿⠀⠀⠘⠛⠉⠉⠻⣿⣧⠀⠈⠛⠛⠛⣻⣿⡿⠀⢀⣾⣿⠛⠉⠻⣿⣷⡀⠀⢸⣿⡟⠛⠉⢻⣿⣷⠀⠀⠀⠀⠀⠀⣼⣿⡏⠀⠀⠀⠀⠀⢸⣿⣿
 ⠀⢰⣿⣿⣤⣤⣼⣿⣷⠀⠀⢸⣿⣿⠀⠀⠀⣿⣿⠀⠀⠀⣿⣿⠀⠀⢀⣴⣶⣶⣶⣿⣿⠀⠀⠀⣠⣾⡿⠋⠀⠀⢸⣿⣿⠀⠀⠀⣿⣿⡇⠀⢸⣿⡇⠀⠀⢸⣿⣿⠀⠀⠀⠀⠀⠀⢹⣿⣇⠀⠀⠀⠀⠀⢸⣿⡿
 ⢀⣿⣿⠋⠉⠉⠉⢻⣿⣇⠀⢸⣿⣿⠀⠀⠀⣿⣿⠀⠀⠀⣿⣿⠀⠀⣿⣿⡀⠀⣠⣿⣿⠀⢀⣴⣿⣋⣀⣀⣀⡀⠘⣿⣿⣄⣀⣠⣿⣿⠃⠀⢸⣿⡇⠀⠀⢸⣿⣿⠀⠀⠀⠀⠀⠀⠈⢿⣿⣦⣀⣀⣀⣴⣿⡿⠃
 ⠚⠛⠋⠀⠀⠀⠀⠘⠛⠛⠀⠘⠛⠛⠀⠀⠀⠛⠛⠀⠀⠀⠛⠛⠀⠀⠙⠻⠿⠟⠋⠛⠛⠀⠘⠛⠛⠛⠛⠛⠛⠃⠀⠈⠛⠿⠿⠿⠛⠁⠀⠀⠘⠛⠃⠀⠀⠘⠛⠛⠀⠀⠀⠀⠀⠀⠀⠀⠙⠛⠿⢿⣿⣿⣋⠀⠀
 ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠿⢿⡧

╭─────────────────────────────── Did you know? ────────────────────────────────╮
│                                                                              │
│         Use /model to select the model to use for this conversation          │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯

/help all commands  •  ctrl + j new lines  •  ctrl + s fuzzy search
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🤖 You are chatting with claude-4-sonnet

MCPサーバーの稼働確認

Strands Agents MCPサーバーが有効になったので、呼び出せるか試してみます。

> Strands Agentsを利用して簡単なアプリを作成して
> Strands Agentsを使って簡単なアプリを作成するお手伝いをします。まず、Strands Agentsの基本的な情報を確認させてください。


🛠️  Using tool: quickstart from mcp server strands_agents
 ⋮
 ● Running quickstart with the param:
 ⋮  {"arguments": {},
 ⋮    "name": "quickstart"

Allow this action? Use 't' to trust (always allow) this tool for the session. [y/n/t]:

> t

 ⋮  }
 ⋮
 ● Completed in 0.18s


> それでは、Strands Agentsを使って簡単なアプリを作成しましょう。まず、プロジェクトの構造を作成します。
・
・
・

strands_agents MCPサーバーの quickstart をちゃんと呼び出せたようです。

次に、Strands Agentsの機能についても聞いてみました。

> Strands Agentsについて説明して
> Strands Agentsについて詳しく説明します。先ほど取得した情報を基に、主要な概念と使い方をご説明しますね。

## Strands Agentsとは

Strands AgentsはAIエージェントを構築するためのPython SDKです。エージェントは主に以下の3つの要素で定義されます:

1. モデル - 推論とツール使用をサポートするAIモデル
2. ツール - エージェントの機能を拡張する外部システムとの連携機能
3. プロンプト - システムプロンプトとユーザーメッセージ

## 主要な概念

### エージェント (Agent)
• モデル、ツール、プロンプトを組み合わせて定義
• 入力クエリとコンテキストに基づいて自動的にツールを使用

### モデル (Model)
• デフォルト:Amazon BedrockのAnthropic Claude Sonnet 3.7 (us-west-2リージョン)
• Amazon Bedrock、Anthropic、LiteLLM経由で多数のモデルをサポート

### ツール (Tools)
• エージェントの機能拡張の主要メカニズム
• 外部システムとの連携、データアクセス、環境操作が可能
• @toolデコレータでPython関数をツール化
• Model Context Protocol (MCP) サーバーもサポート

## パッケージ構成

strands-agents>=0.1.0          # メインSDK
strands-agents-tools>=0.1.0    # サンプルツール集


## 基本的な使用例

python
from strands import Agent, tool
from strands_tools import calculator, current_time, python_repl
・
・
・

ちゃんと理解してくれているようです。
これで書き方を確認してくれるので、Strands Agentsを使ったアプリ作成が簡単にできそうです!

参考URL

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?