How elastic/mcp-server-elasticsearch works
This is a Rust MCP server that lets AI clients access Elasticsearch through stdio or streamable HTTP. The workflow is: select a transport, load configuration and expand environment variables, construct the Elasticsearch-backed MCP service, then handle tool requests against the cluster. The sampled tools cover index listing, mappings, search, ES|QL, and shard inspection; configuration also supports custom search-template/ES|QL tools and prompts. Some implementation details are unsampled, so those capabilities are shown without speculative internal call edges.
Main entry points: mod.rs Elasticsearch MCP service · lib.rs Server runtime · http.rs HTTP serving · base_tools.rs Index and mapping tools
Components 17
Runtime and configuration
- CLI commands
src/cli.rs - Server runtime
src/lib.rs - Config parsing
src/lib.rs
MCP transports
- stdio serving
src/lib.rs - HTTP serving
src/protocol/http.rs
Elasticsearch capabilities
- Elasticsearch MCP service
src/servers/elasticsearch/mod.rs - Request-aware ES client
src/servers/elasticsearch/mod.rs - Index and mapping tools
src/servers/elasticsearch/base_tools.rs - Search and ES|QL
src/servers/elasticsearch/base_tools.rs - Shard inspection
src/servers/elasticsearch/base_tools.rs - Template tools
src/servers/elasticsearch/mod.rs - Configured prompts
src/servers/elasticsearch/mod.rs
Shared support
- Service provider
src/utils/rmcp_ext.rs - Environment interpolation
src/utils/interpolator.rs - Tool inclusion filters
src/servers/mod.rs
Other components
- MCP client
- Elasticsearch cluster
Connections 20
- MCP client → stdio serving: connects via stdio
README.md - MCP client → HTTP serving: connects via HTTP
README.md - CLI commands → Server runtime: selects command
src/lib.rs - Server runtime → Config parsing: loads configuration
src/lib.rs - Config parsing → Environment interpolation: expands variables
src/lib.rs - Config parsing → Elasticsearch MCP service: constructs service
src/lib.rs - Server runtime → stdio serving: serves stdio
src/lib.rs - Server runtime → HTTP serving: starts HTTP
src/lib.rs - HTTP serving → Service provider: wraps provider
src/protocol/http.rs - Elasticsearch MCP service → Request-aware ES client: provides client
src/servers/elasticsearch/mod.rs - Elasticsearch MCP service → Index and mapping tools: registers tools
src/servers/elasticsearch/mod.rs - Elasticsearch MCP service → Search and ES|QL: registers tools
src/servers/elasticsearch/mod.rs - Request-aware ES client → Elasticsearch cluster: sends requests
- Index and mapping tools → Elasticsearch cluster: queries indices
src/servers/elasticsearch/base_tools.rs - Search and ES|QL → Elasticsearch cluster: runs queries
src/servers/elasticsearch/base_tools.rs - Shard inspection → Elasticsearch cluster: reads shard status
src/servers/elasticsearch/base_tools.rs - Template tools → Elasticsearch cluster: runs templates
- Elasticsearch MCP service → Template tools: configures tools
src/servers/elasticsearch/mod.rs - Elasticsearch MCP service → Configured prompts: configures prompts
src/servers/elasticsearch/mod.rs - Tool inclusion filters → Index and mapping tools: filters tools