This is a cache of https://www.elastic.co/search-labs/blog/elastic-mcp-server-amazon-bedrock-agentcore-runtime. It is a snapshot of the page at 2025-09-08T01:05:52.989+0000.
Transforming data interaction: Deploying Elastic’s MCP server on Amazon Bedrock AgentCore Runtime for crafting agentic AI applications - Elasticsearch Labs

Transforming data interaction: Deploying Elastic’s MCP server on Amazon Bedrock AgentCore Runtime for crafting agentic AI applications

Transform complex database queries into simple conversations by deploying Elastic's search capabilities on Amazon Bedrock AgentCore Runtime platform.

Elasticsearch has native integrations to industry leading Gen AI tools and providers. Check out our webinars on going Beyond RAG Basics, or building prod-ready apps Elastic Vector Database.

To build the best search solutions for your use case, start a free cloud trial or try Elastic on your local machine now.

Imagine asking your data questions in plain English: "Fitness/diet recommendations based on my health goals," or "Help find investment opportunities based on my risk level?" and getting accurate answers without writing a single query. Today, we'll explore how to achieve this by deploying Elastic's Model Context Protocol (MCP) server on Amazon Bedrock AgentCore Runtime, creating a powerful bridge between conversational AI and your data.

At its core, this solution combines the power of Elasticsearch's search capabilities with Amazon's serverless AI infrastructure. Here's how it works:

  • Your natural language questions are processed through the MCP server that is deployed on Amazon Bedrock AgentCore Runtime
  • The MCP server translates these questions into precise Elasticsearch queries
  • Results are returned in human-readable format, making your data instantly accessible
  • All of this happens in a secure, scalable environment that's production-ready, deployed on Amazon Bedrock AgentCore Runtime

In this blog post, we'll explore how to:

  • Deploy Elastic's MCP server on Amazon Bedrock AgentCore Runtime
  • Transform local MCP prototypes into production-ready solutions
  • How to Build Conversational Interfaces on top of Elasticsearch
  • Implement secure, scalable AI agent architectures

Background

Model Context Protocol (MCP)

MCP is an open protocol that revolutionizes how businesses interact with their data through AI. Unlike traditional Retrieval-Augmented Generation (RAG) systems that simply retrieve documents, MCP enables AI agents to dynamically construct and execute complex tasks in real-time, mirroring the flexibility of human problem-solving

In practice, this means a business analyst can ask a series of increasingly specific questions about market trends, and the MCP-powered system will intelligently select and combine the appropriate data sources and analytical tools to provide comprehensive answers, while still maintaining context, allowing for follow-up questions without repetition.

For instance, when analyzing a product launch, the AI might integrate data from sales reports, customer feedback, and social media sentiment, orchestrating multiple tools simultaneously to provide a holistic view, thus enabling businesses to uncover deeper insights and make informed decisions, all through natural language interactions with their data systems.

Agents

Agents are AI-powered software applications that can think, plan, and act to achieve specific goals with minimal human supervision. They use foundation models (advanced AI models) to understand and complete complex tasks.

There are two types of AI agents.

Knowledge AI agents

These agents focus on enterprise knowledge. They gather context from company data — documents, logs, dashboards, communications, and customer records — and use that information to complete business tasks.

Example: A knowledge AI agent that can search across contracts, policies, and past tickets to help a customer support representative instantly resolve an issue.

General AI agents

These agents go further. They can understand goals and autonomously execute tasks on behalf of a user in broader, cross-domain workflows.

Example: A general AI agent that books travel, manages schedules, and negotiates with other systems to complete a user’s request end-to-end.

Elastic’s role in agentic AI

For knowledge AI agents: Elastic enables secure access to enterprise data, retrieves relevant context, and grounds responses in facts.

For general AI agents: Elastic serves as the knowledge store and context engine, providing trusted information so agents can perform more complex, goal-driven tasks.

In short, Elastic isn’t just storing data; it’s making enterprise knowledge usable, actionable, and AI-ready. This is the foundation for building intelligent agents that both understand and act.

AWS partnership and MCP server

