create_index
Create a new Elasticsearch index with custom mappings and settings to organize and store data for search and analysis.
Instructions
Create a new index.
Args:
index: Name of the index
body: Optional index configuration including mappings and settings
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| index | Yes | ||
| body | No |
Implementation Reference
- src/tools/index.py:25-34 (handler)The MCP tool handler for 'create_index', decorated with @mcp.tool(). It creates a new index by calling the search client's create_index method.@mcp.tool() def create_index(index: str, body: Optional[Dict] = None) -> Dict: """ Create a new index. Args: index: Name of the index body: Optional index configuration including mappings and settings """ return self.search_client.create_index(index=index, body=body)
- src/server.py:41-53 (registration)Top-level registration where IndexTools (containing create_index) is included in tool_classes and registered via ToolsRegister.register = ToolsRegister(self.logger, self.search_client, self.mcp) # Define all tool classes to register tool_classes = [ IndexTools, DocumentTools, ClusterTools, AliasTools, DataStreamTools, GeneralTools, ] # Register all tools register.register_all_tools(tool_classes)
- src/clients/common/index.py:14-16 (helper)Helper method in IndexClient that implements the low-level index creation delegated by the MCP tool handler.def create_index(self, index: str, body: Optional[Dict] = None) -> Dict: """Creates an index with optional settings and mappings.""" return self.client.indices.create(index=index, body=body)
- src/tools/index.py:9-10 (registration)IndexTools.register_tools method where the @mcp.tool() decorators register the create_index tool (and others) with the MCP instance.def register_tools(self, mcp: FastMCP): @mcp.tool()