Elastic MCP server: Expose Agent Builder tools to any AI agent

Discover how to use the built-in Elastic MCP server in Agent Builder to securely extend any AI agent with access to your private data and custom tools.

Elastic Agent Builder is a platform for creating tools and agents that are deeply integrated with your own data in Elasticsearch. For example, you can create tools that perform semantic search over internal documents, analyze observability logs, or query security alerts.

But the real magic happens when you can bring these custom, data-aware tools into the environments where you spend most of your time. What if your code editor agent could securely access your organization's private knowledge base?

That's where Model Context Protocol (MCP) comes in. Elastic Agent Builder ships with a built-in MCP server that provides access to the tools in the platform.

Why use the Elastic Agent Builder MCP server?

AI agents are incredibly powerful, but their knowledge is typically limited to the data they were trained on and information they can actively search on the public internet. They don't know about your company's internal design documents, your team's specific deployment runbooks, or the unique structure of your application logs.

The challenge is to give your AI assistant the specialized context it needs. This is precisely the problem MCP is designed to solve. MCP is an open standard that allows an AI model or agent to discover and use external tools.

To make this possible, the Elastic Agent Builder natively exposes your custom tools through a built-in MCP server. This means you can easily connect any MCP-compatible client, like Cursor, VS Code, or Claude Desktop, with the specialized, data-aware tools you've built with Elastic Agent Builder.

When to use MCP (and when not to)

Elastic Agent Builder includes several protocols to support different integration patterns. Choosing the right one is key to building effective AI workflows.

  • Use MCP to augment your AI agent (like in Cursor or VS Code) with specialized tools. It's the "bring your own tools" approach, enhancing the assistant you already use with secure access to your private data. Only the tools are exposed through the MCP server — Elastic’s agents are separate from that.
  • Use the A2A Protocol to let your complete custom Elastic Agent collaborate with other autonomous agents (like in Google's Gemini Enterprise). This is for agent-to-agent delegation, where each agent works as a peer to solve a problem.
  • Use the Agent Builder APIs for full programmatic control when building a custom application from scratch.

For a developer looking to get answers from their internal documentation without leaving their IDE, MCP is the perfect fit.

Example: your custom tools in Cursor with Agent Builder MCP server

Let's walk through a practical example that I use daily. First, I crawled and indexed our internal engineering documentation into an Elasticsearch index called elastic-dev-docs. While we could use the generic, built-in tools available in Agent Builder, we'll create our own custom tool to query this specific knowledge base.

The reason for building a custom tool is simple: control and precision. This approach gives us the power to run a fast, semantic query directly against our elastic-dev-docs index. We have full control over exactly which index is targeted and how the data is retrieved.

Now, here’s how we can use this custom knowledge base in an AI-powered code editor, like Cursor.

Step 1: Create a custom knowledge base tool in Agent Builder

First, create a new tool in Agent Builder. A clear and specific tool description is important because it's how any AI agent, whether it's the internal Elastic Agent or an external tool like Cursor connecting via MCP, discovers and selects your tool for the right task.

A strong description should be explicit. For example: “Performs a semantic search on the elastic-dev-docs index to find internal engineering documentation, runbooks, and release procedures.”

With that in place, the tool is configured to perform a semantic search against our specific index. Once saved, it's immediately available to be served.

Before connecting it to the outside world, you can test it directly in the UI. Simply click the Test button to manually fill in parameters, emulating what the LLM will do, and inspect the results to confirm everything is working correctly.

Step 2: Connect Cursor to the Elastic MCP server

Elastic Agent Builder automatically exposes all available tools via a secure MCP endpoint. You can find your unique server URL in the Tools UI within Kibana.

To connect to Cursor, we simply add this URL to its configuration file, along with an Elastic API Key for authentication (learn how to create ES API key). We use an API key for authorization, as it ensures the tools only execute with the permissions you've granted, respecting all your access control rules.

The MCP configuration in Cursor's ~/.cursor/mcp.json looks like this:

{
  "mcpServers": {
    "elastic-agent-builder": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "https://your-kibana.kb.company.io/api/agent_builder/mcp",
        "--header",
        "Authorization:${AUTH_HEADER}"
      ],
      "env": {
        "AUTH_HEADER": "ApiKey <ELASTIC_API_KEY>"
      }
    }
  }
}

Once the config is saved, you should see the Elastic Agent Builder MCP server tool available in Cursor.

Step 3: ask away!

With the connection established, Cursor agents can now invoke your custom tools to answer your questions or guide the code generation process.

Let’s ask a specific question:

“Lookup steps to release crawler service from engineering internal documentation from elastic search org”

Behind the scenes, the magic happens:

  1. Cursor agent decides how to answer your question in the best way, and decides to call the engineering_documentation_internal_search
  2. It invokes the tool with a natural language query
  3. The tool executes a semantic search against the elastic-dev-docs index and returns the most relevant, up-to-date procedures.

We get a precise, trustworthy answer based on our internal documentation, all without ever leaving the code editor. The experience is seamless and powerful.

Your turn to build

You've now seen how to use the built-in MCP server in Elastic Agent Builder to extend your AI assistants with secure access to your private data. Grounding models in your own information is key to making them truly useful.

To recap, we covered the core steps:

  • Choosing the right protocol for your needs (MCP).
  • Building a custom knowledge base tool.
  • Connecting that tool to an IDE assistant like Cursor.

Your agents and tools no longer need to be disconnected from their most valuable context. We hope this guide helps you create more effective, data-aware workflows. Happy building!

Level up your skills with our on-demand webinars: Agentic RAG using Elasticsearch and Intro to MCP with Elasticsearch MCP Server.

You can also take advantage of Elastic’s gen AI capabilities now by starting a free cloud trial or running Elasticsearch locally.

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