Skip to main content
Glama
yufeizhou666

log-analyzer-mcp

by yufeizhou666

log-analyzer-mcp

로그 분석 및 시스템 메트릭 도구를 제공하는 MCP(Model Context Protocol) 서버입니다. stdio 전송을 통해 Claude Code에 연결되며, 로컬 로그 파일을 검색, 카운팅 및 분석하기 위한 5가지 도구를 제공합니다.

기능

도구

설명

search_logs

키워드 또는 정규식 패턴으로 로그 파일 검색

count_by_level

심각도 수준(ERROR/WARN/INFO/DEBUG)별 로그 항목 수 계산

query_by_timerange

특정 시간 범위 내의 로그 필터링

get_system_metrics

CPU, 메모리 및 디스크 사용량 메트릭 가져오기

explain_error

AI 지원 분석을 위해 오류 내용 형식 지정

Related MCP server: ai-ssh-mcp

빠른 시작

# Install dependencies
npm install

# Build TypeScript
npm run build

# Run the server
npm start

개발

# Run with hot reload
npm run dev

Claude Code와 통합

Claude Code에 서버 추가:

# Project-level (only available in this directory)
claude mcp add log-analyzer -- node /path/to/log-analyzer-mcp/dist/index.js

# User-level (available globally)
claude mcp add log-analyzer --scope user -- node /path/to/log-analyzer-mcp/dist/index.js

연결 확인:

claude mcp list

도구 세부 정보

키워드 또는 정규식으로 로그 파일을 검색합니다. 단일 .log 파일 또는 전체 디렉토리 검색을 지원합니다.

{
  "keywords": ["ERROR", "timeout"],
  "regex": "connection.*failed",
  "logPath": "/var/log",
  "limit": 100
}

count_by_level

심각도 수준별로 로그 항목을 계산하며, 선택적으로 시간 범위별로 필터링할 수 있습니다.

{
  "logPath": "/var/log",
  "startTime": "2026-04-29T00:00:00Z",
  "endTime": "2026-04-30T00:00:00Z"
}

query_by_timerange

특정 시간 범위 내의 로그를 필터링하며, 선택적으로 수준 필터를 적용할 수 있습니다.

{
  "startTime": "2026-04-29T00:00:00Z",
  "endTime": "2026-04-30T00:00:00Z",
  "logPath": "/var/log",
  "level": "ERROR",
  "limit": 100
}

get_system_metrics

CPU, 메모리 및 디스크 메트릭을 가져옵니다. Windows 및 Linux를 지원합니다.

{
  "metrics": ["cpu", "memory", "disk"]
}

explain_error

AI 지원 근본 원인 분석을 위해 오류 내용을 형식화합니다.

{
  "errorContent": "java.lang.NullPointerException\n  at com.example.Service.process(Service.java:42)",
  "contextLines": 10
}

아키텍처

src/
├── index.ts           # MCP Server entry point
├── tools/             # Individual MCP tool implementations
├── utils/
│   ├── log_parser.ts  # Timestamp/level parsing, keyword/regex matching
│   └── metrics.ts     # Cross-platform CPU/memory/disk metrics
└── types/             # TypeScript type definitions

이 서버는 StdioServerTransport와 함께 @modelcontextprotocol/sdk를 사용합니다. 도구는 CallToolRequestSchema 핸들러를 통해 등록됩니다.

주요 설계 결정

  • 스트림 처리: readline + createReadStream을 사용하여 대용량 로그 파일을 메모리에 완전히 로드하지 않고 처리합니다.

  • 크로스 플랫폼: 런타임 플랫폼 감지를 통해 Windows(WMIC) 및 Linux(top/free/df) 이중 경로 구현

  • 허용적 파싱: 비표준 로그 형식은 삭제되지 않고 보존됩니다(수준이 누락된 경우 INFO로 기본 설정, 타임스탬프가 누락된 경우 현재 시간으로 기본 설정).

라이선스

MIT

Available Tools

5 tools
count_by_levelB

Count log entries by severity level (ERROR, WARN, INFO, DEBUG)

ParametersJSON Schema
NameRequiredDescriptionDefault
logPathNoPath to log file or directory/var/log
startTimeNoStart time in ISO8601 format
endTimeNoEnd time in ISO8601 format

TDQS

B3.4/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are present, so the description must fully disclose behavior. It only states the counting operation but omits details such as read-only nature, error handling for missing paths, or output format. Minimal disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, front-loaded with action and levels. No wasted words. Efficient and to the point.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has 3 parameters, no output schema, and no annotations. Description is too brief; does not explain output format, behavior with directories vs files, or case sensitivity of levels. Incomplete for a tool aggregating log data by severity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so baseline is 3. The description adds no extra meaning beyond the schema; it does not explain how parameters like startTime/endTime relate to the counting logic.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states the verb 'Count', the resource 'log entries', and the grouping 'by severity level' with explicit levels. It distinguishes from siblings like search_logs and query_by_timerange which do different operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for counting log entries by level but does not explicitly state when to use this over alternatives like search_logs or query_by_timerange. No prerequisites or exclusions provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

explain_errorC

AI-assisted error analysis. Formats error content for AI analysis.

