create_index
Generate a new index in Elasticsearch clusters by specifying index name and optional configurations such as mappings and settings using this tool.
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 |
|---|---|---|---|
| body | No | ||
| index | Yes |
Implementation Reference
- src/tools/index.py:25-34 (handler)The primary handler function for the 'create_index' MCP tool, decorated with @mcp.tool(). It accepts an index name and optional body, then delegates to 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:44-53 (registration)Registration of IndexTools class (which defines create_index) by including it in the tool_classes list and calling register_all_tools on ToolsRegister.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/SearchClientBase that performs the actual index creation via the underlying client API, called by the 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:26-33 (schema)Input schema defined by function parameters (index: str, body: Optional[Dict]=None) and output Dict, with descriptive docstring.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 """
- src/tools/index.py:9-10 (registration)The register_tools method in IndexTools where all index-related tools, including create_index, are defined and registered using @mcp.tool() decorators.def register_tools(self, mcp: FastMCP): @mcp.tool()