opensearch-mcp-server
Allows LangChain agents to use OpenSearch MCP tools via SSE transport.
Provides tools to list indices, retrieve index mappings, search using DSL, and get shard information.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@opensearch-mcp-serverlist all indices"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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-mcpConfiguration
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 sseClaude Desktop Integration
Using the Published PyPI Package (Recommended)
{
"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
Install required packages
pip install langchain langchain-mcp-adapters langchain-openaiSet up OpenAI API key
export OPENAI_API_KEY="<your-openai-key>"Ensure OpenSearch MCP server is running in SSE mode
python -m mcp_server_opensearch --transport sseExample 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:
Development Guide - Setup your development environment
Contributing Guidelines - Learn how to contribute
Available Tools
4 toolsGetShardsToolC
Gets information about shards in OpenSearch
| Name | Required | Description | Default |
|---|---|---|---|
| index | Yes |
TDQS
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.
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.
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.
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.
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.
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
| Name | Required | Description | Default |
|---|---|---|---|
| index | Yes |
TDQS
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.
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.
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.
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.
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.
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
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
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.
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.
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.
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.
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.
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
| Name | Required | Description | Default |
|---|---|---|---|
| index | Yes | ||
| query | Yes |
TDQS
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.
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.
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.
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.
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.
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.
4 tool updates
v0.1.3- First observed
GetShardsTool - First observed
IndexMappingTool - First observed
ListIndexTool - First observed
SearchIndexTool
TDQS
Scored across 4 tools
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.
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.
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.
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
Related MCP Connectors
Search multiple indices, index data, and get personalized recommendations
Provides capabilities that let LLM agents perform a range of infrastructure management tasks.
List datasets, schemas, run APL queries, and use prompts for exploration, anomalies, and monitoring.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenance* 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 documents2MIT
- FlicenseBqualityNot gradedmaintenanceProvides 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-
- FlicenseNot gradedqualityDmaintenanceEnables 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.-
- AlicenseNot gradedqualityCmaintenanceProvides tools to query Elasticsearch indices, retrieve mappings, execute searches, and get cluster health stats.4MIT