search_index
Search an Elasticsearch index using a query string to retrieve data from Elasticsearch clusters through the Model Context Protocol.
Instructions
Search an Elasticsearch index with a simple query string.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| index | Yes | ||
| query | Yes |
Implementation Reference
- tools/elastic_tool.py:28-37 (handler)The handler function for the 'search_index' tool, decorated with @mcp.tool() for registration. It performs a search on an Elasticsearch index using the provided query string and returns the response or an error dictionary.@mcp.tool() def search_index(index: str, query: str) -> dict: """Search an Elasticsearch index with a simple query string.""" try: resp = es.search(index=index, query={"query_string": {"query": query}}) return resp except Exception as e: logger.error(f"Error searching index '{index}': {e}") return {"error": str(e)}