Skip to main content
Glama
anpy-j

graylog-mcp

by anpy-j

Graylog Agent Toolkit

一个不绑定模型厂商的 Graylog MCP 服务,以及可移植的代码运行时诊断 Skill。目标是让 Codex、Gemini CLI、支持 MCP 的 IDE、自建 Agent 使用同一套查询能力和诊断流程。

设计

项目把能力拆成三个稳定层次:

  1. MCP 服务负责 Graylog 认证、查询、脱敏、排序和关联 ID 扩展。

  2. 通用 Skill指导 Agent 从代码中的日志语句提取稳定文本,查询运行时证据,并把日志 映射回代码分支。

  3. 业务 Profile只描述业务入口、阶段、日志文本和额外关联字段。增加几十上百个业务时, 新增 YAML 文件,不复制 MCP 或 Skill。

MCP 暴露标准 Tools、Resources 和 Prompt,并支持 stdio 与 Streamable HTTP。服务端不调用 Codex、Gemini 或任何其他模型 API。

Related MCP server: Log Analyzer MCP

工具

  • graylog_get_system_info:验证认证、API 路径和集群版本。

  • graylog_search_messages:执行受时间范围和结果数限制的原始 Lucene 查询。

  • graylog_diagnose_code_logs:按代码日志常量和业务 ID 查询,并自动扩展结果中的关联 ID。

  • graylog_list_profiles / graylog_get_profile:发现和读取业务 Profile。

  • diagnose_code_runtime MCP Prompt:为不支持本地 Skill 的 MCP 客户端提供同一诊断流程。

安装

需要 Python 3.11+ 和 uv

cd /home/ijx/anpengyu/graylog-agent-toolkit
uv sync --extra dev
cp .env.example .env

编辑 .env 后,本地验证:

GRAYLOG_ENV_FILE=.env uv run graylog-agent-toolkit

stdio 模式启动后等待 MCP 客户端握手,终端无普通输出是正常行为。日志只能写入 stderr, 不能污染 MCP 的 stdout 协议流。

Graylog 认证

支持三种模式:

  • sessionGRAYLOG_SESSION_ID=<浏览器 authentication 对应的 UUID>。Basic Auth 密码固定为 session。浏览器会话可能过期。

  • tokenGRAYLOG_TOKEN=<access token>。Basic Auth 密码固定为 token

  • basicGRAYLOG_USERNAMEGRAYLOG_PASSWORD

使用 Graylog 用户名密码时,.env 配置如下:

GRAYLOG_API_BASE=https://graylog.example.com/api
GRAYLOG_AUTH_MODE=basic
GRAYLOG_USERNAME=your-graylog-username
GRAYLOG_PASSWORD=your-graylog-password

MCP 通过标准 HTTP Basic Auth 连接 Graylog。用户名密码只保存在 MCP 服务端环境中,不应放进 Agent 提示词、业务 Profile 或源码。

不要提交 .env。工具默认对 Authorization、Cookie、密码、Session 和常见签名 URL 参数 脱敏,但脱敏不能代替最小权限和 Graylog 审计。

此实现调用 Graylog 5.1 的 JSON Scripting Search API: POST /api/search/messages。该 API 需要实例启用 scripting_api_preview;当前实例已用真实 JSON 响应验证。如果其他集群未启用,需先开启该特性或新增兼容适配器。

Codex 接入

用本机 CLI 注册 stdio 服务:

codex mcp add graylog \
  --env GRAYLOG_API_BASE="$GRAYLOG_API_BASE" \
  --env GRAYLOG_AUTH_MODE="$GRAYLOG_AUTH_MODE" \
  --env GRAYLOG_SESSION_ID="$GRAYLOG_SESSION_ID" \
  --env GRAYLOG_PROFILE_DIR="/home/ijx/anpengyu/graylog-agent-toolkit/profiles" \
  -- uv --directory /home/ijx/anpengyu/graylog-agent-toolkit run graylog-agent-toolkit

