put_alias
Create or update an alias for a specific index in Elasticsearch clusters using the MCP server, enabling efficient index management with targeted configurations.
Instructions
Create or update an alias for a specific index.
Args:
index: Name of the index
name: Name of the alias
body: Alias configuration
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| body | Yes | ||
| index | Yes | ||
| name | Yes |
Implementation Reference
- src/tools/alias.py:24-34 (handler)The primary MCP tool handler for 'put_alias'. This decorated function defines the tool logic, input parameters via type hints, documentation, and delegates execution to the search client's put_alias method.@mcp.tool() def put_alias(index: str, name: str, body: Dict) -> Dict: """ Create or update an alias for a specific index. Args: index: Name of the index name: Name of the alias body: Alias configuration """ return self.search_client.put_alias(index=index, name=name, body=body)
- src/clients/common/alias.py:14-16 (helper)Supporting client method in AliasClient that implements the put_alias operation by calling the underlying Elasticsearch/OpenSearch client's indices.put_alias API.def put_alias(self, index: str, name: str, body: Dict) -> Dict: """Creates or updates an alias.""" return self.client.indices.put_alias(index=index, name=name, body=body)
- src/server.py:44-51 (registration)Server registration code where AliasTools class (containing put_alias) is included in the list of tool classes instantiated and registered via ToolsRegister.tool_classes = [ IndexTools, DocumentTools, ClusterTools, AliasTools, DataStreamTools, GeneralTools, ]