Octodet Elasticsearch MCP सर्वर
सारांश
Octodet Elasticsearch MCP सर्वर
Octodet Elasticsearch MCP सर्वर एक शक्तिशाली मॉडल संदर्भ प्रोटोकॉल (MCP) सर्वर है जिसे Elasticsearch क्लस्टरों के साथ सहज इंटरैक्शन के लिए डिज़ाइन किया गया है। यह LLM-संचालित अनुप्रयोगों के लिए Elasticsearch के भीतर डेटा प्रबंधन, खोजने और अपडेट करने जैसी विभिन्न ऑपरेशनों को करने का एक मानकीकृत तरीका प्रदान करता है।
विशेषताएँ
- पूर्ण Elasticsearch ऑपरेशन्स: दस्तावेज़ों और अनुक्रमणिकाओं पर पूर्ण CRUD ऑपरेशन्स को आसानी से निष्पादित करें।
- बल्क ऑपरेशन्स: एकल API कॉल में कई ऑपरेशन्स को प्रोसेस करके प्रदर्शन को बढ़ाएँ।
- क्वेरी-आधारित अपडेट/डिलीट: विशिष्ट क्वेरी के आधार पर दस्तावेज़ों को संशोधित या हटाएँ।
- क्लस्टर प्रबंधन: अपने Elasticsearch क्लस्टर की स्वास्थ्य की निगरानी करें, जिसमें शार्द और टेम्पलेट शामिल हैं।
- उन्नत खोज: अंतर्निहित हाइलाइटिंग समर्थन के साथ Elasticsearch DSL क्वेरी की पूर्ण क्षमताओं का उपयोग करें।
कैसे स्थापित करें
NPM पैकेज के रूप में
Octodet Elasticsearch MCP सर्वर को वैश्विक रूप से स्थापित करने के लिए, चलाएँ:
npm install -g @octodet/elasticsearch-mcp
वैकल्पिक रूप से, आप इसे सीधे npx के साथ उपयोग कर सकते हैं:
npx @octodet/elasticsearch-mcp
स्रोत से
- रिपॉजिटरी को क्लोन करें।
- आवश्यक निर्भरताएँ स्थापित करें:
npm install
- सर्वर बनाएं:
npm run build
MCP क्लाइंट्स के साथ एकीकरण
VS कोड एकीकरण
VS कोड MCP एक्सटेंशन के साथ एकीकृत करने के लिए, अपने settings.json
में निम्नलिखित कॉन्फ़िगरेशन जोड़ें:
"mcp.servers": {
"elasticsearch": {
"command": "npx",
"args": [
"-y", "@octodet/elasticsearch-mcp"
],
"env": {
"ES_URL": "http://localhost:9200",
"ES_API_KEY": "your_api_key",
"ES_VERSION": "8"
}
}
}
क्लॉड डेस्कटॉप एकीकरण
क्लॉड डेस्कटॉप के लिए, अपने सेटिंग्स को निम्नलिखित के रूप में कॉन्फ़िगर करें:
{
"mcpServers": {
"elasticsearch": {
"command": "npx",
"args": ["-y", "@octodet/elasticsearch-mcp"],
"env": {
"ES_URL": "http://localhost:9200",
"ES_API_KEY": "your_api_key",
"ES_VERSION": "8"
}
}
}
}
स्थानीय विकास के लिए
यदि आप स्थानीय रूप से MCP सर्वर विकसित कर रहे हैं, तो अपने क्लाइंट्स को अपने स्थानीय निर्माण का उपयोग करने के लिए कॉन्फ़िगर करें:
{
"mcpServers": {
"elasticsearch": {
"command": "node",
"args": ["path/to/build/index.js"],
"env": {
"ES_URL": "http://localhost:9200",
"ES_API_KEY": "your_api_key",
"ES_VERSION": "8"
}
}
}
}
कॉन्फ़िगरेशन
सर्वर को निम्नलिखित पर्यावरण चर का उपयोग करके कॉन्फ़िगर किया जा सकता है:
| चर | विवरण | डिफ़ॉल्ट | | | | | | ES_URL | Elasticsearch सर्वर URL | http://localhost:9200 | | ES_API_KEY | प्रमाणीकरण के लिए API कुंजी | | | ES_USERNAME | प्रमाणीकरण के लिए उपयोगकर्ता नाम | | | ES_PASSWORD | प्रमाणीकरण के लिए पासवर्ड | | | ES_CA_CERT | कस्टम CA प्रमाणपत्र का पथ | | | ES_VERSION | Elasticsearch संस्करण (8 या 9) | 8 | | ES_SSL_SKIP_VERIFY | SSL सत्यापन छोड़ें | false | | ES_PATH_PREFIX | Elasticsearch के लिए पथ उपसर्ग | |
उपकरण
सर्वर में विभिन्न Elasticsearch ऑपरेशन्स के लिए 16 MCP उपकरण शामिल हैं, प्रत्येक के साथ आवश्यक और वैकल्पिक पैरामीटर के साथ दस्तावेज़ित किया गया है।
1. अनुक्रमणिकाएँ सूचीबद्ध करें
सभी उपलब्ध Elasticsearch अनुक्रमणिकाओं की सूची प्राप्त करें जिसमें विस्तृत जानकारी हो।
पैरामीटर:
indexPattern
(वैकल्पिक, स्ट्रिंग): अनुक्रमणिकाओं को फ़िल्टर करने के लिए पैटर्न (जैसे, "logs-", "my-index-")
उदाहरण:
{
"indexPattern": "logs-*"
}
2. मैपिंग प्राप्त करें
विशिष्ट Elasticsearch अनुक्रमणिका के लिए फ़ील्ड मैपिंग प्राप्त करें।
पैरामीटर:
index
(आवश्यक, स्ट्रिंग): उस अनुक्रमणिका का नाम जिसके लिए मैपिंग प्राप्त करनी है।
उदाहरण:
{
"index": "my-index"
}
3. खोजें
प्रदान की गई क्वेरी DSL और हाइलाइटिंग का उपयोग करके Elasticsearch में खोज करें।
पैरामीटर:
index
(आवश्यक, स्ट्रिंग): उस अनुक्रमणिका या अनुक्रमणिकाओं को खोजने के लिए (कोमा से पृथक मानों का समर्थन करता है)।queryBody
(आवश्यक, ऑब्जेक्ट): Elasticsearch क्वेरी DSL बॉडी।highlight
(वैकल्पिक, बूलियन): खोज परिणामों के लिए हाइलाइटिंग सक्षम करें (डिफ़ॉल्ट: true)।
उदाहरण:
{
"index": "my-index",
"queryBody": {
"query": {
"match": {
"content": "search term"
}
},
"size": 10,
"from": 0,
"sort": [{ "_score": { "order": "desc" } }]
},
"highlight": true
}
4. क्लस्टर स्वास्थ्य प्राप्त करें
Elasticsearch क्लस्टर के बारे में स्वास्थ्य जानकारी प्राप्त करें।
पैरामीटर:
- कोई आवश्यक नहीं।
उदाहरण:
{}
5. शार्द प्राप्त करें
सभी या विशिष्ट अनुक्रमणिकाओं के लिए शार्द जानकारी प्राप्त करें।
पैरामीटर:
index
(वैकल्पिक, स्ट्रिंग): विशिष्ट अनुक्रमणिका जिसके लिए शार्द जानकारी प्राप्त करनी है। यदि छोड़ा गया, तो सभी अनुक्रमणिकाओं के लिए शार्द लौटाता है।
उदाहरण:
{
"index": "my-index"
}
6. दस्तावेज़ जोड़ें
विशिष्ट Elasticsearch अनुक्रमणिका में एक नया दस्तावेज़ डालें।
पैरामीटर:
index
(आवश्यक, स्ट्रिंग): वह अनुक्रमणिका जिसमें दस्तावेज़ जोड़ा जाएगा।document
(आवश्यक, ऑब्जेक्ट): जोड़ने के लिए दस्तावेज़ की सामग्री।id
(वैकल्पिक, स्ट्रिंग): दस्तावेज़ ID। यदि छोड़ा गया, तो Elasticsearch स्वचालित रूप से एक उत्पन्न करता है।
उदाहरण:
{
"index": "my-index",
"id": "doc1",
"document": {
"title": "My Document",
"content": "Document content here",
"timestamp": "2025-06-23T10:30:00Z",
"tags": ["important", "draft"]
}
}
7. दस्तावेज़ अपडेट करें
विशिष्ट Elasticsearch अनुक्रमणिका में एक मौजूदा दस्तावेज़ को संशोधित करें।
पैरामीटर:
index
(आवश्यक, स्ट्रिंग): वह अनुक्रमणिका जिसमें दस्तावेज़ है।id
(आवश्यक, स्ट्रिंग): अपडेट करने के लिए दस्तावेज़ का ID।document
(आवश्यक, ऑब्जेक्ट): अपडेट करने के लिए फ़ील्ड के साथ आंशिक दस्तावेज़।
उदाहरण:
{
"index": "my-index",
"id": "doc1",
"document": {
"title": "Updated Document Title",
"last_modified": "2025-06-23T10:30:00Z"
}
}
8. दस्तावेज़ हटाएँ
विशिष्ट Elasticsearch अनुक्रमणिका से एक दस्तावेज़ हटाएँ।
पैरामीटर:
index
(आवश्यक, स्ट्रिंग): वह अनुक्रमणिका जिसमें दस्तावेज़ है।id
(आवश्यक, स्ट्रिंग): हटाने के लिए दस्तावेज़ का ID।
उदाहरण:
{
"index": "my-index",
"id": "doc1"
}
9. क्वेरी द्वारा अपडेट करें
क्वेरी के आधार पर Elasticsearch अनुक्रमणिका में दस्तावेज़ों को अपडेट करें।
पैरामीटर:
index
(आवश्यक, स्ट्रिंग): वह अनुक्रमणिका जिसमें दस्तावेज़ों को अपडेट करना है।query
(आवश्यक, ऑब्जेक्ट): दस्तावेज़ों को अपडेट करने के लिए मेल खाने के लिए Elasticsearch क्वेरी।script
(आवश्यक, ऑब्जेक्ट): मेल खाने वाले दस्तावेज़ों को अपडेट करने के लिए निष्पादित करने के लिए स्क्रिप्ट।conflicts
(वैकल्पिक, स्ट्रिंग): संस्करण संघर्षों को कैसे संभालना है ("abort" या "proceed", डिफ़ॉल्ट: "abort")।refresh
(वैकल्पिक, बूलियन): ऑपरेशन के बाद अनुक्रमणिका को ताज़ा करने के लिए (डिफ़ॉल्ट: false)।
उदाहरण:
{
"index": "my-index",
"query": {
"term": {
"status": "active"
}
},
"script": {
"source": "ctx._source.status = params.newStatus; ctx._source.updated_at = params.timestamp",
"params": {
"newStatus": "inactive",
"timestamp": "2025-06-23T10:30:00Z"
}
},
"conflicts": "proceed",
"refresh": true
}
10. क्वेरी द्वारा हटाएँ
क्वेरी के आधार पर Elasticsearch अनुक्रमणिका से दस्तावेज़ों को हटाएँ।
पैरामीटर:
index
(आवश्यक, स्ट्रिंग): वह अनुक्रमणिका जिसमें दस्तावेज़ों को हटाना है।query
(आवश्यक, ऑब्जेक्ट): दस्तावेज़ों को हटाने के लिए मेल खाने के लिए Elasticsearch क्वेरी।conflicts
(वैकल्पिक, स्ट्रिंग): संस्करण संघर्षों को कैसे संभालना है ("abort" या "proceed", डिफ़ॉल्ट: "abort")।refresh
(वैकल्पिक, बूलियन): ऑपरेशन के बाद अनुक्रमणिका को ताज़ा करने के लिए (डिफ़ॉल्ट: false)।
उदाहरण:
{
"index": "my-index",
"query": {
"range": {
"created_date": {
"lt": "2025-01-01"
}
}
},
"conflicts": "proceed",
"refresh": true
}
11. बल्क ऑपरेशन्स
सुधारित प्रदर्शन के लिए एकल API कॉल में कई दस्तावेज़ ऑपरेशन्स को निष्पादित करें।
पैरामीटर:
operations
(आवश्यक, ऐरे): ऑपरेशन ऑब्जेक्ट्स का ऐरे, प्रत्येक में शामिल:action
(आवश्यक, स्ट्रिंग): ऑपरेशन प्रकार ("index", "create", "update", या "delete")।index
(आवश्यक, स्ट्रिंग): इस ऑपरेशन के लिए अनुक्रमणिका।id
(वैकल्पिक, स्ट्रिंग): दस्तावेज़ ID (अपडेट/हटाने के लिए आवश्यक, इंडेक्स/क्रिएट के लिए वैकल्पिक)।document
(शर्तीय, ऑब्जेक्ट): दस्तावेज़ की सामग्री (इंडेक्स/क्रिएट/अपडेट ऑपरेशन्स के लिए आवश्यक)।
उदाहरण:
{
"operations": [
{
"action": "index",
"index": "my-index",
"id": "doc1",
"document": { "title": "Document 1", "content": "Content here" }
},
{
"action": "update",
"index": "my-index",
"id": "doc2",
"document": { "title": "Updated Title" }
},
{
"action": "delete",
"index": "my-index",
"id": "doc3"
}
]
}
12. अनुक्रमणिका बनाएँ
वैकल्पिक सेटिंग्स और मैपिंग के साथ एक नई Elasticsearch अनुक्रमणिका बनाएँ।
पैरामीटर:
index
(आवश्यक, स्ट्रिंग): बनाने के लिए अनुक्रमणिका का नाम।settings
(वैकल्पिक, ऑब्जेक्ट): अनुक्रमणिका सेटिंग्स जैसे शार्द की संख्या, प्रतिकृतियाँ, आदि।mappings
(वैकल्पिक, ऑब्जेक्ट): फ़ील्ड मैपिंग जो यह परिभाषित करती है कि दस्तावेज़ों को कैसे अनुक्रमित किया जाना चाहिए।
उदाहरण:
{
"index": "new-index",
"settings": {
"number_of_shards": 3,
"number_of_replicas": 1,
"analysis": {
"analyzer": {
"custom_analyzer": {
"type": "standard",
"stopwords": "_english_"
}
}
}
},
"mappings": {
"properties": {
"title": {
"type": "text",
"analyzer": "custom_analyzer"
},
"created": {
"type": "date",
"format": "yyyy-MM-dd'T'HH:mm:ss'Z'"
},
"tags": {
"type": "keyword"
}
}
}
}
13. अनुक्रमणिका हटाएँ
एक Elasticsearch अनुक्रमणिका को स्थायी रूप से हटाएँ।
पैरामीटर:
index
(आवश्यक, स्ट्रिंग): हटाने के लिए अनुक्रमणिका का नाम।
उदाहरण:
{
"index": "my-index"
}
14. दस्तावेज़ों की गणना करें
एक अनुक्रमणिका में दस्तावेज़ों की गणना करें, वैकल्पिक रूप से एक क्वेरी द्वारा फ़िल्टर किया गया।
पैरामीटर:
index
(आवश्यक, स्ट्रिंग): उस अनुक्रमणिका में दस्तावेज़ों की गणना करें।query
(वैकल्पिक, ऑब्जेक्ट): दस्तावेज़ों को गिनने के लिए फ़िल्टर करने के लिए Elasticsearch क्वेरी।
उदाहरण:
{
"index": "my-index",
"query": {
"bool": {
"must": [
{ "term": { "status": "active" } },
{ "range": { "created_date": { "gte": "2025-01-01" } } }
]
}
}
}
15. टेम्पलेट्स प्राप्त करें
Elasticsearch से अनुक्रमणिका टेम्पलेट्स प्राप्त करें।
पैरामीटर:
name
(वैकल्पिक, स्ट्रिंग): विशिष्ट टेम्पलेट नाम जिसे प्राप्त करना है। यदि छोड़ा गया, तो सभी टेम्पलेट लौटाता है।
उदाहरण:
{
"name": "logs-template"
}
16. उपनाम प्राप्त करें
Elasticsearch से अनुक्रमणिका उपनाम प्राप्त करें।
पैरामीटर:
name
(वैकल्पिक, स्ट्रिंग): विशिष्ट उपनाम नाम जिसे प्राप्त करना है। यदि छोड़ा गया, तो सभी उपनाम लौटाता है।
उदाहरण:
{
"name": "logs-alias"
}
विकास
विकास मोड में चलाना
विकास के दौरान सर्वर को वॉच मोड में चलाने के लिए, उपयोग करें:
npm run dev
प्रोटोकॉल कार्यान्वयन
यह सर्वर मॉडल संदर्भ प्रोटोकॉल को लागू करता है ताकि LLM क्लाइंट्स और Elasticsearch के बीच मानकीकृत संचार को सुगम बनाया जा सके। यह विभिन्न Elasticsearch ऑपरेशन्स को करने के लिए MCP क्लाइंट्स द्वारा कॉल किए जाने वाले उपकरणों का एक व्यापक सेट प्रदान करता है।
नए उपकरण जोड़ना
सर्वर में एक नया उपकरण जोड़ने के लिए:
src/index.ts
में MCP सर्वर के उपकरण पंजीकरण प्रारूप का उपयोग करके उपकरण को परिभाषित करें।src/utils/elasticsearchService.ts
में आवश्यक कार्यक्षमता लागू करें।- नए उपकरण को दस्तावेज़ित करने के लिए इस README को अपडेट करें।
अन्य MCP क्लाइंट्स
Octodet Elasticsearch MCP सर्वर का उपयोग किसी भी MCP-संगत क्लाइंट के साथ किया जा सकता है, जिसमें शामिल हैं:
- OpenAI का ChatGPT MCP प्लगइन्स के माध्यम से
- Anthropic का क्लॉड डेस्कटॉप
- VS कोड में क्लॉड
- MCP SDK का उपयोग करके कस्टम अनुप्रयोग
प्रोग्रामेटिक उपयोग
आप अपने Node.js अनुप्रयोगों में सर्वर का प्रोग्रामेटिक रूप से भी उपयोग कर सकते हैं:
import { createOctodetElasticsearchMcpServer } from "@octodet/elasticsearch-mcp";
import { CustomTransport } from "@modelcontextprotocol/sdk/server";
// Elasticsearch कनेक्शन कॉन्फ़िगर करें
const config = {
url: "http://localhost:9200",
apiKey: "your_api_key",
version: "8",
};
// सर्वर बनाएँ और प्रारंभ करें
async function startServer() {
const server = await createOctodetElasticsearchMcpServer(config);
// अपने कस्टम ट्रांसपोर्ट से कनेक्ट करें
const transport = new CustomTransport();
await server.connect(transport);
console.log("Elasticsearch MCP सर्वर प्रारंभ किया गया");
}
startServer().catch(console.error);
लाइसेंस
यह परियोजना MIT लाइसेंस के तहत लाइसेंस प्राप्त है - विवरण के लिए LICENSE फ़ाइल देखें।
विवरण
Octodet Elasticsearch MCP Server
A Model Context Protocol (MCP) server for Elasticsearch operations, providing a comprehensive set of tools for interacting with Elasticsearch clusters through the standardized Model Context Protocol. This server enables LLM-powered applications to search, update, and manage Elasticsearch data.
Features
- Complete Elasticsearch Operations: Full CRUD operations for documents and indices
- Bulk Operations: Process multiple operations in a single API call
- Query-Based Updates/Deletes: Modify or remove documents based on queries
- Cluster Management: Monitor health, shards, and templates
- Advanced Search: Full support for Elasticsearch DSL queries with highlighting
Installation
As an NPM Package
Install the package globally:
npm install -g @octodet/elasticsearch-mcp
Or use it directly with npx:
npx @octodet/elasticsearch-mcp
From Source
- Clone this repository
- Install dependencies:
npm install
- Build the server:
npm run build
Integration with MCP Clients
VS Code Integration
Add the following configuration to your VS Code settings.json to integrate with the VS Code MCP extension:
"mcp.servers": {
"elasticsearch": {
"command": "npx",
"args": [
"-y", "@octodet/elasticsearch-mcp"
],
"env": {
"ES_URL": "http://localhost:9200",
"ES_API_KEY": "your_api_key",
"ES_VERSION": "8"
}
}
}
Claude Desktop Integration
Configure in your Claude Desktop configuration file:
{
"mcpServers": {
"elasticsearch": {
"command": "npx",
"args": ["-y", "@octodet/elasticsearch-mcp"],
"env": {
"ES_URL": "http://localhost:9200",
"ES_API_KEY": "your_api_key",
"ES_VERSION": "8"
}
}
}
}
For Local Development
If you're developing the MCP server locally, you can configure the clients to use your local build:
{
"mcpServers": {
"elasticsearch": {
"command": "node",
"args": ["path/to/build/index.js"],
"env": {
"ES_URL": "http://localhost:9200",
"ES_API_KEY": "your_api_key",
"ES_VERSION": "8"
}
}
}
}
Configuration
The server uses the following environment variables for configuration:
| Variable | Description | Default | | | | | | ES_URL | Elasticsearch server URL | http://localhost:9200 | | ES_API_KEY | API key for authentication | | | ES_USERNAME | Username for authentication | | | ES_PASSWORD | Password for authentication | | | ES_CA_CERT | Path to custom CA certificate | | | ES_VERSION | Elasticsearch version (8 or 9) | 8 | | ES_SSL_SKIP_VERIFY | Skip SSL verification | false | | ES_PATH_PREFIX | Path prefix for Elasticsearch | |
Tools
The server provides 16 MCP tools for Elasticsearch operations. Each tool is documented with its required and optional parameters:
1. List Indices
List all available Elasticsearch indices with detailed information.
Parameters:
indexPattern
(optional, string): Pattern to filter indices (e.g., "logs-", "my-index-")
Example:
{
"indexPattern": "logs-*"
}
2. Get Mappings
Get field mappings for a specific Elasticsearch index.
Parameters:
index
(required, string): The name of the index to get mappings for
Example:
{
"index": "my-index"
}
3. Search
Perform an Elasticsearch search with the provided query DSL and highlighting.
Parameters:
index
(required, string): The index or indices to search in (supports comma-separated values)queryBody
(required, object): The Elasticsearch query DSL bodyhighlight
(optional, boolean): Enable search result highlighting (default: true)
Example:
{
"index": "my-index",
"queryBody": {
"query": {
"match": {
"content": "search term"
}
},
"size": 10,
"from": 0,
"sort": [{ "_score": { "order": "desc" } }]
},
"highlight": true
}
4. Get Cluster Health
Get health information about the Elasticsearch cluster.
Parameters:
- None required
Example:
{}
5. Get Shards
Get shard information for all or specific indices.
Parameters:
index
(optional, string): Specific index to get shard information for. If omitted, returns shards for all indices
Example:
{
"index": "my-index"
}
6. Add Document
Add a new document to a specific Elasticsearch index.
Parameters:
index
(required, string): The index to add the document todocument
(required, object): The document content to addid
(optional, string): Document ID. If omitted, Elasticsearch will generate one automatically
Example:
{
"index": "my-index",
"id": "doc1",
"document": {
"title": "My Document",
"content": "Document content here",
"timestamp": "2025-06-23T10:30:00Z",
"tags": ["important", "draft"]
}
}
7. Update Document
Update an existing document in a specific Elasticsearch index.
Parameters:
index
(required, string): The index containing the documentid
(required, string): The ID of the document to updatedocument
(required, object): The partial document with fields to update
Example:
{
"index": "my-index",
"id": "doc1",
"document": {
"title": "Updated Document Title",
"last_modified": "2025-06-23T10:30:00Z"
}
}
8. Delete Document
Delete a document from a specific Elasticsearch index.
Parameters:
index
(required, string): The index containing the documentid
(required, string): The ID of the document to delete
Example:
{
"index": "my-index",
"id": "doc1"
}
9. Update By Query
Update documents in an Elasticsearch index based on a query.
Parameters:
index
(required, string): The index to update documents inquery
(required, object): Elasticsearch query to match documents for updatescript
(required, object): Script to execute for updating matched documentsconflicts
(optional, string): How to handle version conflicts ("abort" or "proceed", default: "abort")refresh
(optional, boolean): Whether to refresh the index after the operation (default: false)
Example:
{
"index": "my-index",
"query": {
"term": {
"status": "active"
}
},
"script": {
"source": "ctx._source.status = params.newStatus; ctx._source.updated_at = params.timestamp",
"params": {
"newStatus": "inactive",
"timestamp": "2025-06-23T10:30:00Z"
}
},
"conflicts": "proceed",
"refresh": true
}
10. Delete By Query
Delete documents in an Elasticsearch index based on a query.
Parameters:
index
(required, string): The index to delete documents fromquery
(required, object): Elasticsearch query to match documents for deletionconflicts
(optional, string): How to handle version conflicts ("abort" or "proceed", default: "abort")refresh
(optional, boolean): Whether to refresh the index after the operation (default: false)
Example:
{
"index": "my-index",
"query": {
"range": {
"created_date": {
"lt": "2025-01-01"
}
}
},
"conflicts": "proceed",
"refresh": true
}
11. Bulk Operations
Perform multiple document operations in a single API call for better performance.
Parameters:
operations
(required, array): Array of operation objects, each containing:action
(required, string): The operation type ("index", "create", "update", or "delete")index
(required, string): The index for this operationid
(optional, string): Document ID (required for update/delete, optional for index/create)document
(conditional, object): Document content (required for index/create/update operations)
Example:
{
"operations": [
{
"action": "index",
"index": "my-index",
"id": "doc1",
"document": { "title": "Document 1", "content": "Content here" }
},
{
"action": "update",
"index": "my-index",
"id": "doc2",
"document": { "title": "Updated Title" }
},
{
"action": "delete",
"index": "my-index",
"id": "doc3"
}
]
}
12. Create Index
Create a new Elasticsearch index with optional settings and mappings.
Parameters:
index
(required, string): The name of the index to createsettings
(optional, object): Index settings like number of shards, replicas, etc.mappings
(optional, object): Field mappings defining how documents should be indexed
Example:
{
"index": "new-index",
"settings": {
"number_of_shards": 3,
"number_of_replicas": 1,
"analysis": {
"analyzer": {
"custom_analyzer": {
"type": "standard",
"stopwords": "_english_"
}
}
}
},
"mappings": {
"properties": {
"title": {
"type": "text",
"analyzer": "custom_analyzer"
},
"created": {
"type": "date",
"format": "yyyy-MM-dd'T'HH:mm:ss'Z'"
},
"tags": {
"type": "keyword"
}
}
}
}
13. Delete Index
Delete an Elasticsearch index permanently.
Parameters:
index
(required, string): The name of the index to delete
Example:
{
"index": "my-index"
}
14. Count Documents
Count documents in an index, optionally filtered by a query.
Parameters:
index
(required, string): The index to count documents inquery
(optional, object): Elasticsearch query to filter documents for counting
Example:
{
"index": "my-index",
"query": {
"bool": {
"must": [
{ "term": { "status": "active" } },
{ "range": { "created_date": { "gte": "2025-01-01" } } }
]
}
}
}
15. Get Templates
Get index templates from Elasticsearch.
Parameters:
name
(optional, string): Specific template name to retrieve. If omitted, returns all templates
Example:
{
"name": "logs-template"
}
16. Get Aliases
Get index aliases from Elasticsearch.
Parameters:
name
(optional, string): Specific alias name to retrieve. If omitted, returns all aliases
Example:
{
"name": "logs-alias"
}
Development
Running in Development Mode
Run the server in watch mode during development:
npm run dev
Protocol Implementation
This server implements the Model Context Protocol to enable standardized communication between LLM clients and Elasticsearch. It provides a set of tools that can be invoked by MCP clients to perform various Elasticsearch operations.
Adding New Tools
To add a new tool to the server:
- Define the tool in
src/index.ts
using the MCP server's tool registration format - Implement the necessary functionality in
src/utils/elasticsearchService.ts
- Update this README to document the new tool
Other MCP Clients
This server can be used with any MCP-compatible client, including:
- OpenAI's ChatGPT via MCP plugins
- Anthropic's Claude Desktop
- Claude in VS Code
- Custom applications using the MCP SDK
Programmatic Usage
You can also use the server programmatically in your Node.js applications:
import { createOctodetElasticsearchMcpServer } from "@octodet/elasticsearch-mcp";
import { CustomTransport } from "@modelcontextprotocol/sdk/server";
// Configure the Elasticsearch connection
const config = {
url: "http://localhost:9200",
apiKey: "your_api_key",
version: "8",
};
// Create and start the server
async function startServer() {
const server = await createOctodetElasticsearchMcpServer(config);
// Connect to your custom transport
const transport = new CustomTransport();
await server.connect(transport);
console.log("Elasticsearch MCP server started");
}
startServer().catch(console.error);
License
This project is licensed under the MIT License - see the LICENSE file for details.
सर्वर कॉन्फ़िगरेशन
{
"mcpServers": {
"elasticsearch": {
"command": "npx",
"args": [
"-y",
"@octodet/elasticsearch-mcp"
],
"env": {
"ES_URL": "http://localhost:9200",
"ES_API_KEY": "your_api_key",
"ES_VERSION": "8"
}
}
}
}