elastic_mcp
Provides tools to search application logs stored in Elasticsearch, allowing AI agents to query log data by search query, service, level, and limit to retrieve matching documents.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@elastic_mcpShow me error logs from the checkout service in the last hour"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
elastic_mcp
A local Model Context Protocol (MCP) server that exposes Elasticsearch application logs to MCP-compatible AI clients such as ChatGPT, Claude, and MCP Inspector.
The current MVP provides a search_application_logs tool backed by Elasticsearch.
Table of Contents
Related MCP server: es-error-lens
Project structure
elastic-mcp/
├── src/
│ ├── server.py
│ └── elasticsearch.py
│
├── sample/
│ └── elastic-mcp-synthetic-data/
│ ├── data/
│ └── scripts/
│
├── docker-compose.yml
├── requirements.txt
├── .env.example
└── README.mdPrerequisites
Python 3.10+
Docker / Docker Compose
Node.js + npm (only needed for MCP Inspector)
Verify:
python3 --version
docker --version
docker compose version
node --version
npm --version1. Create the Python environment
From the project root:
python3 -m venv .venv
source .venv/bin/activateInstall dependencies:
pip install -r requirements.txt2. Configure environment variables
Create .env:
ELASTICSEARCH_URL=http://localhost:9200
ELASTICSEARCH_INDEX=logs3. Start Elasticsearch
Start the local Elasticsearch container:
docker compose up -dCheck that Elasticsearch is running:
curl http://localhost:9200You should receive an Elasticsearch cluster response.
4. Generate synthetic application data
The project includes a synthetic production-like dataset.
Generate the data:
python scripts/generate_data.pyThis creates:
data/events.ndjsonThe dataset contains services such as:
api-gateway
checkout
payments
orders
users
notifications
It also contains a deliberately injected checkout incident:
07:50 UTC checkout-v1.82 deployed
08:00 UTC checkout latency/error spike begins
08:00-09:00 UTC payment timeouts and 5xx responses increase
5. Create the Elasticsearch index and import data
import the data:
./scripts/import_data.shVerify the document count:
curl "http://localhost:9200/logs/_count?pretty"You should see approximately:
{
"count": 100001
}6. Start the MCP server
From the project root:
python -m src.serverThe server starts with an SSE transport on http://localhost:8000/sse.
Override the transport (e.g. for stdio-based chat clients) with:
MCP_TRANSPORT=stdio python -m src.serverKeep this terminal running.
7. Test the MCP server with MCP Inspector
In a second terminal, from the project root:
npx @modelcontextprotocol/inspectorIn the Inspector, connect using:
Transport type: SSE
URL: http://localhost:8000/sseThe server should expose:
eng-intelligence
Tools
└── search_application_logs
├── query
├── service
├── level
└── limitTry a query such as:
query: payment
service: checkout
limit: 10You should receive matching Elasticsearch documents.
8. Run the tests
Run the test suite (no Elasticsearch connection required — the client is mocked):
python -m pytestThis server cannot be deployed
Maintenance
Related MCP Connectors
Query application logs, traces, and metrics from your AI coding assistant via Foam's MCP server.
Search your AI chat history (ChatGPT, Claude, Codex) from any MCP client. Remote, private, read-only
Search log events, investigate anomalies, and manage cases in your Knowledge Grid tenant.
Read-only access to Auralogs production logs: search logs, inspect errors, review AI analyses.
Related MCP Servers
- AlicenseAqualityAmaintenanceA read-only MCP server that enables AI assistants to search, aggregate, and explore OpenSearch log data through 12 tools for connectivity, index discovery, search, and aggregations.17MIT
- AlicenseAqualityCmaintenanceEnables LLM agents to search and analyze Elasticsearch logs for errors, detect recurring patterns, analyze error-rate trends, and retrieve full trace context through MCP tools.6MIT
- AlicenseAqualityCmaintenanceProvides a standardized MCP interface for querying Graylog logs, enabling AI agents to search, diagnose, and correlate runtime logs with code via configurable profiles.5MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to search Elasticsearch logs, retrieve log details, analyze service health, scan local codebases for APIs, and create Kibana dashboards.517MIT