也可以参考 examples/codex/config.toml.example。把 skills/code-runtime-diagnose 复制或链接到 Codex 的个人 Skill 目录后,新会话可按描述自动启用。 MCP 配置和 Skill 安装后都需要新开或重载 Agent 会话。

Gemini CLI 接入

项目本身是一个 Gemini CLI 扩展,包含标准 MCP 与标准 skills/ 目录:

cd /home/ijx/anpengyu/graylog-agent-toolkit
gemini extensions link .

Gemini CLI 会提示扩展设置,并把敏感值保存到系统密钥链。也可使用 examples/gemini/settings.json.example 手工配置。进入 Gemini CLI 后用 /mcp 检查连接;MCP Prompt 可作为 /diagnose-code-runtime 调用。

自建 Agent 接入

任何实现 MCP 客户端初始化、tools/listtools/call 的 Agent 都可以调用本服务。最小 Python 示例位于 examples/custom-agent/client.py。如果宿主不实现 Agent Skills,可:

  1. 读取 MCP Server Instructions;

  2. 调用 MCP Prompt diagnose_code_runtime;或

  3. skills/code-runtime-diagnose/SKILL.md 作为系统/任务指令载入。

“任何 Agent 可用”的边界是宿主至少支持 MCP,或允许加载文本指令。完全不支持 MCP、Tool Call、 Prompt 或外部指令的宿主无法自动使用外部能力。

Streamable HTTP

共享服务可这样启动:

MCP_TRANSPORT=streamable-http MCP_HOST=127.0.0.1 MCP_PORT=8765 \
  GRAYLOG_ENV_FILE=.env uv run graylog-agent-toolkit

客户端连接 http://127.0.0.1:8765/mcp。需要跨机器访问时,在服务前部署 TLS、身份认证、访问 控制和审计反向代理;不要直接把无认证端口暴露到网络。

新增业务

复制 profiles/weekly-training.yaml,修改名称、入口、稳定日志文本和业务关联字段即可。Profile 结构见 skills/code-runtime-diagnose/references/profile-schema.md

profiles/
├── weekly-training.yaml
├── personal-homework.yaml
└── public-homework.yaml

每次改 Profile 后运行测试,并通过 graylog_get_profile 验证实际加载结果。

验证

uv run ruff check .
uv run pytest -q
python3 /home/ijx/.codex/skills/.system/skill-creator/scripts/quick_validate.py \
  skills/code-runtime-diagnose

Available Tools

5 tools
graylog_diagnose_code_logsA

Correlate code log literals and runtime identifiers, then expand discovered trace keys.

Use this after reading relevant source and finding log statements. Pass stable literal text from those statements plus known values such as studentExamId, taskId, requestNo, or traceId. A business profile adds stage patterns and correlation keys without changing this tool.

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNo
profileNo
streamsNo
to_timeNo
from_timeNo
identifiersNo
log_literalsNo
range_secondsNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
notesNo
eventsYes
profileNo
queriesYes
returnedYes
truncatedYes
correlationsYes

TDQS

A3.9/5.0
Behavior3/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 does reveal a two-step behavior (correlate, then expand) and notes that a business profile changes behavior ('adds stage patterns and correlation keys without changing this tool'). However, it doesn't explain what 'expand discovered trace keys' means operationally, any side effects, or how the tool interacts with Graylog. It adds some value but lacks depth.

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?

Three sentences, front-loaded purpose, no filler. The first sentence states the core action, the second gives usage timing and input guidance, and the third adds a profile nuance. Every sentence earns its place; the description is efficient and well-structured.

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?

The tool has 8 parameters and no annotation coverage, but does have an output schema. The description covers the tool's purpose and the most important input semantics, yet it omits guidance on time range parameters, streams, and limit, which are common but not fully self-explanatory in context. Given moderate complexity and an output schema, the description is adequate but leaves 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 0%, so the description must compensate. It explicitly explains the meaning of log_literals ('stable literal text from those statements') and identifiers ('known values such as studentExamId, taskId, requestNo, or traceId'), and hints at profile. However, it leaves parameters like from_time, to_time, range_seconds, limit, and streams undocumented, relying on their names alone. The description adds value for core parameters but not for all eight.

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 opens with a specific action ('Correlate code log literals and runtime identifiers, then expand discovered trace keys') that clearly distinguishes this tool from siblings like search_messages or list_profiles. It names the resource (code logs, trace keys) and the scope (correlate + expand), making it unmistakable what the tool does.

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

