@teamnetwork-nz/prtg-mcp-server 1.1.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.
- package/README.md +209 -0
- package/dist/client.d.ts +26 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +150 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +114 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/actions.d.ts +4 -0
- package/dist/tools/actions.d.ts.map +1 -0
- package/dist/tools/actions.js +83 -0
- package/dist/tools/actions.js.map +1 -0
- package/dist/tools/devices.d.ts +4 -0
- package/dist/tools/devices.d.ts.map +1 -0
- package/dist/tools/devices.js +99 -0
- package/dist/tools/devices.js.map +1 -0
- package/dist/tools/metrics.d.ts +4 -0
- package/dist/tools/metrics.d.ts.map +1 -0
- package/dist/tools/metrics.js +70 -0
- package/dist/tools/metrics.js.map +1 -0
- package/dist/tools/navigation.d.ts +4 -0
- package/dist/tools/navigation.d.ts.map +1 -0
- package/dist/tools/navigation.js +121 -0
- package/dist/tools/navigation.js.map +1 -0
- package/dist/tools/sensors.d.ts +4 -0
- package/dist/tools/sensors.d.ts.map +1 -0
- package/dist/tools/sensors.js +131 -0
- package/dist/tools/sensors.js.map +1 -0
- package/dist/tools/system.d.ts +4 -0
- package/dist/tools/system.d.ts.map +1 -0
- package/dist/tools/system.js +56 -0
- package/dist/tools/system.js.map +1 -0
- package/dist/types.d.ts +109 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/tz.d.ts +28 -0
- package/dist/tz.d.ts.map +1 -0
- package/dist/tz.js +128 -0
- package/dist/tz.js.map +1 -0
- package/package.json +30 -0
package/README.md
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# @teamnetwork/prtg-mcp-server
|
|
2
|
+
|
|
3
|
+
An MCP server for [PRTG Network Monitor](https://www.paessler.com/prtg) that uses the **PRTG v2 REST API exclusively** — no database, no Data Exporter add-on required.
|
|
4
|
+
|
|
5
|
+
Compatible with Claude Desktop, Claude Code, Cursor, Cline, and any MCP-capable client.
|
|
6
|
+
|
|
7
|
+
## Requirements
|
|
8
|
+
|
|
9
|
+
- Node.js 18+
|
|
10
|
+
- PRTG Network Monitor **25.1.102.1373 or later** with API v2 enabled (tested against 25.1.102.1373+)
|
|
11
|
+
- A PRTG API key (PRTG → My Account → API Keys)
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx @teamnetwork/prtg-mcp-server
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Or install globally:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install -g @teamnetwork/prtg-mcp-server
|
|
23
|
+
prtg-mcp-server
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Configuration
|
|
27
|
+
|
|
28
|
+
Set these environment variables before starting the server:
|
|
29
|
+
|
|
30
|
+
### Required
|
|
31
|
+
|
|
32
|
+
| Variable | Description |
|
|
33
|
+
|---|---|
|
|
34
|
+
| `PRTG_BASE_URL` | Scheme + host + port only — e.g. `https://prtg.example.com:1616`. Do **not** append `/api/v2`. |
|
|
35
|
+
| `PRTG_API_KEY` | Bearer token from PRTG → My Account → API Keys |
|
|
36
|
+
|
|
37
|
+
### Optional
|
|
38
|
+
|
|
39
|
+
| Variable | Default | Description |
|
|
40
|
+
|---|---|---|
|
|
41
|
+
| `PRTG_READWRITE` | `false` | Set to `true` to enable write tools (pause, resume, acknowledge) |
|
|
42
|
+
| `PRTG_IGNORE_SSL` | `false` | Set to `true` to skip TLS verification (self-signed certs) |
|
|
43
|
+
| `PRTG_TZ` | `local` | Timezone for date input/output — see [Timezone handling](#timezone-handling) below |
|
|
44
|
+
| `PRTG_TRANSPORT` | `stdio` | Transport mode: `stdio` (default, local) or `http` (remote agent hosting) |
|
|
45
|
+
| `PRTG_HTTP_PORT` | `3000` | Port to listen on when `PRTG_TRANSPORT=http` |
|
|
46
|
+
| `PRTG_HTTP_HOST` | `0.0.0.0` | Bind address when `PRTG_TRANSPORT=http` |
|
|
47
|
+
|
|
48
|
+
## Timezone handling
|
|
49
|
+
|
|
50
|
+
All PRTG API timestamps are UTC. By default this server converts them **automatically** — inputs from local time to UTC, outputs from UTC to local — so you never have to think about UTC offsets.
|
|
51
|
+
|
|
52
|
+
`PRTG_TZ` controls which timezone is applied:
|
|
53
|
+
|
|
54
|
+
| Value | Behaviour |
|
|
55
|
+
|---|---|
|
|
56
|
+
| `local` *(default)* | Use the system's local timezone (`Intl.DateTimeFormat` auto-detection) |
|
|
57
|
+
| `utc` | No conversion — dates pass through unchanged in UTC |
|
|
58
|
+
| IANA name e.g. `Pacific/Auckland` | Use this explicit timezone regardless of system locale |
|
|
59
|
+
|
|
60
|
+
**Output dates** are returned as ISO-8601 strings with a UTC offset suffix, e.g. `2026-05-09T01:44:56+12:00`.
|
|
61
|
+
|
|
62
|
+
**Input dates** (e.g. for `get_timeseries_custom`) should be local wall-clock time without a timezone suffix, e.g. `2024-01-15T09:00:00`. The server converts them to UTC before sending to PRTG. DST transitions are handled automatically via a two-pass offset resolution.
|
|
63
|
+
|
|
64
|
+
## Claude Desktop configuration
|
|
65
|
+
|
|
66
|
+
Add to `claude_desktop_config.json`:
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"mcpServers": {
|
|
71
|
+
"prtg": {
|
|
72
|
+
"command": "npx",
|
|
73
|
+
"args": ["-y", "@teamnetwork/prtg-mcp-server"],
|
|
74
|
+
"env": {
|
|
75
|
+
"PRTG_BASE_URL": "https://prtg.example.com:1616",
|
|
76
|
+
"PRTG_API_KEY": "your-api-key-here"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Claude Code configuration
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
claude mcp add prtg \
|
|
87
|
+
-e PRTG_BASE_URL=https://prtg.example.com:1616 \
|
|
88
|
+
-e PRTG_API_KEY=your-api-key-here \
|
|
89
|
+
-- npx -y @teamnetwork/prtg-mcp-server
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Running as a remote HTTP server
|
|
93
|
+
|
|
94
|
+
Set `PRTG_TRANSPORT=http` to start an HTTP server instead of reading from stdin. The server exposes a single endpoint at `/mcp` using the [MCP Streamable HTTP transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http) in stateless mode. A health check is available at `GET /health`.
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
PRTG_BASE_URL=https://prtg.example.com:1616 \
|
|
98
|
+
PRTG_API_KEY=your-api-key \
|
|
99
|
+
PRTG_TRANSPORT=http \
|
|
100
|
+
PRTG_HTTP_PORT=3000 \
|
|
101
|
+
PRTG_TZ=Pacific/Auckland \
|
|
102
|
+
node dist/index.js
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Docker
|
|
106
|
+
|
|
107
|
+
```dockerfile
|
|
108
|
+
FROM node:18-alpine
|
|
109
|
+
WORKDIR /app
|
|
110
|
+
COPY package*.json ./
|
|
111
|
+
RUN npm ci --omit=dev
|
|
112
|
+
COPY dist/ ./dist/
|
|
113
|
+
ENV PRTG_TRANSPORT=http
|
|
114
|
+
ENV PRTG_HTTP_PORT=3000
|
|
115
|
+
EXPOSE 3000
|
|
116
|
+
CMD ["node", "dist/index.js"]
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
npm run build
|
|
121
|
+
docker build -t prtg-mcp-server .
|
|
122
|
+
docker run -p 3000:3000 \
|
|
123
|
+
-e PRTG_BASE_URL=https://prtg.example.com:1616 \
|
|
124
|
+
-e PRTG_API_KEY=your-api-key \
|
|
125
|
+
-e PRTG_TZ=Pacific/Auckland \
|
|
126
|
+
prtg-mcp-server
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Claude Code config for remote HTTP server
|
|
130
|
+
|
|
131
|
+
```json
|
|
132
|
+
{
|
|
133
|
+
"mcpServers": {
|
|
134
|
+
"prtg": {
|
|
135
|
+
"type": "http",
|
|
136
|
+
"url": "https://your-host:3000/mcp"
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Available tools
|
|
143
|
+
|
|
144
|
+
### Sensors
|
|
145
|
+
| Tool | Description |
|
|
146
|
+
|---|---|
|
|
147
|
+
| `list_sensors` | List sensors with filters: status, name, parentid, tags, type |
|
|
148
|
+
| `get_sensor` | Get full details for a sensor by ID |
|
|
149
|
+
| `list_alerts` | List sensors in down / warning / unusual / acknowledged state |
|
|
150
|
+
|
|
151
|
+
### Devices & groups
|
|
152
|
+
| Tool | Description |
|
|
153
|
+
|---|---|
|
|
154
|
+
| `list_devices` | List devices with filters: name, parentid, tags, host |
|
|
155
|
+
| `get_device` | Get full details for a device by ID |
|
|
156
|
+
| `list_groups` | List groups with optional filters |
|
|
157
|
+
| `list_probes` | List probes (top-level monitoring nodes) |
|
|
158
|
+
|
|
159
|
+
### Navigation
|
|
160
|
+
| Tool | Description |
|
|
161
|
+
|---|---|
|
|
162
|
+
| `get_hierarchy` | Full object tree: probes → groups → devices (optionally with sensors) |
|
|
163
|
+
| `search` | Universal name search across sensors, devices, and groups |
|
|
164
|
+
|
|
165
|
+
### Metrics
|
|
166
|
+
| Tool | Description |
|
|
167
|
+
|---|---|
|
|
168
|
+
| `get_channels` | Current channel values for a sensor (value, unit, min/max/avg) |
|
|
169
|
+
| `get_timeseries` | Historical data for predefined timeframes: `live`, `short`, `medium`, `long` |
|
|
170
|
+
| `get_timeseries_custom` | Historical data for a custom date/time range (local time input, auto-converted to UTC) |
|
|
171
|
+
|
|
172
|
+
### System
|
|
173
|
+
| Tool | Description |
|
|
174
|
+
|---|---|
|
|
175
|
+
| `get_statistics` | Aggregated counts of sensors/devices/groups by status |
|
|
176
|
+
| `get_license` | PRTG license edition, sensor limits, expiry |
|
|
177
|
+
|
|
178
|
+
### Write actions (enabled with `PRTG_READWRITE=true`; off by default)
|
|
179
|
+
| Tool | Description |
|
|
180
|
+
|---|---|
|
|
181
|
+
| `pause_sensor` | Pause a sensor (optionally with message and auto-resume duration) |
|
|
182
|
+
| `resume_sensor` | Resume a paused sensor |
|
|
183
|
+
| `acknowledge_alert` | Acknowledge a down/warning sensor with a message |
|
|
184
|
+
|
|
185
|
+
## Read-only mode (default)
|
|
186
|
+
|
|
187
|
+
Write tools (`pause_sensor`, `resume_sensor`, `acknowledge_alert`) are **off by default**. Set `PRTG_READWRITE=true` to enable them. When disabled, those tools are never registered — they won't appear in the tool list at all.
|
|
188
|
+
|
|
189
|
+
## Development
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
npm install
|
|
193
|
+
npm run build
|
|
194
|
+
|
|
195
|
+
# Run locally
|
|
196
|
+
PRTG_BASE_URL=https://prtg.example.com:1616 \
|
|
197
|
+
PRTG_API_KEY=your-key \
|
|
198
|
+
node dist/index.js
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Test with the MCP inspector:
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
npx @modelcontextprotocol/inspector node dist/index.js
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## License
|
|
208
|
+
|
|
209
|
+
MIT
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface ClientConfig {
|
|
2
|
+
baseUrl: string;
|
|
3
|
+
apiKey: string;
|
|
4
|
+
ignoreSsl: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare class PrtgApiError extends Error {
|
|
7
|
+
readonly statusCode: number;
|
|
8
|
+
readonly prtgCode: string;
|
|
9
|
+
constructor(statusCode: number, prtgCode: string, message: string);
|
|
10
|
+
}
|
|
11
|
+
export declare class PrtgClient {
|
|
12
|
+
private readonly baseUrl;
|
|
13
|
+
private readonly headers;
|
|
14
|
+
private readonly agent;
|
|
15
|
+
constructor(config: ClientConfig);
|
|
16
|
+
private fetchOptions;
|
|
17
|
+
get<T>(path: string, params?: Record<string, string>): Promise<T>;
|
|
18
|
+
patch<T>(path: string, body: unknown): Promise<T>;
|
|
19
|
+
/**
|
|
20
|
+
* Fetch all pages of a list endpoint, respecting X-Total-Count.
|
|
21
|
+
* Returns the flattened items array.
|
|
22
|
+
*/
|
|
23
|
+
getAll<T>(path: string, params?: Record<string, string>, pageSize?: number): Promise<T[]>;
|
|
24
|
+
}
|
|
25
|
+
export declare function createClient(): PrtgClient;
|
|
26
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,qBAAa,YAAa,SAAQ,KAAK;aAEnB,UAAU,EAAE,MAAM;aAClB,QAAQ,EAAE,MAAM;gBADhB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChC,OAAO,EAAE,MAAM;CAKlB;AAkBD,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;IAEjD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAM;gBAEhB,MAAM,EAAE,YAAY;IAYhC,OAAO,CAAC,YAAY;IAQd,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IA4BrE,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IA+BvD;;;OAGG;IACG,MAAM,CAAC,CAAC,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,EACnC,QAAQ,SAAM,GACb,OAAO,CAAC,CAAC,EAAE,CAAC;CA6ChB;AAED,wBAAgB,YAAY,IAAI,UAAU,CAgBzC"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import https from "node:https";
|
|
2
|
+
export class PrtgApiError extends Error {
|
|
3
|
+
statusCode;
|
|
4
|
+
prtgCode;
|
|
5
|
+
constructor(statusCode, prtgCode, message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.statusCode = statusCode;
|
|
8
|
+
this.prtgCode = prtgCode;
|
|
9
|
+
this.name = "PrtgApiError";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function buildActionMessage(statusCode, prtgCode) {
|
|
13
|
+
if (statusCode === 401 || prtgCode === "AUTH_FAILED") {
|
|
14
|
+
return "Authentication failed. Check your PRTG_API_KEY — generate one via PRTG → My Account → API Keys.";
|
|
15
|
+
}
|
|
16
|
+
if (statusCode === 403) {
|
|
17
|
+
return "Access denied. The API key may lack the required permissions on this PRTG object.";
|
|
18
|
+
}
|
|
19
|
+
if (statusCode === 404) {
|
|
20
|
+
return "Resource not found. The object ID may be incorrect or the object may have been deleted.";
|
|
21
|
+
}
|
|
22
|
+
if (statusCode === 503 || statusCode === 502) {
|
|
23
|
+
return "PRTG core is unavailable. Check that the PRTG service is running.";
|
|
24
|
+
}
|
|
25
|
+
return `PRTG returned HTTP ${statusCode} (${prtgCode}).`;
|
|
26
|
+
}
|
|
27
|
+
export class PrtgClient {
|
|
28
|
+
baseUrl;
|
|
29
|
+
headers;
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
+
agent;
|
|
32
|
+
constructor(config) {
|
|
33
|
+
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
34
|
+
this.headers = {
|
|
35
|
+
Authorization: `Bearer ${config.apiKey}`,
|
|
36
|
+
Accept: "application/json",
|
|
37
|
+
"Content-Type": "application/json",
|
|
38
|
+
};
|
|
39
|
+
if (config.ignoreSsl) {
|
|
40
|
+
this.agent = new https.Agent({ rejectUnauthorized: false });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
fetchOptions(extra = {}) {
|
|
44
|
+
return {
|
|
45
|
+
headers: this.headers,
|
|
46
|
+
...(this.agent ? { agent: this.agent } : {}),
|
|
47
|
+
...extra,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
async get(path, params = {}) {
|
|
51
|
+
const url = new URL(`${this.baseUrl}${path}`);
|
|
52
|
+
for (const [k, v] of Object.entries(params)) {
|
|
53
|
+
if (v !== undefined && v !== "")
|
|
54
|
+
url.searchParams.set(k, v);
|
|
55
|
+
}
|
|
56
|
+
const res = await fetch(url.toString(), this.fetchOptions());
|
|
57
|
+
if (!res.ok) {
|
|
58
|
+
let prtgCode = "UNKNOWN";
|
|
59
|
+
let prtgMessage = res.statusText;
|
|
60
|
+
try {
|
|
61
|
+
const body = (await res.json());
|
|
62
|
+
prtgCode = body.code ?? prtgCode;
|
|
63
|
+
prtgMessage = body.message ?? prtgMessage;
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
// non-JSON error body
|
|
67
|
+
}
|
|
68
|
+
throw new PrtgApiError(res.status, prtgCode, buildActionMessage(res.status, prtgCode) + ` Detail: ${prtgMessage}`);
|
|
69
|
+
}
|
|
70
|
+
return res.json();
|
|
71
|
+
}
|
|
72
|
+
async patch(path, body) {
|
|
73
|
+
const res = await fetch(`${this.baseUrl}${path}`, this.fetchOptions({
|
|
74
|
+
method: "PATCH",
|
|
75
|
+
body: JSON.stringify(body),
|
|
76
|
+
}));
|
|
77
|
+
if (!res.ok) {
|
|
78
|
+
let prtgCode = "UNKNOWN";
|
|
79
|
+
let prtgMessage = res.statusText;
|
|
80
|
+
try {
|
|
81
|
+
const b = (await res.json());
|
|
82
|
+
prtgCode = b.code ?? prtgCode;
|
|
83
|
+
prtgMessage = b.message ?? prtgMessage;
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
// non-JSON error body
|
|
87
|
+
}
|
|
88
|
+
throw new PrtgApiError(res.status, prtgCode, buildActionMessage(res.status, prtgCode) + ` Detail: ${prtgMessage}`);
|
|
89
|
+
}
|
|
90
|
+
// 204 No Content is a valid success for PATCH
|
|
91
|
+
if (res.status === 204)
|
|
92
|
+
return {};
|
|
93
|
+
return res.json();
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Fetch all pages of a list endpoint, respecting X-Total-Count.
|
|
97
|
+
* Returns the flattened items array.
|
|
98
|
+
*/
|
|
99
|
+
async getAll(path, params = {}, pageSize = 500) {
|
|
100
|
+
const results = [];
|
|
101
|
+
let offset = 0;
|
|
102
|
+
while (true) {
|
|
103
|
+
const res = await fetch((() => {
|
|
104
|
+
const url = new URL(`${this.baseUrl}${path}`);
|
|
105
|
+
for (const [k, v] of Object.entries(params)) {
|
|
106
|
+
if (v !== undefined && v !== "")
|
|
107
|
+
url.searchParams.set(k, v);
|
|
108
|
+
}
|
|
109
|
+
url.searchParams.set("limit", String(pageSize));
|
|
110
|
+
url.searchParams.set("offset", String(offset));
|
|
111
|
+
return url.toString();
|
|
112
|
+
})(), this.fetchOptions());
|
|
113
|
+
if (!res.ok) {
|
|
114
|
+
let prtgCode = "UNKNOWN";
|
|
115
|
+
let prtgMessage = res.statusText;
|
|
116
|
+
try {
|
|
117
|
+
const b = (await res.json());
|
|
118
|
+
prtgCode = b.code ?? prtgCode;
|
|
119
|
+
prtgMessage = b.message ?? prtgMessage;
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
// non-JSON error body
|
|
123
|
+
}
|
|
124
|
+
throw new PrtgApiError(res.status, prtgCode, buildActionMessage(res.status, prtgCode) + ` Detail: ${prtgMessage}`);
|
|
125
|
+
}
|
|
126
|
+
const total = parseInt(res.headers.get("X-Total-Count") ?? "0", 10);
|
|
127
|
+
const items = (await res.json());
|
|
128
|
+
results.push(...items);
|
|
129
|
+
offset += items.length;
|
|
130
|
+
if (offset >= total || items.length === 0)
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
return results;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
export function createClient() {
|
|
137
|
+
const baseUrl = process.env["PRTG_BASE_URL"];
|
|
138
|
+
const apiKey = process.env["PRTG_API_KEY"];
|
|
139
|
+
const ignoreSsl = process.env["PRTG_IGNORE_SSL"] === "true";
|
|
140
|
+
if (!baseUrl)
|
|
141
|
+
throw new Error("PRTG_BASE_URL environment variable is required.");
|
|
142
|
+
if (!apiKey)
|
|
143
|
+
throw new Error("PRTG_API_KEY environment variable is required.");
|
|
144
|
+
if (ignoreSsl) {
|
|
145
|
+
process.stderr.write("[prtg-mcp] WARNING: SSL verification disabled (PRTG_IGNORE_SSL=true)\n");
|
|
146
|
+
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0";
|
|
147
|
+
}
|
|
148
|
+
return new PrtgClient({ baseUrl, apiKey, ignoreSsl });
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,YAAY,CAAC;AAQ/B,MAAM,OAAO,YAAa,SAAQ,KAAK;IAEnB;IACA;IAFlB,YACkB,UAAkB,EAClB,QAAgB,EAChC,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QAJC,eAAU,GAAV,UAAU,CAAQ;QAClB,aAAQ,GAAR,QAAQ,CAAQ;QAIhC,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AAED,SAAS,kBAAkB,CAAC,UAAkB,EAAE,Q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AAI,EAAE,CAAQ,CAAC;YACxC,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;YAEvB,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;gBAAE,MAAM;QACnD,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAED,MAAM,UAAU,YAAY;IAC1B,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAC3C,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,KAAK,MAAM,CAAC;IAE5D,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACjF,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IAE/E,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,wEAAwE,CACzE,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,GAAG,GAAG,CAAC;IACpD,CAAC;IAED,OAAO,IAAI,UAAU,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;AACxD,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import http from "node:http";
|
|
3
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
|
+
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
6
|
+
import { createClient } from "./client.js";
|
|
7
|
+
import { registerSensorTools } from "./tools/sensors.js";
|
|
8
|
+
import { registerDeviceTools } from "./tools/devices.js";
|
|
9
|
+
import { registerNavigationTools } from "./tools/navigation.js";
|
|
10
|
+
import { registerMetricsTools } from "./tools/metrics.js";
|
|
11
|
+
import { registerSystemTools } from "./tools/system.js";
|
|
12
|
+
import { registerActionTools } from "./tools/actions.js";
|
|
13
|
+
import { getEffectiveTz } from "./tz.js";
|
|
14
|
+
async function readJsonBody(req) {
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
const chunks = [];
|
|
17
|
+
req.on("data", (chunk) => chunks.push(chunk));
|
|
18
|
+
req.on("end", () => {
|
|
19
|
+
try {
|
|
20
|
+
resolve(JSON.parse(Buffer.concat(chunks).toString()));
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
resolve(undefined);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
req.on("error", reject);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
async function main() {
|
|
30
|
+
let client;
|
|
31
|
+
try {
|
|
32
|
+
client = createClient();
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
process.stderr.write(`[prtg-mcp] Configuration error: ${err.message}\n`);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
let tz;
|
|
39
|
+
try {
|
|
40
|
+
tz = getEffectiveTz();
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
process.stderr.write(`[prtg-mcp] Configuration error: ${err.message}\n`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
const readwrite = process.env["PRTG_READWRITE"] === "true";
|
|
47
|
+
const transportMode = process.env["PRTG_TRANSPORT"] ?? "stdio";
|
|
48
|
+
process.stderr.write(`[prtg-mcp] Timezone: ${tz}\n`);
|
|
49
|
+
if (readwrite) {
|
|
50
|
+
process.stderr.write("[prtg-mcp] Running in read-write mode (write tools enabled)\n");
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
process.stderr.write("[prtg-mcp] Running in read-only mode (set PRTG_READWRITE=true to enable write tools)\n");
|
|
54
|
+
}
|
|
55
|
+
const server = new McpServer({
|
|
56
|
+
name: "@teamnetwork/prtg-mcp-server",
|
|
57
|
+
version: "1.0.0",
|
|
58
|
+
});
|
|
59
|
+
registerSensorTools(server, client);
|
|
60
|
+
registerDeviceTools(server, client);
|
|
61
|
+
registerNavigationTools(server, client);
|
|
62
|
+
registerMetricsTools(server, client);
|
|
63
|
+
registerSystemTools(server, client);
|
|
64
|
+
if (readwrite)
|
|
65
|
+
registerActionTools(server, client);
|
|
66
|
+
if (transportMode === "http") {
|
|
67
|
+
const port = parseInt(process.env["PRTG_HTTP_PORT"] ?? "3000", 10);
|
|
68
|
+
const host = process.env["PRTG_HTTP_HOST"] ?? "0.0.0.0";
|
|
69
|
+
const transport = new StreamableHTTPServerTransport({
|
|
70
|
+
sessionIdGenerator: undefined, // stateless — suitable for remote agent hosting
|
|
71
|
+
});
|
|
72
|
+
await server.connect(transport);
|
|
73
|
+
const httpServer = http.createServer(async (req, res) => {
|
|
74
|
+
const url = req.url ?? "";
|
|
75
|
+
if (url === "/health") {
|
|
76
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
77
|
+
res.end(JSON.stringify({ status: "ok", server: "@teamnetwork/prtg-mcp-server" }));
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (!url.startsWith("/mcp")) {
|
|
81
|
+
res.writeHead(404);
|
|
82
|
+
res.end();
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
if (req.method === "POST") {
|
|
87
|
+
const body = await readJsonBody(req);
|
|
88
|
+
await transport.handleRequest(req, res, body);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
await transport.handleRequest(req, res);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
if (!res.headersSent) {
|
|
96
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
97
|
+
res.end(JSON.stringify({ error: err.message }));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
httpServer.listen(port, host, () => {
|
|
102
|
+
process.stderr.write(`[prtg-mcp] HTTP transport listening on ${host}:${port}/mcp\n`);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
const transport = new StdioServerTransport();
|
|
107
|
+
await server.connect(transport);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
main().catch((err) => {
|
|
111
|
+
process.stderr.write(`[prtg-mcp] Fatal: ${err.message}\n`);
|
|
112
|
+
process.exit(1);
|
|
113
|
+
});
|
|
114
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;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O,EAAE,CAAC,CAAC,CAAC;gBAC7D,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE;YACjC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,0CAA0C,IAAI,IAAI,IAAI,QAAQ,CAAC,CAAC;QACvF,CAAC,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;IAC5B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAsB,GAAa,CAAC,OAAO,IAAI,CAAC,CAAC;IACtE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/tools/actions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CA+F/E"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export function registerActionTools(server, client) {
|
|
3
|
+
server.registerTool("pause_sensor", {
|
|
4
|
+
title: "Pause Sensor",
|
|
5
|
+
description: "Pause a sensor so it stops collecting data and generating alerts. " +
|
|
6
|
+
"Optionally provide a message (shown in PRTG) and a duration in minutes (omit for indefinite pause).",
|
|
7
|
+
inputSchema: {
|
|
8
|
+
sensor_id: z.string().describe("PRTG sensor object ID"),
|
|
9
|
+
message: z
|
|
10
|
+
.string()
|
|
11
|
+
.optional()
|
|
12
|
+
.describe("Reason for pausing (displayed in PRTG UI)"),
|
|
13
|
+
duration_minutes: z
|
|
14
|
+
.number()
|
|
15
|
+
.int()
|
|
16
|
+
.min(1)
|
|
17
|
+
.optional()
|
|
18
|
+
.describe("Auto-resume after this many minutes (omit for indefinite)"),
|
|
19
|
+
},
|
|
20
|
+
}, async ({ sensor_id, message, duration_minutes }) => {
|
|
21
|
+
const body = {
|
|
22
|
+
status: "pausedbyuser",
|
|
23
|
+
};
|
|
24
|
+
if (message)
|
|
25
|
+
body["pausemessage"] = message;
|
|
26
|
+
if (duration_minutes)
|
|
27
|
+
body["pauseduration"] = duration_minutes;
|
|
28
|
+
await client.patch(`/api/v2/experimental/sensors/${sensor_id}`, body);
|
|
29
|
+
return {
|
|
30
|
+
content: [
|
|
31
|
+
{
|
|
32
|
+
type: "text",
|
|
33
|
+
text: `Sensor ${sensor_id} paused successfully.${message ? ` Reason: ${message}` : ""}${duration_minutes ? ` Auto-resumes in ${duration_minutes} minutes.` : ""}`,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
server.registerTool("resume_sensor", {
|
|
39
|
+
title: "Resume Sensor",
|
|
40
|
+
description: "Resume a previously paused sensor so it resumes normal monitoring.",
|
|
41
|
+
inputSchema: {
|
|
42
|
+
sensor_id: z.string().describe("PRTG sensor object ID"),
|
|
43
|
+
},
|
|
44
|
+
}, async ({ sensor_id }) => {
|
|
45
|
+
await client.patch(`/api/v2/experimental/sensors/${sensor_id}`, {
|
|
46
|
+
status: "up",
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
content: [
|
|
50
|
+
{
|
|
51
|
+
type: "text",
|
|
52
|
+
text: `Sensor ${sensor_id} resumed successfully.`,
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
server.registerTool("acknowledge_alert", {
|
|
58
|
+
title: "Acknowledge Alert",
|
|
59
|
+
description: "Acknowledge a sensor that is in a down or warning state. " +
|
|
60
|
+
"The sensor remains in its current state but is marked as acknowledged (suppresses further notifications).",
|
|
61
|
+
inputSchema: {
|
|
62
|
+
sensor_id: z.string().describe("PRTG sensor object ID"),
|
|
63
|
+
message: z
|
|
64
|
+
.string()
|
|
65
|
+
.min(1)
|
|
66
|
+
.describe("Acknowledgement message (required — explain why you're acknowledging)"),
|
|
67
|
+
},
|
|
68
|
+
}, async ({ sensor_id, message }) => {
|
|
69
|
+
await client.patch(`/api/v2/experimental/sensors/${sensor_id}`, {
|
|
70
|
+
status: "acknowledged",
|
|
71
|
+
acknowledgemessage: message,
|
|
72
|
+
});
|
|
73
|
+
return {
|
|
74
|
+
content: [
|
|
75
|
+
{
|
|
76
|
+
type: "text",
|
|
77
|
+
text: `Sensor ${sensor_id} acknowledged. Message: "${message}"`,
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../src/tools/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,MAAM,UAAU,mBAAmB,CAAC,MAAiB,EAAE,MAAkB;IACvE,MAAM,CAAC,YAAY,CACjB,cAAc,EACd;QACE,KAAK,EAAE,cAAc;QACrB,WAAW,EACT,oEAAoE;YACpE,qGAAqG;QACvG,WAAW,EAAE;YACX,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uBAAuB,CAAC;YACvD,OAAO,EAAE,CAAC;iBACP,MAAM,EAAE;iBACR,QAAQ,EAAE;iBACV,QAAQ,CAAC,2CAA2C,CAAC;YACxD,gBAAgB,EAAE,CAAC;iBAChB,MAAM,EAAE;iBACR,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