Elastic has earned the AWS Generative AI Competency status. This recognition is awarded to AWS partners who deliver cutting-edge generative AI solutions that drive measurable gains in business efficiency, creativity, and productivity

Elastic also integrates with the Model Context Protocol (MCP), providing a seamless way for AI agents and applications to interact with Elasticsearch data through natural language conversations.

With the MCP server, you can connect to Elasticsearch directly from any MCP client — such as Claude Desktop, MCP Inspector, or an agentic application. The Elasticsearch MCP server is free to use (though infrastructure and Elasticsearch cluster costs may apply).

And with Amazon Bedrock models (such as Anthropic’s Claude) supporting MCP clients, organizations can now deploy intelligent, data-aware agents more easily and powerfully than ever before.

Amazon Bedrock AgentCore

Amazon Bedrock AgentCore is an enterprise-grade orchestration platform designed for scalable AI agent deployment and management. 

  • The platform provides serverless runtime environments with session isolation capabilities, enabling concurrent agent operations across multiple frameworks.
  • It implements memory management systems for both session-state and persistent storage, facilitating context-aware model interactions and learning capabilities.
  • The architecture includes observability features with granular logging, metrics collection, and advanced debugging capabilities for agent trajectory analysis.
  • The platform's robust identity and access management layer enables secure service-to-service authentication and fine-grained authorization controls for AWS and third-party service integrations.

It features a protocol-agnostic gateway for API transformations and tool discovery, supporting MCP-compliant interfaces. The infrastructure also includes containerized browser instances for web automation workflows and isolated compute environments for secure code execution. This end-to-end solution eliminates the need for building custom infrastructure components while maintaining enterprise security and compliance standards.

Solution overview

High-level architecture

The architecture consists of four main components:

  1. Python client: Handles user interactions and AWS authentication
  2. Amazon Bedrock AgentCore Runtime: Provides serverless hosting and session management
  3. Elastic MCP server: Processes MCP protocol requests and queries Elasticsearch
  4. Elasticsearch cluster: Stores and indexes the searchable data

Step-by-step workflow walkthrough

  1. User authenticates using an authentication mechanism such as OAuth.
  2. User access secured Client application running in a Customer AWS account using authenticated credentials.
  3. The client application invokes a Supervisor Agent that further invokes and orchestrates other Agents.
  4. All the agents are deployed on Amazon AgentCore Runtime and their tools are made available for the Agents, including Elastic’s MCP server and its tools.
  5. Foundation Models are available for the agentic AI application through Amazon Bedrock.
  6. Elastic Cloud is deployed on AWS and its endpoints are accessed by the Elastic MCP Server. Elastic MCP server automatically crafts the required queries, runs the queries against the Elastic data and fetches the response back to the Supervisor Agent.
  7. Supervisor Agent responds back to the end user via the Client Application.

Implementation guide

Please refer to this GitHub repo to get a hands-on experience of how this solution can be implemented. Pay close attention to the prerequisites before getting started.

Step 1: Deploy Elastic MCP server to ECR

The automated deployment script handles the entire container build and upload process:

Here is what the script does when you execute:

  1. Downloads the official Elastic MCP server repository
  2. Builds Docker container using Dockerfile-8000
  3. Creates ECR repository with image scanning enabled
  4. Uploads container image to ECR with proper tagging

Step 2: Create AgentCore Runtime host

Navigate to the AWS Console and configure your AgentCore Runtime:

1. Access AgentCore: Go to Amazon Bedrock AgentCore > Build and Deploy > Agent Runtime > Host Agent

2. Basic configuration: Click on “Host Agent” and give it a meaningful name if you prefer. Point to the Container Image you have uploaded to Amazon ECR.

3. Service role: Choose "Create and use a new service role"

4. Protocol settings: Choose MCP, and for the Inbound Identity, select Use IAM username

5. Environment variables: Finally, configure your Elasticsearch endpoints and pass them as environment variables to your Docker container.

6. After creating the host agent, go ahead and copy the Agent Runtime ARN from the "View invocation code" section. Here is an example:

Step 3: Configure Python client

Install dependencies:

Go ahead and initialize a virtual environment and install the Python libraries.

