# Elasticsearch — how to use (mcp.ai)

Connect your Elasticsearch account and use 4 tools for databases straight from your AI agent. Connect with your own API key. Elasticsearch is a distributed, RESTful search and analytics engine capable of addressing a growing number of use cases. It provides real-time search and analytics for all types of data.

## Option A — via MCP (recommended)
Remote MCP endpoint (HTTP, streamable): `https://api.mcp.ai/p_elasticsearch?ms=1787296020000`
Add it as a custom/remote MCP connector in your client (Claude, Cursor, VS Code…), then authenticate when prompted. Once connected, ask the agent to use the server's tools (e.g. `elasticsearch_get_index_schema`).

## Option B — via direct REST API
Base URL: `https://api.mcp.ai/api/elasticsearch`
Auth: `Authorization: Bearer sk_live_…` — create a workspace API key at https://mcp.ai/settings/api-keys
Discover endpoints: `GET https://api.mcp.ai/api/elasticsearch/_endpoints`

### Endpoints
- `POST https://api.mcp.ai/api/elasticsearch/get/index/schema` — Tool to get the complete schema/mapping of a specific Elasticsearch index. Use when you need to understand the structure, field types, and mappings of an index.
  - body: { index_name: string }
- `POST https://api.mcp.ai/api/elasticsearch/list/indices` — Tool to list all available Elasticsearch indices. Use when you need to get a list of indices in your Elasticsearch cluster, optionally filtering by pattern, health status, or other criteria.
  - body: { index?: string, health?: string, sort_by?: string, expand_wildcards?: string, include_primary_shards_only?: boolean }
- `POST https://api.mcp.ai/api/elasticsearch/ping/cluster` — Tool to ping the Elasticsearch cluster and check if it is running. Use when you need to verify cluster connectivity and health status before performing operations.
- `POST https://api.mcp.ai/api/elasticsearch/query/index` — Tool to query an Elasticsearch index with various filters, time ranges, and pagination support. Use when you need to search for documents in an index with complex filtering criteria.
  - body: { from?: integer, size?: integer, sort?: object[], query?: string, fields?: string[], highlight?: boolean, index_name: string, time_filter?: object, term_filters?: object[], range_filters?: object[], include_aggregations?: boolean }

## Example prompts
- "What can I do in Elasticsearch?"
- "Show me a summary of my Elasticsearch account"

## More
- Page: https://mcp.ai/elasticsearch
- Agent spec (llms.txt): https://mcp.ai/elasticsearch/llms.txt
- Postman collection: https://mcp.ai/elasticsearch/postman.json
