@davidfuchs/mcp-uptime-kuma 0.2.2 → 0.3.1
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.
- package/README.md +62 -12
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +60 -46
- package/dist/server.js.map +1 -1
- package/dist/uptime-kuma-client.d.ts +24 -7
- package/dist/uptime-kuma-client.d.ts.map +1 -1
- package/dist/uptime-kuma-client.js +52 -16
- package/dist/uptime-kuma-client.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -4,14 +4,26 @@ A Model Context Protocol (MCP) server for [Uptime Kuma](https://github.com/louis
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- **
|
|
8
|
-
- **
|
|
7
|
+
- **Uptime Kuma Integration**: Real-time access to monitors and heartbeats via WebSocket connection. This MCP server is immediately notified of status changes in Uptime Kuma.
|
|
8
|
+
- **Context-Friendly**: Carefully controls the amount of data returned to avoid overwhelming the LLM context window. Tools default to returning only essential fields and recent heartbeats, with options to request more when needed.
|
|
9
|
+
- **Multiple Transports**: Supports both stdio (for local integration) and streamable HTTP (for remote access).
|
|
9
10
|
- **MCP SDK**: Uses the official `@modelcontextprotocol/sdk` package
|
|
10
|
-
- **Uptime Kuma Integration**: Real-time access to monitors and heartbeats via WebSocket connection
|
|
11
11
|
- **Comprehensive Tools**: Retrieve monitor configurations and status data (heartbeats)
|
|
12
12
|
|
|
13
13
|
## Available Tools
|
|
14
14
|
|
|
15
|
+
### getMonitorSummary
|
|
16
|
+
Retrieves a summarized list of all monitors with essential information and their current status.
|
|
17
|
+
|
|
18
|
+
- **Input**:
|
|
19
|
+
- `keywords` (string, optional): Space-separated keywords to filter monitors by pathName (case-insensitive). All keywords must match for a monitor to be included.
|
|
20
|
+
- **Output**: Array of monitor summaries with:
|
|
21
|
+
- Monitor ID, name, pathName
|
|
22
|
+
- Active and maintenance state
|
|
23
|
+
- Most recent heartbeat status (0=DOWN, 1=UP, 2=PENDING, 3=MAINTENANCE)
|
|
24
|
+
- Status message from the most recent heartbeat
|
|
25
|
+
- Total count of matching monitors
|
|
26
|
+
|
|
15
27
|
### getMonitor
|
|
16
28
|
Retrieves detailed information about a specific monitor by its ID.
|
|
17
29
|
|
|
@@ -32,22 +44,30 @@ Retrieves heartbeats (status checks) for a specific monitor.
|
|
|
32
44
|
|
|
33
45
|
- **Input**:
|
|
34
46
|
- `monitorID` (number): The ID of the monitor to get heartbeats for
|
|
35
|
-
- `
|
|
36
|
-
- **Output**:
|
|
47
|
+
- `maxHeartbeats` (number, optional): Maximum number of most recent heartbeats to return (1-100). Default: 1
|
|
48
|
+
- **Output**: Object containing:
|
|
49
|
+
- `monitorID`: The monitor ID
|
|
50
|
+
- `heartbeats`: Array of heartbeat objects with status, response time, timestamps, etc.
|
|
51
|
+
- `count`: Number of heartbeats returned
|
|
37
52
|
|
|
38
|
-
###
|
|
39
|
-
Retrieves the
|
|
53
|
+
### listHeartbeats
|
|
54
|
+
Retrieves the heartbeats for all monitors.
|
|
40
55
|
|
|
41
56
|
- **Input**:
|
|
42
|
-
- `
|
|
43
|
-
- **Output**:
|
|
57
|
+
- `maxHeartbeats` (number, optional): Maximum number of most recent heartbeats per monitor (1-100). Default: 1
|
|
58
|
+
- **Output**: Object containing:
|
|
59
|
+
- `heartbeats`: Map of monitor IDs to their heartbeat arrays
|
|
60
|
+
- `monitorCount`: Number of monitors
|
|
61
|
+
- `totalHeartbeatCount`: Total number of heartbeats across all monitors
|
|
44
62
|
|
|
45
63
|
## Usage Notes
|
|
46
64
|
|
|
47
65
|
- **Monitors** contain configuration information (URLs, check intervals, notification settings, etc.)
|
|
48
66
|
- **Heartbeats** contain actual status data (up/down status, response times, timestamps, etc.)
|
|
49
67
|
- To check if something is **up or down**, use the heartbeat tools, not the monitor tools
|
|
50
|
-
-
|
|
68
|
+
- Use **getMonitorSummary** for a quick overview of all monitors and their current status
|
|
69
|
+
- By default, monitor tools return only essential fields. Set `includeAdditionalFields=true` to get all available data
|
|
70
|
+
- By default, heartbeat tools return only the most recent heartbeat. Use `maxHeartbeats` to retrieve more historical data
|
|
51
71
|
|
|
52
72
|
## Prerequisites
|
|
53
73
|
|
|
@@ -79,11 +99,38 @@ For Claude Code, VS Code, or other MCP clients, you can configure the server as
|
|
|
79
99
|
}
|
|
80
100
|
```
|
|
81
101
|
|
|
102
|
+
If you're using LibreChat (librechat.yaml), you can configure it like this:
|
|
103
|
+
|
|
104
|
+
```yaml
|
|
105
|
+
mcpServers:
|
|
106
|
+
uptime-kuma:
|
|
107
|
+
command: npx
|
|
108
|
+
args: ["-y", "@davidfuchs/mcp-uptime-kuma"]
|
|
109
|
+
customUserVars:
|
|
110
|
+
UPTIME_KUMA_URL:
|
|
111
|
+
title: "Uptime Kuma URL"
|
|
112
|
+
description: "The URL to log into Uptime Kuma."
|
|
113
|
+
UPTIME_KUMA_USERNAME:
|
|
114
|
+
title: "Uptime Kuma Username"
|
|
115
|
+
description: "The username to log into Uptime Kuma."
|
|
116
|
+
UPTIME_KUMA_PASSWORD:
|
|
117
|
+
title: "Uptime Kuma Password"
|
|
118
|
+
description: "The password to log into Uptime Kuma."
|
|
119
|
+
env:
|
|
120
|
+
UPTIME_KUMA_URL: "{{UPTIME_KUMA_URL}}"
|
|
121
|
+
UPTIME_KUMA_USERNAME: "{{UPTIME_KUMA_USERNAME}}"
|
|
122
|
+
UPTIME_KUMA_PASSWORD: "{{UPTIME_KUMA_PASSWORD}}"
|
|
123
|
+
serverInstructions: true
|
|
124
|
+
startup: false
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
If you're the only one using the LibreChat server, you can remove `customUserVars` and set the environment variables directly in the `env` section. You can also remove `startup: false` - that's only in there because without it, LibreChat tries to start the mcp-uptime-kuma MCP server immediately on startup, which fails because the user-provided credentials aren't available yet.
|
|
128
|
+
|
|
82
129
|
### For the Streamable HTTP Transport
|
|
83
130
|
|
|
84
131
|
The recommended way to run the MCP server using streamable HTTP is to run it as a Docker container.
|
|
85
132
|
|
|
86
|
-
A docker-compose file is provided
|
|
133
|
+
A docker-compose file is provided in the Github repository. Grab it, update the included environment variables as needed for your Uptime Kuma deployment, and run:
|
|
87
134
|
|
|
88
135
|
`docker compose up -d`
|
|
89
136
|
|
|
@@ -192,15 +239,18 @@ mcp-uptime-kuma/
|
|
|
192
239
|
│ ├── uptime-kuma-client.ts # WebSocket client for Uptime Kuma API
|
|
193
240
|
│ └── types.ts # TypeScript type definitions
|
|
194
241
|
├── dist/ # Compiled JavaScript (generated)
|
|
242
|
+
├── docker-compose.yml # Docker Compose configuration
|
|
243
|
+
├── Dockerfile # Docker image definition
|
|
195
244
|
├── package.json # Project dependencies and scripts
|
|
196
245
|
├── tsconfig.json # TypeScript configuration
|
|
197
246
|
├── .env # Environment configuration (create this)
|
|
247
|
+
├── LICENSE # License file
|
|
198
248
|
└── README.md # This file
|
|
199
249
|
```
|
|
200
250
|
|
|
201
251
|
## Development
|
|
202
252
|
|
|
203
|
-
To add new tools or modify existing ones, edit `src/server.ts`. The Uptime Kuma client in `src/uptime-kuma-client.ts` handles the WebSocket connection and
|
|
253
|
+
To add new tools or modify existing ones, edit `src/server.ts`. The Uptime Kuma client in `src/uptime-kuma-client.ts` handles the WebSocket connection and retrieves monitor and heartbeat data.
|
|
204
254
|
|
|
205
255
|
## Learn More
|
|
206
256
|
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMpE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMpE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAyS/E"}
|
package/dist/server.js
CHANGED
|
@@ -9,22 +9,14 @@ import { HeartbeatSchema, MonitorBaseSchema } from './types.js';
|
|
|
9
9
|
export async function createServer(config) {
|
|
10
10
|
const server = new McpServer({
|
|
11
11
|
name: 'mcp-uptime-kuma',
|
|
12
|
-
version: '0.
|
|
12
|
+
version: '0.3.0',
|
|
13
13
|
}, {
|
|
14
14
|
instructions: `
|
|
15
|
-
This MCP server provides access to Uptime Kuma monitoring data.
|
|
15
|
+
This MCP server provides access to Uptime Kuma monitoring data for system status and uptime/downtime information.
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
- getHeartbeats: Retrieve status checks and uptime data for a specific monitor
|
|
21
|
-
- listAllHeartbeats: Get status checks and uptime data for all monitors
|
|
22
|
-
|
|
23
|
-
Monitors contain configuration information (URLs, check intervals, notification settings, etc.).
|
|
24
|
-
Heartbeats contain actual status data (up/down status, response times, timestamps, etc.).
|
|
25
|
-
To check if something is up or down, use heartbeat tools, not monitor tools.
|
|
26
|
-
|
|
27
|
-
By default, tools return only essential fields. Set includeAdditionalFields=true to get all available data.
|
|
17
|
+
START with 'getMonitorSummary' for status overview questions ("how is everything?", "what's down?").
|
|
18
|
+
Use 'getHeartbeats' or 'listHeartbeats' for historical data (limit to 5-10 heartbeats unless user requests more).
|
|
19
|
+
Use 'listMonitors' only when you need configuration details (URLs, intervals, notification settings).
|
|
28
20
|
`
|
|
29
21
|
});
|
|
30
22
|
// Initialize Uptime Kuma client and login
|
|
@@ -44,7 +36,7 @@ export async function createServer(config) {
|
|
|
44
36
|
// Register getMonitor tool
|
|
45
37
|
server.registerTool('getMonitor', {
|
|
46
38
|
title: 'Get Monitor',
|
|
47
|
-
description: 'Retrieves
|
|
39
|
+
description: 'Retrieves configuration details for a specific monitor by ID (URL, check interval, notification settings, etc.). Use this when you need to examine or modify settings for a specific monitor. For current status, use getMonitorSummary instead. By default returns only core fields; set includeAdditionalFields to true to return all fields.',
|
|
48
40
|
inputSchema: {
|
|
49
41
|
monitorID: z.number().int().positive().describe('The ID of the monitor to retrieve'),
|
|
50
42
|
includeAdditionalFields: z.boolean().optional().describe('Include all additional fields from Uptime Kuma (default: false)')
|
|
@@ -75,7 +67,7 @@ export async function createServer(config) {
|
|
|
75
67
|
// Register listMonitors tool
|
|
76
68
|
server.registerTool('listMonitors', {
|
|
77
69
|
title: 'List Monitors',
|
|
78
|
-
description: 'Retrieves
|
|
70
|
+
description: 'Retrieves configuration details for all monitors (URLs, check intervals, notification settings, etc.). Use this when you need to examine or modify monitor settings. For status checks ("how is everything doing?", "what\'s down?"), use getMonitorSummary instead. By default returns only core fields; set includeAdditionalFields to true to return all fields.',
|
|
79
71
|
inputSchema: {
|
|
80
72
|
includeAdditionalFields: z.boolean().optional().describe('Include all additional fields from Uptime Kuma (default: false)')
|
|
81
73
|
},
|
|
@@ -106,33 +98,67 @@ export async function createServer(config) {
|
|
|
106
98
|
throw new McpError(ErrorCode.InternalError, `Failed to list monitors: ${errorMessage}`);
|
|
107
99
|
}
|
|
108
100
|
});
|
|
101
|
+
// Register getMonitorSummary tool
|
|
102
|
+
server.registerTool('getMonitorSummary', {
|
|
103
|
+
title: 'Get Monitor Summary',
|
|
104
|
+
description: 'START HERE for status overview questions. Retrieves current status for all monitors showing UP/DOWN/PENDING/MAINTENANCE states with the most recent heartbeat message. Use this when asked "how is everything doing?", "what\'s down?", "what\'s up?", or for any general status overview. Returns essential information (ID, name, pathName, active state, maintenance state, status, message). Optionally filter by keywords in the pathName.',
|
|
105
|
+
inputSchema: {
|
|
106
|
+
keywords: z.string().optional().describe('Space-separated keywords to filter monitors by pathName (case-insensitive). All keywords must match for a monitor to be included.')
|
|
107
|
+
},
|
|
108
|
+
outputSchema: {
|
|
109
|
+
summaries: z.array(z.object({
|
|
110
|
+
id: z.number(),
|
|
111
|
+
name: z.string(),
|
|
112
|
+
pathName: z.string(),
|
|
113
|
+
active: z.boolean(),
|
|
114
|
+
maintenance: z.boolean(),
|
|
115
|
+
status: z.number().optional().describe('0=DOWN, 1=UP, 2=PENDING, 3=MAINTENANCE'),
|
|
116
|
+
msg: z.string().optional().describe('Status message from the most recent heartbeat'),
|
|
117
|
+
})).describe('Array of monitor summaries'),
|
|
118
|
+
count: z.number()
|
|
119
|
+
},
|
|
120
|
+
}, async ({ keywords }) => {
|
|
121
|
+
if (!isAuthenticated) {
|
|
122
|
+
throw new McpError(ErrorCode.InternalError, 'Not authenticated with Uptime Kuma');
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
const summaries = client.getMonitorSummary(keywords);
|
|
126
|
+
return {
|
|
127
|
+
content: [{
|
|
128
|
+
type: 'text',
|
|
129
|
+
text: JSON.stringify(summaries, null, 2)
|
|
130
|
+
}],
|
|
131
|
+
structuredContent: {
|
|
132
|
+
summaries,
|
|
133
|
+
count: summaries.length
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
139
|
+
throw new McpError(ErrorCode.InternalError, `Failed to get monitor summary: ${errorMessage}`);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
109
142
|
// Register getHeartbeats tool
|
|
110
143
|
server.registerTool('getHeartbeats', {
|
|
111
144
|
title: 'Get Heartbeats',
|
|
112
|
-
description: 'Retrieves
|
|
145
|
+
description: 'Retrieves historical heartbeat data for a specific monitor (response times, status changes over time). Use this for analyzing patterns or history for one monitor. By default returns only the most recent heartbeat; set maxHeartbeats (up to 100) for historical analysis. Keep maxHeartbeats ≤10 unless user requests more.',
|
|
113
146
|
inputSchema: {
|
|
114
147
|
monitorID: z.number().int().positive().describe('The ID of the monitor to get heartbeats for'),
|
|
115
|
-
|
|
148
|
+
maxHeartbeats: z.number().int().positive().max(100).optional().describe('If set, returns the most recent X heartbeats (up to 100). If unset, returns only the most recent heartbeat (default: 1)')
|
|
116
149
|
},
|
|
117
150
|
outputSchema: {
|
|
118
151
|
monitorID: z.number(),
|
|
119
152
|
heartbeats: z.array(HeartbeatSchema),
|
|
120
153
|
count: z.number()
|
|
121
154
|
},
|
|
122
|
-
}, async ({ monitorID,
|
|
155
|
+
}, async ({ monitorID, maxHeartbeats }) => {
|
|
123
156
|
if (!isAuthenticated) {
|
|
124
157
|
throw new McpError(ErrorCode.InternalError, 'Not authenticated with Uptime Kuma');
|
|
125
158
|
}
|
|
126
159
|
try {
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
if (includeAllFlag) {
|
|
130
|
-
heartbeatsArray = client.getHeartbeatsForMonitor(monitorID, true);
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
const singleHeartbeat = client.getHeartbeatsForMonitor(monitorID, false);
|
|
134
|
-
heartbeatsArray = singleHeartbeat ? [singleHeartbeat] : [];
|
|
135
|
-
}
|
|
160
|
+
const count = maxHeartbeats ?? 1;
|
|
161
|
+
const heartbeatsArray = client.getHeartbeatsForMonitor(monitorID, count);
|
|
136
162
|
return {
|
|
137
163
|
content: [{
|
|
138
164
|
type: 'text',
|
|
@@ -151,36 +177,24 @@ export async function createServer(config) {
|
|
|
151
177
|
}
|
|
152
178
|
});
|
|
153
179
|
// Register listAllHeartbeats tool
|
|
154
|
-
server.registerTool('
|
|
155
|
-
title: 'List
|
|
156
|
-
description: 'Retrieves
|
|
180
|
+
server.registerTool('listHeartbeats', {
|
|
181
|
+
title: 'List Heartbeats',
|
|
182
|
+
description: 'Retrieves historical heartbeat data for ALL monitors (response times, status changes over time). Use this for analyzing patterns across multiple monitors or correlating events. By default returns only the most recent heartbeat per monitor; set maxHeartbeats (up to 100) for historical analysis. Keep maxHeartbeats ≤5 unless user requests more.',
|
|
157
183
|
inputSchema: {
|
|
158
|
-
|
|
184
|
+
maxHeartbeats: z.number().int().positive().max(100).optional().describe('If set, returns the most recent X heartbeats per monitor (up to 100). If unset, returns only the most recent heartbeat per monitor (default: 1)')
|
|
159
185
|
},
|
|
160
186
|
outputSchema: {
|
|
161
187
|
heartbeats: z.record(z.string(), z.array(HeartbeatSchema)).describe('Map of monitor IDs to their heartbeat arrays'),
|
|
162
188
|
monitorCount: z.number(),
|
|
163
189
|
totalHeartbeatCount: z.number()
|
|
164
190
|
},
|
|
165
|
-
}, async ({
|
|
191
|
+
}, async ({ maxHeartbeats }) => {
|
|
166
192
|
if (!isAuthenticated) {
|
|
167
193
|
throw new McpError(ErrorCode.InternalError, 'Not authenticated with Uptime Kuma');
|
|
168
194
|
}
|
|
169
195
|
try {
|
|
170
|
-
const
|
|
171
|
-
const
|
|
172
|
-
? client.getHeartbeatList(true)
|
|
173
|
-
: client.getHeartbeatList(false);
|
|
174
|
-
// Normalize to always return arrays for consistent schema
|
|
175
|
-
const heartbeatList = {};
|
|
176
|
-
for (const [monitorID, heartbeats] of Object.entries(rawHeartbeatList)) {
|
|
177
|
-
if (includeAllFlag) {
|
|
178
|
-
heartbeatList[monitorID] = heartbeats;
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
heartbeatList[monitorID] = heartbeats ? [heartbeats] : [];
|
|
182
|
-
}
|
|
183
|
-
}
|
|
196
|
+
const count = maxHeartbeats ?? 1;
|
|
197
|
+
const heartbeatList = client.getHeartbeatList(count);
|
|
184
198
|
// Calculate total heartbeat count
|
|
185
199
|
const totalCount = Object.values(heartbeatList).reduce((sum, heartbeats) => sum + heartbeats.length, 0);
|
|
186
200
|
return {
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAWhE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,MAAwB;IACzD,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B;QACE,IAAI,EAAE,iBAAiB;QACvB,OAAO,EAAE,OAAO;KACjB,EACD;QACE,YAAY,EAAE
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAWhE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,MAAwB;IACzD,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B;QACE,IAAI,EAAE,iBAAiB;QACvB,OAAO,EAAE,OAAO;KACjB,EACD;QACE,YAAY,EAAE;;;;;;OAMb;KACF,CACF,CAAC;IAGF,0CAA0C;IAC1C,MAAM,MAAM,GAAG,IAAI,gBAAgB,CA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ginResponse, MonitorList, Heartbeat
|
|
2
|
+
import type { MonitorBase, MonitorWithAdditionalFields, LoginResponse, MonitorList, Heartbeat } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Uptime Kuma Socket.io API Client
|
|
5
5
|
*/
|
|
@@ -54,18 +54,35 @@ export declare class UptimeKumaClient {
|
|
|
54
54
|
* Get the cached heartbeat list
|
|
55
55
|
* The list is populated after login and kept up-to-date via server events
|
|
56
56
|
*
|
|
57
|
-
* @param
|
|
58
|
-
* @returns The cached heartbeat list
|
|
57
|
+
* @param maxHeartbeats - Maximum number of heartbeats to return per monitor (default: 1)
|
|
58
|
+
* @returns The cached heartbeat list with arrays of heartbeats
|
|
59
59
|
*/
|
|
60
|
-
getHeartbeatList
|
|
60
|
+
getHeartbeatList(maxHeartbeats?: number): {
|
|
61
|
+
[monitorID: string]: Heartbeat[];
|
|
62
|
+
};
|
|
61
63
|
/**
|
|
62
64
|
* Get heartbeats for a specific monitor from the cache
|
|
63
65
|
*
|
|
64
66
|
* @param monitorID - The ID of the monitor
|
|
65
|
-
* @param
|
|
66
|
-
* @returns
|
|
67
|
+
* @param maxHeartbeats - Maximum number of heartbeats to return (default: 1)
|
|
68
|
+
* @returns Array of heartbeats for the monitor, or empty array if none exist
|
|
67
69
|
*/
|
|
68
|
-
getHeartbeatsForMonitor
|
|
70
|
+
getHeartbeatsForMonitor(monitorID: number, maxHeartbeats?: number): Heartbeat[];
|
|
71
|
+
/**
|
|
72
|
+
* Get a summarized list of all monitors with their most recent heartbeat status
|
|
73
|
+
*
|
|
74
|
+
* @param keywords - Optional space-separated keywords to filter by pathName (case-insensitive)
|
|
75
|
+
* @returns Array of monitor summaries containing essential info and latest heartbeat status
|
|
76
|
+
*/
|
|
77
|
+
getMonitorSummary(keywords?: string): Array<{
|
|
78
|
+
id: number;
|
|
79
|
+
name: string;
|
|
80
|
+
pathName: string;
|
|
81
|
+
active: boolean;
|
|
82
|
+
maintenance: boolean;
|
|
83
|
+
status?: number;
|
|
84
|
+
msg?: string;
|
|
85
|
+
}>;
|
|
69
86
|
/**
|
|
70
87
|
* Get the socket instance (for advanced usage)
|
|
71
88
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uptime-kuma-client.d.ts","sourceRoot":"","sources":["../src/uptime-kuma-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,MAAM,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"uptime-kuma-client.d.ts","sourceRoot":"","sources":["../src/uptime-kuma-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,KAAK,EACV,WAAW,EACX,2BAA2B,EAG3B,aAAa,EAEb,WAAW,EACX,SAAS,EAEV,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,gBAAgB,CAAyB;IACjD,OAAO,CAAC,kBAAkB,CAA2B;gBAEzC,GAAG,EAAE,MAAM;IAIvB;;OAEG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAkBxB;;OAEG;IACH,UAAU,IAAI,IAAI;IAkBlB;;;;;;;OAOG;IACH,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IA8BjF;;;OAGG;IACH,OAAO,CAAC,yBAAyB;IAmBjC;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAoC/B;;;;;OAKG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,2BAA2B,GAAG,SAAS;IAItE;;;;;OAKG;IACH,cAAc,IAAI,WAAW,CAAC,IAAI,CAAC;IAInC;;;;;;OAMG;IACH,gBAAgB,CAAC,aAAa,GAAE,MAAU,GAAG;QAAE,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,CAAA;KAAE;IAUjF;;;;;;OAMG;IACH,uBAAuB,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,GAAE,MAAU,GAAG,SAAS,EAAE;IAUlF;;;;;OAKG;IACH,iBAAiB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;QAC1C,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,OAAO,CAAC;QAChB,WAAW,EAAE,OAAO,CAAC;QACrB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;IAuCF;;OAEG;IACH,SAAS,IAAI,MAAM,GAAG,IAAI;CAG3B;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,2BAA2B,GAAG,WAAW,CAyBrF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { io, Socket } from 'socket.io-client';
|
|
2
|
+
import fuzzysort from 'fuzzysort';
|
|
2
3
|
/**
|
|
3
4
|
* Uptime Kuma Socket.io API Client
|
|
4
5
|
*/
|
|
@@ -156,33 +157,68 @@ export class UptimeKumaClient {
|
|
|
156
157
|
* Get the cached heartbeat list
|
|
157
158
|
* The list is populated after login and kept up-to-date via server events
|
|
158
159
|
*
|
|
159
|
-
* @param
|
|
160
|
-
* @returns The cached heartbeat list
|
|
160
|
+
* @param maxHeartbeats - Maximum number of heartbeats to return per monitor (default: 1)
|
|
161
|
+
* @returns The cached heartbeat list with arrays of heartbeats
|
|
161
162
|
*/
|
|
162
|
-
getHeartbeatList(
|
|
163
|
-
|
|
164
|
-
return this.heartbeatListCache;
|
|
165
|
-
}
|
|
166
|
-
// Return only the most recent heartbeat for each monitor
|
|
167
|
-
const recentHeartbeats = {};
|
|
163
|
+
getHeartbeatList(maxHeartbeats = 1) {
|
|
164
|
+
const result = {};
|
|
168
165
|
for (const [monitorID, heartbeats] of Object.entries(this.heartbeatListCache)) {
|
|
169
|
-
|
|
166
|
+
result[monitorID] = heartbeats.slice(0, maxHeartbeats);
|
|
170
167
|
}
|
|
171
|
-
return
|
|
168
|
+
return result;
|
|
172
169
|
}
|
|
173
170
|
/**
|
|
174
171
|
* Get heartbeats for a specific monitor from the cache
|
|
175
172
|
*
|
|
176
173
|
* @param monitorID - The ID of the monitor
|
|
177
|
-
* @param
|
|
178
|
-
* @returns
|
|
174
|
+
* @param maxHeartbeats - Maximum number of heartbeats to return (default: 1)
|
|
175
|
+
* @returns Array of heartbeats for the monitor, or empty array if none exist
|
|
179
176
|
*/
|
|
180
|
-
getHeartbeatsForMonitor(monitorID,
|
|
177
|
+
getHeartbeatsForMonitor(monitorID, maxHeartbeats = 1) {
|
|
181
178
|
const heartbeats = this.heartbeatListCache[monitorID.toString()];
|
|
182
|
-
if (
|
|
183
|
-
return
|
|
179
|
+
if (!heartbeats) {
|
|
180
|
+
return [];
|
|
181
|
+
}
|
|
182
|
+
return heartbeats.slice(0, maxHeartbeats);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Get a summarized list of all monitors with their most recent heartbeat status
|
|
186
|
+
*
|
|
187
|
+
* @param keywords - Optional space-separated keywords to filter by pathName (case-insensitive)
|
|
188
|
+
* @returns Array of monitor summaries containing essential info and latest heartbeat status
|
|
189
|
+
*/
|
|
190
|
+
getMonitorSummary(keywords) {
|
|
191
|
+
const summaries = [];
|
|
192
|
+
// Parse keywords into an array
|
|
193
|
+
const keywordArray = keywords ? keywords.trim().split(/\s+/) : [];
|
|
194
|
+
for (const [monitorID, monitor] of Object.entries(this.monitorListCache)) {
|
|
195
|
+
// Filter by keywords if provided using fuzzy matching
|
|
196
|
+
if (keywordArray.length > 0) {
|
|
197
|
+
const pathName = monitor.pathName;
|
|
198
|
+
// All keywords must match with a reasonable score
|
|
199
|
+
const matchesAllKeywords = keywordArray.every(keyword => {
|
|
200
|
+
const result = fuzzysort.single(keyword, pathName);
|
|
201
|
+
// Accept matches with score > 0.3 (0 = no match, 1 = perfect match)
|
|
202
|
+
return result && result.score > 0.3;
|
|
203
|
+
});
|
|
204
|
+
if (!matchesAllKeywords) {
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
// Get the most recent heartbeat for this monitor
|
|
209
|
+
const heartbeats = this.heartbeatListCache[monitorID];
|
|
210
|
+
const latestHeartbeat = heartbeats && heartbeats.length > 0 ? heartbeats[0] : undefined;
|
|
211
|
+
summaries.push({
|
|
212
|
+
id: monitor.id,
|
|
213
|
+
name: monitor.name,
|
|
214
|
+
pathName: monitor.pathName,
|
|
215
|
+
active: monitor.active,
|
|
216
|
+
maintenance: monitor.maintenance,
|
|
217
|
+
status: latestHeartbeat?.status,
|
|
218
|
+
msg: latestHeartbeat?.msg,
|
|
219
|
+
});
|
|
184
220
|
}
|
|
185
|
-
return
|
|
221
|
+
return summaries;
|
|
186
222
|
}
|
|
187
223
|
/**
|
|
188
224
|
* Get the socket instance (for advanced usage)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uptime-kuma-client.js","sourceRoot":"","sources":["../src/uptime-kuma-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"uptime-kuma-client.js","sourceRoot":"","sources":["../src/uptime-kuma-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,SAAS,MAAM,WAAW,CAAC;AAalC;;GAEG;AACH,MAAM,OAAO,gBAAgB;IACnB,MAAM,GAAkB,IAAI,CAAC;IAC7B,GAAG,CAAS;IACZ,gBAAgB,GAAsB,EAAE,CAAC;IACzC,kBAAkB,GAAwB,EAAE,CAAC;IAErD,YAAY,GAAW;QACrB,IAAI,CAAC,G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AAkB,KAAK,SAAS;QAAE,QAAQ,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IACvG,IAAI,OAAO,CAAC,yBAAyB,KAAK,SAAS;QAAE,QAAQ,CAAC,yBAAyB,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAC5H,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS;QAAE,QAAQ,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IAE/E,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@davidfuchs/mcp-uptime-kuma",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "A Model Context Protocol (MCP) server for Uptime Kuma version 2, supporting both stdio and streamable HTTP transports.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"@modelcontextprotocol/sdk": "^1.22.0",
|
|
48
48
|
"dotenv": "^17.2.3",
|
|
49
49
|
"express": "^4.21.2",
|
|
50
|
+
"fuzzysort": "^3.1.0",
|
|
50
51
|
"socket.io-client": "^4.8.1",
|
|
51
52
|
"zod": "^3.24.1"
|
|
52
53
|
},
|