ParametersJSON Schema
NameRequiredDescriptionDefault
errorContentYesThe error log or stack trace to analyze
contextLinesNoNumber of context lines around the error

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description bears full responsibility. It implies a read-only analysis but does not explicitly state whether the tool modifies data, requires authentication, or has rate limits. The phrase 'formats error content' suggests it is non-destructive, but this is not confirmed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences, efficient for a simple tool. However, the second sentence ('Formats error content for AI analysis') is somewhat redundant with the first, and the title is null so the description stands alone.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 2 params and no output schema, the description is adequate but does not describe the output format. Given sibling tools (search_logs, count_by_level), it fits well but could mention that the result is formatted text for consumption by an AI.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% with both parameters documented. The description adds no new meaning beyond what the schema provides; it merely repeats 'error log or stack trace' and 'number of context lines'. Baseline 3 applies due to high coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it does AI-assisted error analysis and formats error content for AI analysis. It specifies the verb 'analyze' and resource 'error content'. However, it does not explicitly differentiate from siblings like search_logs which might also process errors.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like search_logs or get_system_metrics. It lacks prerequisites, when-not-to-use scenarios, or context for invocation.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_system_metricsB

Get CPU, memory, and disk metrics from the system

ParametersJSON Schema
NameRequiredDescriptionDefault
metricsNoWhich metrics to retrieve: cpu, memory, disk

TDQS

B3.4/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description bears full responsibility. It only states the action without disclosing side effects, permissions, or potential limitations (e.g., read-only, resource cost).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence that conveys the tool's purpose efficiently with no unnecessary words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of output schema and annotations, the description fails to explain return format, data granularity, or operational context (e.g., whether metrics are real-time or cached). It leaves significant gaps for agent decision-making.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage for the single parameter 'metrics', which already defines its meaning. The tool description adds no extra semantic value beyond identifying the metrics types.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Get' and the resource 'CPU, memory, and disk metrics from the system'. It directly distinguishes from sibling tools like 'search_logs' or 'count_by_level', which handle different data.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for retrieving system metrics, but no explicit guidance on when to use it versus alternatives or exclusions. Siblings are distinct, so the context is clear but not exhaustive.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

query_by_timerangeC

Query logs within a specific time range

ParametersJSON Schema
NameRequiredDescriptionDefault
startTimeYesStart time in ISO8601 format
endTimeYesEnd time in ISO8601 format
logPathNoPath to log file or directory/var/log
levelNoFilter by log level
limitNoMaximum number of results

TDQS

C2.8/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden for behavioral disclosure. It only states the basic operation without revealing any behavioral traits (e.g., read-only, performance, pagination, or effects). This is insufficient for an agent to understand the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely short (6 words), which is concise but at the expense of completeness. It leaves out essential information for an agent to use it effectively.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema is provided, so the description should explain return values, but it does not. The tool has 5 parameters and no annotations, yet the description covers only the basic purpose, leaving significant gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so baseline is 3. The tool description adds minimal meaning beyond the schema (only reiterating the time range). It does not compensate for any missing parameter context.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Query', resource 'logs', and constraint 'within a specific time range'. It provides a specific purpose but does not distinguish from sibling tool 'search_logs' which may have overlapping functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

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 like 'search_logs' or 'count_by_level'. The description lacks context for appropriate usage scenarios.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

search_logsA

Search log files by keywords or regex patterns. Returns matching log entries with timestamps.

ParametersJSON Schema
NameRequiredDescriptionDefault
keywordsNoKeywords to search for in log files
regexNoRegular expression pattern to match
logPathNoPath to log file or directory/var/log
limitNoMaximum number of results

TDQS

A3.5/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must disclose behavioral traits. It states the tool returns matching log entries with timestamps, which is helpful, but omits details like case sensitivity, regex+keyword interaction, and pagination. Basic coverage but incomplete.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences with no redundancy. First sentence states action and method, second states output. Front-loaded, every word adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 4 parameters and no output schema, the description covers core functionality but lacks details on parameter interplay (e.g., can keywords and regex be used together?) and default behavior of logPath and limit. Adequate but not fully complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with descriptions for all 4 parameters. The tool description adds minimal extra meaning beyond restating search mechanisms and output; baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool searches log files using keywords or regex patterns, and returns matching entries with timestamps. This verb+resource specificity distinguishes it from siblings like count_by_level and explain_error.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool versus alternatives. The description does not mention when to prefer search_logs over count_by_level, explain_error, or query_by_timerange, leaving the agent without comparative context.

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.

  1. 5 tool updatesv1.0.0
    • First observedcount_by_level
    • First observedexplain_error
    • First observedget_system_metrics
    • First observedquery_by_timerange
    • First observedsearch_logs

TDQS

B3.4/5.0

Scored across 5 tools

Disambiguation5/5

Each tool has a clearly distinct purpose: counting by level, error explanation, system metrics, time-range queries, and keyword search. No overlap in functionality.

Naming Consistency4/5

Names follow a verb-oriented pattern (count, explain, get, query, search) but mix styles: some use 'by_' (count_by_level, query_by_timerange) while others are plain verb_noun (explain_error, get_system_metrics, search_logs). Mostly consistent but with minor deviations.

Tool Count5/5

5 tools is well-scoped for a log analysis server, covering essential operations without being too few or excessive.

Completeness4/5

Core log analysis tasks are covered: search, count by level, time-range queries, error explanation, and system metrics. Minor gaps exist, such as lacking a tool to list log sources or aggregate statistics beyond level counting.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    D
    maintenance
    Enables natural language SSH server management via Claude Code, allowing users to read logs, check services, run commands, and transfer files across multiple servers.
    6
    MIT
  • F
    license
    A
    quality
    D
    maintenance
    Enables Claude to monitor CPU, memory, disk, processes, network connections, Docker containers, and system logs for system diagnostics and troubleshooting.
    5
    -
  • F
    license
    A
    quality
    D
    maintenance
    Exposes homelab and IT-ops tools to Claude, including system health monitoring, Grafana alert states, Docker container status, Loki logs, SMART disk health, and more.
    8
    1
    -