Skip to main content
Glama
seohyunjun

OpenSearch MCP Server

by seohyunjun

get_mapping

Retrieve index mappings from an OpenSearch cluster using this tool. Specify the index to fetch detailed schema and field definitions for efficient data management and query optimization.

Instructions

Get index mapping

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
indexYes

Implementation Reference

  • The get_mapping tool handler, decorated with @mcp.tool for registration. Fetches the index mapping from OpenSearch and returns it as TextContent.
    @mcp.tool(description="Get index mapping") async def get_mapping(index: str) -> list[TextContent]: """ Get the mapping for an index. It is important to always check the mappings to understand the exact field names and types before constructing queries or URLs. Args: index: Name of the index """ self.logger.info(f"Getting mapping for index: {index}") try: response = self.es_client.indices.get_mapping(index=index) return [TextContent(type="text", text=str(response))] except Exception as e: self.logger.error(f"Error getting mapping: {e}") return [TextContent(type="text", text=f"Error: {str(e)}")]
  • Calls register_tools on the IndexTools instance to register the get_mapping tool (and other index tools) with the MCP server.
    index_tools.register_tools(self.mcp)
  • Defines the tool schema: input 'index' as string, output list[TextContent], with description and Args docstring.
    async def get_mapping(index: str) -> list[TextContent]: """ Get the mapping for an index. It is important to always check the mappings to understand the exact field names and types before constructing queries or URLs. Args: index: Name of the index """
  • Instantiates the IndexTools class which contains the get_mapping tool implementation.
    index_tools = IndexTools(self.logger)

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/seohyunjun/opensearch-mcp-server'

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