Update Agent ARN in my_mcp_client_remote.py:

Next, update the Python MCP client with the agent ARN you obtained in the previous steps.

Here are the key client components in this Python file.

AWS authentication class:

MCP request formation / payload:

Step 4: Run the client

Execute the Python client to test the integration. This Python program implements an asynchronous client for interacting with Amazon Bedrock AgentCore, specifically designed to query event information. The code utilizes AWS SigV4 authentication and consists of two main functions: test_mcp_endpoint() and chat_with_agentcore(). The first function demonstrates basic API interaction by listing available tools and performing a search query, while the second function implements a more sophisticated search functionality specifically for events in Paris.

The program uses the httpx library for async HTTP requests and handles Server-Sent Events (SSE) responses, parsing and displaying event details including names, venues, dates, and descriptions. The authentication is managed through a custom AWSAuth class that handles AWS SigV4 signing of requests. The code includes comprehensive error handling and formatted output display, making it suitable for both testing and production use cases.

Use case demonstrations

Use case 1: Data discovery

Scenario: Finding events in a specific city using natural language.

Query: "Events in Paris"

MCP request: Here is the payload you supply to the Amazon Bedrock Agentcore Runtime.

Response: And here is the response you get after Elastic’s MCP server runs a query in Elastic Search AI Platform and returns the result.

Use case 2: Elastic MCP tool discovery

Scenario: Discovering the available MCP tools that Elastic’s MCP server offers.

MCP request:

This returns a list of available tools that the MCP server provides, enabling dynamic tool discovery.

Use case 3: Complex search queries

Scenario: Advanced filtering with multiple criteria.
You can run more advanced Elastic Search Query Language based queries, like one shown below.

Query: Events with specific price ranges, dates, and categories.

MCP request:

How it works (technical deep dive)

MCP implementation

The Model Context Protocol uses JSON-RPC 2.0 format for all communications:

Key protocol features:

  • Stateless operation: Each request is independent with session isolation
  • Tool discovery: Dynamic discovery of available capabilities
  • Structured responses: Consistent response format across all tools
  • Error handling: Standardized error reporting and recovery

AWS authentication flow:

Session management

AgentCore automatically adds Mcp-Session-Id headers for session isolation:

  • Each client session gets a unique identifier
  • Stateless servers can maintain conversation context
  • Automatic cleanup of inactive sessions

Response processing pipeline

  1. Server-Sent Events (SSE): Responses come as data: {...} in JSON format
  2. JSON parsing: Extract JSON from SSE wrapper
  3. Content extraction: Parse the MCP result structure
  4. Data formatting: Convert Elasticsearch results to user-friendly format

Cleanup

After you have played around with this setup, if you would like to clean up the environment, please follow the steps outlined below.

Delete AgentCore Runtime:

  1. Navigate to Amazon Bedrock AgentCore in AWS Console
  2. Select your agent runtime
  3. Click "Delete" and confirm

Remove ECR repository:

Clean local environment:

Conclusion

By deploying Elastic's MCP server on Amazon Bedrock AgentCore Runtime, we've created a powerful, scalable, production-ready solution for natural language interaction with Elasticsearch data. This implementation opens up new possibilities for data exploration and analysis, making complex queries accessible through simple conversations.

Key takeaways include:

  • Seamless integration: MCP protocol enables natural language querying of complex data
  • Production scalability: AgentCore provides enterprise-grade hosting with minimal configuration
  • Developer productivity: Transform local prototypes to production with minimal code changes
  • Security first: Built-in AWS security and authentication mechanisms

Potential applications can be in any of the following areas of implementation:

  • Customer support: Natural language querying of support ticket databases
  • Business intelligence: Conversational analytics for business metrics
  • Content discovery: Intelligent search across document repositories
  • IoT data analysis: Natural language queries for sensor and telemetry data

Additional resources:

Related content

Ready to build state of the art search experiences?

Sufficiently advanced search isn’t achieved with the efforts of one. Elasticsearch is powered by data scientists, ML ops, engineers, and many more who are just as passionate about search as your are. Let’s connect and work together to build the magical search experience that will get you the results you want.

Try it yourself