es-error-lens
Allows searching and analyzing Elasticsearch logs in ECS format, providing tools for error search, pattern detection, trend analysis, trace context, and error comparison.
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., "@es-error-lenssearch errors in the last hour for checkout-api"
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.
es-error-lens
An MCP server that gives LLM agents eyes on your Elasticsearch logs. Point it at a cluster holding ECS-format logs and any MCP client (Claude Desktop, Claude Code, or your own agent) can search errors, detect recurring patterns, analyze error-rate trends, and pull full trace context — the queries an engineer runs by hand during triage, exposed as tools.
Tool | What it answers |
| "What's failing right now?" — filtered by window, service, level |
| "Is this systemic or a one-off?" — message aggregation with occurrence counts |
| "Is it getting worse?" — time-series histogram, peak detection, trend verdict |
| "What led up to this?" — every log sharing the error's trace ID, in order |
| "Are these two failures related?" — attribute + fuzzy-message comparison |
| "Can I even reach the cluster?" |
Elasticsearch is spoken to over its plain REST API via httpx — no
Elasticsearch client dependency, and the HTTP layer is transport-injectable,
so the entire server runs offline against the bundled FakeElasticsearch
for tests and the demo.
Demo (offline, no cluster, no API keys)
git clone https://github.com/TerraCo89/es-error-lens && cd es-error-lens
python -m venv .venv && source .venv/bin/activate # .venv\Scripts\activate on Windows
pip install -e ".[dev]"
pytest # 22 tests, all offline, < 1 second
es-error-lens-demo # synthetic incident walk-throughThe demo mounts FakeElasticsearch with a deterministic 60-document ECS
corpus simulating a small incident — a steady payment-provider failure, an
escalating search-timeout problem, and background noise — then triages it:
[get_error_patterns] 2 recurring patterns in 57 errors:
42x [TimeoutError] Search query timed out after 30s (search-api)
13x [UpstreamHTTPError] Payment provider returned 502 Bad Gateway (checkout-api)
error types: TimeoutError=42, UpstreamHTTPError=13, TemplateError=1, ConnectionResetError=1
[analyze_error_trend] search-api: 42 errors, trend=INCREASING
peak: 8 errors at 2026-07-10T06:00:00Z
[get_error_context] trace-checkout-7f3a -> [UpstreamHTTPError] Payment provider returned 502 Bad Gateway
3 related logs on the same trace:
info POST /checkout started
info Cart validated: 3 items
warn Payment provider latency 4100ms exceeds SLO
Demo result: OKRelated MCP server: Kibana Log Analysis & API Dashboard MCP Server
Using it against a real cluster
export ELASTICSEARCH_URL=http://localhost:9200 # default
export ES_INDEX_PATTERN=logs-* # default
es-error-lens # stdio, for Claude Desktop / Claude Code
es-error-lens --transport streamable-http --port 8080 # HTTP clientsClaude Desktop / Claude Code config:
{
"mcpServers": {
"es-error-lens": {
"command": "es-error-lens",
"env": { "ELASTICSEARCH_URL": "http://localhost:9200" }
}
}
}Expected document shape — standard ECS fields, the ones Filebeat and the
ECS logging libraries emit by default: @timestamp, log.level, message,
service.name, error.type, error.stack_trace, trace.id, host.name.
Anything missing degrades gracefully (fields come back null).
Testing without a cluster
FakeElasticsearch (also exported) implements just enough of the _search
API for this server: bool queries with term/range clauses, sorting,
terms aggregations with top_hits sub-aggregations, and date_histogram
with fixed intervals. Mount it in your own tests:
from es_error_lens import FakeElasticsearch, set_transport, search_errors
set_transport(FakeElasticsearch(my_ecs_docs).transport())
result = await search_errors(time_range="1h", service="checkout-api")The test suite runs entirely through it — deterministic, offline, fast — and
a hygiene test enforces that all bundled demo data stays synthetic (hosts
under .example, no real domains or addresses).
Provenance
Extracted from a personal observability platform where it fronts the Elasticsearch instance that aggregates structured logs from a fleet of side-project services, letting coding agents triage production errors during development sessions. All demo and test data in this repository is synthetic.
License
MIT © 2026 Kris Cernjavic
Available Tools
6 toolsanalyze_error_trendA
Analyze error rate trends over time for a service.
Builds a time-series histogram of error counts to identify spikes, patterns, and direction of travel.
| Name | Required | Description | Default |
|---|---|---|---|
| service | Yes | Service name to analyze (e.g., "checkout-api") | |
| interval | No | Histogram bucket interval ("1m", "5m", "15m", "1h", "1d") | 1h |
| time_range | No | Time range to analyze (e.g., "24h", "7d", "30d") | 24h |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description must fully disclose behavior. It mentions building a time-series histogram but omits crucial details such as permissions needed, rate limits, or whether the tool is read-only.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences, front-loaded with purpose, no redundant wording.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's moderate complexity and the presence of an output schema, the description provides sufficient context about the purpose and output type, though it could briefly mention how results are interpreted.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 100% schema description coverage, the baseline is 3. The description adds 'histogram' context, but does not elaborate on output semantics beyond what the schema provides.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states it analyzes error rate trends over time for a service, using a verb and specific resource. It distinguishes itself from sibling tools like compare_errors or get_error_context.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage for trend analysis but does not provide explicit guidance on when to use this tool vs alternatives, nor does it mention when not to use it.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
compare_errorsA
Compare two errors to find similarities and differences.
Useful for judging whether two failures are related or share a root cause.
| Name | Required | Description | Default |
|---|---|---|---|
| trace_id_1 | Yes | First error's trace ID | |
| trace_id_2 | Yes | Second error's trace ID |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It states the tool compares errors but does not disclose whether it is read-only, destructive, or has side effects. It implies analysis but lacks explicit behavioral details.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description consists of two efficient sentences, front-loading the core purpose and adding a usage hint. No unnecessary words.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the simple two-parameter tool with a full input schema and an output schema (though not shown), the description is adequate. It could mention its read-only nature given no annotations, but overall it is complete enough for agent selection.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100% and both parameters have descriptions in the schema (trace_id_1 and trace_id_2). The description adds no additional meaning beyond what the schema already provides, so the baseline of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb 'Compare' and the resource 'two errors', specifying the action exactly. It mentions finding similarities and differences, which differentiates it from sibling tools like analyze_error_trend or get_error_context.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides a clear use case: 'judging whether two failures are related or share a root cause.' It does not explicitly state when not to use this tool or name alternatives, but the context is sufficient for the sister tools context.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_error_contextA
Get full context for an error using its trace ID (correlation ID).
Retrieves the error and all related logs sharing the same trace ID, providing complete request context for debugging.
| Name | Required | Description | Default |
|---|---|---|---|
| trace_id | Yes | The trace/correlation ID to search for | |
| include_related | No | Also return non-error logs with the same trace ID |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Without annotations, the description carries the full burden but only states what it retrieves. It does not disclose side effects, auth needs, rate limits, or that it is read-only, which is acceptable for a retrieval tool but lacks explicit behavioral constraints.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences, no unnecessary words. Front-loaded purpose and clear explanation of what is retrieved. Every sentence adds value.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given 2 well-documented parameters and an output schema, the description provides sufficient context for an agent to understand and invoke the tool correctly. It could mention read-only nature or prerequisite that trace_id exists, but overall it is complete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100%, so baseline is 3. The description adds context by explaining that trace_id is used to fetch error and related logs, aligning with include_related. However, it doesn't explicitly describe include_related beyond what the schema provides.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states it retrieves full context for an error using a trace ID, specifying it gets the error and related logs. This distinguishes it from siblings like search_errors or analyze_error_trend, which serve different purposes.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description indicates when to use the tool (when you have a trace ID and need debugging context) but does not explicitly list when not to use it or mention alternative tools, though the sibling names imply alternatives.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_error_patternsA
Detect recurring error patterns by aggregating similar error messages.
Groups errors by message and identifies the most common patterns — useful for separating systemic issues from one-off errors.
| Name | Required | Description | Default |
|---|---|---|---|
| service | No | Service name to filter by (optional) | |
| time_range | No | Time range to analyze (e.g., "15m", "1h", "24h", "7d") | 24h |
| max_patterns | No | Maximum number of patterns to return | |
| min_occurrences | No | Minimum occurrences to be considered a pattern |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided, so description carries full burden. It mentions grouping by message and identifying common patterns, which is a basic behavioral overview. Missing details like read-only hint, permission requirements, or performance implications.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences, no redundancy. Each sentence adds value: first states what it does, second explains the grouping logic and use case. Front-loaded with verb and resource.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given output schema exists to describe return values, description adequately covers purpose and usage context. Missing explicit mention of grouping criterion (message) but it's implied. Siblings provide enough differentiation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema has 100% description coverage, so baseline is 3. Description adds context that patterns are grouped by message and systemic issues are targeted, but does not elaborate on parameter syntax or constraints beyond the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Description clearly states verb 'Detect' and resource 'recurring error patterns' with method 'aggregating similar error messages'. It distinguishes from siblings like 'search_errors' (find specific errors) and 'analyze_error_trend' (trend analysis) by focusing on pattern detection.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Explicitly states use case: 'useful for separating systemic issues from one-off errors'. This provides clear context but does not mention when not to use or compare directly with alternatives.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
health_checkA
Check Elasticsearch connection health.
Returns: Dictionary with: - status: "healthy" or "unhealthy" - elasticsearch_url: Configured Elasticsearch URL - cluster_info: Cluster name/version (when healthy)
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description discloses the return structure (status, url, cluster_info) which provides some behavioral insight. However, it does not explicitly state that the operation is read-only or non-destructive, and no annotations are provided to fill this gap.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is highly concise with two sentences. It starts with the main action and follows with a bullet-like list of return fields. Every word adds value, no redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the simplicity of the tool (no parameters, no annotations, and output schema present), the description is complete. It clearly states the return format, which is sufficient for an agent to understand the tool's behavior and output.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has no parameters (input schema empty, coverage 100%). According to rubric, 0 parameters yields a baseline of 4. The description does not add parameter information, but none is needed.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'Check Elasticsearch connection health.' This is a specific verb+resource combination that distinguishes it from sibling tools which focus on error analysis.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No explicit guidelines on when to use this tool versus alternatives. While the purpose implies it is for verifying connectivity, the description lacks context such as prerequisites or scenarios where it is particularly useful.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
search_errorsC
Search for errors in Elasticsearch logs.
| Name | Required | Description | Default |
|---|---|---|---|
| service | No | Service name to filter by (e.g., "checkout-api") | |
| log_level | No | Log level to filter by ("error", "warn", "info", "debug", "all") | error |
| time_range | No | Time range to search (e.g., "15m", "1h", "24h", "7d") | 1h |
| max_results | No | Maximum number of results to return (default: 100) |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, and the description does not disclose behavioral traits such as permissions, side effects (e.g., read-only nature), or any constraints like rate limits. Since annotations are absent, the description carries the full burden but fails to address these aspects.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single concise sentence that efficiently conveys the primary function. While it could be slightly more informative, it contains no wasted words and is front-loaded.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description fails to explain the output format or any post-processing expectations, despite the presence of an output schema. It also does not mention how results are ordered or paginated. Given the parameter count of 4 and the need for search result details, the description is incomplete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema provides full coverage (100%) with descriptions for all 4 parameters. The tool description adds no additional meaning beyond what the schema already states, so a baseline score of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action and resource ('Search for errors in Elasticsearch logs'), providing a specific verb and resource. However, it does not differentiate from sibling tools like 'get_error_patterns' or 'analyze_error_trend', which could lead to confusion about which tool to use for specific error-related tasks.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus alternatives. The description lacks context for selecting this tool over siblings such as 'analyze_error_trend' or 'get_error_context', leaving the agent without decision-making support.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
6 tool updates
v0.1.0- First observed
analyze_error_trend - First observed
compare_errors - First observed
get_error_context - First observed
get_error_patterns - First observed
health_check - First observed
search_errors
TDQS
Scored across 6 tools
Each tool has a clearly distinct purpose: trend analysis, comparison, context retrieval, pattern detection, health check, and search. No overlapping functionality.
Five tools follow verb_noun pattern (e.g., analyze_error_trend, search_errors); health_check is noun_verb, a minor deviation. Otherwise consistent snake_case.
Six tools is well-scoped for an error analysis server. Each tool contributes a distinct capability without bloat.
Covers error search, trend analysis, pattern detection, context retrieval, comparison, and health check. No obvious gaps for the observation/analysis domain.
Maintenance
Related MCP Connectors
Query application logs, traces, and metrics from your AI coding assistant via Foam's MCP server.
- SpanlyOAuthcom.spanly
MCP observability. Query live traffic, errors, duration, and alerts from your AI agent.
- SuperlogOAuthsh.superlog
Open-source agent that observes and fixes your application. Query logs, traces, metrics, incidents.
MCP-Native LLM Orchestration Agent
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables LLMs to autonomously query AWS CloudWatch Logs and perform structured root-cause analysis via natural language prompts, using MCP tools for log group listing and Insights queries.MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to search Elasticsearch logs, retrieve log details, analyze service health, scan local codebases for APIs, and create Kibana dashboards.510 npmMIT
- FlicenseNot gradedqualityCmaintenanceRead-only MCP server for Elasticsearch log querying. Enables natural language search, filtering, context retrieval, and aggregation of logs.-
- FlicenseNot gradedqualityBmaintenanceEnables AI agents to query and analyze Graylog logs through MCP tools for search, aggregation, stream listing, and saved queries, with optional OpenAI-powered natural language orchestration and audit logging.-