list_index_patterns
Retrieve OpenSearch Dashboards index patterns to organize and access data across your OpenSearch cluster for efficient data management.
Instructions
List OpenSearch Dashboards index patterns2
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The handler function for the 'list_index_patterns' tool. It searches the '.kibana' index for 'index-pattern' objects and returns a JSON list of their titles and IDs, or an error message.@mcp.tool(description="List OpenSearch Dashboards index patterns2") async def list_index_patterns() -> list[TextContent]: """ Find all index pattern IDs stored in the .kibana index. Especially useful for identifying the correct index pattern ID to use in the Discover view URL. This function queries the .kibana index for saved objects of type 'index-pattern' and returns a list of their titles and IDs. Returns: list[TextContent]: A list containing the found index patterns or an error message. """ self.logger.info("Searching for index patterns") try: response = self.es_client.search( index=".kibana", body={ '_source': ['index-pattern.title', '_id'], 'query': { 'term': { 'type': 'index-pattern' } } } ) patterns = json.dumps([{hit["_source"]["index-pattern"]["title"]: hit["_id"].replace('index-pattern:', '')} for hit in response["hits"]["hits"]], indent=4) return [TextContent(type="text", text=(patterns))] except Exception as e: self.logger.error(f"Error finding index patterns: {e}") return [TextContent(type="text", text=f"Error: {(e)}")]
- src/opensearch_mcp_server/server.py:39-39 (registration)Registration call for DashboardTools in the main server, which registers the list_index_patterns tool among others.dashboard_tools.register_tools(self.mcp)
- src/opensearch_mcp_server/server.py:31-31 (registration)Instantiation of DashboardTools class, prerequisite for registering its tools including list_index_patterns.dashboard_tools = DashboardTools(self.logger)