graylog-mcp-server 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +133 -42
  2. package/package.json +14 -4
package/README.md CHANGED
@@ -1,94 +1,185 @@
1
1
  # Graylog MCP Server
2
2
 
3
- A minimal MCP (Model Context Protocol) server in JavaScript that integrates with Graylog.
3
+ An MCP (Model Context Protocol) server for Graylog that enables AI assistants to search logs, filter by fields, view surrounding context, list streams, and discover field values.
4
4
 
5
5
  ## Features
6
6
 
7
- - JavaScript MCP server
8
- - Tools: `fetch_graylog_messages` (query Graylog and return messages)
7
+ - **Multi-connection support** — configure and switch between multiple Graylog instances
8
+ - **Log search with filters** — query logs with field-level filters (env, level, source, logger_name, etc.)
9
+ - **Exact match by default** — queries use exact matching unless explicitly set to fuzzy/wildcard
10
+ - **Surrounding messages** — view messages around a specific log entry by message ID or timestamp
11
+ - **Pagination** — page through large result sets
12
+ - **Stream listing** — list all available Graylog streams
13
+ - **Field value discovery** — find distinct values for any field (top N by count)
14
+ - **Default fields** — returns only key fields by default, reducing noise from internal Graylog fields
9
15
 
10
16
  ## Requirements
11
17
 
12
18
  - Node.js 18+
19
+ - Graylog 6.x (tested on 6.2.10)
13
20
 
14
21
  ## Installation
15
22
 
16
23
  ```bash
17
- git clone git@github.com:lcaliani/graylog-mcp.git
24
+ git clone git@github.com:jagadeesh52423/graylog-mcp.git
18
25
  cd graylog-mcp
19
26
  npm install
20
27
  ```
21
28
 
22
29
  ## Configuration
23
30
 
24
- Set the following environment variables so the server can connect to Graylog:
31
+ Create a config file at `~/.graylog-mcp/config.json`:
25
32
 
26
- - `BASE_URL`: Graylog base URL, e.g. `https://graylog.example.com`
27
- - `API_TOKEN`: Graylog API token (used as the username, with password `token`)
28
-
29
- > :exclamation: Suggestion: add these variables to your respective MCP client configuration file or app. Example in **Cursor** more below.
33
+ ```json
34
+ {
35
+ "connections": {
36
+ "nonprod": {
37
+ "baseUrl": "http://your-graylog-server:9000",
38
+ "apiToken": "your_graylog_api_token"
39
+ },
40
+ "prod": {
41
+ "baseUrl": "http://prod-graylog:9000",
42
+ "apiToken": "your_prod_api_token"
43
+ }
44
+ }
45
+ }
46
+ ```
30
47
 
48
+ You can add multiple named connections and switch between them at runtime.
31
49
 
32
- ## Use with an MCP client (Cursor/Claude Desktop)
50
+ ## Use with an MCP Client
33
51
 
34
- 1. Add this server to your MCP client configuration, poiting to the mcp entrypoint file (`src/index.js`). Common locations:
52
+ Add this server to your MCP client configuration. Common locations:
35
53
 
36
- - Cursor: `~/.cursor/mcp.json`
37
- - Claude Desktop (macOS): `~/Library/Application Support/Claude/claude_desktop_config.json`
38
- - Claude Desktop (Linux): `~/.config/claude-desktop/claude_desktop_config.json`
54
+ - **Claude Code**: `~/.claude/mcp.json`
55
+ - **Cursor**: `~/.cursor/mcp.json`
56
+ - **Claude Desktop (macOS)**: `~/Library/Application Support/Claude/claude_desktop_config.json`
39
57
 
40
- Example config in **Cursor**:
58
+ Example config using npx (recommended):
41
59
 
42
60
  ```json
43
61
  {
44
62
  "mcpServers": {
45
- "simple-graylog-mcp": {
46
- "command": "node",
47
- "args": [
48
- "/path/to/graylog-mcp/src/index.js"
49
- ],
50
- "env": {
51
- "BASE_URL": "http://your.graylog.server.net.br:9000",
52
- "API_TOKEN": "your_graylog_api_token"
53
- }
63
+ "graylog": {
64
+ "command": "npx",
65
+ "args": ["graylog-mcp-server"]
54
66
  }
55
67
  }
56
68
  }
57
69
  ```
58
70
 
59
- 2. After that, your client is already able to use the `fetch_graylog_messages` tool. Example prompt:
71
+ Or with a local clone:
60
72
 
61
- ```
62
- Search for the latest 20 error logs of the example application, given that they occurred in the last 15 minutes.
73
+ ```json
74
+ {
75
+ "mcpServers": {
76
+ "graylog": {
77
+ "command": "node",
78
+ "args": ["/path/to/graylog-mcp/src/index.js"]
79
+ }
80
+ }
81
+ }
63
82
  ```
64
83
 
65
- This should be enough for the tool to be used, but if wanted, you can also explicitly "force" the use of the tool. Example prompt:
84
+ ## Available Tools
66
85
 
67
- ```
68
- Search for the latest 20 error logs of the example application, given that they occurred in the last 15 minutes.
86
+ ### list_connections
69
87
 
