Skip to main content
Glama
Octodet

octodet-elasticsearch-mcp

get_templates

Retrieve index templates from Elasticsearch, optionally filtered by name, to manage and organize data structure configurations efficiently.

Instructions

Get index templates from Elasticsearch

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameNoOptional template name filter

Implementation Reference

  • The handler function for the 'get_templates' tool. It calls esService.getIndexTemplates(name), formats the templates as JSON text response, and handles errors.
    async ({ name }) => { try { const templates = await esService.getIndexTemplates(name); return { content: [ { type: "text", text: `Index Templates:` }, { type: "text", text: JSON.stringify(templates, null, 2) }, ], }; } catch (error) { console.error( `Failed to get templates: ${ error instanceof Error ? error.message : String(error) }` ); return { content: [ { type: "text", text: `Error: ${ error instanceof Error ? error.message : String(error) }`, }, ], }; } }
  • Input schema for the 'get_templates' tool, defining an optional 'name' string parameter to filter templates.
    { name: z.string().optional().describe("Optional template name filter"), },
  • src/index.ts:1078-1111 (registration)
    Registration of the 'get_templates' tool using server.tool(), specifying name, description, input schema, and handler.
    server.tool( "get_templates", "Get index templates from Elasticsearch", { name: z.string().optional().describe("Optional template name filter"), }, async ({ name }) => { try { const templates = await esService.getIndexTemplates(name); return { content: [ { type: "text", text: `Index Templates:` }, { type: "text", text: JSON.stringify(templates, null, 2) }, ], }; } catch (error) { console.error( `Failed to get templates: ${ error instanceof Error ? error.message : String(error) }` ); return { content: [ { type: "text", text: `Error: ${ error instanceof Error ? error.message : String(error) }`, }, ], }; } } );
  • Helper method in ElasticsearchService that performs the actual Elasticsearch API call to retrieve index templates using client.indices.getIndexTemplate.
    async getIndexTemplates(name?: string): Promise<any> { return await this.client.indices.getIndexTemplate({ name, }); }

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