Amazon Bedrock AgentCore Memory を用いた Kiro CLI の会話メモリ拡張
AWS は、Kiro CLI の会話履歴を永続化し、開発者の生産性を向上させるために、Amazon Bedrock AgentCore Memory と連携するカスタム MCP サーバーの実装方法を公開した。
キーポイント
Kiro CLI の記憶機能拡張
従来のセッション限定の記憶から脱却し、過去の会話履歴やユーザーの嗜好を保持することで、文脈に応じた継続的な開発支援を実現する。
MCP サーバーによる統合
Model Context Protocol (MCP) を採用したカスタムサーバーを構築し、Kiro CLI と Amazon Bedrock AgentCore Memory の間でシームレスなデータ連携を行う仕組みを提供する。
Bedrock AgentCore Memory の活用
AWS が提供する完全管理型サービス「AgentCore Memory」を活用し、短期間の作業メモリと長期的な文脈記憶の両方を効果的に管理・検索可能にする。
影響分析・編集コメントを表示
影響分析
この発表は、AI エージェントが単発のタスク完了だけでなく、長期的なプロジェクトにおいて一貫したコンテキストを理解し続けるための標準的なアーキテクチャを示すものであり、開発ワークフローにおける AI の信頼性を高める重要なステップです。特に MCP プロトコルの採用により、異なるツールやプラットフォーム間でのメモリ共有が容易になるため、エージェンティック IDE 分野の標準化を加速させる可能性があります。
編集コメント
エージェンティック IDE の最大の課題である「記憶の断絶」を、MCP という標準プロトコルとクラウドネイティブなメモリサービスで解決する実用的なアプローチです。開発現場での AI ツールの定着率向上に寄与する重要な技術動向と言えます。
過去のセッションでユーザーに伝えた内容を忘れてしまうアジェンティック IDE は、あまり役に立ちません。複雑なビジネス要件を持つ大規模なコードベースを数日あるいは数週間かけて作業しているにもかかわらず、IDE は現在のセッション中のみしか記憶しておらず、会話履歴や会話から導き出された好み、さらには追加の洞察を思い出すことができません。その結果、新しいセッションごとに同じ文脈情報を提供することになります。この繰り返しの文脈設定の必要性が、生産性に悪影響を及ぼします。
本稿では、Amazon Bedrock AgentCore Memory と統合されるカスタム Model Context Protocol(MCP)サーバーを実装することで、Kiro CLI の会話メモリを拡張する方法を示します。Kiro CLI を使用すれば、ターミナルから直接 Kiro の AI エージェントと対話できます。Amazon Bedrock AgentCore Memory は、AI エージェントが過去のやり取りからの情報を保持し、より知的で文脈を意識した会話を可能にするフルマネージドサービスです。カスタム MCP サーバーを実装することで、Kiro CLI に会話コンテキストの保存・取得ツールやメモリ使用状況の監視機能、および基盤となる Bedrock Agent Core Memory インフラストラクチャの管理機能を提供できます。
ソリューション概要
本ソリューションは、以下の 3 つの主要なコンポーネントが連携して構成されています:
- Amazon Bedrock AgentCore Memory は、会話の文脈を保存・検索する完全管理型サービスであり、組み込みのセマンティック検索機能により永続的な記憶能力を提供します。AgentCore Memory は、短期間の作業メモリと長期的なインテリジェントメモリの両方を維持するための強力な機能を提供し、AI エージェントが文脈を保持し、対話から学習し、真にパーソナライズされた体験を提供できるようにします。
- カスタム MCP サーバーは、MCP を通じて Amazon Bedrock AgentCore Memory の機能を公開し、MCP 互換クライアントに対してメモリ操作へのアクセスを可能にします。
- Kiro CLI は STDIO プロトコルを通じて MCP サーバーに接続し、会話履歴の保存および検索を行います。
MCP サーバーは、Kiro CLI と Amazon Bedrock AgentCore Memory の間の橋渡し役として機能し、Kiro CLI がセッションを超えて会話履歴と文脈を維持できるようにします。MCP サーバーは、3 つのカテゴリに整理されたツールを提供します。
- コンバーセーションツール – トピックや時間枠ごとに会話履歴を検索したり、一貫したセッション追跡機能付きで会話を保存したり、完全な会話内容を取得したり、以前に保存されたセッションを一覧表示したりできます。
- モニタリングツール – メモリ使用量の統計情報と MCP サーバー設定を表示できます。
- 管理ツール – 必要に応じて特定のセッションを削除したり、保存データを削除したりできます。
このソリューションは二段階の検索戦略を採用しています。まず、概念的な一致のために retrieve_memory_records Bedrock AgentCore Memory API を使用した意味検索を試行し、その後、AgentCore Memory セッションに保存された生会話ペイロードをスキャンする直接イベントレベルの内容マッチングにフォールバックします。このカスケード型のアプローチにより、意味戦略による処理が完了しているかどうかに関わらず、会話を確実に取得できるようにしています。プロンプトでは「直近 (recent)」、「昨夜 (last night)」、「昨日 (yesterday)」などの時間枠を指定して、関連する会話を見つけることができます。
このアーキテクチャにより、Kiro CLI は文脈認識型となります。セッションを超えてユーザーの好み、プロジェクトの詳細、ワークフローを記憶するため、同じ情報を繰り返し提供する必要がありません。
手順の解説
今回のデモでは、以下の前提条件が必要です:
- AWS Management Console および AWS Command Line Interface (AWS CLI) を通じた AWS アカウントへのアクセス権限。
使用する AWS Identity and Access Management (IAM) ユーザーには、本記事で言及されている必要な AWS サービス呼び出しおよび AWS リソースの管理を行うための権限が付与されている必要があります。IAM ユーザーに権限を付与する際は、最小権限の原則に従ってください。
- AWS Builder ID の取得。
- デスクトップまたはラップトップにインストールされ、設定された Kiro CLI。
ターミナルから以下の手順を実行してください:
- 以下のコマンドを実行してリポジトリをクローンします:
git clone https://github.com/aws-samples/sample-amazon-bedrock-agentcore-memory-mcp-server.git
- 以下のコマンドを実行して Python の仮想環境を作成し、依存関係をインストールします:
cd sample-amazon-bedrock-agentcore-memory-mcp-server
python3 -m venv venv;
source venv/bin/activate;
pip3 install -r requirements.txt;
- Amazon Bedrock AgentCore Memory リソースの作成および Kiro エージェント設定の生成を行うための以下のコマンドを実行します。このステップには数分かかる場合があります:
python3 setup_bedrock_agentcore_memory.py
プロンプトが表示されたら、アクター識別子として以下のオプションのいずれかを選択してください。変換結果はこの識別子に対して保存されます。
- オプション 1: ユーザー ID(デフォルト)– これは個人利用に推奨されます。これは USER 環境変数から取得したシステムのユーザー名を使用します。上記のコマンドは、agent/kiro_memory.json に ACTOR_ID_TYPE=userid を設定します。
- オプション 2: プロジェクト ID – これはチームまたはプロジェクトベースのメモリ分離に推奨されます。プロンプトが表示された場合は、projectid と your-project-id を入力する必要があります。上記のコマンドは、agent/kiro_memory.json に ACTOR_ID_TYPE=projectid および PROJECT_ID=your-project-id を設定します。
使用される名前空間戦略は以下の通りです:/strategy/semanticMemoryStrategy/actor/{actorId}/session/{sessionId}
- kiro エージェントの設定
mkdir -p ~/.kiro/agents/
mkdir -p ~/.kiro/hooks/
cp -p agent/kiro_memory.json ~/.kiro/agents/
cp -p hooks/cache-prompt.sh ~/.kiro/hooks/
cp -p hooks/load-preferences.sh ~/.kiro/hooks/
cp -p hooks/store-conversation.sh ~/.kiro/hooks/
chmod 755 ~/.kiro/hooks/*
- kiro_memory エージェントをデフォルトエージェントとして設定する。
kiro_memory エージェントをデフォルトで使用するには、~/.kiro/settings/ディレクトリ内の cli.json ファイルに以下の内容を追加してください:{"chat.defaultAgent": "kiro_memory"}
- Kiro CLI へのログイン
Kiro CLI にログインするには、AWS Builder ID または組織からの有効な Kiro サブスクリプションのいずれかが必要です。
どちらもお持ちでない場合は、Create your AWS Builder ID の手順を完了することで、AWS Builder ID を作成できます。
kiro-cli login --use-device-flow
ログイン方法については、キーボードの矢印キーを使用して Use for Free with Builder ID を選択し、Enter キーを押してください。
新しい Builder ID の作成に使用される URL が生成されます。Open this URL を選択するか、リンクをコピーして新しいブラウザタブに貼り付けてください。
直ちに作成した Builder ID でログインしてください。
リクエストの確認を促すプロンプトが表示されます。Confirm and continue を選択してください。
次に、Kiro CLI がデータにアクセスする許可を求めるメッセージが表示されます。Allow access をクリックしてください。
その後、ローカルのターミナルに戻ると、「Logged in successfully」というメッセージが表示されるはずです。ターミナルで以下のコマンドを入力してください:
kiro-cli --classic
Kiro CLI 上で /mcp コマンドを実行し、このセッションに設定されている MCP サーバーのリストを表示します。
MCP サーバーが正常に初期化された後、/tools コマンドを実行して、セッションで利用可能なツールのリストを表示してください。
agentcore-memory-mcp-server を介して、以下のツールがセッションで使用可能である点にご注意ください。
- clear_all_data – メモリ内の特定のネームスペースから情報を削除する
- delete_session – 特定のセッションを削除する
- get_direct_conversation_history – 特定のセッションの会話内容全体にアクセスする
- get_memory_stats – list_memory_records を使用してメモリの概要を提供する
- get_server_config – MCP サーバーの設定情報を提供する
- get_session_details – 特定のセッションに関する情報を提供する
- list_sessions – 以前保存されたセッションを一覧表示する
- search_conversation_history – トピックや時間枠に基づいて会話履歴を検索するためのツール
- search_memories – 長期記憶を検索するための別のツール
- store_conversation – 一貫したセッション ID を使用して会話を保存する
ソリューションのテスト
Kiro CLI は、プロンプトに応じて応答またはアクションを実行するために必要な機能に基づいて MCP サーバーを呼び出します。Kiro CLI のフックは、会話ごとにトリガーされ、会話を保存します。以下にいくつかの使用例を示します。
AWS DevOps エージェントとは何ですか?まだ一般提供(GA)されていますか?
Kiro が使用許可を求める可能性があるツールのアクセスを許可してください。応答を取得した後、/quit と入力して Kiro CLI を終了します。
再度 Kiro CLI にログインし、以下のように質問してください。
AWS DevOps エージェントについて何讨论了しましたか?
Kiro CLI からのツール使用リクエストを許可してください。Kiro は agentcore-memory-mcp-server(AgentCore Memory MCP サーバー)を使用して、Bedrock AgentCore メモリから関連情報を取得します。
以下のようなフォローアップ質問も可能です:
GitHub を AWS DevOps エージェントに統合することはできますか?
AWS DevOps エージェントの料金体系はどうなっていますか?
再度、Kiro CLI セッションを終了(/quit)し、しばらく待ってから再ログインしてください。その後、自然言語で AWS DevOps エージェントに関する過去の議論を Kiro CLI に取得するよう指示してください。Kiro は過去の議論の要約を表示します。
詳細については、以下の録画デモをご参照ください:
クリーンアップ
本記事はデモンストレーション目的のみで追従された場合、将来の課金を避けるために、本記事で作成したリソースを削除する次のコマンドを実行してください:
python3 cleanup_bedrock_agentcore_memory.py
本記事で作成したエージェント設定を kiro ディレクトリ(~/.kiro/agents/kiro_memory.json)から削除してください。
本記事で作成したフックを kiro ディレクトリ(~/.kiro/hooks/)から削除してください。
結論
本記事では、Amazon Bedrock AgentCore Memory に統合されたカスタム MCP サーバーを使用して、Kiro CLI の文脈の永続性をどのように強化できるかを実演しました。このカスタム MCP サーバーは、会話の文脈の保存と取得、メモリ使用状況の監視、および永続的なメモリインフラストラクチャの管理のための包括的なツールを提供します。スマートな検索機能、自然言語による時間範囲指定、そしてカスケードフォールバック戦略などの機能を備えることで、同じ文脈情報を繰り返し提供することなく、会話履歴を確実にアクセスすることが可能になります。
執筆者について
Biswanath Mukherjee は、Amazon Web Services のシニアソリューションアーキテクトです。AWS の大規模な戦略的顧客に対して、クラウド上のアプリケーションの移行と近代化に向けた技術指導を提供しています。広範な業界横断的なクラウドアーキテクチャの経験を活かし、顧客と連携して、スケーラビリティ、信頼性、アジリティを備えた AWS のベストプラクティスに沿った革新的なソリューションを開発し、ビジネスニーズに応えています。
Sathish Kumar Prabakaran は、AWS のシニアソリューションアーキテクトで、クラウドインフラストラクチャ、アプリケーション、セキュリティ、DevOps にわたる 20 年間の経験を持っています。ビジネス価値とコスト最適化のバランスを取りながら複雑な技術ソリューションを提供することに特化しており、アーキテクチャ、クラウド、インフラストラクチャの各分野において複数の業界認定資格を保有しています。
原文を表示
Agentic IDEs that forget what you told them in previous sessions aren’t very helpful. You work on your large codebase with complex business requirements for days or weeks. However, your IDE only remembers you during your current session and can’t recall your conversational history, preferences derived from the conversations, or additional insights. You end up providing the same contextual information in every new session. This need for repetitive context-setting impacts your productivity.
In this post, we demonstrate how you can extend the conversational memory of Kiro CLI by implementing a custom Model Context Protocol (MCP) server that integrates with Amazon Bedrock AgentCore Memory. You can use Kiro CLI to interact with AI agents of Kiro directly from your terminal. Amazon Bedrock AgentCore Memory is a fully managed service that allows AI agents to retain information from past interactions, creating more intelligent and context-aware conversations. By implementing a custom MCP server, you can provide Kiro CLI with tools to store and retrieve conversation context, monitor memory usage, and manage the underlying Bedrock Agent Core Memory infrastructure.
Solution overview
The solution consists of three main components working together:
- Amazon Bedrock AgentCore Memory is a fully managed service that stores and retrieves conversation context, providing persistent memory capabilities with built-in semantic search. AgentCore Memory provides powerful capabilities for maintaining both short-term working memory and long-term intelligent memory, so AI agents can retain context, learn from interactions, and deliver truly personalized experiences.
- Custom MCP Server exposes Amazon Bedrock AgentCore Memory capabilities through the MCP, making memory operations accessible to MCP-compatible clients.
- Kiro CLI connects to the MCP server through STDIO protocols to store and retrieve conversational history.
The MCP server acts as a bridge between Kiro CLI and Amazon Bedrock AgentCore Memory, allowing the Kiro CLI to maintain conversation history and context across sessions.The MCP server provides tools organized into three categories.
- Conversation tools – you can search conversation history by topic or timeframe, store conversations with consistent session tracking, retrieve complete conversation content, and list previously stored sessions.
- Monitoring tools – you can view memory usage statistics and MCP server config
- Management tools – you can delete specific sessions and delete stored data when needed.
The solution uses a two-stage retrieval strategy: it first attempts semantic search using the retrieve_memory_records Bedrock AgentCore Memory API for conceptual matching, then falls back to direct event-level content matching, scanning raw conversation payloads stored in AgentCore Memory sessions. This cascading approach makes sure that conversations are retrievable regardless of whether the semantic strategy has finished processing them. You can use timeframes in your prompt like *recent*, *last night*, or *yesterday* to find relevant conversations.
This architecture makes Kiro CLI context-aware. It remembers your preferences, project details, and workflows across sessions, so you don’t need to repeatedly provide the same information.
Walkthrough
For this demo, you should have the following prerequisites:
- Access to an AWS account through the AWS Management Console and the AWS Command Line Interface (AWS CLI).
The AWS Identity and Access Management (IAM) user that you use must have permissions to make the necessary AWS service calls and manage AWS resources mentioned in this post. While providing permissions to the IAM user, follow the principle of least-privilege.
- An AWS Builder ID.
- Kiro CLI installed on your desktop/laptop and configured.
Run the following steps from the terminal:
- Run the following command to clone the repository:
git clone https://github.com/aws-samples/sample-amazon-bedrock-agentcore-memory-mcp-server.git- Run the following command to create a Python virtual environment and install dependencies:
cd sample-amazon-bedrock-agentcore-memory-mcp-server
python3 -m venv venv;
source venv/bin/activate;
pip3 install -r requirements.txt;- Run the following command to create an Amazon Bedrock AgentCore Memory resource and generate Kiro agent config. Note that it might take a couple of minutes complete this step:
python3 setup_bedrock_agentcore_memory.pyWhen prompted, choose one of the following options for an actor identifier. The conversions are stored against this identifier.
- Option 1: User ID (default) – this is recommended for personal use. This uses your system username from the USER environment variable. The preceding command sets ACTOR_ID_TYPE=userid in agent/kiro_memory.json
- Option 2: Project ID – this is recommended for team or project-based memory isolation. When prompted, you must provide projectid and your-project-id. The preceding command sets ACTOR_ID_TYPE=projectid and PROJECT_ID=your-project-id in agent/kiro_memory.json
The namespace strategy used is: /strategy/semanticMemoryStrategy/actor/{actorId}/session/{sessionId}
- Setup kiro agent configuration
mkdir -p ~/.kiro/agents/
mkdir -p ~/.kiro/hooks/
cp -p agent/kiro_memory.json ~/.kiro/agents/
cp -p hooks/cache-prompt.sh ~/.kiro/hooks/
cp -p hooks/load-preferences.sh ~/.kiro/hooks/
cp -p hooks/store-conversation.sh ~/.kiro/hooks/
chmod 755 ~/.kiro/hooks/*- Configure kiro_memory agent as the default agent.
Add the following to the cli.json file in ~/.kiro/settings/ directory to use kiro_memory agent by default: {"chat.defaultAgent": "kiro_memory"}
- Login to Kiro CLI
For logging in to Kiro CLI, you will need either an AWS Builder ID or an active Kiro subscription from your organization.
If you don’t have either one, you can create an AWS Builder ID by completing the steps in Create your AWS Builder ID.
kiro-cli login --use-device-flow
For the log in method, select Use for Free with Builder ID using your keyboard arrow keys and press enter.
A URL will be generated to create new Builder ID. Select Open this URL or copy paste the link in a new browser tab.
Log in with the Builder ID that you just created.
You will get a prompt to confirm the request. Select Confirm and continue.
It will now ask you for permission to allow Kiro CLI to access the data. Click Allow access.
Now go back to your local terminal and you should see the message Logged in successfully. Enter the following command on the terminal:
kiro-cli --classic
Now, on the Kiro CLI enter the command /mcp to see the list of MCP servers configured on this session.
After the MCP server has successfully initialized, run the /tools command to list the tools available in the session.
Notice that the following tools are available to the session through the agentcore-memory-mcp-server.
- clear_all_data – Delete the information from a particular namespace in memory
- delete_session – Delete a particular session
- get_direct_conversation_history – Access complete conversation content for specific sessions
- get_memory_stats – uses list_memory_records to provide an overview of the memory
- get_server_config – provides the configuration of the MCP server
- get_session_details – provides information about a particular session
- list_sessions – List previously stored sessions
- search_conversation_history – Tool for searching conversation history by topic or timeframe
- search_memories – Another tool for searching long term memory
- store_conversation – Store conversations with consistent session IDs
Test the solution
Kiro CLI invokes MCP servers based on the functionality required to respond or act based on your prompt. Kiro CLI hooks trigger and store the conversation after every conversation. Here are some usage examples:
What is AWS DevOps agent? Is it GA yet?
Allow tool access that Kiro may ask for approval to use. After getting the response quit the Kiro CLI by typing /quit.
Re-login to Kiro CLI and ask:
What have we discussed about AWS DevOps agent?
Allow tool usage request from Kiro CLI. Kiro will use the agentcore-memory-mcp-server to fetch relevant information from Bedrock AgentCore memory.
You can ask follow up questions like:
Can I integrate GitHub with AWS DevOps agent?
What is the pricing for AWS DevOps agent?Again /quit the Kiro CLI session and re-login after some time. Ask Kiro CLI to retrieve previous discussion about AWS DevOps Agent in your natural language. Kiro shows you the summary of previous discussion.
Refer to the following recorded demo for more details:
Cleaning up
If you followed along only for demonstration purpose, to avoid incurring future charges, run the following command to delete the resources created in this post:
python3 cleanup_bedrock_agentcore_memory.py
Delete the Agent configuration created in this post from your kiro directory (~/.kiro/agents/kiro_memory.json)
Delete the hooks created in this post from your kiro directory (~/.kiro/hooks/)
Conclusion
In this post, we demonstrated how you can enhance context persistence of Kiro CLI using a custom MCP server that integrates with Amazon Bedrock AgentCore Memory. The custom MCP server provides comprehensive tools for storing and retrieving conversation contexts, monitoring memory usage, and managing your persistent memory infrastructure. With features like smart retrieval, natural language timeframes, and cascading fallback strategies, you can reliably access your conversation history without repeatedly providing the same contextual information.
About the authors
Biswanath Mukherjee is a Senior Solutions Architect at Amazon Web Services. He works with large strategic customers of AWS by providing them technical guidance to migrate and modernize their applications on AWS Cloud. With his extensive cross industry experience in cloud architecture, he partners with customers to develop innovative solutions that follows the scalability, reliability, and agility of AWS best practices to meet their business needs.
Sathish Kumar Prabakaran is a Sr.Solutions Architect at AWS with two decades of experience spanning cloud infrastructure, applications, security, and DevOps. He specializes in delivering complex technical solutions that balance business value with cost optimization, and holds multiple industry certifications in architecture, cloud, and infrastructure domains.
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み