madhankb/opensearch-mcp-integration
If you are the rightful owner of opensearch-mcp-integration and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The Model Context Protocol (MCP) server facilitates seamless integration between natural language processing tools and OpenSearch, enabling efficient data interaction and management.
OpenSearch MCP <> LLM Integration Guide
This guide provides step-by-step instructions for integrating Amazon Q & Anthropic Claude desktop with OpenSearch using MCP servers for natural language interactions.
Anthropic Claude
Amazon Q
Prerequisites
- Docker and Docker Compose installed
- Python 3.x installed
- pipx installed (
pip install pipx) - Amazon Q CLI
- Anthropic Claude Desktop
1. Setting up Local OpenSearch Instance
-
Create a new directory for your project:
mkdir opensearch-mcp && cd opensearch-mcp -
Create a
docker-compose.ymlfile with the following content:version: '3' services: opensearch: image: opensearchproject/opensearch:latest environment: - discovery.type=single-node - bootstrap.memory_lock=true - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" - "OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!" - "plugins.security.ssl.http.enabled=true" - "plugins.security.ssl.transport.enabled=true" - "plugins.security.ssl.http.pemcert_filepath=certs/node.pem" - "plugins.security.ssl.http.pemkey_filepath=certs/node-key.pem" - "plugins.security.ssl.http.pemtrustedcas_filepath=certs/root-ca.pem" - "plugins.security.ssl.transport.pemcert_filepath=certs/node.pem" - "plugins.security.ssl.transport.pemkey_filepath=certs/node-key.pem" - "plugins.security.ssl.transport.pemtrustedcas_filepath=certs/root-ca.pem" ulimits: memlock: soft: -1 hard: -1 nofile: soft: 65536 hard: 65536 volumes: - opensearch-data:/usr/share/opensearch/data - ./certs:/usr/share/opensearch/config/certs ports: - 9200:9200 - 9600:9600 networks: - opensearch-net opensearch-dashboards: image: opensearchproject/opensearch-dashboards:latest environment: - 'OPENSEARCH_HOSTS=["https://opensearch:9200"]' - "OPENSEARCH_SSL_VERIFICATIONMODE=none" - "OPENSEARCH_SECURITY_ADMIN_PASSWORD=myStrongPassword123!" - "SERVER_SSL_ENABLED=true" - "SERVER_SSL_CERTIFICATE=/usr/share/opensearch-dashboards/config/certs/node.pem" - "SERVER_SSL_KEY=/usr/share/opensearch-dashboards/config/certs/node-key.pem" ports: - 5601:5601 volumes: - ./certs:/usr/share/opensearch-dashboards/config/certs depends_on: - opensearch networks: - opensearch-net volumes: opensearch-data: networks: opensearch-net: -
Start the containers:
docker compose up -d
2. Installing OpenSearch MCP Server
- Install the OpenSearch MCP server using pipx:
pipx install opensearch-mcp-server
3. Configuring LLMs with MCP server configurations
-
Amazon Q: Create amcp.jsonfile in your Amazon Q configuration directory (~/.aws/amazonq/mcp.json) -
Anthropic Claude: Create aclaude_desktop_config.jsonfile in your Claude Desktop configuration directory (~/Library/Application Support/Claude/claude_desktop_config.json){ "mcpServers": { "opensearch-mcp-server": { "command": "/Users/YOUR_USERNAME/.local/bin/opensearch-mcp-server", "args": [], "env": { "OPENSEARCH_URL": "https://localhost:9200", "OPENSEARCH_SSL_VERIFY": "none", "OPENSEARCH_USERNAME": "admin", "OPENSEARCH_PASSWORD": "myStrongPassword123!" } } } }Replace
YOUR_USERNAMEwith your system username or specify the location where the opensearch-mcp-server is installed.
4. Verifying the Setup
-
Check OpenSearch is running:
curl -XGET -u admin:myStrongPassword123! https://localhost:9200 -
Verify OpenSearch Dashboards:
- Open https://localhost:5601 in your browser
-
Check indices:
curl -XGET -u admin:myStrongPassword123! https://localhost:9200/_cat/indices
5. Using Natural Language with OpenSearch
Here are some example commands you can try in LLMs:
-
Create an index:
Create a new index called "books" with title and author fields -
Add documents:
Add a document to the books index with title "The Great Gatsby" and author "F. Scott Fitzgerald" -
Search documents:
Search for books by F. Scott Fitzgerald -
Get index information:
Show me the mapping of the books index
Troubleshooting
-
If MCP server fails to initialize:
- Check if OpenSearch is running (
docker ps) - Verify credentials in
mcp_config.json - Check OpenSearch logs (
docker compose logs opensearch)
- Check if OpenSearch is running (
-
If tools are not available:
- Restart the LLMs
- Check MCP server logs
- Verify the
mcp_config.jsonsyntax
Available MCP Tools
The OpenSearch MCP server provides several tools for interacting with OpenSearch:
list_indices: List all indices.get_index: Returns information (mappings, settings, aliases) about one or more indices. Args: index: Name of the indexcreate_index: Create a new index. Args: index: Name of the index body: Optional index configuration including mappings and settingsdelete_index: Delete an index. Args: index: Name of the indexsearch_documents: Search for documents. Args: index: Name of the index body: Search queryindex_document: Creates or updates a document in the index. Args: index: Name of the index document: Document data id: Optional document IDget_document: Get a document by ID. Args: index: Name of the index id: Document IDdelete_document: Delete a document by ID. Args: index: Name of the index id: Document IDdelete_by_query: Deletes documents matching the provided query. Args: index: Name of the index body: Query to match documents for deletionget_cluster_health: Returns basic information about the health of the cluster.get_cluster_stats: Returns high-level overview of cluster statistics.list_aliases: List all aliases.get_alias: Get alias information for a specific index. Args: index: Name of the indexput_alias: Create or update an alias for a specific index. Args: index: Name of the index name: Name of the alias body: Alias configurationdelete_alias: Delete an alias for a specific index. Args: index: Name of the index name: Name of the aliasgeneral_api_request: Perform a general HTTP API request. Use this tool for any Elasticsearch/OpenSearch API that does not have a dedicated tool. Args: method: HTTP method (GET, POST, PUT, DELETE, etc.) path: API endpoint path params: Query parameters body: Request body
Security Notes
- Always use strong passwords in production
- Enable SSL in production environments
- Regularly rotate credentials