70
- use simple-graylog-mcp
71
- ```
88
+ List all configured Graylog connections.
72
89
 
90
+ ### use_connection
73
91
 
74
- ## Available tools
92
+ Connect to a specific Graylog instance by name. Must be called before using other tools.
93
+
94
+ | Parameter | Type | Required | Description |
95
+ |-----------|------|----------|-------------|
96
+ | `name` | string | Yes | Connection name from config |
75
97
 
76
98
  ### fetch_graylog_messages
77
99
 
78
- Fetch messages from Graylog.
100
+ Search and fetch log messages from Graylog.
101
+
102
+ | Parameter | Type | Required | Default | Description |
103
+ |-----------|------|----------|---------|-------------|
104
+ | `query` | string | No | `*` | Search query |
105
+ | `filters` | object | No | | Field filters (e.g. `{"env": "marketplace_loki", "level": 7}`) |
106
+ | `exactMatch` | boolean | No | `true` | Wrap query in quotes for exact match. Set `false` for fuzzy/wildcard |
107
+ | `searchTimeRangeInSeconds` | number | No | `900` | Relative time range in seconds |
108
+ | `pageSize` | number | No | `50` | Messages per page |
109
+ | `page` | number | No | `1` | Page number |
110
+ | `fields` | string | No | default set | Comma-separated fields, or `*` for all |
111
+
112
+ **Default fields returned:** `timestamp`, `gl2_message_id`, `source`, `env`, `level`, `message`, `logger_name`, `thread_name`, `PODNAME`
113
+
114
+ ### get_surrounding_messages
115
+
116
+ View messages around a specific log entry. Useful for understanding context.
79
117
 
80
- Parameters:
118
+ | Parameter | Type | Required | Default | Description |
119
+ |-----------|------|----------|---------|-------------|
120
+ | `messageId` | string | No* | | `gl2_message_id` of the target message (preferred) |
121
+ | `messageTimestamp` | string | No* | | ISO timestamp (fallback) |
122
+ | `surroundingSeconds` | number | No | `5` | Time window (± seconds) |
123
+ | `query` | string | No | `*` | Additional query filter |
124
+ | `filters` | object | No | | Field filters |
125
+ | `exactMatch` | boolean | No | `true` | Exact match for query |
126
+ | `limit` | number | No | `50` | Max messages to return |
127
+ | `fields` | string | No | default set | Comma-separated fields, or `*` for all |
81
128
 
82
- - `query` (string): Search query. Example: `level:ERROR AND service:api`.
83
- - `searchTimeRangeInSeconds` (number, optional): Relative time range in seconds. Default: `900` (15 minutes).
84
- - `searchCountLimit` (number, optional): Max number of messages. Default: `50`.
85
- - `fields` (string, optional): Comma-separated fields to include. Default: `*`.
129
+ *Either `messageId` or `messageTimestamp` must be provided.
130
+
131
+ ### list_streams
132
+
133
+ List all available Graylog streams in the active connection. No parameters required.
134
+
135
+ ### list_field_values
136
+
137
+ Discover distinct values for a field, sorted by message count (descending).
138
+
139
+ | Parameter | Type | Required | Default | Description |
140
+ |-----------|------|----------|---------|-------------|
141
+ | `field` | string | Yes | | Field name (e.g. `source`, `env`, `logger_name`) |
142
+ | `query` | string | No | `*` | Scope the results |
143
+ | `filters` | object | No | | Field filters to narrow scope |
144
+ | `exactMatch` | boolean | No | `true` | Exact match for query |
145
+ | `timeRangeInSeconds` | number | No | `3600` | Time range |
146
+ | `limit` | number | No | `20` | Max distinct values |
147
+
148
+ ## Example Prompts
149
+
150
+ ```
151
+ Connect to nonprod and show me the latest error logs from prefr-management in marketplace_loki
152
+ ```
153
+
154
+ ```
155
+ List all available sources in the last hour
156
+ ```
157
+
158
+ ```
159
+ Show me the surrounding messages for this log entry: 01KH5PDR893AZJQBYJJ87AQTW5
160
+ ```
161
+
162
+ ```
163
+ What environments are available?
164
+ ```
165
+
166
+ ## Project Structure
167
+
168
+ ```
169
+ src/
170
+ ├── index.js — Server bootstrap, routing, and handlers
171
+ ├── config.js — Connection config and default fields
172
+ ├── query.js — Query building, Graylog API client, message extraction
173
+ └── tools.js — Tool schema definitions
174
+ ```
86
175
 
87
176
  ## Troubleshooting
88
177
 
89
- - Ensure `BASE_URL` and `API_TOKEN` are set.
90
- - Verify Node.js version is 18+.
91
- - Run `npm install` if dependencies are missing.
178
+ - Ensure `~/.graylog-mcp/config.json` exists with valid connections
179
+ - Verify Node.js version is 18+ (`node --version`)
180
+ - Run `npm install` if dependencies are missing
181
+ - Use `list_connections` to verify your config is loaded
182
+ - Use `use_connection` before any search tools
92
183
 
93
184
  ## License
94
185
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "graylog-mcp-server",
3
- "version": "1.0.0",
4
- "description": "MCP server for fetching data from Graylog",
3
+ "version": "2.0.0",
4
+ "description": "MCP server for Graylog search logs, filter by fields, view surrounding messages, list streams, and discover field values",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
7
7
  "scripts": {
@@ -14,10 +14,20 @@
14
14
  "mcp",
15
15
  "graylog",
16
16
  "logging",
17
- "model-context-protocol"
17
+ "model-context-protocol",
18
+ "log-search",
19
+ "observability"
18
20
  ],
19
- "author": "Leo Ruellas",
21
+ "author": "Jagadeesh Pulamarasetti",
20
22
  "license": "MIT",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/jagadeesh52423/graylog-mcp.git"
26
+ },
27
+ "bugs": {
28
+ "url": "https://github.com/jagadeesh52423/graylog-mcp/issues"
29
+ },
30
+ "homepage": "https://github.com/jagadeesh52423/graylog-mcp#readme",
21
31
  "dependencies": {
22
32
  "@modelcontextprotocol/sdk": "^1.18.0",
23
33
  "axios": "^1.12.2",