Skip to main content
Glama
opensearch-mcp-server

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

Inputs: index (required).

IndexMappingToolB

Retrieves index mapping and setting information for an index in OpenSearch

Inputs: index (required).

ListIndexToolA

Lists all indices in OpenSearch

Inputs: no named parameters.

SearchIndexToolB

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

Inputs: index (required), query (required).

Tool Schema Changelog

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

Loading tool schema changelog…

    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 recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      F
      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
      D
      maintenance
      Provides tools to query Elasticsearch indices, retrieve mappings, execute searches, and get cluster health stats.
      4
      MIT