get_index_mappings
Retrieve the field mappings and data structure definitions for a specified Elasticsearch index to understand its schema and data organization.
Instructions
Get the mappings of a specific Elasticsearch index.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| index | Yes |
Implementation Reference
- tools/elastic_tool.py:49-58 (handler)The handler function for the 'get_index_mappings' tool, decorated with @mcp.tool(). It retrieves the mappings for a specified Elasticsearch index using es.indices.get_mapping() and returns them or an error dictionary.@mcp.tool() def get_index_mappings(index: str) -> dict: """Get the mappings of a specific Elasticsearch index.""" try: mappings = es.indices.get_mapping(index=index) return mappings.get(index, {}) except Exception as e: logger.error(f"Error getting mappings for index '{index}': {e}") return {"error": str(e)}