Skip to main content
Glama
rithinpullela

opensearch-mcp-server

NOTICE: This project has been graduated and moved to the opensearch-mcp-server-py repository. See you there! This repository is now archived.

OpenSearch MCP Server

A minimal Model Context Protocol (MCP) server for OpenSearch exposing 4 tools over stdio and sse server.

Available tools

  • ListIndexTool: Lists all indices in OpenSearch.

  • IndexMappingTool: Retrieves index mapping and setting information for an index in OpenSearch.

  • SearchIndexTool: Searches an index using a query written in query domain-specific language (DSL) in OpenSearch.

  • GetShardsTool: Gets information about shards in OpenSearch.

More tools coming soon. Click here

Related MCP server: Elastic MCP Server

User Guide

Installation

Install from PyPI:

pip install test-opensearch-mcp

Configuration

Authentication Methods:

  • Basic Authentication

export OPENSEARCH_URL="<your_opensearch_domain_url>"
export OPENSEARCH_USERNAME="<your_opensearch_domain_username>"
export OPENSEARCH_PASSWORD="<your_opensearch_domain_password>"
  • IAM Role Authentication

export OPENSEARCH_URL="<your_opensearch_domain_url>"
export AWS_REGION="<your_aws_region>"
export AWS_ACCESS_KEY="<your_aws_access_key>"
export AWS_SECRET_ACCESS_KEY="<your_aws_secret_access_key>"
export AWS_SESSION_TOKEN="<your_aws_session_token>"

Running the Server

# Stdio Server
python -m mcp_server_opensearch

# SSE Server
python -m mcp_server_opensearch --transport sse

Claude Desktop Integration

{
    "mcpServers": {
        "opensearch-mcp-server": {
            "command": "uvx",
            "args": [
                "test-opensearch-mcp"
            ],
            "env": {
                // Required
                "OPENSEARCH_URL": "<your_opensearch_domain_url>",

                // For Basic Authentication
                "OPENSEARCH_USERNAME": "<your_opensearch_domain_username>",
                "OPENSEARCH_PASSWORD": "<your_opensearch_domain_password>",

                // For IAM Role Authentication
                "AWS_REGION": "<your_aws_region>",
                "AWS_ACCESS_KEY": "<your_aws_access_key>",
                "AWS_SECRET_ACCESS_KEY": "<your_aws_secret_access_key>",
                "AWS_SESSION_TOKEN": "<your_aws_session_token>"
            }
        }
    }
}
  • Using the Installed Package (via pip):

{
    "mcpServers": {
        "opensearch-mcp-server": {
            "command": "python",  // Or full path to python with PyPI package installed
            "args": [
                "-m",
                "mcp_server_opensearch"
            ],
            "env": {
                // Required
                "OPENSEARCH_URL": "<your_opensearch_domain_url>",

                // For Basic Authentication
                "OPENSEARCH_USERNAME": "<your_opensearch_domain_username>",
                "OPENSEARCH_PASSWORD": "<your_opensearch_domain_password>",

                // For IAM Role Authentication
                "AWS_REGION": "<your_aws_region>",
                "AWS_ACCESS_KEY": "<your_aws_access_key>",
                "AWS_SECRET_ACCESS_KEY": "<your_aws_secret_access_key>",
                "AWS_SESSION_TOKEN": "<your_aws_session_token>"
            }
        }
    }
}

LangChain Integration

The OpenSearch MCP server can be easily integrated with LangChain using the SSE server transport

Prerequisites

  1. Install required packages

pip install langchain langchain-mcp-adapters langchain-openai
  1. Set up OpenAI API key

export OPENAI_API_KEY="<your-openai-key>"
  1. Ensure OpenSearch MCP server is running in SSE mode

python -m mcp_server_opensearch --transport sse

Example Integration Script

import asyncio
from langchain_mcp_adapters.client import MultiServerMCPClient
from langchain_openai import ChatOpenAI
from langchain.agents import AgentType, initialize_agent

# Initialize LLM (can use any LangChain-compatible LLM)
model = ChatOpenAI(model="gpt-4o")

async def main():
    # Connect to MCP server and create agent
    async with MultiServerMCPClient({
        "opensearch-mcp-server": {
            "transport": "sse",
            "url": "http://localhost:9900/sse",  # SSE server endpoint
            "headers": {
                "Authorization": "Bearer secret-token",
            }
        }
    }) as client:
        tools = client.get_tools()
        agent = initialize_agent(
            tools=tools,
            llm=model,
            agent=AgentType.OPENAI_FUNCTIONS,
            verbose=True,  # Enables detailed output of the agent's thought process
        )

        # Example query
        await agent.ainvoke({"input": "List all indices"})

