<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title><![CDATA[Matt Ryan - Elasticsearch Labs]]></title>
    <description><![CDATA[Articles and tutorials from the Search team at Elastic]]></description>
    <copyright><![CDATA[© 2026. Elasticsearch B.V. All Rights Reserved]]></copyright>
    <image>
      <title><![CDATA[Matt Ryan - Elasticsearch Labs]]></title>
      <url>https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt1121c0bf0e8a6e65/6a88da6340a1841030ef456f/search-labs-thumbnail.png</url>
      <link>https://www.elastic.co/search-labs/author/matt-ryan</link>
    </image>
    <link>https://www.elastic.co/search-labs/author/matt-ryan</link>
    <atom:link href="https://www.elastic.co/search-labs/rss/author/matt-ryan.xml" rel="self" type="application/rss+xml"/>
    <language><![CDATA[en]]></language>
    <lastBuildDate>Wed, 16 Sep 2026 18:00:46 GMT</lastBuildDate>
  <item>
    <title><![CDATA[You and your AI agent shouldn't be using curl: Introducing the Elastic CLI and Agent Skills]]></title>
    <description><![CDATA[Elastic CLI reaches every Elasticsearch, Kibana and Cloud API from one command, and it's what Elastic Agent Skills run on. Input is validated against a JSON Schema before anything leaves your machine, and API keys stay in your OS keychain.]]></description>
    <content:encoded><![CDATA[<p><a href="https://github.com/elastic/cli">The Elastic CLI</a> gives you one command for every public Elastic API: Elasticsearch, Kibana, and Elastic Cloud's control plane, including Serverless projects. Learn <code>elastic es search</code>, and you already know how <code>elastic kb data-views list</code> behaves. It's built to be driven by an AI coding agent as easily as by you, so every command takes JSON in and out and validates input against a JSON Schema before sending anything. Plus, it exits with a code that an agent can branch on. Administrators control which commands run at all, and API keys go to your OS keychain, never into a large language model (LLM) transcript. Our Agent Skills now run on it. The command line interface (CLI) is in technical preview today.</p><p><a href="https://cloud.elastic.co/serverless-registration">Start a free Elastic Cloud Serverless trial</a> or <a href="https://cloud.elastic.co/login">log in to Elastic Cloud</a> to follow along, and install the CLI via <a href="https://www.npmjs.com/">npm</a>: </p>npm install -g @elastic/cli<h2>Designing the Elastic CLI for people and AI agents</h2><p>A useful side effect of building flexible tools for developers is that they’re more useful to AI agents, too. It’s also the tool that our<a href="https://github.com/elastic/agent-skills"> Agent Skills</a> now use to get things done, closing <a href="https://www.elastic.co/search-labs/blog/agent-skills-elastic">the loop that we opened in March 2026</a>, when we said that a CLI for agent workflows was coming.</p><p>The CLI gives every public API across Elasticsearch, Kibana, and Elastic Cloud one shape: the same flags, input and output conventions, authentication method, and failure mode. Consistency is the ergonomic feature; everything else is built on it.</p><p>Agents need the same thing, only stricter. An agent won’t know how to craft a valid CLI command or notice if a tool “feels” wrong; it needs output it can parse and input it can validate before sending, along with failures it can branch on. Agents are now a first-class interface to Elastic, alongside people, whether they live on the platform or in your editor and terminal.<a href="https://github.com/elastic/agent-skills"> Agent Skills</a>, and now the CLI, are how we serve the second kind, so those needs are built into the core of the CLI rather than tacked on.</p><h3>JSON input and output for every command</h3><p>Agents love structured text, and almost every Elastic API already speaks JSON, so first-class JSON support was a hard requirement. Developers who are quick with a <u><code>jq</code></u> query will be equally satisfied.</p><ul><li><p><strong>JSON output:</strong> Any command, like <code>elastic version</code> and <code>elastic es indices delete ...</code>, supports <code>--json</code>, which prints JSON-parseable output to stdout and nothing else. Failed commands print <code>{"error": {"code": "...", "message": "..."}}</code> to stderr.</p></li><li><p><strong>JSON input:</strong> Every command that takes input accepts JSON on stdin or via <code>--input-file</code>. Every top-level key in that JSON also works as a CLI argument, and inline arguments take precedence, so you can keep a big request body in a file and tweak a value or two per invocation.</p></li><li><p><strong>JSON Schema as </strong><strong><code>-</code></strong><strong><code>-help</code></strong><strong> output:</strong> Pass <code>--help --json</code> to any command, and it prints a valid JSON Schema for its input, which also feeds nicely into codegen tools. <code>elastic cli-schema</code> prints the whole command tree.</p></li></ul><h3>Exit codes that an AI agent can branch on</h3><p>Agents loop on exit codes as much as they do over stdout. All failure modes are distinguishable from success, even if stdout and stderr are never read.</p><h3>Safety rails: Keychain storage, allow lists, and validation</h3><p>No model uses tools perfectly 100% of the time, so an agent-friendly CLI should provide safety rails wherever possible.</p><ul><li><p><strong>Contexts and secret storage:</strong> Connection details live in named contexts in <code>~/.elasticrc.yml</code>, <code>kubectl</code>-style; switch with <code>--use-context</code>. API commands never take credentials as flags. <code>elastic config context add</code> writes API keys to your OS keychain (macOS, Linux, Windows) and leaves a <code>$(keychain:...)</code> reference in the YAML; <code>$(env:...)</code>, <code>$(cmd:...)</code>, and <code>$(file:...)</code> work, too. Creating a Serverless project with <code>--save-as</code> writes its credentials straight to the keychain and never prints them, so nothing leaks into logs or LLM transcripts.</p></li><li><p><strong>Allowlists/blocklists:</strong> A <code>commands.allowed</code> (or <code>commands.blocked</code>) list in the config file, globally or per context, ensures that only the commands an administrator wants are runnable.</p></li></ul>commands:
   allowed:
     - version
     - stack.es.search
     - stack.es.esql.*<ul><li><p><strong>Validation:</strong> Every command has a JSON Schema, so inputs are validated before any request is sent. Add <code>--dry-run</code> to any command that takes input, and it validates and exits without sending anything.</p></li><li><p><strong>Confirmation:</strong> Destructive commands prompt in a terminal. In a noninteractive session, where agents live, they refuse to run without <code>--yes</code> and say so in a structured error.</p></li><li><p><strong>Sanitization:</strong> Index, field, and pipeline names have length limits and forbidden characters. <code>elastic sanitize index-name '&lt;value&gt;'</code> (and <code>field-name</code>, <code>pipeline-name</code>, …) prints a version stripped of anything invalid.</p></li></ul><h3>Keeping API responses inside an agent's context window</h3><p>Elastic APIs return a lot of data, and an agent’s context window is finite. Three controls help keep unnecessary text out of the context window:</p><ul><li><p><strong>Field masks:</strong> <code>--output-fields</code> takes a comma-separated list, with dot notation for nested fields.</p></li></ul>elastic es info --output-fields 'name,version.number'
 # {
 #   "name": "serverless",
 #   "version": { "number": "9.5.0" }
 # }<ul><li><p><strong>String templates:</strong> For total control, <code>--output-template</code> takes a <a href="https://mustache.github.io/">mustache</a>-style template.</p></li></ul>elastic es info --output-template 'ES version: {{ version.number }}'
# ES version: 9.5.0<ul><li><strong>Command profiles:</strong> <code>--command-profile</code> serverless (or <code>default_profile: serverless</code> in your config) hides Elastic Cloud Hosted commands and the Elasticsearch namespaces that don’t exist on Serverless. That means less to scroll past and less for an agent to guess wrong. It’s the profile we recommend for agents.</li></ul><p><strong>Control</strong></p><p><strong>What it does</strong></p><p><strong>Syntax</strong></p><p><strong>When to use</strong></p><p>Field mask</p><p>Returns only the fields you name, using dot notation for nested fields</p><p><code>--output-fields 'name,version.number'</code></p><p>You want valid JSON back, just less of it. This is the default choice for agents parsing structured output.</p><p>String template</p><p>Renders the response through a mustache-style template</p><p><code>--output-template 'ES version: {{ version.number }}'</code></p><p>You need one value in a specific shape, for a shell variable, a log line, or a prompt.</p><p>Command profile</p><p>Hides commands and namespaces that don't apply to your deployment</p><p><code>--command-profile serverless</code>or <code>default_profile: serverless</code></p><p>You want a smaller command surface so an agent has less to scroll past and less to guess wrong. This is recommended for agents.</p><p></p><h2>Helpers for bulk ingest, scroll search, and msearch</h2><p>Some of Elasticsearch’s most popular APIs have a learning curve, so elastic es helpers wraps them:</p><ul><li><p><code>scroll-search</code>: Stream a large result set as NDJSON with paging handled for you.</p></li><li><p><code>bulk-ingest</code>: Ingest from a file, a directory, or stdin (NDJSON, JSON arrays, or CSV) with streaming, batching, concurrency, and retries.</p></li><li><p><code>msearch</code>: Send multiple searches in one request.</p></li><li><p><code>watch</code>: Print new documents from an index to stdout as they’re indexed. This is great for piping into logging tools.</p></li></ul><p><code>elastic es</code> and <code>elastic kb</code> are aliases for <code>elastic stack elasticsearch</code> and <code>elastic stack kibana</code>. If we don’t ship a command you need, <code>elastic extension create</code> scaffolds one for you.</p><h2>Searching Elastic docs from the terminal</h2><p>If you or your agents don’t know which API to use, elastic docs search (plus docs read and docs ask) searches Elastic’s documentation from the terminal, returning Markdown or <code>--json</code>. These are experimental. You’ll see a warning until you pass <code>--accept-experimental</code>, so explore, but don’t script against them yet.</p><h2>Shell completion for Bash, Zsh, and Fish</h2><p>Autocomplete hooks are available for Bash, Zsh, and Fish, and they always respect your <code>commands.allowed</code> or <code>commands.blocked</code> policy.</p><h2>How Elastic Agent Skills use the CLI</h2><p><a href="https://github.com/elastic/agent-skills">Agent Skills</a> teach an AI coding agent how an Elastic expert approaches a job; for example, which cluster health field is the verdict or how to stage a reindex so it doesn’t fall over. They capture process and judgment but not transport. A skill that embeds <a href="https://curl.se/">curl</a> with an auth header has hard-coded a hostname, key, and runtime, and it breaks when any of those change.</p><p>So our skills now use a <em>universal</em> format that runs unchanged in any runtime that can execute the <code>elastic</code> CLI, including Claude Code, Codex, Cursor, and GitHub Copilot. The body refers to operations in HTTP shorthand (<code>GET /_cluster/health</code>, <code>POST /_query</code>), and an operations table at the end binds each to a CLI command. That table is the only place transport appears:</p><p>HTTP API (shorthand)</p><p><code>elastic</code> CLI command</p><p><code>GET /{index}/_mapping</code></p><p><code>elastic es indices get-mapping --index '&lt;index&gt;'</code></p><p><code>POST /_query</code></p><p><code>elastic es esql query --format tsv --query "&lt;esql&gt;"</code></p><p><code>POST cloud:/api/v1/serverless/projects/elasticsearch</code></p><p><code>elastic cloud serverless projects search create --input-file &lt;json&gt; --wait --save-as &lt;ctx&gt;</code></p><p>Every universal skill also inherits a blunt preamble; that is, use the CLI, don’t guess credentials, don’t call the HTTP API directly, and never ask the user to paste an API key into the chat.</p><p>The two halves need each other. The skill supplies the expertise that the model doesn’t have, and the CLI supplies a way to act on it that’s validated, credential-safe, and scoped by your allowlist. Tell your agent to <em>spin up a Serverless project and load products.csv into it</em>, and the provisioning skill creates it with <code>--save-as</code>. The ingest skill dry-runs a mapping and loads with <code>elastic es bulk</code>, and the Elasticsearch Query Language (ES|QL) skill writes a query that parses on the first try. Every step returns JSON, exits non-zero on failure, and can only do what your policy allows.</p><p>Skills for Elastic Cloud onboarding and provisioning, Elastic Workflows, and Kubernetes investigation are available today. Skills for Elasticsearch query, ingest, reindex, and index design, plus Kibana dashboards and alerting, are close behind.</p><h2>What’s in the Elastic CLI technical preview, and what’s next</h2><p>The preview covers all public Elasticsearch Serverless, Kibana Serverless, and Elastic Cloud APIs. Hosted-only 9.x Elasticsearch API coverage is nearly 100%, and hosted-only 9.x Kibana APIs will be added soon.</p><p>We’re actively planning more developer experience work, including broader coverage for all supported stack releases, more helpers for common workflows, more skills in the public catalog, and loading the same skills into agents that run on the Elastic platform itself. What shapes that list is hearing how you and your agents use the CLI. Tell us what’s awkward and what’s missing, along with what you’d automate next.</p><h2>Install the Elastic CLI and Agent Skills</h2><p>The Elastic CLI is available now on npm (Node.js 22+). Install it and the skills together:</p>npm install -g @elastic/cli # or: npx -y @elastic/cli --help
npx skills add elastic/agent-skills<p>Then, add a context and check it:</p>elastic config context add prod --es-url https://&lt;project&gt;.es.us-east-1.aws.elastic.cloud --es-api-key &lt;KEY&gt;
 elastic status<p>Even without a project, you can <a href="https://cloud.elastic.co/serverless-registration">start a free Serverless trial</a> in about a minute, with no credit card. If you already have a project, <a href="https://cloud.elastic.co/login">log in</a> and create API keys for Elastic Cloud and your Elasticsearch clusters. Before pointing an agent at anything real, start with a trial project, a read-only key, and a scoped commands.allowed list. Be sure to take five minutes to read the <a href="https://github.com/elastic/agent-skills#security-considerations">security notes</a> in the skills repo.</p><p>Replace all those curl commands in your Bash scripts, and add some usage instructions to your AGENTS.md. Then let your agent’s skills work efficiently and accurately with our APIs. Let us know what you think, and don’t hesitate to<a href="https://github.com/elastic/cli/issues"> open an issue</a> if you find a bug or if your use case isn’t well supported. Your feedback directly shapes what we build next.</p><h2>Elastic CLI and Agent Skills resources</h2><ul><li><p><a href="https://github.com/elastic/cli">Elastic CLI on GitHub</a> and<a href="https://github.com/elastic/cli/tree/main/docs/cli"> CLI documentation</a></p></li><li><p><a href="https://github.com/elastic/agent-skills">Elastic Agent Skills on GitHub</a></p></li><li><p><a href="https://agentskills.io">agentskills.io specification</a></p></li><li><p><a href="https://www.elastic.co/docs/deploy-manage/deploy/elastic-cloud/serverless">Elastic Cloud Serverless documentation</a></p></li><li><p><a href="https://github.com/elastic/cli/issues">Report a CLI issue</a> ·<a href="https://github.com/elastic/agent-skills/issues"> Report a skills issue</a> ·<a href="https://discuss.elastic.co/"> Discuss</a></p></li></ul>]]></content:encoded>
    <link>https://www.elastic.co/search-labs/blog/elastic-cli-ai-agents</link>
    <guid isPermaLink="true">https://www.elastic.co/search-labs/blog/elastic-cli-ai-agents</guid>
    <category><![CDATA[Developer Experience]]></category>
    <category><![CDATA[AI Tools ]]></category>
    <category><![CDATA[Agentic AI]]></category>
    <dc:creator><![CDATA[Josh Mock,Matt Ryan]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt111f4783cff3ef01/6aa7bad035eddc3a1a11d192/image1.png" length="0" type="image/png"/>
    <pubDate>Mon, 14 Sep 2026 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[Transforming data interaction: Deploying Elastic’s MCP server on Amazon Bedrock AgentCore Runtime for crafting agentic AI applications]]></title>
    <description><![CDATA[Transform complex database queries into simple conversations by deploying Elastic's search capabilities on Amazon Bedrock AgentCore Runtime platform.]]></description>
    <content:encoded><![CDATA[<p>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 <a href="https://www.anthropic.com/news/model-context-protocol">Model Context Protocol</a> (MCP) server on <a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-how-it-works.html">Amazon Bedrock AgentCore Runtime</a>, creating a powerful bridge between conversational AI and your data.</p><p>At its core, this solution combines the power of Elasticsearch's search capabilities with Amazon's serverless AI infrastructure. Here's how it works:</p><ul><li><p>Your natural language questions are processed through the MCP server that is deployed on Amazon Bedrock AgentCore Runtime</p></li><li><p>The MCP server translates these questions into precise Elasticsearch queries</p></li><li><p>Results are returned in human-readable format, making your data instantly accessible</p></li><li><p>All of this happens in a secure, scalable environment that's production-ready, deployed on Amazon Bedrock AgentCore Runtime</p></li></ul><p>In this blog post, we'll explore how to:</p><ul><li><p>Deploy Elastic's MCP server on Amazon Bedrock AgentCore Runtime</p></li><li><p>Transform local MCP prototypes into production-ready solutions</p></li><li><p>How to Build Conversational Interfaces on top of Elasticsearch</p></li><li><p>Implement secure, scalable AI agent architectures</p></li></ul><h2>Background</h2><h3>Model Context Protocol (MCP)</h3><p>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</p><p>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.</p><p>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.</p><h3>Agents</h3><p>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.</p><p>There are two types of AI agents.</p><p><strong>Knowledge AI agents</strong></p><p>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.</p><p><em>Example: A knowledge AI agent that can search across contracts, policies, and past tickets to help a customer support representative instantly resolve an issue.</em></p><p><strong>General AI agents</strong></p><p>These agents go further. They can understand goals and autonomously execute tasks on behalf of a user in broader, cross-domain workflows.</p><p><em>Example: A general AI agent that books travel, manages schedules, and negotiates with other systems to complete a user’s request end-to-end.</em></p><h3>Elastic’s role in agentic AI</h3><p><strong>For knowledge AI agents</strong>: Elastic enables secure access to enterprise data, retrieves relevant context, and grounds responses in facts.</p><p><strong>For general AI agents</strong>: Elastic serves as the knowledge store and context engine, providing trusted information so agents can perform more complex, goal-driven tasks.</p><p>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.</p><h3>AWS partnership and MCP server</h3><p>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</p><p>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.</p><p>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).</p><p>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.</p><h3>Amazon Bedrock AgentCore</h3><p><a href="https://aws.amazon.com/bedrock/agentcore/?trk=e61dee65-4ce8-4738-84db-75305c9cd4fe&amp;sc_channel=el">Amazon Bedrock AgentCore</a> is an enterprise-grade orchestration platform designed for scalable AI agent deployment and management. </p><ul><li><p>The platform provides serverless runtime environments with session isolation capabilities, enabling concurrent agent operations across multiple frameworks.</p></li><li><p>It implements memory management systems for both session-state and persistent storage, facilitating context-aware model interactions and learning capabilities.</p></li><li><p>The architecture includes observability features with granular logging, metrics collection, and advanced debugging capabilities for agent trajectory analysis.</p></li><li><p>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.</p></li></ul><p>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.</p><h2><strong>Solution overview</strong></h2><h3><strong>High-level architecture</strong></h3><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltb55c578d65fd5085/6a17f3046864a47abeb688cc/40812bd3424c21232c6d03e24b74e01034ab2c76-1600x503.png" alt="" /><p>The architecture consists of four main components:</p><ol><li><p><strong> Python client: </strong>Handles user interactions and AWS authentication</p></li><li><p><strong>Amazon Bedrock</strong> AgentCore Runtime: Provides serverless hosting and session management</p></li><li><p><strong>Elastic MCP server</strong>: Processes MCP protocol requests and queries Elasticsearch</p></li><li><p><strong>Elasticsearch cluster</strong>: Stores and indexes the searchable data</p></li></ol><h3>Step-by-step workflow walkthrough</h3><ol><li><p>User authenticates using an authentication mechanism such as OAuth.</p></li><li><p>User access secured Client application running in a Customer AWS account using authenticated credentials.</p></li><li><p>The client application invokes a Supervisor Agent that further invokes and orchestrates other Agents.</p></li><li><p>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.</p></li><li><p>Foundation Models are available for the agentic AI application through Amazon Bedrock.</p></li><li><p>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.</p></li><li><p>Supervisor Agent responds back to the end user via the Client Application.</p></li></ol><h2>Implementation guide</h2><p>Please refer to <a href="https://github.com/aws-samples/aws-generativeai-partner-samples/tree/main/elastic/mcp/elastic-mcp-on-agentcore">this GitHub repo</a> to get a hands-on experience of how this solution can be implemented. Pay close attention to the <a href="https://github.com/aws-samples/aws-generativeai-partner-samples/tree/main/elastic/mcp/elastic-mcp-on-agentcore#-prerequisites">prerequisites</a> before getting started.</p><h3>Step 1: Deploy Elastic MCP server to ECR</h3><p>The <a href="https://github.com/aws-samples/aws-generativeai-partner-samples/blob/main/elastic/mcp/elastic-mcp-on-agentcore/deploy-elastic-mcp.sh">automated deployment script</a> handles the entire container build and upload process:</p>./deploy-elastic-mcp.sh<p>Here is what the script does when you execute:</p><ol><li><p>Downloads the official Elastic MCP server repository</p></li><li><p>Builds Docker container using <code>Dockerfile-8000</code></p></li><li><p>Creates ECR repository with image scanning enabled</p></li><li><p>Uploads container image to ECR with proper tagging</p></li></ol><h3>Step 2: Create AgentCore Runtime host</h3><p>Navigate to the AWS Console and configure your AgentCore Runtime:</p><p>1. Access AgentCore: Go to Amazon Bedrock AgentCore &gt; Build and Deploy &gt; Agent Runtime &gt; Host Agent</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt4750c7fd2c1cdc5c/6a17f3062f4a5c7105fa8a1a/6818bafc00fdcba4c311b8ea1199c3d4ba9e979c-1428x396.png" alt="" /><p>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.</p>   Name: hosted_agent_elastic_mcp
   Container Image: [ECR URI from Step 1]
<img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt22fa13daf65713e3/6a17f30896142a918aeb1c29/beea587f4d1c022216c03f8f2895072c7075c1aa-1600x654.png" alt="" /><p>3. Service role: Choose "Create and use a new service role"</p><p>4. Protocol settings: Choose MCP, and for the Inbound Identity, select <code>Use IAM username</code></p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltc4e24abbc56b21b2/6a17f309414c647a149452a9/a0cc50ebdfaf657cb2a5fbb0e60f1b5b45aa60fe-1600x505.png" alt="" /><p>5. Environment variables: Finally, configure your Elasticsearch endpoints and pass them as environment variables to your Docker container.</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltdec0c051b141511c/6a17f30b414c6499b59452ad/b3c1e97513b516bf5604c87950811a444b93745e-1432x358.png" alt="" /><p>6. After creating the host agent, go ahead and copy the Agent Runtime ARN from the "View invocation code" section. Here is an example:</p>arn:aws:bedrock-agentcore:us-west-2:XXXXXXXXXX:runtime/hosted_agent_elastic_mcp-xWSaxNGjf5<img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blte88f4a7205373342/6a17f30d96142a177feb1c2d/27330cf1d735d1240f4ce292f032d0a22cf6d986-1600x651.png" alt="" /><h3>Step 3: Configure Python client</h3><p><strong>Install dependencies:</strong></p><p>Go ahead and initialize a virtual environment and install the Python libraries.</p>python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt<p>Update Agent ARN in <code>my_mcp_client_remote.py</code>:</p><p>Next, update the Python MCP client with the agent ARN you obtained in the previous steps.</p>agent_arn = "arn:aws:bedrock-agentcore:us-west-2:XXXXXXXX:runtime/hosted_agent_elastic_mcp-xWSbYNGjf5"<p>Here are the key client components in this Python file.</p><p><strong>AWS authentication class:</strong></p>class AWSAuth:
    def __init__(self, service='bedrock-agentcore', region='us-west-2'):
        self.session = boto3.Session()
        self.credentials = self.session.get_credentials()
        self.region = region
        self.service = service
        
    def get_auth_headers(self, url, method='POST', body=None):
        request = AWSRequest(method=method, url=url, data=body)
        SigV4Auth(self.credentials, self.service, self.region).add_auth(request)
        return dict(request.headers)<p><strong>MCP request formation / payload:</strong></p>chat_request = {
    "jsonrpc": "2.0",
    "id": 3,
    "method": "tools/call",
    "params": {
        "name": "search",
        "arguments": {
            "index": "events",
            "query_body": {
                "query": {
                    "bool": {
                        "should": [
                            {"match": {"name": "paris"}},
                            {"match": {"description": "paris"}},
                            {"match": {"venue": "paris"}},
                            {"match": {"address": "paris"}}
                        ]
                    }
                },
                "size": 10
            }
        }
    }
}<h3>Step 4: Run the client</h3><p>Execute the <a href="https://github.com/aws-samples/aws-generativeai-partner-samples/blob/main/elastic/mcp/elastic-mcp-on-agentcore/my_mcp_client_remote.py">Python client</a> 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: <code>test_mcp_endpoint()</code> and <code>chat_with_agentcore()</code>. 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.</p><p>The program uses the <code>httpx</code> 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 <code>AWSAuth</code> 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.</p>python my_mcp_client_remote.py<h2>Use case demonstrations</h2><h3>Use case 1: Data discovery</h3><p>Scenario: Finding events in a specific city using natural language.</p><p>Query: "Events in Paris"</p><p>MCP request: Here is the payload you supply to the Amazon Bedrock Agentcore Runtime.</p>{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "search",
    "arguments": {
      "index": "events",
      "query_body": {
        "query": {
          "bool": {
            "should": [
              {"match": {"name": "paris"}},
              {"match": {"description": "paris"}},
              {"match": {"venue": "paris"}},
              {"match": {"address": "paris"}}
            ]
          }
        }
      }
    }
  }
}<p><strong>Response</strong>: And here is the response you get after Elastic’s MCP server runs a query in Elastic Search AI Platform and returns the result.</p>🎉 I found 1 events in Paris:


1. Paris Fashion Week
   📍 Murray-Howell Theater - 17814 Mills Mountains Apt. 815, Poncetown, DE 29241
   📅 2026-04-02
   📝 Major fashion event showcasing the latest collections from top designers.
   💰 $$$
   🎫 https://tickets.reed.net/event/DEST0001_EVT002<h3>Use case 2: Elastic MCP tool discovery</h3><p><strong>Scenario</strong>: Discovering the available MCP tools that Elastic’s MCP server offers.</p><p><strong>MCP request:</strong></p>{
  "jsonrpc": "2.0",
  "method": "tools/list",
  "id": 1
}<p>This returns a list of available tools that the MCP server provides, enabling dynamic tool discovery.</p><h3>Use case 3: Complex search queries</h3><p><strong>Scenario</strong>: Advanced filtering with multiple criteria.
You can run more advanced Elastic Search Query Language based queries, like one shown below.</p><p><strong>Query</strong>: Events with specific price ranges, dates, and categories.</p><p><strong>MCP request:</strong></p>{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "search",
    "arguments": {
      "index": "events",
      "query_body": {
        "query": {
          "bool": {
            "must": [
              {"range": {"start_date": {"gte": "2026-01-01"}}},
              {"term": {"price_range": "$$$"}}
            ],
            "should": [
              {"match": {"type": "Fashion"}},
              {"match": {"type": "Music"}}
            ]
          }
        },
        "size": 20
      }
    }
  }
}<h2>How it works (technical deep dive)</h2><h3>MCP implementation</h3><p>The Model Context Protocol uses JSON-RPC 2.0 format for all communications:</p>Client Request → AgentCore → MCP Server → Elasticsearch → Response Chain<p><strong>Key protocol features:</strong></p><ul><li><p>Stateless operation: Each request is independent with session isolation</p></li><li><p>Tool discovery: Dynamic discovery of available capabilities</p></li><li><p>Structured responses: Consistent response format across all tools</p></li><li><p>Error handling: Standardized error reporting and recovery</p></li></ul><p><strong>AWS authentication flow:</strong></p># 1. Create AWS request object
request = AWSRequest(method='POST', url=mcp_url, data=body)


# 2. Apply SigV4 authentication
SigV4Auth(credentials, 'bedrock-agentcore', region).add_auth(request)


# 3. Extract headers for HTTP client
headers = dict(request.headers)
headers["Content-Type"] = "application/json"
headers["Accept"] = "application/json, text/event-stream"<h3>Session management</h3><p>AgentCore automatically adds <code>Mcp-Session-Id</code> headers for session isolation:</p><ul><li><p>Each client session gets a unique identifier</p></li><li><p>Stateless servers can maintain conversation context</p></li><li><p>Automatic cleanup of inactive sessions</p></li></ul><h3>Response processing pipeline</h3><ol><li><p>Server-Sent Events (SSE): Responses come as <code>data: {...}</code> in JSON format</p></li><li><p>JSON parsing: Extract JSON from SSE wrapper</p></li><li><p>Content extraction: Parse the MCP result structure</p></li><li><p>Data formatting: Convert Elasticsearch results to user-friendly format</p></li></ol># Parse SSE response
if response.text.startswith('data: '):
    json_part = response.text[6:]  # Remove 'data: ' prefix
    response_json = json.loads(json_part)
    
    # Extract search results
    result = response_json.get('result', {})
    for content_item in result['content']:
        if content_item['type'] == 'text':
            # Process and format results
            search_results = json.loads(content_item['text'])<h3>Cleanup</h3><p>After you have played around with this setup, if you would like to clean up the environment, please follow the steps outlined below.</p><p><strong>Delete AgentCore Runtime:</strong></p><ol><li><p>Navigate to Amazon Bedrock AgentCore in AWS Console</p></li><li><p>Select your agent runtime</p></li><li><p>Click "Delete" and confirm</p></li></ol><p><strong>Remove ECR repository:</strong></p>aws ecr delete-repository \
    --repository-name elastic-mcp-server \
    --region us-west-2 \
    --force<p><strong>Clean local environment:</strong></p># Remove virtual environment
deactivate
rm -rf venv

# Remove cloned repository
rm -rf mcp-server-elasticsearch

# Remove Docker images
docker rmi elastic-mcp-server:latest
docker rmi [ECR_URI]:latest<h2>Conclusion</h2><p>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.</p><p>Key takeaways include:</p><ul><li><p>Seamless integration: MCP protocol enables natural language querying of complex data</p></li><li><p>Production scalability: AgentCore provides enterprise-grade hosting with minimal configuration</p></li><li><p>Developer productivity: Transform local prototypes to production with minimal code changes</p></li><li><p>Security first: Built-in AWS security and authentication mechanisms</p></li></ul><p>Potential applications can be in any of the following areas of implementation: </p><ul><li><p>Customer support: Natural language querying of support ticket databases</p></li><li><p>Business intelligence: Conversational analytics for business metrics</p></li><li><p>Content discovery: Intelligent search across document repositories</p></li><li><p>IoT data analysis: Natural language queries for sensor and telemetry data</p></li></ul><p>Additional resources:</p><ul><li><p><a href="https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-amazonbedrock">Amazon Bedrock integration documentation</a></p></li><li><p><a href="https://github.com/elastic/mcp-server-elasticsearch?tab=readme-ov-file#elasticsearch-mcp-server">Elastic MCP server documentation</a></p></li></ul>]]></content:encoded>
    <link>https://www.elastic.co/search-labs/blog/elastic-mcp-server-amazon-bedrock-agentcore-runtime</link>
    <guid isPermaLink="true">https://www.elastic.co/search-labs/blog/elastic-mcp-server-amazon-bedrock-agentcore-runtime</guid>
    <category><![CDATA[AI]]></category>
    <dc:creator><![CDATA[Udayasimha Theepireddy,Srinivas Pendyala,Matt Ryan,Ganesh Ramesh Shenoy]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt576d87464937da1e/6a17f30e0b0bed0469dd36b1/7086754859ba2cbbaf673c843013462892738c30-720x420.jpg" length="0" type="image/jpeg"/>
    <pubDate>Thu, 04 Sep 2025 00:00:00 GMT</pubDate>
  </item>
  </channel>
</rss>