OpenSearch MCP Server
opensearch-mcp-server-py is a Model Context Protocol (MCP) server for OpenSearch that enables AI assistants to interact with OpenSearch clusters. It provides a standardized interface for AI models to perform operations like searching indices, retrieving mappings, and managing shards through both stdio and streaming (SSE/Streamable HTTP) protocols.
Key features:
- Seamless integration with AI assistants and LLMs through the MCP protocol
- Support for both stdio and streaming server transports (SSE and Streamable HTTP)
- Built-in tools for common OpenSearch operations
- Dynamic per-call connection parameters for targeting different clusters without server reconfiguration
- Easy integration with Claude Desktop and LangChain
- Secure authentication using basic auth, IAM roles, header-based auth, and OpenSearch mTLS
For detailed setup, including Kubernetes deployment and mTLS configuration, see the User Guide.
Available Tools
By default, only core tools are enabled to provide essential OpenSearch functionality:
Core Tools (Enabled by Default)
Core tools are grouped under the core_tools category and can be disabled at once using OPENSEARCH_DISABLED_CATEGORIES=core_tools. Avoid creating custom categories with this name as they will override the built-in category.
- ListIndexTool: Lists all indices in OpenSearch with full information including docs.count, docs.deleted, store.size, etc. If an index parameter is provided, returns detailed information about that specific index.
- 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.
- ClusterHealthTool: Returns basic information about the health of the cluster.
- CountTool: Returns number of documents matching a query.
- ExplainTool: Returns information about why a specific document matches (or doesn't match) a query.
- MsearchTool: Allows to execute several search operations in one request.
- [GenericOpenSearchApiTool]: A flexible tool that can call any OpenSearch API endpoint with custom paths, methods, query parameters, and request bodies. Reduces tool explosion by providing a single interface for all OpenSearch APIs.
Additional Tools (Disabled by Default)
The following tools are available but disabled by default. To enable them, see the Tool Filter section in the User Guide.
- GetClusterStateTool: Gets the current state of the cluster including node information, index settings, and more.
- GetSegmentsTool: Gets information about Lucene segments in indices, including memory usage, document counts, and segment sizes.
- CatNodesTool: Gets information about nodes in the OpenSearch cluster, including system metrics like CPU usage, memory, disk space, and node roles.
- GetNodesTool: Gets detailed information about nodes in the OpenSearch cluster, including static information like host system details, JVM info, processor type, node settings, thread pools, installed plugins, and more.
- GetIndexInfoTool: Gets detailed information about an index including mappings, settings, and aliases. Supports wildcards in index names.
- GetIndexStatsTool: Gets statistics about an index including document count, store size, indexing and search performance metrics.
- GetQueryInsightsTool: Gets query insights from the /_insights/top_queries endpoint, showing information about query patterns and performance.
- GetNodesHotThreadsTool: Gets information about hot threads in the cluster nodes from the /_nodes/hot_threads endpoint.
Agentic Memory Tools (Disabled by Default)
The following tools expose the OpenSearch Agentic Memory API — a server-side memory system built into OpenSearch itself. The OpenSearch cluster manages memory containers, sessions, and inference (LLM-based extraction of facts from conversations). These tools require OpenSearch 3.3.0 or later.
When to use: You want OpenSearch to own the full memory lifecycle — including LLM-based inference to extract facts from raw conversations, structured memory types (sessions, working, long-term, history), and server-managed namespacing. Best for production agentic pipelines where memory management should be centralized and not depend on the MCP client.
Setup: You must create a memory container in OpenSearch before using these tools (one-time admin operation requiring LLM connector and embedding model configuration). See Agentic Memory Tools in the Agent Memory Guide.
Enable with OPENSEARCH_ENABLED_CATEGORIES=agentic_memory. When memory_container_id is configured via the agentic_memory config section or OPENSEARCH_MEMORY_CONTAINER_ID environment variable, it is automatically pre-filled in all tool calls.
Observability Tools (Disabled by Default)
Observability tools are grouped under the observability category and can be enabled using OPENSEARCH_ENABLED_CATEGORIES=observability or by adding enabled_categories: [observability] to the config file. Alternatively, enable the analytics category to get both observability and skills tools at once.
- PPLQueryTool: Executes a PPL (Piped Processing Language) query against OpenSearch. PPL provides a pipe-based syntax for querying data (
source=<index> | <command> | <command>), supporting filtering, aggregation, sorting, deduplication, and field selection. Supports jdbc, csv, and raw output formats.
Search Relevance Workbench Tools (Disabled by Default)
Search Relevance Workbench tools are grouped under the search_relevance category and can be enabled at once using OPENSEARCH_ENABLED_CATEGORIES=search_relevance or by adding enabled_categories: [search_relevance] or explicitly adding individual tools to their config file. See the Tool Filter section in the User Guide for additional information about how to filter tools.
Skills Tools (Disabled by Default)
Skills tools are grouped under the skills category and can be enabled at once using OPENSEARCH_ENABLED_CATEGORIES=skills or by adding enabled_categories: [skills] to the config file. Alternatively, enable the analytics category to get both skills and observability tools at once. See the Tool Filter section in the User Guide for additional information about how to filter tools.
- DataDistributionTool: Analyzes data distribution patterns and field value frequencies within OpenSearch indices. Supports both single dataset analysis and comparative analysis between two time periods to identify distribution changes.
- LogPatternAnalysisTool: Detects anomalous log patterns and sequences through comparative analysis between baseline and selection time ranges. Supports log sequence analysis with trace correlation, log pattern difference analysis, and log insights analysis for error detection.
- MetricChangeAnalysisTool: Compares percentile distributions (P50, P90) of all numeric fields between a baseline and a selection time range, then returns the top fields ranked by change score. Useful for identifying which numeric metrics shifted most during an anomaly window.
Memory Tools (Opt-in)
Memory tools give the MCP agent itself persistent, cross-session memory backed by OpenSearch. The agent decides what to save as plain-text statements; OpenSearch stores and semantically indexes them. Enable with MEMORY_TOOLS_ENABLED=true. See the Agent Memory Guide for full setup instructions.
When to use: You want a lightweight, agent-driven memory layer that works with any MCP-compatible IDE (Kiro, Claude Code, Cursor). The agent controls what gets remembered — no LLM connectors or embedding models to configure on the OpenSearch side. Requires Amazon OpenSearch Service (managed domain 2.19+ or Serverless) for automatic semantic enrichment. See the Agent Memory Guide for full setup instructions.
- SaveMemoryTool: Saves facts, decisions, and preferences to persistent storage with automatic semantic enrichment.
- SearchMemoryTool: Searches memories using natural language with recency-aware ranking.
- DeleteMemoryTool: Removes outdated or incorrect memories by document ID.
Tool Parameters
All tools accept the following optional connection parameters that override the server's environment variable configuration on a per-call basis. When all are omitted, the server uses its configured environment variables or cluster config as usual. When you supply opensearch_url, the credentials must come from that same call: the server will not use its own credentials against a URL a caller chose, unless the operator sets OPENSEARCH_ALLOW_AMBIENT_AWS_FALLBACK=true to share its AWS credentials.
| Parameter | Type | Description |
|---|
opensearch_url | string | OpenSearch endpoint URL. Overrides OPENSEARCH_URL. |
opensearch_username | string | Username for basic auth. Overrides OPENSEARCH_USERNAME. |
opensearch_password | string | Password for basic auth. Overrides OPENSEARCH_PASSWORD. |
opensearch_no_auth | boolean | Connect without authentication. Overrides OPENSEARCH_NO_AUTH. |
aws_region | string | AWS region. Overrides AWS_REGION. |
aws_iam_arn | string | IAM role ARN. Overrides AWS_IAM_ARN. |
This allows agents to dynamically target different clusters per tool call without reconfiguring the server (single mode only). Credentials must come from the same call as the URL, unless OPENSEARCH_ALLOW_AMBIENT_AWS_FALLBACK=true lets the server sign caller-supplied URLs with its own AWS credentials. OPENSEARCH_SSRF_GUARD=true restricts caller-supplied URLs to public HTTPS addresses. See Dynamic Connection Parameters in the User Guide for details and examples.
In addition to the common connection parameters above, each tool accepts its own specific parameters:
Note: The opensearch_url parameter listed under individual tools below is part of the common connection parameters described above. All common connection parameters (opensearch_username, opensearch_password, aws_region, etc.) are available on every tool but are not repeated in each tool's parameter list for brevity.
-
ListIndexTool
opensearch_url (optional): The OpenSearch cluster URL to connect to
index (optional): The name of the index to get detailed information for. If provided, returns detailed information about this specific index instead of listing all indices.
-
IndexMappingTool
opensearch_url (optional): The OpenSearch cluster URL to connect to
index (required): The name of the index to retrieve mappings for
-
SearchIndexTool
opensearch_url (optional): The OpenSearch cluster URL to connect to
index (required): The name of the index to search in
query_dsl (required): The search query in OpenSearch Query DSL format
format (optional): The format of SearchIndexTool response. options are csv and json
size (optional): The size of SearchIndexTool response. Default is 10, maximum is 100 (configurable). To change the maximum limit, set max_size_limit via CLI arguments or config file. See Tool Customization for details.
-
GetShardsTool
opensearch_url (optional): The OpenSearch cluster URL to connect to
index (required): The name of the index to get shard information for
More tools coming soon. Click here
User Guide
For detailed usage instructions, configuration options, and examples, please see the User Guide.
Agent Memory
The OpenSearch MCP server includes two distinct memory systems. Both use OpenSearch as the storage backend but differ in who controls the memory lifecycle and what infrastructure they require.
Choosing the right approach
| Memory Tools (MEMORY_TOOLS_ENABLED) | Agentic Memory Tools (agentic_memory category) |
|---|
| Who stores memories | The MCP agent decides what to save as plain-text statements | OpenSearch processes raw conversations and extracts facts via LLM inference |
| Setup complexity | Low — index is auto-created on first use | High — requires creating a memory container with LLM connector and embedding model |
| OpenSearch version | Amazon OpenSearch Service 2.19+ or Serverless | OpenSearch 3.3.0+ |
| Semantic search | Yes, via AWS automatic semantic enrichment | Yes, via configured embedding model |
| Memory structure | Flat — each memory is a plain-text statement | Structured — sessions, working, long-term, and history types |
| LLM inference | No — agent writes exactly what it wants to remember | Optional (infer: true) — OpenSearch uses an LLM to extract facts from conversations |
| Best for | IDE agents (Kiro, Claude Code, Cursor) that need quick setup and cross-session continuity |
Use Memory Tools when you want a lightweight, agent-driven memory layer that works out of the box with any MCP-compatible IDE. The agent controls what gets remembered. See the Agent Memory Guide for setup.
Use Agentic Memory Tools when you want OpenSearch to own the full memory lifecycle — including LLM-based extraction of facts from raw conversations, structured memory types, and server-managed namespacing. See the Agent Memory Guide for setup.
Contributing
Interested in contributing? Check out our:
Code of Conduct
This project has adopted the Amazon Open Source Code of Conduct. For more information see the Code of Conduct FAQ, or contact opensource-codeofconduct@amazon.com with any additional questions or comments.
License
This project is licensed under the Apache v2.0 License.
Copyright
Copyright 2020-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.