MCP server for OpenSearch with native support
## OpenSearch MCP Server: Search and Analytics Engine The **OpenSearch MCP Server** integrates OpenSearch into Google Antigravity, enabling full-text search, log analytics, and observability operations directly from your development environment. ### Why OpenSearch MCP? - **Open Source**: Apache 2.0 licensed Elasticsearch fork - **Full-Text Search**: Advanced text search capabilities - **Analytics**: Real-time log and metrics analysis - **Observability**: Traces, metrics, and logs in one place - **Scalable**: Distributed architecture for large datasets ### Key Features #### 1. Search Queries ```python # Full-text search result = await mcp.search( index="products", query={ "bool": { "must": [ {"match": {"name": "laptop gaming"}} ], "filter": [ {"range": {"price": {"lte": 2000}}}, {"term": {"in_stock": True}} ] } }, highlight={"fields": {"name": {}, "description": {}}}, size=20 ) for hit in result["hits"]["hits"]: print(f"Product: {hit['_source']['name']} - Score: {hit['_score']}") ``` #### 2. Document Operations ```python # Index document await mcp.index( index="products", id="prod_123", document={ "name": "Gaming Laptop", "description": "High-performance gaming laptop...", "price": 1499.99, "category": "electronics", "in_stock": True } ) # Bulk index await mcp.bulk([ {"index": {"_index": "products", "_id": "1"}}, {"name": "Product 1", "price": 99.99}, {"index": {"_index": "products", "_id": "2"}}, {"name": "Product 2", "price": 149.99} ]) # Delete document await mcp.delete(index="products", id="prod_123") ``` #### 3. Aggregations ```python # Analytics aggregation result = await mcp.search( index="logs", query={"range": {"timestamp": {"gte": "now-1h"}}}, aggs={ "status_codes": {"terms": {"field": "status_code"}}, "avg_response_time": {"avg": {"field": "response_time"}}, "requests_over_time": { "date_histogram": {"field": "timestamp", "interval": "5m"} } }, size=0 ) print(f"Total requests: {result['hits']['total']['value']}") ``` #### 4. Index Management ```python # Create index with mappings await mcp.create_index( index="logs", body={ "mappings": { "properties": { "message": {"type": "text"}, "level": {"type": "keyword"}, "timestamp": {"type": "date"} } } } ) # Get index info info = await mcp.get_index(index="products") ``` ### Configuration ```json { "mcpServers": { "opensearch": { "command": "npx", "args": ["-y", "@anthropic/mcp-opensearch"], "env": { "OPENSEARCH_URL": "https://localhost:9200", "OPENSEARCH_USERNAME": "admin", "OPENSEARCH_PASSWORD": "your-password" } } } } ``` ### Use Cases **Product Search**: Full-text product search with facets. **Log Analytics**: Centralized log analysis and alerting. **Observability**: Application performance monitoring. **Security Analytics**: SIEM and threat detection. The OpenSearch MCP enables search and analytics within your development environment.
{
"mcpServers": {
"opensearch": {
"mcpServers": {
"opensearch": {
"env": {
"OPENSEARCH_URL": "https://localhost:9200",
"OPENSEARCH_PASSWORD": "YOUR_PASSWORD",
"OPENSEARCH_USERNAME": "admin"
},
"args": [
"-y",
"opensearch-mcp-server"
],
"command": "npx"
}
}
}
}
}