if __name__ == "__main__":
    asyncio.run(main())

Notes:

  • The script is compatible with any LLM that integrates with LangChain and supports tool calling

  • Make sure the OpenSearch MCP server is running before executing the script

  • Configure authentication and environment variables as needed

Development

Interested in contributing? Check out our:

Available Tools

4 tools
GetShardsToolC

Gets information about shards in OpenSearch

ParametersJSON Schema
NameRequiredDescriptionDefault
indexYes

TDQS

C2.2/5.0
Behavior2/5

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

With no annotations, the description is the sole source of behavioral transparency. It implies a read operation ('Gets') but does not disclose whether it requires special permissions, what side effects (if any) occur, the return format, or how it handles errors or missing indices. The description adds minimal behavior beyond a bare read.

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

Conciseness4/5

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

At 10 words, the description is compact and front-loaded, with no filler. It is a single sentence that focuses attention on the core action. However, it is so brief that it sacrifices informative value, making it efficient but under-specified.

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

Completeness2/5

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

There is no output schema or annotation, and the description does not explain what constitutes 'information about shards' or the shape of the response. Complexity is low, but the absence of any behavioral or return details leaves the agent guessing. For a simple one-param tool, a short description might suffice, but this one is too generic to be fully contextual.

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

Parameters2/5

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

Schema description coverage for the 'index' parameter is 0%, and the tool description does not explain it beyond the property name. An agent can infer it likely means the index name, but the description gives no details about expected format, whether multiple indices are accepted, or how it relates to shard selection. The parameter name is self-explanatory, but the description adds no compensatory semantics.

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 'Gets information about shards in OpenSearch' essentially restates the tool name with minimal expansion. It does not specify what information about shards is returned (health, stats, allocation, routing), leaving the tool's exact purpose vague. It differentiates from sibling tools by resource type, but not by the specific kind of shard data provided.

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

Usage Guidelines2/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 instead of ListIndexTool, IndexMappingTool, or SearchIndexTool. No prerequisites, exclusions, or alternative references are given. The agent receives no context about the appropriate use case beyond the tool's name and generic description.

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

IndexMappingToolB

Retrieves index mapping and setting information for an index in OpenSearch

ParametersJSON Schema
NameRequiredDescriptionDefault
indexYes

TDQS

B3.4/5.0
Behavior2/5

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

No annotations are provided, so the description must carry the full burden. The word 'Retrieves' implies a read-only operation, but the description doesn't disclose whether permissions are needed, how errors are handled (e.g., missing index), or whether any side effects occur. There is no mention of the return format or additional behaviors.

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 a single, 12-word sentence that front-loads the purpose. Every word is useful; there is no redundancy or filler.

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

Completeness4/5

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

This is a very simple tool with one parameter, no output schema, and read-only implication. The description explains what it does and what input it takes, which covers the essential context. It doesn't mention return format or error scenarios, but the phrase 'mapping and setting information' gives a reasonable idea of the output. It could be slightly richer, but for the tool's simplicity it is largely complete.

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

Parameters3/5

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

The input schema has a single 'index' parameter with no description, and coverage is 0%. However, the description's phrase 'for an index in OpenSearch' clarifies that the parameter refers to the name of the index. This adds meaning beyond the bare schema, though it doesn't provide format constraints, examples, or edge-case semantics.

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

Purpose5/5

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

The description clearly states the verb ('Retrieves'), the resource ('index mapping and setting information'), and the target ('an index in OpenSearch'). This distinguishes it from sibling tools like ListIndexTool (list indices), SearchIndexTool (search data), and GetShardsTool (shard info).

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

Usage Guidelines2/5

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

The description provides no explicit guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, exclusions, or when ListIndexTool or GetShardsTool would be more appropriate. The intended use is only implied by the tool name and the phrase 'for an index'.

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

ListIndexToolA

Lists all indices in OpenSearch

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4/5.0
Behavior3/5

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

With no annotations provided, the description carries full responsibility for disclosing behavior. 'Lists all indices' implies a read-only, non-destructive operation, but it does not explicitly state safety, permission requirements, pagination, or return format. The behavior is simple and apparent, yet lacks explicit disclosure.

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 a single, concise sentence ('Lists all indices in OpenSearch') that is front-loaded and contains no unnecessary information. Every word contributes to the meaning.

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

Completeness4/5

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

