|
1 | 1 | # Elasticsearch MCP Server |
2 | 2 |
|
3 | | -Connect to your Elasticsearch data directly from any MCP Client (like Claude Desktop) using the Model Context Protocol (MCP). |
4 | | - |
5 | | -This server connects agents to your Elasticsearch data using the Model Context Protocol (MCP). It allows you to interact with your Elasticsearch indices through natural language conversations. |
6 | | - |
7 | | -## Features |
8 | | - |
9 | | -* **List Indices**: View all available Elasticsearch indices |
10 | | -* **Get Mappings**: Inspect field mappings for specific indices |
11 | | -* **Search**: Execute Elasticsearch queries using full Query DSL capabilities with automatic highlighting |
12 | | - |
13 | | -## Prerequisites |
14 | | - |
15 | | -* Node.js (v22+) |
16 | | -* An Elasticsearch instance |
17 | | -* Elasticsearch API key with appropriate permissions |
18 | | -* Claude Desktop App (free version is sufficient) |
19 | | - |
20 | | -## Installation & Setup |
21 | | - |
22 | | -### Using the Published NPM Package |
23 | | - |
24 | | -The easiest way to use Elasticsearch MCP Server is through the published npm package: |
25 | | - |
26 | | -1. **Configure Claude Desktop App** |
27 | | - - Open Claude Desktop App |
28 | | - - Go to Settings > Developer > MCP Servers |
29 | | - - Click `Edit Config` and add a new MCP Server with the following configuration to your `claude_desktop_config.json`: |
30 | | - |
31 | | -```json |
32 | | -{ |
33 | | - "mcpServers": { |
34 | | - "elasticsearch-mcp-server": { |
35 | | - "command": "npx", |
36 | | - "args": [ |
37 | | - "-y", |
38 | | - "mcp-server-elasticsearch" |
39 | | - ], |
40 | | - "env": { |
41 | | - "ES_URL": "your-elasticsearch-url", |
42 | | - "ES_API_KEY": "your-api-key" |
43 | | - } |
44 | | - } |
45 | | - } |
46 | | -} |
47 | | -``` |
48 | | - |
49 | | -2. **Start a Conversation** |
50 | | - - Open a new conversation in Claude Desktop App |
51 | | - - The MCP server should connect automatically |
52 | | - - You can now ask Claude questions about your Elasticsearch data |
53 | | - |
54 | | -### Developing Locally |
55 | | - |
56 | | -If you want to develop or modify the server locally: |
57 | | - |
58 | | -1. **Use the correct Node.js version** |
59 | | -```bash |
60 | | -nvm use |
61 | | -``` |
62 | | - |
63 | | -2. **Install Dependencies** |
64 | | -```bash |
65 | | -npm install |
66 | | -``` |
67 | | - |
68 | | -3. **Build the Project** |
69 | | -```bash |
70 | | -npm run build |
71 | | -``` |
72 | | - |
73 | | -4. **Configure Claude Desktop for local development** |
74 | | - - Open Claude Desktop App |
75 | | - - Go to Settings > Developer > MCP Servers |
76 | | - - Click `Edit Config` and add a new MCP Server with the following configuration: |
77 | | - |
78 | | -```json |
79 | | -{ |
80 | | - "mcpServers": { |
81 | | - "Elasticsearch MCP Server (Local)": { |
82 | | - "command": "node", |
83 | | - "args": [ |
84 | | - "/path/to/your/project/dist/index.js" |
85 | | - ], |
86 | | - "env": { |
87 | | - "ES_URL": "your-elasticsearch-url", |
88 | | - "ES_API_KEY": "your-api-key" |
89 | | - } |
90 | | - } |
91 | | - } |
92 | | -} |
93 | | -``` |
94 | | - |
95 | | -5. **Debugging** |
96 | | -```bash |
97 | | -npm run inspector |
98 | | -``` |
99 | | - |
100 | | -## Example Questions |
101 | | - |
102 | | -* "What indices do I have in my Elasticsearch cluster?" |
103 | | -* "Show me the field mappings for the 'products' index" |
104 | | -* "Find all orders over $500 from last month" |
105 | | -* "Which products received the most 5-star reviews?" |
106 | | - |
107 | | -## How It Works |
108 | | - |
109 | | -When you ask Claude a question about your data: |
110 | | -1. Claude analyzes your request and determines which Elasticsearch operations are needed |
111 | | -2. The MCP server carries out these operations (listing indices, fetching mappings, performing searches) |
112 | | -3. Claude processes the results and presents them in a user-friendly format |
113 | | - |
114 | | -## Security Best Practices |
115 | | - |
116 | | -You can create a dedicated Elasticsearch API key with minimal permissions to control access to your data: |
117 | | - |
118 | | -``` |
119 | | -POST /_security/api_key |
120 | | -{ |
121 | | - "name": "es-mcp-server-access", |
122 | | - "role_descriptors": { |
123 | | - "claude_role": { |
124 | | - "cluster": [ |
125 | | - "monitor" |
126 | | - ], |
127 | | - "indices": [ |
128 | | - { |
129 | | - "names": [ |
130 | | - "index-1", |
131 | | - "index-2", |
132 | | - "index-pattern-*" |
133 | | - ], |
134 | | - "privileges": [ |
135 | | - "read", |
136 | | - "view_index_metadata" |
137 | | - ] |
138 | | - } |
139 | | - ] |
140 | | - } |
141 | | - } |
142 | | -} |
143 | | -``` |
144 | | - |
145 | | -## Troubleshooting |
146 | | - |
147 | | -* If the server isn't connecting, check that your MCP configuration is correct |
148 | | -* Ensure your Elasticsearch URL is accessible from your machine |
149 | | -* Verify that your API key has the necessary permissions |
150 | | -* Check the terminal output for any error messages |
| 3 | +Moved to: https://github.com/elastic/mcp-server-elasticsearch |
0 commit comments