{
  "markdown": "The official Elasticsearch extension for the [Gemini CLI](https://github.com/google-gemini/gemini-cli) to search, retrieve, and analyze Elasticsearch data in developer and agentic workflows.\n\nConnects directly to Elasticsearch using:\n- Model Context Protocol (MCP)\n- Agent Skills (using the `skills.js` script)\n\n> [!CAUTION]\n> This extension is currently experimental.\n\n## Installation & Setup\n\n1. Install the **elasticsearch** extension:\n    ```sh\n    gemini extensions install https://github.com/elastic/gemini-cli-elasticsearch\n    ```\n2. To use the Elastic Agent Builder MCP server (on Elastic Serverless or 9.3+) you need [your MCP server URL](https://www.elastic.co/docs/explore-analyze/ai-features/agent-builder/tools#copy-your-mcp-server-url):\n    - Get your MCP server URL from **Agents > View all tools > Manage MCP > Copy MCP Server URL**\n    - The URL will look like: `https://your-deployment.kb.region.gcp.elastic.cloud/api/agent_builder/mcp`\n\n3. You need an API key. If you are running Elasticsearch with [start-local](https://github.com/elastic/start-local) you already have the API key in the start-local `.env` file.\n   Otherwise, you can create a [standard Elasticsearch API key](https://www.elastic.co/docs/deploy-manage/api-keys/elasticsearch-api-keys):\n    - In Kibana: **Stack Management > Security > API Keys > Create API key**\n    - Copy the **encoded** API key value\n\n4. Set the required environment variables in your shell:\n\n    ```sh\n    export ELASTIC_URL=\"your-elasticsearch-url\"\n    export ELASTIC_MCP_URL=\"your-elasticsearch-mcp-url\"\n    export ELASTIC_API_KEY=\"your-encoded-api-key\"\n    ```\n\n    To make these permanent, add them to your shell config file (`~/.bashrc`, `~/.zshrc`, `~/.config/fish/config.fish`, etc.)\n\n5. Verify the extension is installed and active:\n\n    ```sh\n    gemini extensions list\n    ```\n\n6. Verify the MCP server connection:\n\n    ```sh\n    gemini mcp list\n    ```\n    \n    You should see `✓ elastic-agent-builder ... - Connected`\n\n7. (Optional) Install Agent Skills using the `skills.js` script -- see [Install Elastic Skills](#install-elastic-skills) below.\n\n8. Test with a query using MCP:\n\n    ```sh\n    gemini chat \"list my elasticsearch indices\"\n    ```\n\n## Usage with MCP\n\nOnce installed with an active connection to the Elasticsearch MCP server, the **elasticsearch** extension automatically invokes available Tools as part of your natural language query input (where each Tool invocation is displayed as part of the CLI output response).\n\n### Example Queries\n\n```sh\ngemini chat \"show me all my elasticsearch indices\"\ngemini chat \"search for documents about 'error' in my logs\"\ngemini chat \"what fields are in my user-data index?\"\ngemini chat \"show me the top 10 error codes from my logs this week\"\n```\n\n### Available Tools\n\n| Tool | Description |\n| -------- | -------- |\n| `platform_core.search` | Used for finding documents, counting, aggregating, or summarizing data from a known index. Supports both full-text relevance searches and structured analytical queries. |\n| `platform_core.get_document_by_id` | Retrieve the full content (source) of an Elasticsearch document based on its ID and index name. |\n| `platform_core.get_index_mapping` | Retrieve mappings for the specified index or indices. |\n| `platform_core.index_explorer` | List relevant indices, aliases and datastreams based on a natural language query. |\n| `platform_core.list_indices` | List the indices, aliases and datastreams from the Elasticsearch cluster. |\n| `platform_core.execute_esql` | Execute an ES\\|QL query and return the results in a tabular format. |\n| `platform_core.generate_esql` | Generate an ES\\|QL query from a natural language query. |\n\n### Available commands\n\nThis extension exposes Gemini commands to directly call MCP tools.\n\n| Command | Description |\n| ------- | ----------- |\n| `/elastic:list-indices` | List the indices, aliases and datastreams from the Elasticsearch cluster. |\n| `/elastic:explore-indices` | List relevant indices, aliases and datastreams based on a natural language query. |\n| `/elastic:get-mapping` | Retrieve mappings for the specified index or indices. |\n| `/elastic:search-dsl`| Search the Elasticsearch cluster using DSL queries |\n| `/elastic:search-esql` | Search the Elasticsearch cluster using ES\\|QL queries generated by the MCP server |\n\n## Troubleshooting\n\n**If `gemini mcp list` shows \"Disconnected\":**\n- Verify environment variables are set: `echo $ELASTIC_MCP_URL` and `echo $ELASTIC_API_KEY`\n- Open a new terminal window to reload environment variables\n- Check Agent Builder is enabled in Kibana\n- Verify your API key hasn't expired\n\n**Authentication errors:**\n- Ensure you're using the **encoded** API key format\n- Check the key has proper permissions in Kibana\n\n## Install Elastic Skills\n\nFrom version 0.3.0+, the Elastic skills are not automatically installed in the Gemini extension. We released a dedicated [elastic/agent-skills](https://github.com/elastic/agent-skills) repository, which provides skills for Elasticsearch, Kibana, Observability, Security, and Elastic Cloud.\n\nYou can list, select and install the Elastic skills using the following terminal command:\n\n```sh\nnode ~/.gemini/extensions/elasticsearch/skills.js --install --interactive\n```\n\nIf you are in the Gemini CLI terminal, remember to use `!` as a prefix for the command.\n\nFor more information about the `skills.js` script you can read the [dedicated page](SKILLS_INSTALL.md).\n\n## Disabling MCP when using skills\n\nSince some skills may overlap with the tools available on the `elastic-agent-builder` MCP server, you can disable it:\n\n```sh\n/mcp disable elastic-agent-builder\n```\n\nTo re-enable it: `/mcp enable elastic-agent-builder`\n\n## Support\n\nFor more help, see the [Elastic Community Forums](https://discuss.elastic.co/)\n\n## License\n\nThis software is licensed under the [Apache License 2.0](./LICENSE). See [NOTICE](./NOTICE).",
  "bytes": 5897,
  "sha": "8005e2fc7827e3315f63a4fce152344c4cf715bc623b1fe5150f32eb6ba95312",
  "repo_slug": "elastic/gemini-cli-elasticsearch",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/plg_elastic_gemini_cli_elasticsearch_f90266fa/readme"
}