Skip to main content
Glama
seohyunjun

OpenSearch MCP Server

by seohyunjun

get_mapping

Retrieve index mapping details from OpenSearch to understand data structure and field definitions for effective querying and analysis.

Instructions

Get index mapping

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
indexYes

Implementation Reference

  • The handler function that implements the 'get_mapping' tool logic. It retrieves the mapping for the specified index using the OpenSearch client's indices.get_mapping method and returns it as a list of TextContent.
    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)}")]
  • The tool is registered within the IndexTools.register_tools method using the @mcp.tool decorator, providing the description and implicitly defining the schema from the function signature.
    @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)}")]
  • In the OpensearchMCPServer, an IndexTools instance is created and its register_tools method is called to register all tools from that module, including 'get_mapping', to the MCP server.
    index_tools.register_tools(self.mcp)
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Get index mapping' gives no information about whether this is a read-only operation, what permissions might be required, whether it has side effects, rate limits, or what format the response takes. For a tool with zero annotation coverage, this description fails to provide any behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise at just three words. While this represents under-specification rather than optimal conciseness, from a pure structural perspective, it's front-loaded with no wasted words. Every word earns its place, even though those words provide minimal information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of what appears to be an Elasticsearch-related tool (based on sibling tool names), no annotations, no output schema, and 0% schema description coverage, this description is completely inadequate. It doesn't explain what 'mapping' means in this context, what the tool returns, or how it differs from similar tools. The description fails to provide the necessary context for effective tool selection and invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description provides no information about the single required parameter 'index'. With 0% schema description coverage, the schema only indicates it's a required string parameter. The description doesn't explain what 'index' refers to, what format it should be in, or provide any examples. It fails to compensate for the complete lack of schema documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Get index mapping' is a tautology that essentially restates the tool name 'get_mapping' with the addition of 'index'. It doesn't specify what 'mapping' refers to (e.g., Elasticsearch index mapping, data structure mapping, configuration mapping) or what the operation actually retrieves. While it mentions a resource ('index mapping'), the verb 'Get' is too generic and doesn't distinguish this from sibling tools like 'get_settings' or 'get_index_templates'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention any prerequisites, appropriate contexts, or exclusions. With sibling tools like 'get_settings', 'get_index_templates', and 'list_indices' available, there's no indication of how this tool differs or when it should be selected over those alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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