winhelm-mcp 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/CHANGELOG.md +96 -0
- package/LICENSE +21 -0
- package/README.md +646 -0
- package/dist/config/config-manager.d.ts +50 -0
- package/dist/config/config-manager.d.ts.map +1 -0
- package/dist/config/config-manager.js +300 -0
- package/dist/config/config-manager.js.map +1 -0
- package/dist/config/default-config.d.ts +4 -0
- package/dist/config/default-config.d.ts.map +1 -0
- package/dist/config/default-config.js +48 -0
- package/dist/config/default-config.js.map +1 -0
- package/dist/config/profiles.d.ts +16 -0
- package/dist/config/profiles.d.ts.map +1 -0
- package/dist/config/profiles.js +208 -0
- package/dist/config/profiles.js.map +1 -0
- package/dist/engine/filesystem.d.ts +52 -0
- package/dist/engine/filesystem.d.ts.map +1 -0
- package/dist/engine/filesystem.js +499 -0
- package/dist/engine/filesystem.js.map +1 -0
- package/dist/engine/http-client.d.ts +10 -0
- package/dist/engine/http-client.d.ts.map +1 -0
- package/dist/engine/http-client.js +93 -0
- package/dist/engine/http-client.js.map +1 -0
- package/dist/engine/pdf-generator.d.ts +15 -0
- package/dist/engine/pdf-generator.d.ts.map +1 -0
- package/dist/engine/pdf-generator.js +325 -0
- package/dist/engine/pdf-generator.js.map +1 -0
- package/dist/engine/powershell-runner.d.ts +23 -0
- package/dist/engine/powershell-runner.d.ts.map +1 -0
- package/dist/engine/powershell-runner.js +148 -0
- package/dist/engine/powershell-runner.js.map +1 -0
- package/dist/engine/ripgrep.d.ts +20 -0
- package/dist/engine/ripgrep.d.ts.map +1 -0
- package/dist/engine/ripgrep.js +173 -0
- package/dist/engine/ripgrep.js.map +1 -0
- package/dist/engine/system.d.ts +67 -0
- package/dist/engine/system.d.ts.map +1 -0
- package/dist/engine/system.js +558 -0
- package/dist/engine/system.js.map +1 -0
- package/dist/engine/task-manager.d.ts +66 -0
- package/dist/engine/task-manager.d.ts.map +1 -0
- package/dist/engine/task-manager.js +203 -0
- package/dist/engine/task-manager.js.map +1 -0
- package/dist/gateway/dashboard-html.d.ts +7 -0
- package/dist/gateway/dashboard-html.d.ts.map +1 -0
- package/dist/gateway/dashboard-html.js +624 -0
- package/dist/gateway/dashboard-html.js.map +1 -0
- package/dist/gateway/preview-html.d.ts +5 -0
- package/dist/gateway/preview-html.d.ts.map +1 -0
- package/dist/gateway/preview-html.js +351 -0
- package/dist/gateway/preview-html.js.map +1 -0
- package/dist/gateway/rate-limiter.d.ts +8 -0
- package/dist/gateway/rate-limiter.d.ts.map +1 -0
- package/dist/gateway/rate-limiter.js +51 -0
- package/dist/gateway/rate-limiter.js.map +1 -0
- package/dist/gateway/server.d.ts +18 -0
- package/dist/gateway/server.d.ts.map +1 -0
- package/dist/gateway/server.js +337 -0
- package/dist/gateway/server.js.map +1 -0
- package/dist/gateway/sse-gateway.d.ts +43 -0
- package/dist/gateway/sse-gateway.d.ts.map +1 -0
- package/dist/gateway/sse-gateway.js +161 -0
- package/dist/gateway/sse-gateway.js.map +1 -0
- package/dist/gateway/streamable-gateway.d.ts +39 -0
- package/dist/gateway/streamable-gateway.d.ts.map +1 -0
- package/dist/gateway/streamable-gateway.js +176 -0
- package/dist/gateway/streamable-gateway.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +164 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/desktop-tools.d.ts +3 -0
- package/dist/tools/desktop-tools.d.ts.map +1 -0
- package/dist/tools/desktop-tools.js +280 -0
- package/dist/tools/desktop-tools.js.map +1 -0
- package/dist/tools/file-tools.d.ts +3 -0
- package/dist/tools/file-tools.d.ts.map +1 -0
- package/dist/tools/file-tools.js +433 -0
- package/dist/tools/file-tools.js.map +1 -0
- package/dist/tools/index.d.ts +12 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +16 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/network-tools.d.ts +3 -0
- package/dist/tools/network-tools.d.ts.map +1 -0
- package/dist/tools/network-tools.js +108 -0
- package/dist/tools/network-tools.js.map +1 -0
- package/dist/tools/registry.d.ts +50 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +54 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/terminal-tools.d.ts +3 -0
- package/dist/tools/terminal-tools.d.ts.map +1 -0
- package/dist/tools/terminal-tools.js +152 -0
- package/dist/tools/terminal-tools.js.map +1 -0
- package/dist/tools/tool-wrapper.d.ts +7 -0
- package/dist/tools/tool-wrapper.d.ts.map +1 -0
- package/dist/tools/tool-wrapper.js +47 -0
- package/dist/tools/tool-wrapper.js.map +1 -0
- package/dist/types/index.d.ts +261 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/file-logger.d.ts +24 -0
- package/dist/utils/file-logger.d.ts.map +1 -0
- package/dist/utils/file-logger.js +117 -0
- package/dist/utils/file-logger.js.map +1 -0
- package/dist/utils/logger.d.ts +51 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +189 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/sanitizer.d.ts +13 -0
- package/dist/utils/sanitizer.d.ts.map +1 -0
- package/dist/utils/sanitizer.js +60 -0
- package/dist/utils/sanitizer.js.map +1 -0
- package/docs/EXAMPLES.md +171 -0
- package/docs/PROFILES.md +423 -0
- package/docs/SECURITY.md +190 -0
- package/docs/TOOLS.md +366 -0
- package/manifest.json +74 -0
- package/package.json +89 -0
- package/scripts/build-exe.ps1 +37 -0
- package/scripts/manage-service.ps1 +112 -0
- package/server.json +23 -0
- package/winhelm.config.example.json +30 -0
package/docs/TOOLS.md
ADDED
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
# WinHelm MCP — Comprehensive Tools Reference
|
|
2
|
+
|
|
3
|
+
WinHelm provides **38 native Windows tools** and **1 MCP Resource** designed for AI coding agents and desktop automation.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Tool Profiles Matrix
|
|
8
|
+
|
|
9
|
+
WinHelm supports loading subset profiles to prevent prompt context bloat:
|
|
10
|
+
|
|
11
|
+
| Tool Name | `minimal` (6) | `core` (15) | `dev` (28) | `sysadmin` (37) | `full` (38) | Category | Description |
|
|
12
|
+
| :--- | :---: | :---: | :---: | :---: | :---: | :--- | :--- |
|
|
13
|
+
| `terminal_run` | ✅ | ✅ | ✅ | ✅ | ✅ | Terminal | Synchronous PowerShell runner with UTF-8 encoding |
|
|
14
|
+
| `terminal_task_start` | ❌ | ❌ | ✅ | ✅ | ✅ | Terminal | Starts detached background daemon task |
|
|
15
|
+
| `terminal_task_list` | ❌ | ❌ | ✅ | ✅ | ✅ | Terminal | Lists active and exited background tasks |
|
|
16
|
+
| `terminal_task_logs` | ❌ | ❌ | ✅ | ✅ | ✅ | Terminal | Retrieves buffered output logs of a task |
|
|
17
|
+
| `terminal_task_send` | ❌ | ❌ | ✅ | ✅ | ✅ | Terminal | Sends interactive input (`stdin`) to a task |
|
|
18
|
+
| `terminal_task_kill` | ❌ | ❌ | ✅ | ✅ | ✅ | Terminal | Terminates a background task process tree |
|
|
19
|
+
| `file_read` | ✅ | ✅ | ✅ | ✅ | ✅ | Filesystem | Reads file content with optional line slicing |
|
|
20
|
+
| `file_write` | ✅ | ✅ | ✅ | ✅ | ✅ | Filesystem | Writes UTF-8 file (creates directories) |
|
|
21
|
+
| `file_edit` | ❌ | ✅ | ✅ | ✅ | ✅ | Filesystem | Precise surgical text replacement |
|
|
22
|
+
| `file_list` | ✅ | ✅ | ✅ | ✅ | ✅ | Filesystem | Lists directory entries with stats |
|
|
23
|
+
| `file_search` | ✅ | ✅ | ✅ | ✅ | ✅ | Filesystem | Substring search across files |
|
|
24
|
+
| `file_delete_safe` | ❌ | ✅ | ✅ | ✅ | ✅ | Filesystem | Moves file to Windows Recycle Bin (recoverable) |
|
|
25
|
+
| `file_move` | ❌ | ✅ | ✅ | ✅ | ✅ | Filesystem | Atomically moves or renames a file/folder |
|
|
26
|
+
| `file_copy` | ❌ | ✅ | ✅ | ✅ | ✅ | Filesystem | Recursively copies files or directories |
|
|
27
|
+
| `archive_zip` | ❌ | ❌ | ✅ | ✅ | ✅ | Filesystem | Compresses directory to `.zip` via native .NET |
|
|
28
|
+
| `archive_unzip` | ❌ | ❌ | ✅ | ✅ | ✅ | Filesystem | Extracts `.zip` archive via native .NET |
|
|
29
|
+
| `file_tail` | ❌ | ✅ | ✅ | ✅ | ✅ | Filesystem | Reads trailing N lines of large files/logs |
|
|
30
|
+
| `file_hash` | ❌ | ✅ | ✅ | ✅ | ✅ | Filesystem | Computes SHA-256, MD5, or SHA-1 checksum |
|
|
31
|
+
| `file_search_ripgrep` | ❌ | ❌ | ✅ | ✅ | ✅ | Codebase | Fast regex code search with streaming pagination |
|
|
32
|
+
| `pdf_generate` | ❌ | ❌ | ✅ | ❌ | ✅ | Document | Generates styled PDF via headless Edge/Chrome |
|
|
33
|
+
| `file_preview` | ❌ | ❌ | ✅ | ✅ | ✅ | Preview | File metadata and web preview URL |
|
|
34
|
+
| `clipboard_get` | ❌ | ❌ | ❌ | ✅ | ✅ | Desktop | Reads text from Windows Clipboard |
|
|
35
|
+
| `clipboard_set` | ❌ | ❌ | ❌ | ✅ | ✅ | Desktop | Writes text to Windows Clipboard |
|
|
36
|
+
| `screen_capture` | ❌ | ❌ | ❌ | ✅ | ✅ | Desktop | Captures desktop screenshot (base64 PNG) |
|
|
37
|
+
| `system_open` | ❌ | ❌ | ✅ | ✅ | ✅ | Desktop | Opens URL, file, or folder in default app |
|
|
38
|
+
| `notification_send` | ❌ | ❌ | ❌ | ✅ | ✅ | Desktop | Dispatches Windows native Toast Notification |
|
|
39
|
+
| `system_info` | ✅ | ✅ | ✅ | ✅ | ✅ | System | OS version, CPU, RAM, drives & uptime |
|
|
40
|
+
| `gpu_info` | ❌ | ✅ | ✅ | ✅ | ✅ | System | NVIDIA GPU telemetry (VRAM, temp) or WMI |
|
|
41
|
+
| `process_list` | ❌ | ✅ | ✅ | ✅ | ✅ | System | Lists top processes sorted by RAM or CPU |
|
|
42
|
+
| `process_kill` | ❌ | ❌ | ❌ | ✅ | ✅ | System | Kills process by PID or executable name |
|
|
43
|
+
| `port_check` | ❌ | ✅ | ✅ | ✅ | ✅ | System | Checks TCP port usage and owning PID |
|
|
44
|
+
| `eventlog_query` | ❌ | ❌ | ❌ | ✅ | ✅ | System | Queries Windows Event Log (errors/warnings) |
|
|
45
|
+
| `service_list` | ❌ | ❌ | ❌ | ✅ | ✅ | Services | Lists Windows Services and status |
|
|
46
|
+
| `service_status` | ❌ | ❌ | ❌ | ✅ | ✅ | Services | Detailed status and PID of a service |
|
|
47
|
+
| `service_control` | ❌ | ❌ | ❌ | ✅ | ✅ | Services | Starts, stops, or restarts a service |
|
|
48
|
+
| `http_ping` | ❌ | ❌ | ✅ | ✅ | ✅ | Network | Fast HTTP latency and health probe |
|
|
49
|
+
| `http_request` | ❌ | ❌ | ✅ | ✅ | ✅ | Network | Dispatches HTTP requests (GET/POST/etc.) |
|
|
50
|
+
| `network_info` | ❌ | ❌ | ❌ | ✅ | ✅ | Network | Network adapters, IPs, DNS, and Tailscale |
|
|
51
|
+
| `preview://file` *(Resource)* | ❌ | ❌ | ✅ | ✅ | ✅ | MCP Resource | Dynamic interactive HTML preview resource |
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Table of Contents
|
|
56
|
+
|
|
57
|
+
1. [Terminal & Background Execution](#1-terminal--background-execution) (6 tools)
|
|
58
|
+
2. [Filesystem, Safe Delete & Archives](#2-filesystem-safe-delete--archives) (12 tools)
|
|
59
|
+
3. [Codebase Search, PDF & Preview](#3-codebase-search-pdf--preview) (3 tools)
|
|
60
|
+
4. [Desktop & Productivity](#4-desktop--productivity) (5 tools)
|
|
61
|
+
5. [System, Processes & Windows Services](#5-system-processes--windows-services) (9 tools)
|
|
62
|
+
6. [Network & Web Diagnostics](#6-network--web-diagnostics) (3 tools)
|
|
63
|
+
7. [MCP Resources](#7-mcp-resources) (1 resource)
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## 1. Terminal & Background Execution
|
|
68
|
+
|
|
69
|
+
### `terminal_run`
|
|
70
|
+
Executes a PowerShell command synchronously with automatic UTF-8 encoding enforcement and timeout handling.
|
|
71
|
+
- **Parameters:**
|
|
72
|
+
- `command` *(string, required)*: The PowerShell command to execute.
|
|
73
|
+
- `cwd` *(string, optional)*: Working directory for execution.
|
|
74
|
+
- `timeout_ms` *(number, optional, default: 60000)*: Timeout in milliseconds.
|
|
75
|
+
- **Returns:** Text output containing stdout and stderr.
|
|
76
|
+
|
|
77
|
+
### `terminal_task_start`
|
|
78
|
+
Launches a long-running command in the background (e.g. dev servers, npm build, test watchers) returning a Task ID immediately.
|
|
79
|
+
- **Parameters:**
|
|
80
|
+
- `command` *(string, required)*: Background command to run.
|
|
81
|
+
- `cwd` *(string, optional)*: Working directory.
|
|
82
|
+
- **Returns:** `{ message: string, task: { id, command, cwd, pid, status, startTime } }`
|
|
83
|
+
|
|
84
|
+
### `terminal_task_list`
|
|
85
|
+
Lists all active, completed, or failed background tasks managed by WinHelm.
|
|
86
|
+
- **Parameters:** None.
|
|
87
|
+
- **Returns:** Array of background task objects.
|
|
88
|
+
|
|
89
|
+
### `terminal_task_logs`
|
|
90
|
+
Retrieves live buffered output logs and status from a running or completed background task.
|
|
91
|
+
- **Parameters:**
|
|
92
|
+
- `task_id` *(string, required)*: Task ID returned from `terminal_task_start`.
|
|
93
|
+
- `tail_lines` *(number, optional, default: 100)*: Number of trailing lines to view.
|
|
94
|
+
- **Returns:** Header with task status followed by recent standard output and error text.
|
|
95
|
+
|
|
96
|
+
### `terminal_task_send`
|
|
97
|
+
Sends interactive text/keystrokes directly to the `stdin` stream of a running background process.
|
|
98
|
+
- **Parameters:**
|
|
99
|
+
- `task_id` *(string, required)*: Task ID of running process.
|
|
100
|
+
- `input` *(string, required)*: Text to send to stdin.
|
|
101
|
+
- **Returns:** Confirmation message.
|
|
102
|
+
|
|
103
|
+
### `terminal_task_kill`
|
|
104
|
+
Terminates a running background task and its entire Windows process tree (`taskkill /T /F`) with zero orphan processes.
|
|
105
|
+
- **Parameters:**
|
|
106
|
+
- `task_id` *(string, required)*: Task ID to terminate.
|
|
107
|
+
- **Returns:** Confirmation message.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## 2. Filesystem, Safe Delete & Archives
|
|
112
|
+
|
|
113
|
+
### `file_read`
|
|
114
|
+
Reads file content in UTF-8, with optional 1-indexed line range slicing to conserve LLM context window.
|
|
115
|
+
- **Parameters:**
|
|
116
|
+
- `path` *(string, required)*: File path.
|
|
117
|
+
- `start_line` *(number, optional)*: 1-indexed start line.
|
|
118
|
+
- `end_line` *(number, optional)*: 1-indexed end line.
|
|
119
|
+
- **Returns:** Content string with line numbers when a range is specified.
|
|
120
|
+
|
|
121
|
+
### `file_write`
|
|
122
|
+
Writes or creates a file with UTF-8 encoding, creating parent directories automatically.
|
|
123
|
+
- **Parameters:**
|
|
124
|
+
- `path` *(string, required)*: Target file path.
|
|
125
|
+
- `content` *(string, required)*: Full content to write.
|
|
126
|
+
- **Returns:** Confirmation with bytes written.
|
|
127
|
+
|
|
128
|
+
### `file_edit`
|
|
129
|
+
Surgically replaces a unique block of text inside an existing file without modifying unrelated lines. Fails safely if `old_text` does not appear uniquely.
|
|
130
|
+
- **Parameters:**
|
|
131
|
+
- `path` *(string, required)*: File path to edit.
|
|
132
|
+
- `old_text` *(string, required)*: Exact text block to replace.
|
|
133
|
+
- `new_text` *(string, required)*: Replacement text block.
|
|
134
|
+
- **Returns:** Confirmation of successful replacement.
|
|
135
|
+
|
|
136
|
+
### `file_list`
|
|
137
|
+
Lists files and directories with size, type, and modification dates.
|
|
138
|
+
- **Parameters:**
|
|
139
|
+
- `path` *(string, optional, default: ".")*: Directory path.
|
|
140
|
+
- `recursive` *(boolean, optional, default: false)*: Scan subdirectories up to 3 levels.
|
|
141
|
+
- **Returns:** JSON directory listing.
|
|
142
|
+
|
|
143
|
+
### `file_search`
|
|
144
|
+
Quick substring or pattern search across files in a directory.
|
|
145
|
+
- **Parameters:**
|
|
146
|
+
- `query` *(string, required)*: Search string to find within files.
|
|
147
|
+
- `path` *(string, optional, default: ".")*: Base folder path.
|
|
148
|
+
- `file_pattern` *(string, optional)*: File name filter (e.g. `.ts`, `.json`).
|
|
149
|
+
- **Returns:** List of matching files and occurrences.
|
|
150
|
+
|
|
151
|
+
### `file_delete_safe`
|
|
152
|
+
Safely moves files or directories to the **Windows Recycle Bin** instead of permanent deletion. Items can be restored from the desktop Recycle Bin if deleted accidentally.
|
|
153
|
+
- **Parameters:**
|
|
154
|
+
- `path` *(string, required)*: Target file or directory path.
|
|
155
|
+
- **Returns:** Confirmation message.
|
|
156
|
+
|
|
157
|
+
### `file_move`
|
|
158
|
+
Atomically moves or renames a file or folder.
|
|
159
|
+
- **Parameters:**
|
|
160
|
+
- `source` *(string, required)*: Source file or folder path.
|
|
161
|
+
- `destination` *(string, required)*: Destination path.
|
|
162
|
+
- `overwrite` *(boolean, optional, default: false)*: Overwrite existing destination.
|
|
163
|
+
- **Returns:** Confirmation of move.
|
|
164
|
+
|
|
165
|
+
### `file_copy`
|
|
166
|
+
Recursively copies files or directories using native Windows shell operations.
|
|
167
|
+
- **Parameters:**
|
|
168
|
+
- `source` *(string, required)*: Source path.
|
|
169
|
+
- `destination` *(string, required)*: Target destination path.
|
|
170
|
+
- `overwrite` *(boolean, optional, default: true)*: Overwrite existing target.
|
|
171
|
+
- **Returns:** Confirmation of copy.
|
|
172
|
+
|
|
173
|
+
### `archive_zip`
|
|
174
|
+
Compresses a directory into a standard `.zip` archive using native Windows .NET APIs.
|
|
175
|
+
- **Parameters:**
|
|
176
|
+
- `source_dir` *(string, required)*: Directory path to compress.
|
|
177
|
+
- `zip_path` *(string, required)*: Destination `.zip` file path.
|
|
178
|
+
- **Returns:** Confirmation message.
|
|
179
|
+
|
|
180
|
+
### `archive_unzip`
|
|
181
|
+
Extracts a `.zip` archive into a target directory.
|
|
182
|
+
- **Parameters:**
|
|
183
|
+
- `zip_path` *(string, required)*: Path to `.zip` file.
|
|
184
|
+
- `target_dir` *(string, required)*: Destination folder path.
|
|
185
|
+
- `overwrite` *(boolean, optional, default: true)*: Overwrite existing files.
|
|
186
|
+
- **Returns:** Confirmation message.
|
|
187
|
+
|
|
188
|
+
### `file_tail`
|
|
189
|
+
Reads the trailing N lines of large log or data files with line numbers without exhausting LLM context.
|
|
190
|
+
- **Parameters:**
|
|
191
|
+
- `path` *(string, required)*: Target file path.
|
|
192
|
+
- `lines` *(number, optional, default: 50)*: Number of trailing lines.
|
|
193
|
+
- **Returns:** Trailing lines with line numbers.
|
|
194
|
+
|
|
195
|
+
### `file_hash`
|
|
196
|
+
Computes cryptographic hash digests of a file via low-memory chunked streaming.
|
|
197
|
+
- **Parameters:**
|
|
198
|
+
- `path` *(string, required)*: Target file path.
|
|
199
|
+
- `algorithm` *(string, optional, default: "sha256")*: `"sha256"`, `"md5"`, or `"sha1"`.
|
|
200
|
+
- **Returns:** `{ path: string, algorithm: string, hash: string, sizeBytes: number }`
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## 3. Codebase Search, PDF & Preview
|
|
205
|
+
|
|
206
|
+
### `file_search_ripgrep`
|
|
207
|
+
High-speed codebase search using `ripgrep` (`rg.exe`) with regex, glob filters, and streaming pagination to prevent token blowups.
|
|
208
|
+
- **Parameters:**
|
|
209
|
+
- `query` *(string, required)*: Search string or regex pattern.
|
|
210
|
+
- `path` *(string, optional, default: ".")*: Directory path to search.
|
|
211
|
+
- `file_pattern` *(string, optional)*: Glob pattern filter (e.g. `'*.ts'`, `'src/**'`).
|
|
212
|
+
- `case_sensitive` *(boolean, optional, default: false)*: Case-sensitive matching.
|
|
213
|
+
- `is_regex` *(boolean, optional, default: false)*: Treat query as regex.
|
|
214
|
+
- `page` *(number, optional, default: 1)*: Page number (1-based).
|
|
215
|
+
- `page_size` *(number, optional, default: 50, max: 200)*: Matches per page.
|
|
216
|
+
- `context_lines` *(number, optional, default: 0)*: Lines of context around matches.
|
|
217
|
+
- **Returns:** Formatted list of matches with file, line, column, and text.
|
|
218
|
+
|
|
219
|
+
### `pdf_generate`
|
|
220
|
+
Converts Markdown text or Markdown file into a styled PDF document using headless Microsoft Edge or Google Chrome.
|
|
221
|
+
- **Parameters:**
|
|
222
|
+
- `source_path` *(string, required)*: Path to input Markdown (`.md`), HTML, or text file.
|
|
223
|
+
- `pdf_path` *(string, required)*: Output destination `.pdf` file path.
|
|
224
|
+
- `landscape` *(boolean, optional, default: false)*: Landscape orientation.
|
|
225
|
+
- `title` *(string, optional)*: Document title for page headers.
|
|
226
|
+
- **Returns:** PDF generation report with file size and browser engine used.
|
|
227
|
+
|
|
228
|
+
### `file_preview`
|
|
229
|
+
Generates file metadata and an interactive browser preview link.
|
|
230
|
+
- **Parameters:**
|
|
231
|
+
- `path` *(string, required)*: File path to preview.
|
|
232
|
+
- `max_lines` *(number, optional, default: 50)*: Maximum snippet lines in response.
|
|
233
|
+
- **Returns:** JSON object containing `previewUrl`, line count, file size, and preview snippet.
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## 4. Desktop & Productivity
|
|
238
|
+
|
|
239
|
+
### `clipboard_get`
|
|
240
|
+
Reads current text from the Windows Clipboard.
|
|
241
|
+
- **Parameters:** None.
|
|
242
|
+
- **Returns:** Text content from clipboard.
|
|
243
|
+
|
|
244
|
+
### `clipboard_set`
|
|
245
|
+
Copies UTF-8 text into the Windows Clipboard.
|
|
246
|
+
- **Parameters:**
|
|
247
|
+
- `text` *(string, required)*: Text to copy to clipboard.
|
|
248
|
+
- **Returns:** Confirmation message.
|
|
249
|
+
|
|
250
|
+
### `screen_capture`
|
|
251
|
+
Takes a high-resolution screenshot of the Windows desktop and returns a base64-encoded PNG image.
|
|
252
|
+
- **Parameters:** None.
|
|
253
|
+
- **Returns:** MCP Image content block (PNG) and descriptive text.
|
|
254
|
+
|
|
255
|
+
### `system_open`
|
|
256
|
+
Opens a URL in the default browser, or opens a file/folder in Windows File Explorer.
|
|
257
|
+
- **Parameters:**
|
|
258
|
+
- `target` *(string, required)*: URL, folder path, or file path to open.
|
|
259
|
+
- **Returns:** Confirmation message.
|
|
260
|
+
|
|
261
|
+
### `notification_send`
|
|
262
|
+
Dispatches a native Windows Toast Notification to the Action Center.
|
|
263
|
+
- **Parameters:**
|
|
264
|
+
- `title` *(string, required)*: Notification title.
|
|
265
|
+
- `message` *(string, required)*: Notification body text.
|
|
266
|
+
- `sound` *(boolean, optional, default: true)*: Play alert chime.
|
|
267
|
+
- **Returns:** Confirmation message.
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## 5. System, Processes & Windows Services
|
|
272
|
+
|
|
273
|
+
### `system_info`
|
|
274
|
+
Comprehensive hardware and OS summary: CPU model & cores, RAM (Total/Used/Free), OS version, allowed drive capacities, and uptime.
|
|
275
|
+
- **Parameters:** None.
|
|
276
|
+
- **Returns:** JSON system telemetry snapshot.
|
|
277
|
+
|
|
278
|
+
### `gpu_info`
|
|
279
|
+
Queries NVIDIA GPU metrics (model, VRAM total/used/free, temperature, driver version) via `nvidia-smi` with WMI fallback.
|
|
280
|
+
- **Parameters:** None.
|
|
281
|
+
- **Returns:** JSON GPU telemetry.
|
|
282
|
+
|
|
283
|
+
### `process_list`
|
|
284
|
+
Lists running Windows processes with PID, Process Name, RAM usage (Working Set MB), CPU %, and paths.
|
|
285
|
+
- **Parameters:**
|
|
286
|
+
- `limit` *(number, optional, default: 20, max: 100)*: Max number of processes to return.
|
|
287
|
+
- `sort_by` *(string, optional, default: "memory")*: `"memory"`, `"cpu"`, `"name"`, or `"pid"`.
|
|
288
|
+
- `filter` *(string, optional)*: Substring filter on process name or path.
|
|
289
|
+
- **Returns:** JSON array of process objects.
|
|
290
|
+
|
|
291
|
+
### `process_kill`
|
|
292
|
+
Terminates a Windows process safely by PID or Process Name.
|
|
293
|
+
- **Parameters:**
|
|
294
|
+
- `pid` *(number, optional)*: Target Process ID.
|
|
295
|
+
- `name` *(string, optional)*: Target process name (e.g. `'node'`, `'notepad'`).
|
|
296
|
+
- **Returns:** JSON termination result.
|
|
297
|
+
|
|
298
|
+
### `port_check`
|
|
299
|
+
Checks if a TCP port is currently open/listening and identifies the owning process PID and process name.
|
|
300
|
+
- **Parameters:**
|
|
301
|
+
- `port` *(number, required)*: TCP port number to inspect (e.g. 8788, 3000).
|
|
302
|
+
- **Returns:** JSON object containing `port`, `inUse`, `pid`, `processName`.
|
|
303
|
+
|
|
304
|
+
### `eventlog_query`
|
|
305
|
+
Queries the Windows Event Log (Application, System) for crash reports, error traces, and warnings.
|
|
306
|
+
- **Parameters:**
|
|
307
|
+
- `log_name` *(string, optional, default: "Application")*: `"Application"` or `"System"`.
|
|
308
|
+
- `level` *(string, optional, default: "Error")*: `"Critical"`, `"Error"`, `"Warning"`, `"Information"`, or `"All"`.
|
|
309
|
+
- `hours` *(number, optional, default: 24)*: Retrieve events from the past N hours.
|
|
310
|
+
- `source` *(string, optional)*: Provider or application source filter.
|
|
311
|
+
- `limit` *(number, optional, default: 20, max: 100)*: Max events to retrieve.
|
|
312
|
+
- **Returns:** JSON array of event log entries.
|
|
313
|
+
|
|
314
|
+
### `service_list`
|
|
315
|
+
Lists Windows Services with current status (`Running`, `Stopped`) and display names.
|
|
316
|
+
- **Parameters:**
|
|
317
|
+
- `filter` *(string, optional)*: Substring filter on service name or display name.
|
|
318
|
+
- **Returns:** JSON array of services.
|
|
319
|
+
|
|
320
|
+
### `service_status`
|
|
321
|
+
Inspects detailed status, startup type, and PID of a specific Windows Service.
|
|
322
|
+
- **Parameters:**
|
|
323
|
+
- `service_name` *(string, required)*: Exact name of the service (e.g. `'wslservice'`, `'ssh-agent'`).
|
|
324
|
+
- **Returns:** JSON service details.
|
|
325
|
+
|
|
326
|
+
### `service_control`
|
|
327
|
+
Starts, stops, or restarts a Windows Service (requires appropriate privileges).
|
|
328
|
+
- **Parameters:**
|
|
329
|
+
- `service_name` *(string, required)*: Exact name of the service.
|
|
330
|
+
- `action` *(string, required)*: `"start"`, `"stop"`, or `"restart"`.
|
|
331
|
+
- **Returns:** JSON execution status.
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
## 6. Network & Web Diagnostics
|
|
336
|
+
|
|
337
|
+
### `http_ping`
|
|
338
|
+
Rapidly pings an HTTP/HTTPS endpoint to measure roundtrip latency in milliseconds, status code, and header info.
|
|
339
|
+
- **Parameters:**
|
|
340
|
+
- `url` *(string, required)*: Target HTTP/HTTPS URL.
|
|
341
|
+
- `timeout_ms` *(number, optional, default: 5000)*: Timeout in milliseconds.
|
|
342
|
+
- `expected_status` *(number, optional)*: Expected HTTP status code (default: any 2xx).
|
|
343
|
+
- **Returns:** JSON latency and response status.
|
|
344
|
+
|
|
345
|
+
### `http_request`
|
|
346
|
+
Dispatches an HTTP request (GET, POST, PUT, DELETE, PATCH, HEAD) with custom headers and payload for REST API testing.
|
|
347
|
+
- **Parameters:**
|
|
348
|
+
- `url` *(string, required)*: Target URL.
|
|
349
|
+
- `method` *(string, optional, default: "GET")*: HTTP method.
|
|
350
|
+
- `headers` *(object, optional)*: Key-value map of HTTP headers.
|
|
351
|
+
- `body` *(string, optional)*: Request payload string.
|
|
352
|
+
- `timeout_ms` *(number, optional, default: 15000)*: Timeout in milliseconds.
|
|
353
|
+
- **Returns:** Response status, duration, headers, and parsed body.
|
|
354
|
+
|
|
355
|
+
### `network_info`
|
|
356
|
+
Retrieves local IP addresses, network adapters, Default Gateway, DNS servers, and Tailscale IP (`100.x.y.z`).
|
|
357
|
+
- **Parameters:**
|
|
358
|
+
- `include_listening_ports` *(boolean, optional, default: false)*: Include list of listening TCP ports.
|
|
359
|
+
- **Returns:** JSON network summary.
|
|
360
|
+
|
|
361
|
+
---
|
|
362
|
+
|
|
363
|
+
## 7. MCP Resources
|
|
364
|
+
|
|
365
|
+
### `preview://file`
|
|
366
|
+
Interactive file preview resource registered on the MCP Server (`text/html;profile=mcp-app`). Allows MCP client apps and web browsers to view syntax-highlighted code and rendered Markdown at `http://localhost:8788/preview?path=<filepath>`.
|
package/manifest.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"manifest_version": "0.3",
|
|
3
|
+
"name": "winhelm-mcp",
|
|
4
|
+
"version": "1.1.0",
|
|
5
|
+
"description": "WinHelm - Windows Native MCP Server with Unified HTTP/SSE/Streamable Gateway and 38 System Tools",
|
|
6
|
+
"long_description": "WinHelm is a lightweight, all-in-one MCP server designed for the Windows operating system. It embeds a native Streamable HTTP and SSE gateway, complete with Web Monitor, UTF-8 PowerShell runner, surgical file editor, Ripgrep search, PDF generation, clipboard, screen capture, and system inspection tools.",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "dhammawatthumpra-coder",
|
|
9
|
+
"email": "dhammawatthumpra@gmail.com",
|
|
10
|
+
"url": "https://github.com/dhammawatthumpra-coder"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/dhammawatthumpra-coder/winhelm-mcp",
|
|
13
|
+
"documentation": "https://github.com/dhammawatthumpra-coder/winhelm-mcp#readme",
|
|
14
|
+
"server": {
|
|
15
|
+
"type": "node",
|
|
16
|
+
"entry_point": "dist/index.js",
|
|
17
|
+
"mcp_config": {
|
|
18
|
+
"command": "node",
|
|
19
|
+
"args": [
|
|
20
|
+
"${__dirname}/dist/index.js",
|
|
21
|
+
"--port",
|
|
22
|
+
"${user_config.port}",
|
|
23
|
+
"--host",
|
|
24
|
+
"${user_config.host}"
|
|
25
|
+
],
|
|
26
|
+
"env": {
|
|
27
|
+
"PORT": "${user_config.port}",
|
|
28
|
+
"HOST": "${user_config.host}",
|
|
29
|
+
"MCP_AUTH_TOKEN": "${user_config.auth_token}",
|
|
30
|
+
"MCP_ALLOWED_DIRECTORIES": "${user_config.allowed_directories}",
|
|
31
|
+
"MCP_ALLOWED_HOSTS": "${user_config.allowed_hosts}"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"user_config": {
|
|
36
|
+
"port": {
|
|
37
|
+
"type": "number",
|
|
38
|
+
"title": "Server Port",
|
|
39
|
+
"description": "Port on which the HTTP, SSE, and Streamable HTTP gateway listens.",
|
|
40
|
+
"required": false,
|
|
41
|
+
"default": 8788,
|
|
42
|
+
"minimum": 1024,
|
|
43
|
+
"maximum": 65535
|
|
44
|
+
},
|
|
45
|
+
"host": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"title": "Bind Host",
|
|
48
|
+
"description": "Network host interface to bind (e.g. 127.0.0.1 for local only, 0.0.0.0 for Tailscale/LAN).",
|
|
49
|
+
"required": false,
|
|
50
|
+
"default": "127.0.0.1"
|
|
51
|
+
},
|
|
52
|
+
"auth_token": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"title": "Authentication Bearer Token",
|
|
55
|
+
"description": "Optional Bearer token required for all incoming requests (mandatory when binding to non-loopback host 0.0.0.0).",
|
|
56
|
+
"required": false,
|
|
57
|
+
"default": ""
|
|
58
|
+
},
|
|
59
|
+
"allowed_directories": {
|
|
60
|
+
"type": "string",
|
|
61
|
+
"title": "Allowed Directories",
|
|
62
|
+
"description": "Comma-separated list of directories permitted for file operations. Leave empty to block all filesystem access (fail-closed). Use \"*\" or \"all\" to allow all drives (not recommended for network-exposed servers).",
|
|
63
|
+
"required": false,
|
|
64
|
+
"default": ""
|
|
65
|
+
},
|
|
66
|
+
"allowed_hosts": {
|
|
67
|
+
"type": "string",
|
|
68
|
+
"title": "Allowed Hosts",
|
|
69
|
+
"description": "Comma-separated list of permitted Host header values for DNS rebinding protection (e.g. \"localhost,127.0.0.1,[::1],*.ts.net\").",
|
|
70
|
+
"required": false,
|
|
71
|
+
"default": "localhost,127.0.0.1,[::1],*.ts.net"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "winhelm-mcp",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "WinHelm - Windows Native MCP Server with Unified HTTP/SSE/Streamable Gateway and 38 Tools",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"winhelm": "dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"docs",
|
|
21
|
+
"manifest.json",
|
|
22
|
+
"server.json",
|
|
23
|
+
"winhelm.config.example.json",
|
|
24
|
+
"scripts/build-exe.ps1",
|
|
25
|
+
"scripts/manage-service.ps1",
|
|
26
|
+
"CHANGELOG.md",
|
|
27
|
+
"README.md",
|
|
28
|
+
"LICENSE"
|
|
29
|
+
],
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/dhammawatthumpra-coder/winhelm-mcp.git"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/dhammawatthumpra-coder/winhelm-mcp#readme",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/dhammawatthumpra-coder/winhelm-mcp/issues"
|
|
37
|
+
},
|
|
38
|
+
"author": {
|
|
39
|
+
"name": "dhammawatthumpra-coder",
|
|
40
|
+
"email": "dhammawatthumpra@gmail.com",
|
|
41
|
+
"url": "https://github.com/dhammawatthumpra-coder"
|
|
42
|
+
},
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"keywords": [
|
|
45
|
+
"mcp",
|
|
46
|
+
"model-context-protocol",
|
|
47
|
+
"windows",
|
|
48
|
+
"ai",
|
|
49
|
+
"claude",
|
|
50
|
+
"cursor",
|
|
51
|
+
"automation",
|
|
52
|
+
"powershell",
|
|
53
|
+
"windows-native",
|
|
54
|
+
"llm-tools"
|
|
55
|
+
],
|
|
56
|
+
"scripts": {
|
|
57
|
+
"prepublishOnly": "npm run build && npm test",
|
|
58
|
+
"build": "rimraf dist && tsc",
|
|
59
|
+
"build:exe": "powershell -ExecutionPolicy Bypass -File scripts/build-exe.ps1",
|
|
60
|
+
"watch": "tsc --watch",
|
|
61
|
+
"start": "node dist/index.js",
|
|
62
|
+
"dev": "tsx watch src/index.ts",
|
|
63
|
+
"dev:type-check": "tsc --noEmit --watch",
|
|
64
|
+
"test": "tsx --test \"test/**/*.test.ts\"",
|
|
65
|
+
"type-check": "tsc --noEmit",
|
|
66
|
+
"service:install": "powershell -ExecutionPolicy Bypass -File scripts/manage-service.ps1 -Action install",
|
|
67
|
+
"service:uninstall": "powershell -ExecutionPolicy Bypass -File scripts/manage-service.ps1 -Action uninstall",
|
|
68
|
+
"service:start": "powershell -ExecutionPolicy Bypass -File scripts/manage-service.ps1 -Action start",
|
|
69
|
+
"service:stop": "powershell -ExecutionPolicy Bypass -File scripts/manage-service.ps1 -Action stop",
|
|
70
|
+
"service:status": "powershell -ExecutionPolicy Bypass -File scripts/manage-service.ps1 -Action status"
|
|
71
|
+
},
|
|
72
|
+
"dependencies": {
|
|
73
|
+
"@modelcontextprotocol/sdk": "^1.9.0",
|
|
74
|
+
"cors": "^2.8.5",
|
|
75
|
+
"express": "^4.21.2",
|
|
76
|
+
"zod": "^3.24.1"
|
|
77
|
+
},
|
|
78
|
+
"devDependencies": {
|
|
79
|
+
"@types/cors": "^2.8.17",
|
|
80
|
+
"@types/express": "^4.17.21",
|
|
81
|
+
"@types/node": "^22.13.10",
|
|
82
|
+
"rimraf": "^6.0.1",
|
|
83
|
+
"tsx": "^4.19.3",
|
|
84
|
+
"typescript": "^5.8.2"
|
|
85
|
+
},
|
|
86
|
+
"engines": {
|
|
87
|
+
"node": ">=20.0.0"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Build Standalone Windows Executable (winhelm.exe)
|
|
2
|
+
$PSScriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Definition
|
|
3
|
+
$ProjectDir = (Get-Item $PSScriptRoot).Parent.FullName
|
|
4
|
+
Set-Location $ProjectDir
|
|
5
|
+
|
|
6
|
+
Write-Host "==========================================" -ForegroundColor Cyan
|
|
7
|
+
Write-Host " Building Standalone winhelm.exe..." -ForegroundColor Green
|
|
8
|
+
Write-Host "==========================================" -ForegroundColor Cyan
|
|
9
|
+
|
|
10
|
+
# 1. Compile TypeScript
|
|
11
|
+
Write-Host "Step 1: Compiling TypeScript..." -ForegroundColor Yellow
|
|
12
|
+
npx rimraf dist
|
|
13
|
+
npx tsc
|
|
14
|
+
|
|
15
|
+
# 2. Bundle with esbuild
|
|
16
|
+
Write-Host "Step 2: Bundling with esbuild..." -ForegroundColor Yellow
|
|
17
|
+
npx esbuild src/index.ts --bundle --platform=node --target=node22 --outfile=dist/bundle.cjs --format=cjs
|
|
18
|
+
|
|
19
|
+
# 3. Generate SEA Blob
|
|
20
|
+
Write-Host "Step 3: Generating Single Executable Blob..." -ForegroundColor Yellow
|
|
21
|
+
node --experimental-sea-config sea-config.json
|
|
22
|
+
|
|
23
|
+
# 4. Copy node.exe
|
|
24
|
+
Write-Host "Step 4: Preparing Executable Binary..." -ForegroundColor Yellow
|
|
25
|
+
$nodeSource = (Get-Command node -ErrorAction Stop).Source
|
|
26
|
+
Copy-Item $nodeSource -Destination dist\winhelm.exe -Force
|
|
27
|
+
|
|
28
|
+
# 5. Inject Blob
|
|
29
|
+
Write-Host "Step 5: Injecting code into winhelm.exe..." -ForegroundColor Yellow
|
|
30
|
+
npx --yes postject dist\winhelm.exe NODE_SEA_BLOB dist\sea-prep.blob --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2
|
|
31
|
+
|
|
32
|
+
Write-Host ""
|
|
33
|
+
Write-Host "======================================================" -ForegroundColor Green
|
|
34
|
+
Write-Host " [OK] Standalone Binary Created Successfully!" -ForegroundColor Green
|
|
35
|
+
Write-Host " Path: $ProjectDir\dist\winhelm.exe" -ForegroundColor Cyan
|
|
36
|
+
Write-Host "======================================================" -ForegroundColor Green
|
|
37
|
+
Write-Host ""
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# WinHelm - Windows Service & Background Daemon Manager
|
|
2
|
+
param (
|
|
3
|
+
[Parameter(Mandatory=$true)]
|
|
4
|
+
[ValidateSet("install", "uninstall", "start", "stop", "status", "restart")]
|
|
5
|
+
[string]$Action,
|
|
6
|
+
[int]$Port = 8788,
|
|
7
|
+
[string]$Auth = "",
|
|
8
|
+
[string]$AllowedDirs = ""
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
$TaskName = "WinHelm-MCP-Service"
|
|
12
|
+
$ProjectDir = (Get-Item $PSScriptRoot).Parent.FullName
|
|
13
|
+
$NodeExe = (Get-Command node -ErrorAction SilentlyContinue).Source
|
|
14
|
+
$DistIndex = Join-Path $ProjectDir "dist\index.js"
|
|
15
|
+
|
|
16
|
+
if (-not $NodeExe) {
|
|
17
|
+
Write-Error "Node.js executable was not found on PATH."
|
|
18
|
+
exit 1
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function Check-Admin {
|
|
22
|
+
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
|
|
23
|
+
return $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
switch ($Action) {
|
|
27
|
+
"install" {
|
|
28
|
+
Write-Host "Installing WinHelm as an Always-On Windows Background Service..." -ForegroundColor Cyan
|
|
29
|
+
|
|
30
|
+
# Make sure build exists
|
|
31
|
+
if (-not (Test-Path $DistIndex)) {
|
|
32
|
+
Write-Host "Building project first..." -ForegroundColor Yellow
|
|
33
|
+
Push-Location $ProjectDir
|
|
34
|
+
npm run build
|
|
35
|
+
Pop-Location
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
$argList = "`"$DistIndex`" --port $Port"
|
|
39
|
+
if ($Auth) { $argList += " --auth `"$Auth`"" }
|
|
40
|
+
if ($AllowedDirs) { $argList += " --allowed-dirs `"$AllowedDirs`"" }
|
|
41
|
+
|
|
42
|
+
# Create Task Action
|
|
43
|
+
$TaskAction = New-ScheduledTaskAction -Execute $NodeExe -Argument $argList -WorkingDirectory $ProjectDir
|
|
44
|
+
|
|
45
|
+
# Create Trigger: At Windows Startup
|
|
46
|
+
$TaskTrigger = New-ScheduledTaskTrigger -AtStartup
|
|
47
|
+
|
|
48
|
+
# Settings: Restart on failure, no execution time limit
|
|
49
|
+
$TaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable -RestartCount 3 -RestartInterval (New-TimeSpan -Minutes 1) -ExecutionTimeLimit 0
|
|
50
|
+
|
|
51
|
+
# Unregister existing if present
|
|
52
|
+
Unregister-ScheduledTask -TaskName $TaskName -Confirm:$false -ErrorAction SilentlyContinue
|
|
53
|
+
|
|
54
|
+
# Register Scheduled Task with SYSTEM or Current User
|
|
55
|
+
if (Check-Admin) {
|
|
56
|
+
$TaskPrincipal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -LogonType ServiceAccount -RunLevel Highest
|
|
57
|
+
Register-ScheduledTask -TaskName $TaskName -Action $TaskAction -Trigger $TaskTrigger -Settings $TaskSettings -Principal $TaskPrincipal | Out-Null
|
|
58
|
+
Write-Host "[OK] Successfully installed as SYSTEM Background Service!" -ForegroundColor Green
|
|
59
|
+
} else {
|
|
60
|
+
$TaskPrincipal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -LogonType Interactive -RunLevel Highest
|
|
61
|
+
Register-ScheduledTask -TaskName $TaskName -Action $TaskAction -Trigger $TaskTrigger -Settings $TaskSettings -Principal $TaskPrincipal | Out-Null
|
|
62
|
+
Write-Host "[OK] Successfully installed for user '$env:USERNAME' (Run as Admin for SYSTEM-wide daemon)!" -ForegroundColor Green
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
# Start task immediately
|
|
66
|
+
Start-ScheduledTask -TaskName $TaskName
|
|
67
|
+
Write-Host "[OK] Service started! Access Web Monitor at http://localhost:$Port/" -ForegroundColor Green
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
"uninstall" {
|
|
71
|
+
Write-Host "Stopping and uninstalling WinHelm Service..." -ForegroundColor Yellow
|
|
72
|
+
Stop-ScheduledTask -TaskName $TaskName -ErrorAction SilentlyContinue
|
|
73
|
+
Unregister-ScheduledTask -TaskName $TaskName -Confirm:$false -ErrorAction SilentlyContinue
|
|
74
|
+
Write-Host "[OK] WinHelm Service successfully uninstalled." -ForegroundColor Green
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
"start" {
|
|
78
|
+
Write-Host "Starting WinHelm Service..." -ForegroundColor Cyan
|
|
79
|
+
Start-ScheduledTask -TaskName $TaskName
|
|
80
|
+
Write-Host "[OK] Service started." -ForegroundColor Green
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
"stop" {
|
|
84
|
+
Write-Host "Stopping WinHelm Service..." -ForegroundColor Yellow
|
|
85
|
+
Stop-ScheduledTask -TaskName $TaskName -ErrorAction SilentlyContinue
|
|
86
|
+
Write-Host "[OK] Service stopped." -ForegroundColor Green
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
"restart" {
|
|
90
|
+
Write-Host "Restarting WinHelm Service..." -ForegroundColor Cyan
|
|
91
|
+
Stop-ScheduledTask -TaskName $TaskName -ErrorAction SilentlyContinue
|
|
92
|
+
Start-Sleep -Seconds 1
|
|
93
|
+
Start-ScheduledTask -TaskName $TaskName
|
|
94
|
+
Write-Host "[OK] Service restarted." -ForegroundColor Green
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
"status" {
|
|
98
|
+
$task = Get-ScheduledTask -TaskName $TaskName -ErrorAction SilentlyContinue
|
|
99
|
+
if ($task) {
|
|
100
|
+
$info = Get-ScheduledTaskInfo -TaskName $TaskName
|
|
101
|
+
Write-Host "=== WinHelm Windows Service Status ===" -ForegroundColor Cyan
|
|
102
|
+
Write-Host "Name: $($task.TaskName)"
|
|
103
|
+
Write-Host "State: $($task.State)" -ForegroundColor $(if ($task.State -eq 'Running') { 'Green' } else { 'Yellow' })
|
|
104
|
+
Write-Host "Last Run: $($info.LastRunTime)"
|
|
105
|
+
Write-Host "Last Result: $($info.LastTaskResult)"
|
|
106
|
+
Write-Host "Next Run: $($info.NextRunTime)"
|
|
107
|
+
} else {
|
|
108
|
+
Write-Host "WinHelm Service is NOT installed." -ForegroundColor Red
|
|
109
|
+
Write-Host "Run: .\scripts\manage-service.ps1 -Action install" -ForegroundColor Gray
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|