8000 feat(tool/elasticsearch-list-indices): add tool to list indices by yaroslav-koval · Pull Request #4569 · googleapis/mcp-toolbox · GitHub
[go: up one dir, main page]

Skip to content

feat(tool/elasticsearch-list-indices): add tool to list indices - #4569

Open
yaroslav-koval wants to merge 4 commits into
googleapis:mainfrom
yaroslav-koval:feat/elasticsearch-list-indices
Open

yaroslav-koval wants to merge 4 commits into
googleapis:mainfrom
yaroslav-koval:feat/elasticsearch-list-indices

Conversation

@yaroslav-koval
@yaroslav-koval yaroslav-koval commented Nov 21, 2026 •
Copy link
Copy Markdown
Contributor

Description

Adds the elasticsearch-list-indices tool: it lists the indices of a cluster.

Impact. Today an agent cannot find out which indices exist. The only Elasticsearch
tools run ES|QL, and ES|QL has no command to list indices, so the agent can only query
an index whose name it already knows. I use the ES MCP daily and this is one of the most
useful tools. I'll create a PR for index mappings later, so the agent can start with zero
knowledge about the cluster.

How it works. It takes patterns (like users,logs-*) and returns all the indices that match. With the default value * it lists all the indices.
output_format (simple or detailed) sets how many fields outputted. Indices
starting with . are listed only when a pattern starts with .. Read-only.

Changes.

  • Tool elasticsearch-list-indices and source method ListIndices are added.
  • list_indices is added to the elasticsearch prebuilt config.
  • Unit tests and an integration test are added. The integration test needs only Docker.
  • Docs: the tool page is created, the prebuilt config page is updated.

Security. patterns goes into the request path through esapi.CatIndicesRequest,
so the client escapes it. No credentials are logged. Auth checks are not overridden.

PR Checklist

  • Make sure you reviewed
    CONTRIBUTING.md
  • Make sure to open an issue as a
    bug/issue
    before writing your code! That way we can discuss the change, evaluate
    designs, and agree on the general idea
  • Ensure you have manually reviewed the entire diff before requesting a
    review
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)
  • Make sure to add ! if this involve a breaking change

Add the elasticsearch-list-indices tool so an agent can discover index names. It takes optional comma-separated names or wildcard patterns and an output_format (simple or detailed). Indices starting with a dot are listed only when a pattern starts with a dot.

The tool is added to the elasticsearch prebuilt config, with unit tests, an integration test and docs.
@yaroslav-koval
yaroslav-koval requested a review from a team as a code owner November 21, 2026 12:42
@gemini-code-assist gemini-code-assist Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new elasticsearch-list-indices tool to list the indices of an Elasticsearch cluster, supporting both simple and detailed output formats. It includes the tool implementation, configuration updates, documentation, and corresponding unit and integration tests. The review feedback highlights potential connection leaks in the integration tests due to unclosed response bodies from several Elasticsearch API requests (IndicesDeleteRequest, IndicesCreateRequest, and IndexRequest), which should be resolved by ensuring res.Body.Close() is called.

@yaroslav-koval
Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new elasticsearch-list-indices tool to list indices of an Elasticsearch cluster, including source implementation, unit and integration tests, prebuilt configurations, and documentation. Feedback on the changes suggests defining detailedColumns directly as a slice literal instead of using append at runtime to improve readability and avoid unnecessary allocation overhead.

@yaroslav-koval
Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new elasticsearch-list-indices tool to list the indices of an Elasticsearch cluster, along with its implementation, tests, and documentation. The reviewer suggested a performance optimization to precompute and reuse the column name slices as package-level variables to avoid redundant allocations on every tool invocation.

…ices

The names are derived once at package init from simpleColumns and detailedColumns, so they cannot drift.

googleapis#4569 (comment)
@yaroslav-koval
Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new elasticsearch-list-indices tool (named list_indices) to list the indices of an Elasticsearch cluster. The implementation includes adding the ListIndices method to the Elasticsearch source, registering the new tool, updating prebuilt configurations, and adding comprehensive documentation and tests. Feedback on the changes suggests defining the detailedColumns slice directly as a literal rather than appending to simpleColumns at runtime to improve code readability and maintainability.

@yaroslav-koval
Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment
Copy link
Co 8000 py Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new tool 'elasticsearch-list-indices' (name 'list_indices') to list the indices of an Elasticsearch cluster. It implements the 'ListIndices' method on the Elasticsearch source, adds the tool implementation, updates documentation, registers the tool in the prebuilt configurations, and adds comprehensive unit and integration tests. There are no review comments, and I have no feedback to provide.

@yaroslav-koval
Copy link
Copy Markdown
Contributor Author

Hey @duwenxin99, I resolved all the Gemini reviews, this PR is ready. Could you review it, please?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0