跳过安装。2 分钟内即可运行。
在 cloud.anythingmcp.com 开始免费试用,一键添加 Elasticsearch,然后将你的 AI 客户端(Claude、ChatGPT、Copilot 或 Cursor)指向生成的 MCP 端点。无需 Docker,无需 git clone,无需任何工程经验。
摘要
让你的 AI 浏览和查询你在 Elastic Cloud、Serverless 或自有服务器上的 Elasticsearch 集群:列出索引和数据流,读取映射,搜索、聚合、计数,运行 ES|QL,并在你确认后写入文档。
试试这样问
Elasticsearch 的示例提示
点击任意提示即可复制,然后粘贴到 Claude、ChatGPT、Cursor、Gemini、Copilot 或 OpenClaw 中,在该连接器上运行。
Claude 是 AI,可能会出错。请核对回答。
💡 无需安装? 直接使用 cloud.anythingmcp.com。 登录、点击 Connectors → Elasticsearch、粘贴凭证、生成 MCP API key,即可完成。无 Docker、无
git clone、无本地服务器。
Elasticsearch + Cursor
让你的 AI 浏览和查询你在 Elastic Cloud、Serverless 或自有服务器上的 Elasticsearch 集群:列出索引和数据流,读取映射,搜索、聚合、计数,运行 ES|QL,并在你确认后写入文档。
前提条件
完整的设置说明已内置在连接器中 (在 store 中选择连接器时可见)。所需环境变量:
ELASTICSEARCH_URL, ELASTICSEARCH_API_KEY
步骤 1 — 获取凭证
- 找到 Elasticsearch 端点。Elastic Cloud Hosted:在
https://cloud.elastic.co打开部署,复制 Elasticsearch endpoint,例如https://my-deployment.es.europe-west3.gcp.cloud.es.io。Serverless:打开项目,复制它的 Elasticsearch 端点。自管集群:集群响应的 HTTPS 地址和端口,例如https://search.example.com:9200。把它粘贴到ELASTICSEARCH_URL,末尾不要带斜杠。请使用 Elasticsearch 端点,而不是 Kibana 地址。 - 在 Kibana 的 Stack Management → API keys → Create API key 中创建 API 密钥(Serverless:项目设置 → API keys)。为它命名,例如
anythingmcp,设置过期时间,并打开 Control security privileges 来限制权限(见下文)。 - 复制 Encoded 值(base64):Elastic 只显示一次。把它粘贴到
ELASTICSEARCH_API_KEY,然后安装连接器。单独的id或api_key值无法使用,也不支持用户名和密码登录。 - 用
elasticsearch_whoami检查设置:它不需要任何权限,会显示密钥属于谁。
集群部署位置:Elastic Cloud Hosted、Elastic Cloud Serverless 以及版本 8 及以上的自管集群。AnythingMCP Cloud 需要能通过互联网访问的集群;自托管的 AnythingMCP 在管理员允许该主机后,也可以访问你内网中的集群。
只读密钥(推荐):在 Kibana 表单中使用以下角色描述符,或在 Kibana 的 Dev Tools 中运行该请求,并从响应中复制 encoded:
POST /_security/api_key
{
"name": "anythingmcp-read",
"expiration": "365d",
"role_descriptors": {
"anythingmcp_read": {
"cluster": ["monitor"],
"indices": [
{ "names": ["*"], "privileges": ["read", "view_index_metadata", "monitor"] }
]
}
}
}
把 "*" 换成允许 AI 查看的索引模式,例如 ["products", "logs-*"]。read 涵盖搜索、计数、聚合、ES|QL 和单个文档;view_index_metadata 涵盖映射、别名和数据流;monitor 涵盖索引列表和集群健康状态。密钥的权限永远不会超过创建它的用户。
AI 能做什么:列出索引、别名和数据流;在查询前读取索引的字段映射;用 Query DSL 搜索(默认 10 条结果,每次最多 100 条);运行聚合,例如按值计数、求和、平均值和日期直方图;统计匹配数量;运行 ES|QL 查询获取表格结果(最多 500 行);读取单个文档。常见的向量字段不会出现在搜索结果中。在由 Elastic 托管集群的 Serverless 上无法查看集群健康状态。
写入前会先问你:elasticsearch_index_document 创建或整体替换文档,elasticsearch_update_document 修改文档的部分字段。每次调用前,AI 都会给你看索引、_id 和内容,并等你同意。两者都需要 write 权限,所以使用上面的只读密钥时会返回 403,这正是预期的安全保障。
安装时默认关闭:elasticsearch_delete_document 和 elasticsearch_delete_by_query。删除无法撤销,delete by query 可能删除数百万个文档。需要管理员有意识地开启;开启后,AI 会先统计匹配的文档数,并在删除前征求你的确认。
常见错误:401:密钥错误、过期或已失效,或者粘贴的是 id 而不是 Encoded 值。403 security_exception:密钥缺少消息中指出的权限。404 index_not_found_exception:索引名称不存在。400 parsing_exception 或 verification_exception:查询有错误;消息会指出字段或位置。429:集群过载;请稍候重试。
该连接器只与 Elasticsearch 通信,不连接 Kibana。它不会创建或删除索引,不会修改映射或设置,也不涉及快照、摄取管道、安全管理和 Bulk API。
步骤 2 — 安装 adapter
curl -fsSL https://raw.githubusercontent.com/HelpCode-ai/anythingmcp/main/docker-compose.quickstart.yml -o docker-compose.yml
printf 'JWT_SECRET=%s\nENCRYPTION_KEY=%s\n' "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" > .env
docker compose up -d
步骤 3 — 在 Cursor 中添加连接器
你的服务器 URL: 在 AnythingMCP 中打开 MCP Servers → 此连接器所在的服务器,复制它的 URL(
https://cloud.anythingmcp.com/mcp/…)。本指南中出现YOUR_SERVER_ID的地方都用它替换。
Cursor 从 ~/.cursor/mcp.json 读取 MCP 服务器。添加以下条目:
{
"mcpServers": {
"anythingmcp": {
"url": "https://cloud.anythingmcp.com/mcp/YOUR_SERVER_ID",
"headers": { "X-API-Key": "YOUR_MCP_API_KEY" }
}
}
}
- 在 AnythingMCP 的 MCP Servers → 你的服务器 → API keys 中创建 MCP API 密钥,并用它替换
YOUR_MCP_API_KEY。 - 保存文件并重启 Cursor。
- 打开 Cursor → Settings → MCP,确认
anythingmcp已列出并处于已连接状态。 - 开始对话,智能体现在可以调用
Elasticsearch的工具。
可用工具
| Tool | What it does |
|---|---|
elasticsearch_whoami | Show who the connector is signed in as: the user behind the API key, the key's name and id and the authentication type |
elasticsearch_cluster_info | Get basic information about the cluster: name, uuid, Elasticsearch version and build flavor (serverless on Elastic Cloud Serverless) |
elasticsearch_cluster_health | Get the cluster health: status (green, yellow or red), node counts, active, relocating, initializing and unassigned shards and pending tasks |
elasticsearch_list_indices | List indices with their health, status, document count, store size, primary and replica shard counts and creation date, sorted by name (at… |
elasticsearch_get_mapping | Get the field mapping of an index or data stream: every field with its type (text, keyword, date, long, dense_vector...) |
elasticsearch_search | Search an index, data stream or alias with the Query DSL and get the matching documents (total, and per hit _index, _id, _score, _source… |
elasticsearch_aggregate | Run aggregations over an index or data stream without returning documents: counts per value (terms), sums and averages, date histograms… |
elasticsearch_count | Count the documents in an index, data stream or alias that match a query (all documents without a query) |
elasticsearch_esql_query | Run an ES|QL query, a piped language for filtering, aggregating and joining (Elasticsearch 8.11 or later, and Serverless) |
elasticsearch_get_document | Get one document by its _id from an index: found, _version and the _source, optionally only some fields |
elasticsearch_list_aliases | List index aliases: alias name, the index it points to, whether it has a filter and whether it is the write index |
elasticsearch_list_data_streams | List data streams (time series such as logs and metrics): name, health status, index template, generation, number of backing indices… |
elasticsearch_index_document | Create or replace a whole document under a given _id in an index |
elasticsearch_update_document | Change some fields of an existing document by _id, leaving the others as they are (a partial update with doc) |
elasticsearch_delete_document | Delete one document by _id |
elasticsearch_delete_by_query | Delete every document that matches a query |
示例提示
- “我们有哪些索引?每个索引有多少文档、占多大空间?”
- “在 products 索引中搜索 100 欧元以下的无线耳机,显示名称、品牌和价格。”
- “用 ES|QL 统计 logs- 过去 24 小时内每台主机的错误数,显示前 10 名。”*
- “9 月份我们每天有多少订单?在 orders 索引上用日期直方图统计。”
- “把 products 索引中商品 4711 的 stock 字段设为 0。修改前先给我看要改的内容。”
FAQ
Cursor 免费套餐支持自定义 MCP 服务器吗? 支持,Hobby、Pro 和 Business 套餐均可使用 MCP。
下一步
这份指南对你有帮助吗?