Skip to main content
Glama
Octodet

octodet-elasticsearch-mcp

delete_index

Remove a specific Elasticsearch index by specifying its name, ensuring streamlined data management and storage optimization.

Instructions

Delete an Elasticsearch index

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
indexYesName of the Elasticsearch index to delete

Implementation Reference

  • The handler function for the 'delete_index' MCP tool. It takes the index name, calls the esService.deleteIndex helper, and returns a success or error message in the expected MCP content format.
    async ({ index }) => { try { await esService.deleteIndex(index); return { content: [ { type: "text", text: `Index '${index}' deleted successfully.` }, ], }; } catch (error) { console.error( `Failed to delete index: ${ error instanceof Error ? error.message : String(error) }` ); return { content: [ { type: "text", text: `Error: ${ error instanceof Error ? error.message : String(error) }`, }, ], }; } }
  • Zod schema defining the input parameters for the 'delete_index' tool: a required trimmed string 'index' name.
    { index: z .string() .trim() .min(1, "Index name is required") .describe("Name of the Elasticsearch index to delete"), },
  • src/index.ts:991-1027 (registration)
    Registration of the 'delete_index' tool using server.tool(), including name, description, input schema, and handler function.
    server.tool( "delete_index", "Delete an Elasticsearch index", { index: z .string() .trim() .min(1, "Index name is required") .describe("Name of the Elasticsearch index to delete"), }, async ({ index }) => { try { await esService.deleteIndex(index); return { content: [ { type: "text", text: `Index '${index}' deleted successfully.` }, ], }; } catch (error) { console.error( `Failed to delete index: ${ error instanceof Error ? error.message : String(error) }` ); return { content: [ { type: "text", text: `Error: ${ error instanceof Error ? error.message : String(error) }`, }, ], }; } } );
  • Supporting helper method in the ElasticsearchService class that deletes the specified index using the Elasticsearch client.
    async deleteIndex(index: string): Promise<any> { return await this.client.indices.delete({ index, }); }

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/Octodet/elasticsearch-mcp'

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