Given the tool has no parameters and no output schema, the description adequately conveys the core behavior of listing all indices. It could be more explicit about the return format or whether system indices are included, but for such a simple tool, the description is sufficient.

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

Parameters4/5

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

The input schema has zero properties, so there are no parameters to document. The description appropriately adds no parameter information, and the baseline for zero-parameter tools is high. No further explanation is needed.

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

Purpose5/5

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

The description uses the specific verb 'Lists' and identifies the resource as 'all indices in OpenSearch', making the tool's purpose immediately clear. This clearly distinguishes it from sibling tools like IndexMappingTool, SearchIndexTool, and GetShardsTool, which serve different purposes.

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

Usage Guidelines3/5

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

The description implies when to use the tool—whenever a list of all indices is needed—but provides no explicit guidance on when not to use it or how it compares to alternatives. There are no exclusions or alternative tool references, so the usage context is only implied.

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

SearchIndexToolB

Searches an index using a query written in query domain-specific language (DSL) in OpenSearch

ParametersJSON Schema
NameRequiredDescriptionDefault
indexYes
queryYes

TDQS

B3.3/5.0
Behavior2/5

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

With no annotations, the description must carry the full burden of behavioral disclosure. It only mentions the action and query DSL, but does not explicitly state that the operation is read-only, mention required permissions, response format, error handling, or side effects. The term 'searches' is suggestive but not explicit.

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 a single, concise sentence that directly states the operation and query language without any redundant or filler content. It is well-structured and front-loaded with the core action.

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

Completeness2/5

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

The tool's complexity is moderate due to the arbitrary nature of the DSL query, but the description provides no guidance on query construction or the return structure (no output schema). An agent would need external knowledge to correctly invoke the tool, making the description incomplete for practical use.

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

Parameters2/5

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

Schema description coverage is 0%, and the 'query' parameter lacks a type. The description adds that the query is in query DSL, providing partial context, but it does not explain the expected structure or format of the DSL query, nor does it detail the 'index' parameter beyond obvious inference from the tool's purpose.

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

Purpose5/5

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

The description clearly states the verb 'Searches' and the resource 'an index', specifying that queries are written in OpenSearch query DSL. This distinguishes it from sibling tools like ListIndexTool, IndexMappingTool, and GetShardsTool, which handle listing, mapping, and shard operations.

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

Usage Guidelines3/5

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

The description implicitly indicates this tool is for executing search queries but does not explicitly state when to use it versus alternatives or provide any exclusion criteria. The context is clear but relies on the agent to infer distinctiveness from sibling tools.

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

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 4 tool updatesv0.1.3
    • First observedGetShardsTool
    • First observedIndexMappingTool
    • First observedListIndexTool
    • First observedSearchIndexTool

TDQS

B3.2/5.0

Scored across 4 tools

Disambiguation5/5

Each tool targets a distinct OpenSearch resource: indices, index mappings, search results, and shard info. There is no overlap, and the descriptions clearly delineate their purposes.

Naming Consistency4/5

Most tool names follow a verb-noun pattern (ListIndex, SearchIndex, GetShards), but IndexMappingTool deviates by leading with a noun. The consistent 'Tool' suffix helps, but the mixed pattern is a minor inconsistency.

Tool Count5/5

The 4 tools are well-scoped for an OpenSearch read-only server focusing on index and shard inspection. Each tool has a clear purpose, and the count fits within the ideal 3-15 range.

Completeness2/5

The tool surface lacks fundamental OpenSearch operations such as creating or deleting indices, indexing, or retrieving documents. This makes the server suitable only for inspection tasks, leaving significant gaps for common workflows.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    * Index Management Tools: * List all indices in OpenSearch cluster * Get index mapping * Get index settings * Cluster Management Tools: * Get cluster health status * Get cluster statistics * Document Tools: * Search documents
    2
    MIT
  • F
    license
    B
    quality
    Not graded
    maintenance
    Provides comprehensive tools for managing Elasticsearch clusters, including security management, search operations, and index administration. It enables users to monitor cluster health, handle InfoSec tasks, and execute complex queries using Elasticsearch Query DSL and ES|QL.
    37
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables LLMs to interact with OpenSearch clusters to monitor cluster health, manage indices, and perform data searches. It provides a standardized interface for real-time OpenSearch operations within MCP-compatible environments like Open WebUI.
    -
  • A
    license
    Not graded
    quality
    C
    maintenance
    Provides tools to query Elasticsearch indices, retrieve mappings, execute searches, and get cluster health stats.
    4
    MIT