get_index_mappings
Retrieve the field structure and data types of an 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. It retrieves the mapping schema for a specified Elasticsearch index using the Elasticsearch client. Includes error handling and logging.@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)}
- tools/elastic_tool.py:49-49 (registration)The @mcp.tool() decorator registers the get_index_mappings function as an MCP tool.@mcp.tool()