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.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"index": "<index>"
},
"name": "get_index_mappings"
}
}Input 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)}