Usage Guidelines4/5

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

Provides explicit when-to-use guidance: 'Use this after reading relevant source and finding log statements.' It also tells the caller what to pass (stable literal text, known identifiers) and mentions the profile behavior. While it doesn't explicitly name alternatives or exclusions, the context given is clear enough to guide selection among siblings.

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

graylog_get_profileA

Return one validated business diagnosis profile by name or alias.

ParametersJSON Schema
NameRequiredDescriptionDefault
nameYes

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A3.5/5.0
Behavior2/5

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 doesn't disclose side effects, error behavior, or the meaning of 'validated' beyond a vague qualifier. There's no mention of read-only status or what happens if no profile matches.

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, well-structured sentence that conveys the essential action and selection criteria without any wasted words.

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?

This is a simple retrieval tool, and the output schema is present, covering return structure. Yet the lack of behavioral context (e.g., validation logic, error handling) and usage guidance makes it only minimally complete for an agent to select and invoke confidently.

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 0%, but the description compensates by clarifying that the 'name' parameter can be a name or an alias. However, it doesn't provide additional constraints or examples, leaving room for ambiguity.

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 uses a specific verb 'Return' and clearly identifies the resource as 'one validated business diagnosis profile', with selection criteria 'by name or alias'. This effectively distinguishes it from sibling tools like graylog_list_profiles.

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 the tool should be used when you have a specific name or alias, but it provides no explicit comparison to alternative tools (e.g., graylog_list_profiles for listing all profiles) or when-not-to-use guidance.

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

graylog_get_system_infoA

Verify Graylog connectivity and return cluster version/node metadata.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A4.2/5.0
Behavior3/5

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

With no annotations provided, the description carries the transparency burden. It discloses that the call is a read-only operation ('Verify', 'return') and indicates the output type, but does not elaborate on access requirements, potential side effects (likely none), or response format. This is adequate for a simple system-info getter.

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, front-loaded sentence that states the action and the result. Every word earns its place, with no fluff or repetition.

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

Completeness4/5

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 nested objects), the description sufficiently covers the purpose and high-level output. It could mention that this is a lightweight health-check call, but the provided information is largely complete for invoking it.

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

Parameters4/5

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

The tool has zero parameters, which the schema makes fully explicit (100% coverage). Per the rubric, a zero-parameter tool gets a baseline of 4 since there are no parameter semantics to explain.

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 verifies Graylog connectivity and returns cluster version/node metadata. It uses a specific verb ('verify') and resource ('system info'), and is distinct from sibling tools focused on profiles, messages, and diagnostics.

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

Usage Guidelines4/5

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

The description clearly implies this is for checking connectivity and retrieving system-level info, which is a distinct use case from the sibling tools. It doesn't explicitly state when not to use it, but the purpose is self-evident enough for an agent to choose correctly.

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

graylog_list_profilesA

List available business diagnosis profiles and their trigger aliases.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4/5.0
Behavior3/5

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

The description is straightforward for a list operation, and 'List' implies a read-only behavior. However, no annotations are provided, and the description does not explicitly disclose that no data is mutated, nor does it mention any permissions, pagination, or error behavior. It adds some context with 'trigger aliases' but stops short of a fuller behavioral 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?

The description is a single, clear sentence with no filler. It front-loads the core action ('List') and resource, and every word contributes to understanding the tool's function.

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

Completeness4/5

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

For a simple list operation with zero parameters and an output schema present, the description covers the essential purpose and output contents ('profiles and their trigger aliases'). It does not mention potential caveats like result limits or ordering, but given the simplicity of the tool, this is sufficient.

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

Parameters4/5

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

