get_index_templates
Retrieve index template configurations from OpenSearch clusters to manage and analyze data structure settings.
Instructions
Get index template configurations
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The main handler function for the 'get_index_templates' tool. It performs a GET request to '/_index_template' using the OpenSearch client, filters the response, and returns the templates as TextContent objects or an error message.@mcp.tool(description="Get index template configurations") async def get_index_templates() -> list[TextContent]: """ Get index templates and their configurations. Returns template names and their configured number of shards. This helps understand how new indices will be created. """ self.logger.info("Fetching index templates...") try: response = self.es_client.transport.perform_request( 'GET', '/_index_template', params={'filter_path': ' _index_template?filter_path=index_templates.name,index_templates.index_template.index_patterns,index_templates.index_template.template.settings.index.number_of_shards'} ) return [TextContent(type="text", text=str(response))] except Exception as e: self.logger.error(f"Error fetching index templates: {e}") return [TextContent(type="text", text=f"Error: {str(e)}")]
- src/opensearch_mcp_server/server.py:40-40 (registration)Calls register_tools on the AdminIndexTools instance, which defines and registers the 'get_index_templates' tool via decorators inside its register_tools method.admin_index_tools.register_tools(self.mcp)