Skip to main content
Glama
rishab2404

Elasticsearch MCP Server

by rishab2404

get_mappings

Retrieve field mappings for a specified Elasticsearch index to understand its structure and data types, enabling accurate querying and data analysis.

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

  • The handler function for the 'get_mappings' tool. It takes an index name, calls esClient.indices.getMapping(index), and returns the mappings in a formatted text response, with error handling.
    async ({ index }) => { console.error("[DEBUG] get_mappings tool called", index); try { const mappingResponse = await esClient.indices.getMapping({ index, }); return { content: [ { type: "text" as const, text: `Mappings for index: ${index}`, }, { type: "text" as const, text: `Mappings for index ${index}: ${JSON.stringify( mappingResponse[index]?.mappings || {}, null, 2 )}`, }, ], }; } catch (error) { console.error( `Failed to get mappings: ${ error instanceof Error ? error.message : String(error) }` ); return { content: [ { type: "text" as const, text: `Error: ${ error instanceof Error ? error.message : String(error) }`, }, ], }; } }
  • Input schema for the 'get_mappings' tool, defining the required 'index' parameter as a non-empty trimmed string.
    index: z .string() .trim() .min(1, "Index name is required") .describe("Name of the Elasticsearch index to get mappings for"), },
  • index.ts:177-228 (registration)
    Registration of the 'get_mappings' tool using server.tool(), including name, description, input schema, and handler function.
    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 }) => { console.error("[DEBUG] get_mappings tool called", index); try { const mappingResponse = await esClient.indices.getMapping({ index, }); return { content: [ { type: "text" as const, text: `Mappings for index: ${index}`, }, { type: "text" as const, text: `Mappings for index ${index}: ${JSON.stringify( mappingResponse[index]?.mappings || {}, null, 2 )}`, }, ], }; } catch (error) { console.error( `Failed to get mappings: ${ error instanceof Error ? error.message : String(error) }` ); return { content: [ { type: "text" as const, text: `Error: ${ error instanceof Error ? error.message : String(error) }`, }, ], }; } } );

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/rishab2404/mcp_es'

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