Extending conversational memory in Kiro CLI using Amazon Bedrock AgentCore Memory

TutoSartup excerpt from this article:
Run the following steps from the terminal: Run the following command to clone the repository: git clone https://github… 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 integrate…

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:

  1. 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.
  2. Custom MCP Server exposes Amazon Bedrock AgentCore Memory capabilities through the MCP, making memory operations accessible to MCP-compatible clients.
  3. Kiro CLI connects to the MCP server through STDIO protocols to store and retrieve conversational history.

Architecture diagram showing Kiro CLI integration with Amazon Bedrock AgentCore Memory and MCP Server

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:

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.

Run the following steps from the terminal:

  1. Run the following command to clone the repository:
    git clone https://github.com/aws-samples/sample-amazon-bedrock-agentcore-memory-mcp-server.git
  2. 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;
  3. 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.py

When 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}

  1. 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/*
  2. 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"}

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

Debug console screenshot showing Kiro CLI login method selection with Builder ID and IDC Account options

For the log in method, select Use for Free with Builder ID using your keyboard arrow keys and press enter.

Terminal output showing Kiro CLI device flow login with browser confirmation URL and authorization code.

A URL will be generated to create new Builder ID. Select Open this URL or copy paste the link in a new browser tab.

AWS Builder ID sign-in page with email input field, Continue button, and Google authentication option

Log in with the Builder ID that you just created.

You will get a prompt to confirm the request. Select Confirm and continue.

AWS authorization dialog requesting code confirmation to grant application access to AWS account resources

It will now ask you for permission to allow Kiro CLI to access the data. Click Allow access.

AWS permission dialog asking user to allow Kiro CLI to access their data, with Allow and Deny options

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.

Kiro CLI terminal showing agentcore-memory-mcp-server loaded in 1.15 seconds with a context hooks tip

After the MCP server has successfully initialized, run the /tools command to list the tools available in the session.

Kiro CLI tools permission matrix showing built-in tools and agentcore-memory-mcp-server operations with trust levels

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

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.

Extending conversational memory in Kiro CLI using Amazon Bedrock AgentCore Memory
Author: Biswanath Mukherjee