Skip to main content
Glama
cr7258

Elasticsearch MCP Server

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
NameRequiredDescriptionDefault
bodyNo
indexYes

Implementation Reference

  • 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)
  • 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)
  • 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 """
  • 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()

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cr7258/elasticsearch-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server