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

Real-Time Voice Agents Using Stream Vision Agents and Amazon Nova 2 Sonic

Building Production-Grade Real-Time Voice Agents with Stream and Amazon...

Go.Compare Introduces Insurance App Powered by ChatGPT

Go.Compare Launches ChatGPT App for Effortless Insurance Comparison Go.Compare Launches...

Dstl-Backed Robotics Innovation Revolutionizes Military Manufacturing – A Case Study

Revolutionizing Manufacturing: Rivelin Robotics’ Innovations in Precision Finishing for...

Understanding Patient Sentiment in Atopic Dermatitis Management

Insights into Patient Sentiment and Treatment Perceptions in Atopic...

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

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

VOXI UK Launches First AI Chatbot to Support Customers

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

Real-Time Voice Agents Using Stream Vision Agents and Amazon Nova 2...

Building Production-Grade Real-Time Voice Agents with Stream and Amazon Bedrock Co-Authored by Neevash Ramdial, Technical Marketing Leader at Stream Creating natural and responsive production-grade voice agents...

Create Financial Document Processing Solutions Using Pulse AI and Amazon Bedrock

Transforming Financial Document Processing: Leveraging Pulse AI and Amazon Bedrock for Accurate Data Extraction Introduction Financial institutions process thousands of complex documents daily. Optical Character Recognition...

Automating Schema Creation for Smart Document Processing

Streamlining Document Processing: Introducing Multi-Document Discovery for Intelligent Document Processing (IDP) Overcoming Schema Challenges in Large Document Collections The IDP Accelerator: Revolutionizing Document Processing Automated Solution Overview...