Skip to main content
Glama
Octodet

octodet-elasticsearch-mcp

get_mappings

Retrieve field mappings for a specified Elasticsearch index to understand its data structure and schema. Input the index name to access detailed mappings.

Instructions

Get field mappings for a specific Elasticsearch index

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
indexYesName of the Elasticsearch index to get mappings for

Implementation Reference

  • Handler function that executes the get_mappings tool: calls esService.getMappings(index), formats success/error response with JSON mappings.
    async ({ index }) => { try { const mappings = await esService.getMappings(index); return { content: [ { type: "text", text: `Mappings for index: ${index}`, }, { type: "text", text: JSON.stringify(mappings, null, 2), }, ], }; } catch (error) { console.error( `Failed to get mappings: ${ error instanceof Error ? error.message : String(error) }` ); return { content: [ { type: "text", text: `Error: ${ error instanceof Error ? error.message : String(error) }`, }, ], }; } }
  • Input schema for get_mappings tool: requires 'index' string parameter.
    { index: z .string() .trim() .min(1, "Index name is required") .describe("Name of the Elasticsearch index to get mappings for"), },
  • src/index.ts:144-188 (registration)
    Registration of the get_mappings tool using server.tool(name, description, schema, handler).
    server.tool( "get_mappings", "Get field mappings for a specific Elasticsearch index", { index: z .string() .trim() .min(1, "Index name is required") .describe("Name of the Elasticsearch index to get mappings for"), }, async ({ index }) => { try { const mappings = await esService.getMappings(index); return { content: [ { type: "text", text: `Mappings for index: ${index}`, }, { type: "text", text: JSON.stringify(mappings, null, 2), }, ], }; } catch (error) { console.error( `Failed to get mappings: ${ 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 calls the Elasticsearch indices.getMapping API and extracts mappings for the given index.
    async getMappings(index: string): Promise<any> { const response = await this.client.indices.getMapping({ index, }); return response[index]?.mappings || {}; }

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