{"_id":"elasticsearch-mcp","_rev":"2-2ee8d52b72957491b010a6ffaea37347","name":"elasticsearch-mcp","dist-tags":{"latest":"0.1.3"},"versions":{"0.1.2":{"name":"elasticsearch-mcp","version":"0.1.2","keywords":["elasticsearch","mcp","model-context-protocol","elastic-cloud","search","analytics","data-export","claude","typescript","security"],"author":{"name":"Your Organization"},"license":"MIT","_id":"elasticsearch-mcp@0.1.2","maintainers":[{"name":"rajwardhan-shinde07","email":"rajshinde55553@gmail.com"}],"homepage":"https://github.com/RajwardhanShinde/elk-mcp#readme","bugs":{"url":"https://github.com/RajwardhanShinde/elk-mcp/issues"},"bin":{"elasticsearch-mcp":"build/index.js"},"dist":{"shasum":"59fd4e6c77fc6ccb2a5dcc57abd0a82c05ce3661","tarball":"https://registry.npmjs.org/elasticsearch-mcp/-/elasticsearch-mcp-0.1.2.tgz","fileCount":63,"integrity":"sha512-ZOESZsEd5FFGseDhg6tWZAWQpPpYu7ayq/R8q9r+NJUbuOgIsS2d574omBCKMR3vY+AoDQIgxwSb1qn+ALVbmg==","signatures":[{"sig":"MEQCIBps7m6sznYOVLrmmLqeTGFF+FYUF4jtGvIAX8MW8uQjAiBISw/bkYTNKCp7/vL1368PTGCcO1NacJsu3LFUECqmww==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":221077},"main":"build/index.js","types":"./build/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"4fc097809a5c757839c6e775d3214aabc9d06052","scripts":{"dev":"tsx watch src/index.ts","lint":"eslint src/**/*.ts","test":"jest","build":"tsc","start":"node build/index.js","format":"prettier --write src/**/*.ts","prepare":"husky install","lint:fix":"eslint src/**/*.ts --fix","test:watch":"jest --watch","type-check":"tsc --noEmit","test:coverage":"jest --coverage","prepublishOnly":"npm run build"},"_npmUser":{"name":"rajwardhan-shinde07","email":"rajshinde55553@gmail.com"},"repository":{"url":"git+https://github.com/RajwardhanShinde/elk-mcp.git","type":"git"},"_npmVersion":"10.9.2","description":"Secure MCP server for Elasticsearch integration with comprehensive tools and Elastic Cloud support","directories":{},"_nodeVersion":"22.16.0","dependencies":{"zod":"^3.22.0","csv-writer":"^1.6.0","@elastic/elasticsearch":"^8.11.0","@modelcontextprotocol/sdk":"^1.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.0.0","jest":"^29.5.0","husky":"^8.0.0","eslint":"^8.0.0","ts-jest":"^29.1.0","prettier":"^3.0.0","typescript":"^5.0.0","@types/jest":"^29.5.0","@types/node":"^20.0.0","eslint-config-prettier":"^9.0.0","eslint-plugin-prettier":"^5.0.0","@typescript-eslint/parser":"^6.0.0","@typescript-eslint/eslint-plugin":"^6.0.0"},"_npmOperationalInternal":{"tmp":"tmp/elasticsearch-mcp_0.1.2_1754220939300_0.6058659547139444","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"elasticsearch-mcp","version":"0.1.3","description":"Secure MCP server for Elasticsearch integration with comprehensive tools and Elastic Cloud support","main":"build/index.js","bin":{"elasticsearch-mcp":"build/index.js"},"scripts":{"build":"tsc","dev":"tsx watch src/index.ts","start":"node build/index.js","test":"jest","test:watch":"jest --watch","test:coverage":"jest --coverage","lint":"eslint src/**/*.ts","lint:fix":"eslint src/**/*.ts --fix","format":"prettier --write src/**/*.ts","type-check":"tsc --noEmit","prepare":"husky install","prepublishOnly":"npm run build"},"keywords":["elasticsearch","mcp","model-context-protocol","elastic-cloud","search","analytics","data-export","claude","typescript","security"],"author":{"name":"Your Organization"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/RajwardhanShinde/elk-mcp.git"},"bugs":{"url":"https://github.com/RajwardhanShinde/elk-mcp/issues"},"homepage":"https://github.com/RajwardhanShinde/elk-mcp#readme","engines":{"node":">=18.0.0"},"dependencies":{"@modelcontextprotocol/sdk":"^1.0.0","@elastic/elasticsearch":"^8.11.0","zod":"^3.22.0","csv-writer":"^1.6.0"},"devDependencies":{"@types/node":"^20.0.0","@types/jest":"^29.5.0","@typescript-eslint/eslint-plugin":"^6.0.0","@typescript-eslint/parser":"^6.0.0","eslint":"^8.0.0","eslint-config-prettier":"^9.0.0","eslint-plugin-prettier":"^5.0.0","husky":"^8.0.0","jest":"^29.5.0","prettier":"^3.0.0","ts-jest":"^29.1.0","tsx":"^4.0.0","typescript":"^5.0.0"},"_id":"elasticsearch-mcp@0.1.3","gitHead":"ec2d8dd398dcdbc3e0c194b5b23f1a1cce14993d","types":"./build/index.d.ts","_nodeVersion":"22.16.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-I91K1ADCiNWEN3gPmtyGeO3+LWwbnKxOlfZDxgmqmuRMTgBCI6jfJe0sD5GwV/88WhbNqujbgzJNORCrMWd/9w==","shasum":"911cbeb703d253e456ee226fe770973747bd09c2","tarball":"https://registry.npmjs.org/elasticsearch-mcp/-/elasticsearch-mcp-0.1.3.tgz","fileCount":63,"unpackedSize":221151,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDb+9cOcwVLHVRMfimydyd+wiOp8sMLfU/hTi7OjYjPUgIhAOwWN/my1TbPjptnYi5gNphfLhepfox93JUfpNrPs4fy"}]},"_npmUser":{"name":"rajwardhan-shinde07","email":"rajshinde55553@gmail.com"},"directories":{},"maintainers":[{"name":"rajwardhan-shinde07","email":"rajshinde55553@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/elasticsearch-mcp_0.1.3_1754284495473_0.49136945152641376"},"_hasShrinkwrap":false}},"time":{"created":"2025-08-03T11:35:39.298Z","modified":"2025-08-04T05:14:55.842Z","0.1.2":"2025-08-03T11:35:39.496Z","0.1.3":"2025-08-04T05:14:55.687Z"},"bugs":{"url":"https://github.com/RajwardhanShinde/elk-mcp/issues"},"author":{"name":"Your Organization"},"license":"MIT","homepage":"https://github.com/RajwardhanShinde/elk-mcp#readme","keywords":["elasticsearch","mcp","model-context-protocol","elastic-cloud","search","analytics","data-export","claude","typescript","security"],"repository":{"type":"git","url":"git+https://github.com/RajwardhanShinde/elk-mcp.git"},"description":"Secure MCP server for Elasticsearch integration with comprehensive tools and Elastic Cloud support","maintainers":[{"name":"rajwardhan-shinde07","email":"rajshinde55553@gmail.com"}],"readme":"# Elasticsearch MCP\n\n> **Model Context Protocol server for Elasticsearch integration with comprehensive security and performance features**\n\n[![npm version](https://badge.fury.io/js/elasticsearch-mcp.svg)](https://www.npmjs.com/package/elasticsearch-mcp)\n[![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)\n[![Elasticsearch](https://img.shields.io/badge/Elasticsearch-005571?logo=elasticsearch&logoColor=white)](https://www.elastic.co/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n**elasticsearch-mcp** is a Model Context Protocol (MCP) server that provides standardized, secure tools for interacting with Elasticsearch clusters. Built with TypeScript and optimized for Elastic Cloud environments, it offers comprehensive data management capabilities with enterprise-grade security features.\n\n## 🚀 Features\n\n- **🔐 Secure by Design**: Input validation, script sanitization, injection prevention\n- **☁️ Elastic Cloud Ready**: Native support for cloud ID and API key authentication  \n- **⚡ High Performance**: Streaming for large datasets, connection pooling, health monitoring\n- **🛠️ Comprehensive Tools**: 7 essential tools covering all major Elasticsearch operations\n- **📊 Advanced Querying**: Full Elasticsearch DSL support with aggregations and highlighting\n- **📁 Data Export**: Stream large datasets to CSV with compression support\n- **🔍 Smart Validation**: Zod-based schemas with security-first validation\n- **📝 Full TypeScript**: Complete type safety with strict null checks\n\n## 📦 Installation\n\n```bash\nnpm install elasticsearch-mcp\n```\n\n## 🏃‍♂️ Quick Start\n\n### 1. Basic Setup\n\n```bash\n# Set your Elasticsearch credentials\nexport ELASTIC_CLOUD_ID=\"your-cloud-id\"\nexport ELASTIC_API_KEY=\"your-api-key\"\n\n# Start the MCP server\nnpx elasticsearch-mcp\n```\n\n### 2. Using with Claude Desktop\n\nAdd to your Claude Desktop MCP configuration:\n\n```json\n{\n  \"mcpServers\": {\n    \"elasticsearch-mcp\": {\n      \"command\": \"npx\",\n      \"args\": [\"elasticsearch-mcp\"],\n      \"env\": {\n        \"ELASTIC_CLOUD_ID\": \"your-cloud-id\",\n        \"ELASTIC_API_KEY\": \"your-api-key\"\n      }\n    }\n  }\n}\n```\n\n### 3. Using with any MCP Client\n\n```typescript\nimport { ElasticMCPServer } from 'elasticsearch-mcp';\n\nconst server = new ElasticMCPServer();\nawait server.start();\n```\n\n## 🛠️ Available Tools\n\n| Tool | Description | Use Cases |\n|------|-------------|-----------|\n| `fetch_indices` | List and filter Elasticsearch indices | Index management, monitoring |\n| `search_elasticsearch` | Advanced search with aggregations | Data analysis, querying |\n| `create_index` | Create indices with mappings/settings | Schema management |\n| `insert_data` | Insert documents with validation | Data ingestion |\n| `update_document` | Update documents with scripts | Data modification |\n| `delete_document` | Delete by ID or query | Data cleanup |\n| `export_to_csv` | Stream data to CSV files | Reporting, data export |\n\n## 📋 Tool Examples\n\n### Search with Aggregations\n\n```json\n{\n  \"tool\": \"search_elasticsearch\",\n  \"arguments\": {\n    \"index\": \"sales-data\",\n    \"query\": {\n      \"range\": {\n        \"date\": {\n          \"gte\": \"2024-01-01\",\n          \"lte\": \"2024-12-31\"\n        }\n      }\n    },\n    \"aggregations\": {\n      \"monthly_sales\": {\n        \"date_histogram\": {\n          \"field\": \"date\",\n          \"calendar_interval\": \"month\"\n        },\n        \"aggs\": {\n          \"total_revenue\": {\n            \"sum\": { \"field\": \"amount\" }\n          }\n        }\n      }\n    }\n  }\n}\n```\n\n### Export Large Dataset\n\n```json\n{\n  \"tool\": \"export_to_csv\",\n  \"arguments\": {\n    \"index\": \"user-analytics\",\n    \"query\": {\n      \"bool\": {\n        \"filter\": [\n          { \"term\": { \"status\": \"active\" } },\n          { \"range\": { \"last_login\": { \"gte\": \"2024-01-01\" } } }\n        ]\n      }\n    },\n    \"fields\": [\"user_id\", \"email\", \"last_login\", \"country\"],\n    \"filename\": \"active_users_2024.csv\",\n    \"compress\": true,\n    \"maxRows\": 100000\n  }\n}\n```\n\n### Create Index with Schema\n\n```json\n{\n  \"tool\": \"create_index\",\n  \"arguments\": {\n    \"name\": \"product-catalog\",\n    \"mappings\": {\n      \"properties\": {\n        \"name\": { \"type\": \"text\", \"analyzer\": \"standard\" },\n        \"price\": { \"type\": \"float\" },\n        \"category\": { \"type\": \"keyword\" },\n        \"created_at\": { \"type\": \"date\" },\n        \"tags\": { \"type\": \"keyword\" },\n        \"description\": { \"type\": \"text\" }\n      }\n    },\n    \"settings\": {\n      \"number_of_shards\": 1,\n      \"number_of_replicas\": 1,\n      \"analysis\": {\n        \"analyzer\": {\n          \"product_analyzer\": {\n            \"type\": \"standard\",\n            \"stopwords\": \"_english_\"\n          }\n        }\n      }\n    },\n    \"aliases\": [\"products\", \"catalog\"]\n  }\n}\n```\n\n## ⚙️ Configuration\n\n### Environment Variables\n\n| Variable | Description | Required | Example |\n|----------|-------------|----------|---------|\n| `ELASTIC_CLOUD_ID` | Elastic Cloud deployment ID | Yes* | `deployment:dXMtY2VudHJhbDE=` |\n| `ELASTIC_API_KEY` | Elasticsearch API key | Yes* | `VnVhQ2ZHY0JDZGJrU...` |\n| `ELASTIC_NODE` | Self-hosted Elasticsearch URL | Yes* | `https://localhost:9200` |\n| `ELASTIC_USERNAME` | Basic auth username | No | `elastic` |\n| `ELASTIC_PASSWORD` | Basic auth password | No | `changeme` |\n| `LOG_LEVEL` | Logging level | No | `info` |\n| `LOG_FORMAT` | Log output format | No | `text` |\n| `MAX_CONCURRENT_REQUESTS` | Request concurrency limit | No | `10` |\n\n*Either `ELASTIC_CLOUD_ID` or `ELASTIC_NODE` is required\n\n### Configuration File\n\nCreate `.env` file:\n\n```bash\n# Elastic Cloud (recommended)\nELASTIC_CLOUD_ID=your-deployment-id\nELASTIC_API_KEY=your-api-key\n\n# Logging\nLOG_LEVEL=info\nLOG_FORMAT=json\n\n# Performance\nMAX_CONCURRENT_REQUESTS=10\nREQUEST_TIMEOUT_MS=30000\n```\n\n## 🔒 Security Features\n\n### Input Validation\n- **Zod Schemas**: Strict type validation for all inputs\n- **Field Name Validation**: Prevents reserved field usage\n- **Size Limits**: Document size, array length, string length limits\n- **Depth Validation**: Prevents deeply nested objects/queries\n\n### Script Security\n- **Script Sanitization**: Blocks dangerous script patterns\n- **Parameter Validation**: Validates script parameters\n- **Execution Limits**: Prevents resource exhaustion\n\n### Query Security\n- **Injection Prevention**: Sanitizes and validates all queries\n- **Script Query Blocking**: Prevents script-based queries in sensitive operations\n- **Rate Limiting**: Protects against abuse\n\n### Data Protection\n- **Credential Masking**: Never logs sensitive information\n- **Secure Connections**: TLS/SSL support\n- **Access Control**: Validates permissions before operations\n\n## 🏗️ Architecture\n\n```\n┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐\n│   MCP Client    │◄──►│Elasticsearch MCP│◄──►│  Elasticsearch  │\n│  (Claude, etc.) │    │     Server      │    │    Cluster      │\n└─────────────────┘    └─────────────────┘    └─────────────────┘\n                              │\n                       ┌─────────────┐\n                       │   Tools     │\n                       │             │\n                       │ • fetch     │\n                       │ • search    │\n                       │ • create    │\n                       │ • insert    │\n                       │ • update    │\n                       │ • delete    │\n                       │ • export    │\n                       └─────────────┘\n```\n\n## 📊 Performance\n\n### Benchmarks\n- **Search**: <500ms average response time\n- **Large Exports**: 10K+ documents/second with streaming\n- **Memory Usage**: <100MB for typical operations\n- **Concurrent Requests**: Up to 10 simultaneous operations\n\n### Optimization Features\n- **Connection Pooling**: Reuses Elasticsearch connections\n- **Streaming**: Memory-efficient processing of large datasets\n- **Compression**: Reduces export file sizes by 70%+\n- **Health Monitoring**: Automatic reconnection on failures\n\n## 🔧 Development\n\n### Setup Development Environment\n\n```bash\n# Clone repository\ngit clone https://github.com/RajwardhanShinde/elk-mcp.git\ncd elk-mcp\n\n# Install dependencies\nnpm install\n\n# Set up environment\ncp .env.example .env\n# Edit .env with your Elasticsearch credentials\n\n# Run in development mode\nnpm run dev\n\n# Run tests\nnpm test\n\n# Build for production\nnpm run build\n```\n\n### Project Structure\n\n```\nelasticsearch-mcp/\n├── src/\n│   ├── tools/           # MCP tool implementations\n│   ├── elasticsearch/   # ES client and connection management\n│   ├── validation/      # Input validation schemas\n│   ├── errors/          # Error handling utilities\n│   ├── config.ts        # Configuration management\n│   ├── logger.ts        # Structured logging\n│   └── server.ts        # Main MCP server\n├── tests/               # Comprehensive test suite\n├── docs/                # Documentation\n└── build/               # Compiled output\n```\n\n## 🤝 Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.\n\n### Development Workflow\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes with tests\n4. Ensure all tests pass\n5. Submit a pull request\n\n## 📚 Documentation\n\n- [Quick Start Guide](docs/guides/quick-start.md)\n- [API Reference](docs/api/tools.md)\n- [Configuration Guide](docs/api/configuration.md)\n- [Elastic Cloud Setup](docs/guides/elastic-cloud-setup.md)\n- [Troubleshooting](docs/guides/troubleshooting.md)\n- [Examples](docs/examples/)\n\n## 🐛 Troubleshooting\n\n### Common Issues\n\n**Connection Failed**\n```bash\n# Check credentials\necho $ELASTIC_CLOUD_ID\necho $ELASTIC_API_KEY\n\n# Test connection\ncurl -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \\\\\n     \"$ELASTIC_NODE/_cluster/health\"\n```\n\n**Permission Denied**\n- Ensure API key has required privileges\n- Check index permissions\n- Verify cluster access\n\n**Tool Validation Errors**\n- Check input parameter types\n- Validate required fields\n- Review field name restrictions\n\nSee [Troubleshooting Guide](docs/guides/troubleshooting.md) for more details.\n\n## 📄 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## 🏷️ Version History\n\n- **v0.1.0** - Initial release with 7 core tools\n- Full changelog: [CHANGELOG.md](CHANGELOG.md)\n\n## 🔗 Links\n\n- [npm Package](https://www.npmjs.com/package/elasticsearch-mcp)\n- [GitHub Repository](https://github.com/RajwardhanShinde/elk-mcp)\n- [Issue Tracker](https://github.com/RajwardhanShinde/elk-mcp/issues)\n- [Elasticsearch Documentation](https://www.elastic.co/guide/)\n- [Model Context Protocol](https://modelcontextprotocol.io/)\n\n---\n\n**Built with ❤️ for the Elasticsearch and MCP communities**","readmeFilename":"README.md"}