Skip to main content

OpenSearch MCP Server

Project description

OpenSearch logo

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
  • Easy integration with Claude Desktop and LangChain
  • Secure authentication using basic auth or IAM roles

Installing opensearch-mcp-server-py

Opensearch-mcp-server-py can be installed from PyPI via pip:

pip install opensearch-mcp-server-py

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.
  • GetAllocationTool: Gets information about shard allocation across nodes in the cluster from the /_cat/allocation endpoint.
  • GetLongRunningTasksTool: Gets information about long-running tasks in the cluster, sorted by running time in descending order.

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 (Enabled by Default)

Advanced analysis tools for data analysis and troubleshooting.

  • 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.

Tool Parameters

  • 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
  • ClusterHealthTool

    • opensearch_url (optional): The OpenSearch cluster URL to connect to
    • index (optional): Limit health reporting to a specific index
  • CountTool

    • opensearch_url (optional): The OpenSearch cluster URL to connect to
    • index (optional): The name of the index to count documents in
    • body (optional): Query in JSON format to filter documents
  • ExplainTool

    • opensearch_url (optional): The OpenSearch cluster URL to connect to
    • index (required): The name of the index to retrieve the document from
    • id (required): The document ID to explain
    • body (required): Query in JSON format to explain against the document
  • MsearchTool

    • opensearch_url (optional): The OpenSearch cluster URL to connect to
    • index (optional): Default index to search in
    • body (required): Multi-search request body in NDJSON format
  • GetClusterStateTool

    • opensearch_url (optional): The OpenSearch cluster URL to connect to
    • metric (optional): Limit the information returned to the specified metrics. Options include: _all, blocks, metadata, nodes, routing_table, routing_nodes, master_node, version
    • index (optional): Limit the information returned to the specified indices
  • GetSegmentsTool

    • opensearch_url (optional): The OpenSearch cluster URL to connect to
    • index (optional): Limit the information returned to the specified indices. If not provided, returns segments for all indices
  • CatNodesTool

    • opensearch_url (optional): The OpenSearch cluster URL to connect to
    • metrics (optional): A comma-separated list of metrics to display. Available metrics include: id, name, ip, port, role, master, heap.percent, ram.percent, cpu, load_1m, load_5m, load_15m, disk.total, disk.used, disk.avail, disk.used_percent
  • GetNodesTool

    • opensearch_url (optional): The OpenSearch cluster URL to connect to
    • node_id (optional): A comma-separated list of node IDs or names to limit the returned information. Supports node filters like _local, _master, master:true, data:false, etc. Defaults to _all.
    • metric (optional): A comma-separated list of metric groups to include in the response. Options include: settings, os, process, jvm, thread_pool, transport, http, plugins, ingest, aggregations, indices. Defaults to all metrics.
  • GetIndexInfoTool

    • opensearch_url (optional): The OpenSearch cluster URL to connect to
    • index (required): The name of the index to get detailed information for. Wildcards are supported.
  • GetIndexStatsTool

    • opensearch_url (optional): The OpenSearch cluster URL to connect to
    • index (required): The name of the index to get statistics for. Wildcards are supported.
    • metric (optional): Limit the information returned to the specified metrics. Options include: _all, completion, docs, fielddata, flush, get, indexing, merge, query_cache, refresh, request_cache, search, segments, store, warmer, bulk
  • GetQueryInsightsTool

    • opensearch_url (optional): The OpenSearch cluster URL to connect to
  • GetNodesHotThreadsTool

    • opensearch_url (optional): The OpenSearch cluster URL to connect to
  • GetAllocationTool

    • opensearch_url (optional): The OpenSearch cluster URL to connect to
  • GetLongRunningTasksTool

    • opensearch_url (optional): The OpenSearch cluster URL to connect to
    • limit (optional): The maximum number of tasks to return. Default is 10.
  • DataDistributionTool

    • index (required): Target OpenSearch index name.
    • selectionTimeRangeStart (required): Start time for analysis target period.
    • selectionTimeRangeEnd (required): End time for analysis target period.
    • timeField (required): Date/time field for filtering.
    • baselineTimeRangeStart (optional): Start time for baseline period.
    • baselineTimeRangeEnd (optional): End time for baseline period.
    • size (optional): Maximum number of documents to analyze. Default is 1000.
  • LogPatternAnalysisTool

    • index (required): Target OpenSearch index name containing log data.
    • logFieldName (required): Field containing raw log messages to analyze.
    • selectionTimeRangeStart (required): Start time for analysis target period.
    • selectionTimeRangeEnd (required): End time for analysis target period.
    • timeField (required): Date/time field for time-based filtering.
    • traceFieldName (optional): Field for trace/correlation ID.
    • baseTimeRangeStart (optional): Start time for baseline comparison period.
    • baseTimeRangeEnd (optional): End time for baseline comparison period.

More tools coming soon. Click here

User Guide

For detailed usage instructions, configuration options, and examples, please see the User Guide.

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opensearch_mcp_server_py-0.9.0.tar.gz (65.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opensearch_mcp_server_py-0.9.0-py3-none-any.whl (70.3 kB view details)

Uploaded Python 3

File details

Details for the file opensearch_mcp_server_py-0.9.0.tar.gz.

File metadata

  • Download URL: opensearch_mcp_server_py-0.9.0.tar.gz
  • Upload date:
  • Size: 65.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for opensearch_mcp_server_py-0.9.0.tar.gz
Algorithm Hash digest
SHA256 58d0ac32b5afb5c9d77726d8d817f41514b57c1e56c0bbb9654d5fb799e050b7
MD5 459b905731c489d9ac4269b13dd62f74
BLAKE2b-256 9a97f5304e3692a42a2cb8f3c522d262b532014ced1982d4ab2cc83534bbb67a

See more details on using hashes here.

Provenance

The following attestation bundles were made for opensearch_mcp_server_py-0.9.0.tar.gz:

Publisher: publish-release.yml on opensearch-project/opensearch-mcp-server-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file opensearch_mcp_server_py-0.9.0-py3-none-any.whl.

File metadata

File hashes

Hashes for opensearch_mcp_server_py-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 28fcac2d432aaa5b5c8bb7b8bd3f23daf59f6cf0baba78b247678b4548b914e1
MD5 557db3c6af8fcaed8254dc978af2e946
BLAKE2b-256 fc5bb3691845f78a61a851ca3d834e0dad6d3b285d4d3496386c6189232ec8ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for opensearch_mcp_server_py-0.9.0-py3-none-any.whl:

Publisher: publish-release.yml on opensearch-project/opensearch-mcp-server-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page