The tool has zero parameters, and the schema is empty. According to the rubric, a baseline of 4 applies when there are no parameters. The description does not need to compensate for any parameter ambiguity since there are none.

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 states a specific action ('List') on a specific resource ('business diagnosis profiles') and adds the detail of 'trigger aliases' in the output. This clearly distinguishes it from sibling tools like graylog_get_profile, which targets a single profile.

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?

Usage is implied: use this tool when you need to enumerate all available business diagnosis profiles. However, there is no explicit mention of when NOT to use it or alternatives, such as graylog_get_profile for a specific profile. The sibling tool names provide context but the description itself offers no direct guidance.

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

graylog_search_messagesC

Run a raw Graylog Lucene query over an absolute RFC3339 time range.

ParametersJSON Schema
NameRequiredDescriptionDefault
sortNotimestamp
limitNo
queryYes
fieldsNo
offsetNo
streamsNo
to_timeYes
from_timeYes
sort_orderNoAscending

Output Schema

ParametersJSON Schema
NameRequiredDescription
queryYes
eventsYes
returnedYes
truncatedYes
effective_timerangeNo

TDQS

C2.8/5.0
Behavior2/5

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

No annotations exist, so the description must carry the full burden. It only states that a raw Lucene query is run over a time range, but does not disclose side effects (though search is likely read-only), rate limits, permissions, or pagination behavior.

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, front-loaded sentence with zero filler words. It is maximally concise and easy to parse.

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?

With 9 parameters, a raw query language, and no annotation support, the description is too sparse. It only covers the query and time range, omitting important details about filtering, sorting, pagination, and stream selection. The output schema covers return shape but not tool-specific behavior.

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

Parameters2/5

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

Schema description coverage is 0%, and the description only adds meaning to the time parameters by specifying 'absolute RFC3339'. The other parameters (query, limit, offset, fields, streams, sort, sort_order) are not explained in the description.

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 uses a specific verb 'run' and resource 'Graylog Lucene query', clearly indicating a search over messages. It distinguishes from sibling tools that manage profiles or system info, though it does not explicitly say 'messages'.

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. The description does not mention sibling tools, exclusions, or context like 'use for searching log messages'.

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. Dates show when Glama detected each change.

  1. 5 tool updatesv0.1.0
    • First observedgraylog_diagnose_code_logs
    • First observedgraylog_get_profile
    • First observedgraylog_get_system_info
    • First observedgraylog_list_profiles
    • First observedgraylog_search_messages

TDQS

A3.7/5.0
Disambiguation5/5

Each tool has a clearly distinct purpose: listing profiles, fetching a specific profile, checking system info, searching messages, and running log diagnosis. Even the two profile tools are differentiated by list vs. single get, matching standard patterns.

Naming Consistency5/5

All tools follow the consistent verb_noun pattern with a common 'graylog_' prefix: list_profiles, get_profile, get_system_info, search_messages, diagnose_code_logs. The verbs are clear and uniform in style.

Tool Count5/5

Five tools is well within the ideal range for a focused MCP server. Each tool is purposeful and contributes to the overall workflow of profile-based log diagnosis without redundancy.

Completeness4/5

The tool surface covers the core workflow: retrieving diagnosis profiles, searching raw messages, and running a specialized diagnosis. Minor gaps exist, such as no tool for creating/updating profiles or fetching a single message by ID, but these are not critical for the stated purpose.

Maintenance

ActivitySlowing
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables AI assistants to query and analyze logs from Graylog instances using universal search with relative or absolute time windows, supporting both full result retrieval and lightweight count-only queries.
    23
    1
    MIT
  • F
    license
    B
    quality
    C
    maintenance
    Enables AI-assisted analysis of log files through advanced searching, filtering, and test execution capabilities. Supports time-based queries, pattern matching, test summarization, and code coverage reporting directly within compatible MCP clients.
    12
    -
  • A
    license
    A
    quality
    C
    maintenance
    Enables querying Graylog log management system for messages using natural language, supporting multiple instances and flexible search parameters.
    1
    34
    9
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    An MCP server that gives AI assistants direct access to your Graylog logs -- search, aggregate, analyze, and cluster log data through natural language.
    23
    27
    MIT

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/anpy-j/graylog-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server