1
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?

AWS Blog「Harness the power of MCP servers with Amazon Bedrock Agents」を試した記録

Last updated at Posted at 2025-09-02

AWS Blog の「Harness the power of MCP servers with Amazon Bedrock Agents」が日本語に翻訳されていたので、実際に動かしながら読みました。
参照:Amazon Bedrock Agents で MCP サーバーを活用する

自分なりの解釈

このブログが言いたいことは、一言でまとめると以下の通り。
Amazon Bedrock Agentsを仲介役として、様々なデータソースにアクセスし、そのデータを生成AIに提供した上で命令できるよ!

ユースケースとして紹介されているのは、以下の流れでした。

  1. Amazon Bedrock AgentsAWS Cost Explorerから直近の利用状況データを取得
  2. Perplexity AI などの生成AIにデータを渡して自然言語での解釈やグラフ化を実行
  3. ユーザーは「最近7日間の利用コストをグラフにして」などの自然な問合せができる

つまり、データソースと生成AIの間にMCPサーバー+Amazon Bedrock Agentsが入り、自然な形でデータ取得と生成AIへの問合せをコントロールしてくれるという構造です。
これを応用すれば、「コスト削減のために何をすればいいか?」といった分析的な問いにも答えてくれる可能性があります。


実際に動かしてみたログ

1. GitHubリポジトリのクローンと初期準備

  • sample-cloud-spend-mcp-server をUbuntuにクローンして利用開始
  • .env ファイルを作成する際に、ブログ記載通りでは動かず、AWS_PROFILE の行追加が必要でした
AWS_PROFILE=my-dev

2. モデル指定の落とし穴

ブログでは Amazon Bedrock Agents の基盤モデルに Claude 3.5 Sonnet を利用している。
自分は ap-northeast-1(東京)の Claude 3.5 Sonnet モデルで試したが、エージェント連携が未サポートで動かなかった。
us-east-1 のus.anthropic.claude-3-5-sonnet-20241022-v2:0"モデルを指定することで解決。

3. モデルアクセス有効化

Bedrockの対象モデルは 事前にAWSコンソールのモデルアクセスで「アクセス有効化」しておかないと利用不可。

4. 実行時に発生したエラーと修正

  • 引数の型エラー
    • MCPサーバー呼び出しのプロンプト型が誤っており、修正が必要
    • chatGPTに相談して修正 → 解決
    Tool output: Error executing tool get_detailed_breakdown_by_day: 1 validation error for get_detailed_breakdown_by_dayArguments
params
  Input should be a valid dictionary or instance of DaysParam [type=model_type, input_value='7', input_type=str]
    For further information visit https://errors.pydantic.dev/2.11/v/model_type
  • AWSプロファイルの参照エラー
    • MCPサーバーのDockerにてroot/.aws/config を参照できない問題
    • config.pyにてhomeディレクトリをroot/.awsにマウントする設定になっていた
      ~/.aws を root/.awsにマウントする形に修正 → 解決
Tool output: Error executing tool get_detailed_breakdown_by_day: The config profile (my-dev) could not be found

5. Cost Explorerの利用初回制約

  • AWSコンソールからCost Explorerに初めてアクセスしたため、データ集計に24時間かかるという制約に遭遇
  • 翌日以降に再実行予定
    image.png

6. Bedrockの利用制限

  • Cost Explorerにアクセスできた後、グラフの作成でBedrockの利用制限エラー
  • throttlingExceptionと出ていることから、Service Quotasにて利用上限の引き上げ申請
(throttlingException) when calling the InvokeInlineAgent operation: Your request rate is too high. Reduce the frequency of requests. Check your Bedrock model invocation quotas to find the acceptable frequency.'))

今後の展望

今後は実際にCost Explorerのデータが集計された状態で「どこに無駄があるか?」の質問まで試してみたいです。Bedrockの請求額が怖いけど(笑)。

1
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
1
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?