Exclusive Content:

Haiper steps out of stealth mode, secures $13.8 million seed funding for video-generative AI

Haiper Emerges from Stealth Mode with $13.8 Million Seed...

Running Your ML Notebook on Databricks: A Step-by-Step Guide

A Step-by-Step Guide to Hosting Machine Learning Notebooks in...

“Revealing Weak Infosec Practices that Open the Door for Cyber Criminals in Your Organization” • The Register

Warning: Stolen ChatGPT Credentials a Hot Commodity on the...

Introducing Stateful MCP Client Features in Amazon Bedrock AgentCore Runtime

Unlocking Interactive AI Workflows: Introducing Stateful MCP Client Capabilities on Amazon Bedrock AgentCore Runtime

Transforming Agent Interactions with Elicitation, Sampling, and Progress Notifications

In this article, we delve into the newly introduced stateful capabilities of the Model Context Protocol (MCP) on Amazon Bedrock AgentCore Runtime. These enhancements empower developers to create interactive, multi-turn agent workflows, overcoming limitations associated with stateless implementations. Discover how elicitation, sampling, and progress notification capabilities can elevate user engagement and streamline complex operations by fostering bidirectional communication between clients and servers.

Transforming AI Agent Interactivity with Stateful MCP Client Capabilities on Amazon Bedrock AgentCore Runtime

In recent advancements within the realm of AI agents, the introduction of Stateful Model Context Protocol (MCP) client capabilities on Amazon Bedrock AgentCore Runtime marks a significant leap forward. This new functionality enables interactive, multi-turn workflows that were previously unattainable with stateless implementations.

The Challenge of Stateless Architectures

Builders of AI agents have often faced limitations with stateless MCP servers. In stateless implementations, each incoming HTTP request operates independently, making it impossible for servers to maintain a conversation thread, ask users for clarification mid-execution, or provide real-time updates during lengthy operations. Developers commonly struggled with scenarios where workflows had to pause mid-execution to seek user input or dynamically generate content. These challenges hampered the ability to create engaging and interactive applications.

The Solution: Stateful MCP Capabilities

With the introduction of stateful MCP mode, three pivotal client capabilities enhance interaction between MCP servers and clients:

  1. Elicitation: Allows servers to request structured user input during execution.
  2. Sampling: Enables servers to request LLM-generated content from clients.
  3. Progress Notifications: Provides real-time updates to users about ongoing operations.

These capabilities transform previously one-dimensional interactions into a dynamic, bidirectional conversation, vastly improving user experience.

From Stateless to Stateful MCP

Traditionally, running MCP servers on AgentCore utilized a stateless model where requests lacked shared context. However, by configuring the server with stateless_http=False, developers can enable stateful mode. This change provisions a dedicated microVM for each user session, maintaining session continuity through the Mcp-Session-Id header.

Key Differences in Modes

Feature Stateless Mode Stateful Mode
Session Isolation Not supported Dedicated microVM per session
Client Capabilities Not supported Elicitation, Sampling, Progress Notifications
Recommended for Simple tool serving Interactive, multi-turn workflows

Deep Dive into Client Capabilities

Let’s explore the three new client capabilities in detail.

Elicitation: Server-Initiated User Input

The elicitation capability allows an MCP server to pause execution and ask for specific data. This can include anything from confirming a decision to collecting user preferences:

result = await ctx.elicit('How much did you spend?', AmountInput)

Here, the server sends an elicitation request, and the client presents this as a user interface. The response can be accepted, declined, or canceled, allowing for a flexible interaction.

Sampling: Server-Initiated LLM Generation

Using sampling, the server can request a language model’s output without exposing its own API credentials. The client sends the server’s prompts to the appropriate LLM and returns the result. For example:

response = await ctx.sample(messages=prompt, max_tokens=300)

This mechanism empowers servers to leverage powerful LLMs for generating content, making it easier to create dynamic and context-aware interactions.

