search_index
Query Elasticsearch indices using natural language to retrieve specific data from your search 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:29-36 (handler)The handler function that implements the core logic of the 'search_index' tool, performing a search on the specified Elasticsearch index using the query string and returning the response or an error dictionary.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)}
- tools/elastic_tool.py:29-30 (schema)Input schema defined by type annotations: index (str), query (str); output: dict. Includes docstring describing the tool.def search_index(index: str, query: str) -> dict: """Search an Elasticsearch index with a simple query string."""
- tools/elastic_tool.py:28-28 (registration)Registers the search_index function as an MCP tool using the FastMCP decorator.@mcp.tool()