Progress Notifications: Real-Time Operation Feedback

Progress notifications keep users informed about the status of long-running operations, enhancing the overall user experience:

await ctx.report_progress(progress=2, total=total)

This feature allows the server to report back through a progress bar or status indicator, ensuring users don’t feel lost during lengthy processes.

Code Implementation: Building a Stateful MCP Server

To build a functional stateful MCP server, simply enable stateful mode during initialization:

mcp.run(transport="streamable-http", host="0.0.0.0", port=8000, stateless_http=False)

From here, the three capabilities become available automatically once the MPC client declares support during initialization. An example of a stateful server call might include an interactive expense entry tool:

@mcp.tool()
async def add_expense_interactive(user_alias: str, ctx: Context) -> str:
    # Various elicitation steps
    ...

Example Implementation

To solidify understanding of these concepts, let’s look at how a tool can implement elicitation:

result = await ctx.elicit('What was it for?', DescriptionInput)

Each elicitation step collects user input iteratively, providing a structured way to gather necessary information.

Conclusion

The introduction of stateful MCP client capabilities on Amazon Bedrock AgentCore Runtime provides a powerful framework for developers to build more interactive and human-like AI agents. By overcoming the constraints of stateless implementations, these advancements empower organizations to create engaging applications that can handle real-time user interactions, generate dynamic content, and provide user feedback on long operations.

Explore the resources and documentation available to accelerate your development and take full advantage of these enhancements. As you implement these features, share your experiences and innovations to advance the capabilities of AI within your organization.

About the Authors

  • Evandro Franco: Sr. Data Scientist at AWS.
  • Phelipe Fabres: Sr. Solutions Architect for Generative AI at AWS.
  • Zihang Huang: Solution Architect at AWS.
  • Sayee Kulkarni: Software Development Engineer at AWS Bedrock AgentCore.

Together, let’s shape the future of AI interactivity!

Latest

I Tried the ‘Let Them’ Rule for 24 Hours with ChatGPT — Here’s How I Stopped Overthinking

Embracing the "Let Them" Rule: How AI Helped Me...

Springwood High School Students in King’s Lynn Develop Problem-Solving Robots for Global Challenge

Aspiring Engineers at Springwood High School Tackle the First...

Non-Stop Work, 24/7

The Rise of AI Employees: Transforming the Modern Workplace Understanding...

Questions Arise from Generative AI Illustration in The New Yorker

The Unsettling Intersection of AI and Art: Sam Altman's...

Don't miss

Haiper steps out of stealth mode, secures $13.8 million seed funding for video-generative AI

Haiper Emerges from Stealth Mode with $13.8 Million Seed...

Running Your ML Notebook on Databricks: A Step-by-Step Guide

A Step-by-Step Guide to Hosting Machine Learning Notebooks in...

VOXI UK Launches First AI Chatbot to Support Customers

VOXI Launches AI Chatbot to Revolutionize Customer Services in...

Investing in digital infrastructure key to realizing generative AI’s potential for driving economic growth | articles

Challenges Hindering the Widescale Deployment of Generative AI: Legal,...

Contemporary Topic Modeling Techniques in Python

Unveiling Hidden Themes with BERTopic: A Comprehensive Guide to Advanced Topic Modeling Understanding the Basics of Topic Modeling Explore traditional methods vs. modern approaches. What is BERTopic? An...

Comprehensive Guide to the Lifecycle of Amazon Bedrock Models

Managing Foundation Model Lifecycle in Amazon Bedrock: Best Practices for Migration and Transition Overview of Amazon Bedrock Model Lifecycle Pricing Considerations During Extended Access Communication Process for...

Human-in-the-Loop Frameworks for Autonomous Workflows in Healthcare and Life Sciences

Implementing Human-in-the-Loop Constructs in Healthcare AI: Four Practical Approaches with AWS Services Understanding the Importance of Human-in-the-Loop in Healthcare Overview of Solutions for HITL in Agentic...