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/PROFILES.md
ADDED
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
# WinHelm MCP — Tool Profiles & Context Optimization
|
|
2
|
+
|
|
3
|
+
Modern AI coding assistants consume **thousands of tokens before the first message** just to load tool schemas. Every tool definition (name, description, parameter types, enums, defaults) is sent on every request — even when the tool is never called.
|
|
4
|
+
|
|
5
|
+
WinHelm solves this with **Dynamic Profile Loading**: you decide which subset of the 38 tools your agent actually sees.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Table of Contents
|
|
10
|
+
|
|
11
|
+
- [Why Profiles Matter](#why-profiles-matter)
|
|
12
|
+
- [The Token Math](#the-token-math)
|
|
13
|
+
- [Built-in Profiles](#built-in-profiles)
|
|
14
|
+
- [`minimal` — 6 tools](#minimal--6-tools-small-models--token-constrained-workflows)
|
|
15
|
+
- [`core` — 15 tools](#core--15-tools-general-purpose-baseline)
|
|
16
|
+
- [`dev` — 28 tools](#dev--28-tools-software-development)
|
|
17
|
+
- [`sysadmin` — 37 tools](#sysadmin--37-tools-system-administration)
|
|
18
|
+
- [`full` — 38 tools](#full--38-tools-everything)
|
|
19
|
+
- [Comparison Matrix](#comparison-matrix)
|
|
20
|
+
- [Custom Profiles (`--tools`)](#custom-profiles---tools)
|
|
21
|
+
- [Use Case Recipes](#use-case-recipes)
|
|
22
|
+
- [FAQ](#faq)
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Why Profiles Matter
|
|
27
|
+
|
|
28
|
+
Every MCP tool schema averages **200–300 tokens** when serialized. Loading all 38 tools means:
|
|
29
|
+
|
|
30
|
+
- **~10,000 tokens** consumed before the conversation even starts
|
|
31
|
+
- **Slower tool selection** — the model scans 38 candidates to pick the right one
|
|
32
|
+
- **Higher hallucination rate** — overlapping tool names increase wrong-tool calls
|
|
33
|
+
- **Higher cost** — every turn re-sends the full tool list
|
|
34
|
+
|
|
35
|
+
For small models (Claude Haiku, Llama 3 8B, Phi-3), the entire context window is only 8k–32k tokens. Loading 38 tools can consume **50–100% of the window** before any user message.
|
|
36
|
+
|
|
37
|
+
**Loading only what you need is the single highest-leverage optimization.**
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## The Token Math
|
|
42
|
+
|
|
43
|
+
Estimated based on schema serialization + description length:
|
|
44
|
+
|
|
45
|
+
| Profile | Tools | Approx. Tokens | Context Saved | Best For |
|
|
46
|
+
| :--- | :---: | :---: | :---: | :--- |
|
|
47
|
+
| `full` | 38 | ~10,000 | baseline | Power users, visual previews & complete suite |
|
|
48
|
+
| `sysadmin` | 37 | ~9,200 | **−8%** | IT ops, server diagnostics, Windows services |
|
|
49
|
+
| `dev` | 28 | ~6,800 | **−32%** | Coding agents (default for software engineering) |
|
|
50
|
+
| `core` | 15 | ~4,000 | **−60%** | Everyday coding & file operations |
|
|
51
|
+
| `minimal` | 6 | ~1,500 | **−85%** | Claude Haiku, Llama 8B, local models |
|
|
52
|
+
|
|
53
|
+
> **Real-world impact:** Running Claude Haiku 3.5 (200k context) with `full` wastes ~5% of the window on tools. Running Llama 3.1 8B (8k context) with `full` is **impossible** — the tool list alone overflows the context.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Built-in Profiles
|
|
58
|
+
|
|
59
|
+
### `minimal` — 6 tools (Small Models / Token-Constrained Workflows)
|
|
60
|
+
|
|
61
|
+
```powershell
|
|
62
|
+
winhelm --profile minimal
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**Tools included:**
|
|
66
|
+
|
|
67
|
+
| Tool | Purpose |
|
|
68
|
+
| :--- | :--- |
|
|
69
|
+
| `terminal_run` | Run PowerShell commands |
|
|
70
|
+
| `file_read` | Read file contents |
|
|
71
|
+
| `file_write` | Create / overwrite files |
|
|
72
|
+
| `file_list` | List directories |
|
|
73
|
+
| `file_search` | Substring search across files |
|
|
74
|
+
| `system_info` | CPU / RAM / OS / drives telemetry |
|
|
75
|
+
|
|
76
|
+
**Use when:**
|
|
77
|
+
- Running Claude Haiku, Llama 3 8B, Phi-3, or any model with ≤ 32k context
|
|
78
|
+
- You need a fast, focused agent that only reads/writes code
|
|
79
|
+
- You want to minimize cost per request
|
|
80
|
+
|
|
81
|
+
**Trade-offs:**
|
|
82
|
+
- No file editing (use `file_write` instead)
|
|
83
|
+
- No background tasks
|
|
84
|
+
- No process/service management
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
### `core` — 15 tools (General-Purpose Baseline)
|
|
89
|
+
|
|
90
|
+
```powershell
|
|
91
|
+
winhelm --profile core
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Tools included:**
|
|
95
|
+
|
|
96
|
+
| Category | Tools |
|
|
97
|
+
| :--- | :--- |
|
|
98
|
+
| Terminal | `terminal_run` |
|
|
99
|
+
| Filesystem | `file_read`, `file_write`, `file_edit`, `file_list`, `file_search`, `file_copy`, `file_move`, `file_delete_safe`, `file_tail`, `file_hash` |
|
|
100
|
+
| System | `system_info`, `gpu_info`, `process_list`, `port_check` |
|
|
101
|
+
|
|
102
|
+
**Use when:**
|
|
103
|
+
- General-purpose assistant that edits code but doesn't build/run long tasks
|
|
104
|
+
- You want safe file operations (Recycle Bin delete) without archive/PDF bloat
|
|
105
|
+
- Balanced default for most users
|
|
106
|
+
|
|
107
|
+
**Trade-offs:**
|
|
108
|
+
- No background daemons (can't run `npm run dev` async)
|
|
109
|
+
- No ripgrep (slower search on large codebases)
|
|
110
|
+
- No PDF / preview / clipboard / notification
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
### `dev` — 28 tools (Software Development)
|
|
115
|
+
|
|
116
|
+
```powershell
|
|
117
|
+
winhelm --profile dev
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Tools included:** All `core` (15 tools) + the following 13 tools:
|
|
121
|
+
|
|
122
|
+
| Category | Added Tools |
|
|
123
|
+
| :--- | :--- |
|
|
124
|
+
| Terminal | `terminal_task_start`, `terminal_task_list`, `terminal_task_logs`, `terminal_task_send`, `terminal_task_kill` |
|
|
125
|
+
| Filesystem | `archive_zip`, `archive_unzip` |
|
|
126
|
+
| Codebase & Docs | `file_search_ripgrep`, `pdf_generate`, `file_preview` |
|
|
127
|
+
| Network | `http_ping`, `http_request` |
|
|
128
|
+
| Desktop | `system_open` |
|
|
129
|
+
|
|
130
|
+
**Use when:**
|
|
131
|
+
- Autonomous coding agents (Claude 3.7 Sonnet, Cursor, Cline, Windsurf, ChatGPT)
|
|
132
|
+
- Running dev servers, test watchers, or builds in the background
|
|
133
|
+
- Searching large codebases with streaming ripgrep
|
|
134
|
+
- Testing REST API endpoints (`http_request`) and health checks (`http_ping`)
|
|
135
|
+
- Zipping build artifacts and exporting Markdown documentation to styled PDFs
|
|
136
|
+
- Opening generated files or URLs in default applications (`system_open`)
|
|
137
|
+
|
|
138
|
+
**Trade-offs:**
|
|
139
|
+
- No process kill (guards against accidental termination of system processes)
|
|
140
|
+
- No Windows service control
|
|
141
|
+
- No Windows event log inspection
|
|
142
|
+
- No desktop surveillance (clipboard and screen capture omitted)
|
|
143
|
+
|
|
144
|
+
> **This is the recommended default for software engineering agents.**
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
### `sysadmin` — 37 tools (System Administration & Ops)
|
|
149
|
+
|
|
150
|
+
```powershell
|
|
151
|
+
winhelm --profile sysadmin
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**Tools included:** All tools in WinHelm **except `pdf_generate`** (All `core` + 22 advanced tools):
|
|
155
|
+
|
|
156
|
+
| Category | Added Tools |
|
|
157
|
+
| :--- | :--- |
|
|
158
|
+
| Terminal | `terminal_task_start`, `terminal_task_list`, `terminal_task_logs`, `terminal_task_send`, `terminal_task_kill` |
|
|
159
|
+
| Filesystem | `archive_zip`, `archive_unzip` |
|
|
160
|
+
| Codebase & Preview | `file_search_ripgrep`, `file_preview` |
|
|
161
|
+
| System | `process_kill`, `eventlog_query` |
|
|
162
|
+
| Services | `service_list`, `service_status`, `service_control` |
|
|
163
|
+
| Network | `network_info`, `http_ping`, `http_request` |
|
|
164
|
+
| Desktop | `clipboard_get`, `clipboard_set`, `screen_capture`, `system_open`, `notification_send` |
|
|
165
|
+
|
|
166
|
+
**Use when:**
|
|
167
|
+
- IT operations, Windows DevOps, and server management
|
|
168
|
+
- Troubleshooting crashes via Windows Event Log and killing runaway PIDs
|
|
169
|
+
- Starting, stopping, and inspecting Windows Services
|
|
170
|
+
- Searching massive server logs with ripgrep and archiving bundles to `.zip`
|
|
171
|
+
- Inspecting network adapters, DNS, open ports, and Tailscale IPs
|
|
172
|
+
- Desktop automation with native Toast notifications and screenshot capture
|
|
173
|
+
|
|
174
|
+
**Trade-offs:**
|
|
175
|
+
- No headless Chromium PDF generation (`pdf_generate` omitted to preserve a clean, lightweight footprint in headless/server environments without Edge or Chrome)
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
### `full` — 38 tools (Everything)
|
|
180
|
+
|
|
181
|
+
```powershell
|
|
182
|
+
winhelm --profile full
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**Default when `--profile` is omitted.**
|
|
186
|
+
|
|
187
|
+
Includes **all 38 tools** plus the `preview://file` MCP Resource.
|
|
188
|
+
|
|
189
|
+
**Use when:**
|
|
190
|
+
- You're building a power-user agent
|
|
191
|
+
- You need every capability in one session
|
|
192
|
+
- You don't care about token cost
|
|
193
|
+
|
|
194
|
+
**Trade-offs:**
|
|
195
|
+
- Highest token cost
|
|
196
|
+
- Slower tool selection
|
|
197
|
+
- Overkill for 90% of tasks
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Comparison Matrix
|
|
202
|
+
|
|
203
|
+
| Tool | `minimal` (6) | `core` (15) | `dev` (28) | `sysadmin` (37) | `full` (38) |
|
|
204
|
+
| :--- | :---: | :---: | :---: | :---: | :---: |
|
|
205
|
+
| `terminal_run` | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
206
|
+
| `terminal_task_start` | ❌ | ❌ | ✅ | ✅ | ✅ |
|
|
207
|
+
| `terminal_task_list` | ❌ | ❌ | ✅ | ✅ | ✅ |
|
|
208
|
+
| `terminal_task_logs` | ❌ | ❌ | ✅ | ✅ | ✅ |
|
|
209
|
+
| `terminal_task_send` | ❌ | ❌ | ✅ | ✅ | ✅ |
|
|
210
|
+
| `terminal_task_kill` | ❌ | ❌ | ✅ | ✅ | ✅ |
|
|
211
|
+
| `file_read` | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
212
|
+
| `file_write` | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
213
|
+
| `file_edit` | ❌ | ✅ | ✅ | ✅ | ✅ |
|
|
214
|
+
| `file_list` | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
215
|
+
| `file_search` | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
216
|
+
| `file_delete_safe` | ❌ | ✅ | ✅ | ✅ | ✅ |
|
|
217
|
+
| `file_move` | ❌ | ✅ | ✅ | ✅ | ✅ |
|
|
218
|
+
| `file_copy` | ❌ | ✅ | ✅ | ✅ | ✅ |
|
|
219
|
+
| `archive_zip` | ❌ | ❌ | ✅ | ✅ | ✅ |
|
|
220
|
+
| `archive_unzip` | ❌ | ❌ | ✅ | ✅ | ✅ |
|
|
221
|
+
| `file_tail` | ❌ | ✅ | ✅ | ✅ | ✅ |
|
|
222
|
+
| `file_hash` | ❌ | ✅ | ✅ | ✅ | ✅ |
|
|
223
|
+
| `file_search_ripgrep` | ❌ | ❌ | ✅ | ✅ | ✅ |
|
|
224
|
+
| `pdf_generate` | ❌ | ❌ | ✅ | ❌ | ✅ |
|
|
225
|
+
| `file_preview` | ❌ | ❌ | ✅ | ✅ | ✅ |
|
|
226
|
+
| `clipboard_get` | ❌ | ❌ | ❌ | ✅ | ✅ |
|
|
227
|
+
| `clipboard_set` | ❌ | ❌ | ❌ | ✅ | ✅ |
|
|
228
|
+
| `screen_capture` | ❌ | ❌ | ❌ | ✅ | ✅ |
|
|
229
|
+
| `system_open` | ❌ | ❌ | ✅ | ✅ | ✅ |
|
|
230
|
+
| `notification_send` | ❌ | ❌ | ❌ | ✅ | ✅ |
|
|
231
|
+
| `system_info` | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
232
|
+
| `gpu_info` | ❌ | ✅ | ✅ | ✅ | ✅ |
|
|
233
|
+
| `process_list` | ❌ | ✅ | ✅ | ✅ | ✅ |
|
|
234
|
+
| `process_kill` | ❌ | ❌ | ❌ | ✅ | ✅ |
|
|
235
|
+
| `port_check` | ❌ | ✅ | ✅ | ✅ | ✅ |
|
|
236
|
+
| `eventlog_query` | ❌ | ❌ | ❌ | ✅ | ✅ |
|
|
237
|
+
| `service_list` | ❌ | ❌ | ❌ | ✅ | ✅ |
|
|
238
|
+
| `service_status` | ❌ | ❌ | ❌ | ✅ | ✅ |
|
|
239
|
+
| `service_control` | ❌ | ❌ | ❌ | ✅ | ✅ |
|
|
240
|
+
| `http_ping` | ❌ | ❌ | ✅ | ✅ | ✅ |
|
|
241
|
+
| `http_request` | ❌ | ❌ | ✅ | ✅ | ✅ |
|
|
242
|
+
| `network_info` | ❌ | ❌ | ❌ | ✅ | ✅ |
|
|
243
|
+
| `preview://file` *(resource)* | ❌ | ❌ | ✅ | ✅ | ✅ |
|
|
244
|
+
| **Total** | **6** | **15** | **28** | **37** | **38** |
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Custom Profiles (`--tools`)
|
|
249
|
+
|
|
250
|
+
For advanced users who need a specific subset, WinHelm supports explicit tool selection:
|
|
251
|
+
|
|
252
|
+
### Whitelist Mode
|
|
253
|
+
|
|
254
|
+
Load only the tools you list:
|
|
255
|
+
|
|
256
|
+
```powershell
|
|
257
|
+
winhelm --profile custom --tools "terminal_run,file_read,file_write,file_list"
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### Extend a Preset
|
|
261
|
+
|
|
262
|
+
Start from a preset and add specific tools:
|
|
263
|
+
|
|
264
|
+
```powershell
|
|
265
|
+
winhelm --profile dev --tools "+pdf_generate,process_kill"
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Exclude from a Preset
|
|
269
|
+
|
|
270
|
+
Start from a preset and remove specific tools:
|
|
271
|
+
|
|
272
|
+
```powershell
|
|
273
|
+
winhelm --profile full --tools "-screen_capture,-clipboard_set"
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Via Config File
|
|
277
|
+
|
|
278
|
+
```json
|
|
279
|
+
{
|
|
280
|
+
"profile": "custom",
|
|
281
|
+
"customTools": [
|
|
282
|
+
"terminal_run",
|
|
283
|
+
"file_read",
|
|
284
|
+
"file_write",
|
|
285
|
+
"file_list",
|
|
286
|
+
"system_info"
|
|
287
|
+
]
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
**Validation:**
|
|
292
|
+
- Unknown tool names → startup error with suggestion
|
|
293
|
+
- Conflicting `+` and `-` in the same list → error
|
|
294
|
+
- Empty result → warning + fallback to `core`
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## Multi-Project Isolation (`--config <path>` & Session Non-Persistence)
|
|
299
|
+
|
|
300
|
+
When running multiple AI agents or projects concurrently with different security scopes or profiles:
|
|
301
|
+
|
|
302
|
+
1. **Dedicated Config File per Project (`--config`)**:
|
|
303
|
+
Point WinHelm to an explicit project configuration file:
|
|
304
|
+
```powershell
|
|
305
|
+
winhelm --config "D:\mcp\configs\project-a.json"
|
|
306
|
+
```
|
|
307
|
+
Or in Claude Desktop configuration:
|
|
308
|
+
```json
|
|
309
|
+
{
|
|
310
|
+
"mcpServers": {
|
|
311
|
+
"project-a": {
|
|
312
|
+
"command": "winhelm",
|
|
313
|
+
"args": ["--stdio", "--config", "D:\\mcp\\configs\\project-a.json"]
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
2. **Session-Only CLI Overrides (`--no-persist`)**:
|
|
320
|
+
By default, CLI flags (`--allowed-dirs`, `--auth`, `--profile`, `--tools`, `--read-only`) apply **only to that running instance** without overwriting the config file on disk (`persist = false`). This ensures that multiple instances running in parallel will not clobber each other's settings. To permanently save CLI flags back to disk, explicitly pass `--persist`.
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## Use Case Recipes
|
|
325
|
+
|
|
326
|
+
### Recipe 1: Claude Haiku on a Budget
|
|
327
|
+
|
|
328
|
+
```powershell
|
|
329
|
+
winhelm --profile minimal --port 8788
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
Result: **~1,500 tokens** for tools → leaves 198k+ for the conversation.
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
### Recipe 2: Cursor AI Coding Agent
|
|
337
|
+
|
|
338
|
+
```powershell
|
|
339
|
+
winhelm --profile dev --port 8788
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
Result: **~6,800 tokens** for tools → covers 98% of software development tasks with background tasks, ripgrep, and archives.
|
|
343
|
+
|
|
344
|
+
---
|
|
345
|
+
|
|
346
|
+
### Recipe 3: Remote Windows Server Monitoring
|
|
347
|
+
|
|
348
|
+
```powershell
|
|
349
|
+
winhelm --profile sysadmin --auth <strong-token> --host 0.0.0.0
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
Result: **~9,200 tokens** → full ops capability without headless Chromium PDF bloat.
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
### Recipe 4: Read-Only Audit Agent
|
|
357
|
+
|
|
358
|
+
```powershell
|
|
359
|
+
winhelm --profile custom --read-only --tools "file_read,file_list,file_search,file_tail,file_hash,system_info,eventlog_query"
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
Result: **~2,000 tokens** → no mutation possible, perfect for auditors.
|
|
363
|
+
|
|
364
|
+
---
|
|
365
|
+
|
|
366
|
+
### Recipe 5: PDF Report Generator
|
|
367
|
+
|
|
368
|
+
```powershell
|
|
369
|
+
winhelm --profile custom --tools "file_read,file_write,pdf_generate,file_list,system_info"
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
Result: **~1,300 tokens** → minimum viable report workflow.
|
|
373
|
+
|
|
374
|
+
---
|
|
375
|
+
|
|
376
|
+
## FAQ
|
|
377
|
+
|
|
378
|
+
**Q: What's the default profile?**
|
|
379
|
+
A: `full` when `--profile` is omitted. For most users, `dev` is a better default — see recommendations below.
|
|
380
|
+
|
|
381
|
+
**Q: Can I switch profiles at runtime?**
|
|
382
|
+
A: No. Profiles are resolved at startup. Restart the server to change.
|
|
383
|
+
|
|
384
|
+
**Q: Does the profile affect the Web Dashboard?**
|
|
385
|
+
A: No. The dashboard always shows all metrics regardless of profile.
|
|
386
|
+
|
|
387
|
+
**Q: Which profile should I start with?**
|
|
388
|
+
A:
|
|
389
|
+
- **Coding agents** → `dev`
|
|
390
|
+
- **General assistants** → `core`
|
|
391
|
+
- **Small models** → `minimal`
|
|
392
|
+
- **Ops / IT** → `sysadmin`
|
|
393
|
+
- **Undecided** → `dev`
|
|
394
|
+
|
|
395
|
+
**Q: How do you calculate token counts?**
|
|
396
|
+
A: We serialize each tool's JSON schema (name + description + parameters + enums) and count tokens with `tiktoken` (cl100k_base). Actual counts vary ±10% across models.
|
|
397
|
+
|
|
398
|
+
**Q: Why not just use `full` always?**
|
|
399
|
+
A: Because every token sent costs money, adds latency, and increases the chance of wrong-tool selection. The difference between `full` and `dev` is ~3,500 tokens **per request**.
|
|
400
|
+
|
|
401
|
+
**Q: Will you add more profiles?**
|
|
402
|
+
A: Unlikely. Five profiles cover 99% of use cases. For anything else, use `--tools`.
|
|
403
|
+
|
|
404
|
+
**Q: Can I define my own named profile?**
|
|
405
|
+
A: Yes, via `winhelm.config.json`:
|
|
406
|
+
|
|
407
|
+
```json
|
|
408
|
+
{
|
|
409
|
+
"profiles": {
|
|
410
|
+
"mytools": ["terminal_run", "file_read", "system_info"]
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
Then: `winhelm --profile mytools`
|
|
416
|
+
|
|
417
|
+
---
|
|
418
|
+
|
|
419
|
+
## See Also
|
|
420
|
+
|
|
421
|
+
- [Tools Reference](./TOOLS.md) — full parameter documentation for every tool
|
|
422
|
+
- [Security Model](./SECURITY.md) — read-only mode, path confinement, blacklist
|
|
423
|
+
- [Real-World Examples](./EXAMPLES.md) — end-to-end agent workflows
|
package/docs/SECURITY.md
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# WinHelm MCP — Security Model & Architecture
|
|
2
|
+
|
|
3
|
+
Security is a foundational design pillar of WinHelm. Giving an AI agent access to terminal execution, filesystem writes, and system processes requires robust, multi-layered safeguards.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Multi-Layer Security Architecture
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
[ MCP Client / AI Agent ]
|
|
11
|
+
│
|
|
12
|
+
▼
|
|
13
|
+
┌──────────────────────────────────────────────┐
|
|
14
|
+
│ Layer 1: Network & Authentication Gate │
|
|
15
|
+
│ - Token Authentication (Bearer Header) │
|
|
16
|
+
│ - Rate Limiting (120 req/min Sliding Window)│
|
|
17
|
+
└──────────────────────────────────────────────┘
|
|
18
|
+
│
|
|
19
|
+
▼
|
|
20
|
+
┌──────────────────────────────────────────────┐
|
|
21
|
+
│ Layer 2: Operation & Read-Only Guard │
|
|
22
|
+
│ - Enforce Read-Only Mode (--read-only) │
|
|
23
|
+
│ - Mutating Tools Blocked at Dispatcher │
|
|
24
|
+
└──────────────────────────────────────────────┘
|
|
25
|
+
│
|
|
26
|
+
▼
|
|
27
|
+
┌──────────────────────────────────────────────┐
|
|
28
|
+
│ Layer 3: Filesystem Confinement │
|
|
29
|
+
│ - Allowed Directories Whitelist │
|
|
30
|
+
│ - Drive Letter Isolation (e.g. D:\ only) │
|
|
31
|
+
│ - Path Traversal (..\) Sanitization │
|
|
32
|
+
└──────────────────────────────────────────────┘
|
|
33
|
+
│
|
|
34
|
+
▼
|
|
35
|
+
┌──────────────────────────────────────────────┐
|
|
36
|
+
│ Layer 4: Command Filter & Execution Shield │
|
|
37
|
+
│ - Blacklist Pattern Regex Filtering │
|
|
38
|
+
│ - Destructive Command Interception │
|
|
39
|
+
│ - NonInteractive / NoProfile PowerShell │
|
|
40
|
+
└──────────────────────────────────────────────┘
|
|
41
|
+
│
|
|
42
|
+
▼
|
|
43
|
+
┌──────────────────────────────────────────────┐
|
|
44
|
+
│ Layer 5: Secret Masking & Audit Logging │
|
|
45
|
+
│ - Auto Redaction of API Keys & Passwords │
|
|
46
|
+
│ - Daily Rotating Log Files with Hashing │
|
|
47
|
+
└──────────────────────────────────────────────┘
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 2. Authentication & Access Control
|
|
53
|
+
|
|
54
|
+
By default, WinHelm binds strictly to **`127.0.0.1` (localhost loopback)**, preventing external machines on your local network (LAN) or public internet from reaching the server.
|
|
55
|
+
|
|
56
|
+
If you bind WinHelm to an external interface (`--host 0.0.0.0`) without an authentication token, a prominent startup warning is emitted to alert you of open exposure. In any shared, multi-user, LAN, or remote setup, you should enforce Bearer Token authentication:
|
|
57
|
+
|
|
58
|
+
### CLI Flag
|
|
59
|
+
```powershell
|
|
60
|
+
winhelm --auth "my-secure-random-token-here"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Environment Variable
|
|
64
|
+
```powershell
|
|
65
|
+
$env:MCP_AUTH_TOKEN = "my-secure-random-token-here"
|
|
66
|
+
winhelm
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
When enabled:
|
|
70
|
+
- All protocol endpoints (`/mcp`, `/sse`, `/message`), file previews (`/preview`), and administrative telemetry APIs (`/api/monitor/*`) require an `Authorization: Bearer <token>` header.
|
|
71
|
+
- For clients without custom header support (such as Claude.ai Custom Connectors) or convenient browser access to the Web Monitor Dashboard and Previewer, the token can also be supplied via URL query parameter (`?token=<token>` or `?auth=<token>`) or browser cookie.
|
|
72
|
+
- Unauthenticated access is strictly confined to public health checks (`/health`) and the basic dashboard HTML shell (`/`, `/dashboard`).
|
|
73
|
+
|
|
74
|
+
### Disabling Authentication (`"authToken": null`)
|
|
75
|
+
|
|
76
|
+
If `"authToken"` is explicitly set to `null` in `winhelm.config.json` (or `--auth` / `MCP_AUTH_TOKEN` is omitted):
|
|
77
|
+
- The server operates in **No-Auth Mode** (`Public network mode active (No auth token set)`).
|
|
78
|
+
- Incoming MCP requests and tools are executed without verifying any Bearer token or query token.
|
|
79
|
+
- **Safety Restriction:** This mode should be strictly confined to local loopback development (`127.0.0.1`). Exposing an unauthenticated server with unrestricted drive access to public networks is dangerous and guarded by safety gates in `start-funnel.ps1`.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## 3. Read-Only Enforcement Mode
|
|
84
|
+
|
|
85
|
+
If you wish to allow an AI agent to read code, query event logs, and inspect system telemetry without modifying anything, start WinHelm in **Read-Only Mode**:
|
|
86
|
+
|
|
87
|
+
```powershell
|
|
88
|
+
winhelm --read-only
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
When active, any call to mutating tools (e.g. `file_write`, `file_edit`, `file_delete_safe`, `terminal_run`, `process_kill`, `service_control`) is rejected before reaching the execution engine.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## 4. Path Confinement (`allowedDirectories`) & Fail-Closed Design
|
|
96
|
+
|
|
97
|
+
WinHelm follows a **fail-closed by default** security principle:
|
|
98
|
+
- **Default (`allowedDirectories: []` or empty)**: If no allowed directories are configured, **all filesystem operations are strictly blocked**. This prevents accidental full-machine exposure when running an unconfigured instance.
|
|
99
|
+
- **Specific Directory Whitelist**: Specify target directories or drives to restrict access:
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"allowedDirectories": [
|
|
103
|
+
"D:\\mcp",
|
|
104
|
+
"C:\\Projects"
|
|
105
|
+
],
|
|
106
|
+
"allowSystemExecution": true
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
- **Whole-Volume Whitelist**: You can whitelist an entire volume by specifying `"D:\\"`, `"D:"`, or `"D"`.
|
|
110
|
+
- **Wildcard Full-Drive Access (`["*"]` or `["all"]`)**: You can explicitly opt-in to unrestricted machine access by configuring `["*"]` or `["all"]`.
|
|
111
|
+
> ⚠️ **Warning:** Wildcard access (`["*"]`) should only be used for trusted, local single-user development with authentication enabled. Never expose an unauthenticated server with wildcard access to a public network or reverse proxy.
|
|
112
|
+
- Any attempt to access paths outside the whitelist is rejected with a descriptive security error.
|
|
113
|
+
- Path traversal tricks (`..\..\Windows\System32`) and NTFS directory junctions/symlinks are resolved to canonical real paths via `fs.realpathSync` before boundary checks.
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## 5. Security Model & Trust Boundaries (Important Clarification)
|
|
120
|
+
|
|
121
|
+
To configure WinHelm safely, understand the distinction between hard security boundaries and defense-in-depth safeguards:
|
|
122
|
+
|
|
123
|
+
### 🛡️ Hard Security Boundaries
|
|
124
|
+
1. **Authentication Token (`authToken` / `--auth`)**:
|
|
125
|
+
- The primary security perimeter. When enabled, all MCP protocol interactions, tool dispatches, file previews, and monitoring APIs require token verification via timing-safe comparison (`crypto.timingSafeEqual`).
|
|
126
|
+
2. **Tool Profiles (`--profile minimal` or `--profile core`)**:
|
|
127
|
+
- The most effective containment strategy. Profiles strictly exclude tools at registration time. Using `core` provides 15 file inspection and reading tools while completely excluding `terminal_run`, `terminal_task_start`, and system mutation tools.
|
|
128
|
+
3. **Read-Only Mode (`--read-only`)**:
|
|
129
|
+
- Enforces an immutable environment. Blocks all filesystem modifications, archive creations, service controls, process terminations, mutating HTTP methods (POST/PUT/DELETE), and shell executions (`terminal_run` / `terminal_task_start`).
|
|
130
|
+
|
|
131
|
+
### ⚠️ Defense-in-Depth Safeguards (Not Hard Security Boundaries)
|
|
132
|
+
1. **Command Blocklist Patterns**:
|
|
133
|
+
- Regex-based command filtering is designed to prevent accidental destructive operations (e.g. `format-volume`, `rmdir /s /q C:\`). It is **not** an impregnable security sandbox against intentional evasion, as PowerShell syntax supports aliases, string concatenation, and encoded commands (`-EncodedCommand`, `iex`).
|
|
134
|
+
2. **Filesystem Confinement (`allowedDirectories`)**:
|
|
135
|
+
- Strictly confines native **File Tools** (`file_read`, `file_write`, `file_edit`, `file_delete_safe`, `copy_file`, `create_zip`, `extract_zip`). It also sets the working directory for terminal execution. However, if `terminal_run` is enabled (under `dev`, `sysadmin`, or `full` profiles) with `allowSystemExecution: true`, processes run with the full operating system permissions of the Windows user account running WinHelm.
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## 6. Network Hardening & Web Protections
|
|
140
|
+
|
|
141
|
+
1. **Host Header Validation (DNS Rebinding Defense)**:
|
|
142
|
+
- WinHelm validates incoming `Host` headers against an allowlist (`localhost`, `127.0.0.1`, `[::1]`, and configured `allowedHosts` such as `*.ts.net`). Requests with unauthorized host headers are rejected with **HTTP 403 Forbidden**, preventing malicious websites from exploiting browser same-origin policies via DNS rebinding.
|
|
143
|
+
2. **Unauthenticated Remote Proxy / Tunnel Guard**:
|
|
144
|
+
- If WinHelm is started without an authentication token (`authToken: null`), any request detected arriving through a reverse proxy or tunnel (containing `X-Forwarded-For` or `Forwarded` headers) is immediately blocked with **HTTP 403 Forbidden** (Fail-Closed). This prevents accidental exposure of a local shell to the internet.
|
|
145
|
+
3. **Content Security Policy & Security Headers**:
|
|
146
|
+
- File previews (`/preview`) enforce a strict Content Security Policy (`default-src 'none'; connect-src 'none'; form-action 'none'; frame-ancestors 'none'`) preventing previewed Markdown files from executing network requests against the local API.
|
|
147
|
+
- Global HTTP responses include `X-Content-Type-Options: nosniff` and `X-Frame-Options: DENY`.
|
|
148
|
+
4. **Token Security Notice**:
|
|
149
|
+
- While `?token=...` query parameters are supported for browser dashboards and Claude.ai custom connectors, automated tools and production integrations should prefer `Authorization: Bearer <token>` headers to avoid token retention in intermediate proxy logs or browser history.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## 7. Dangerous Command Blacklist
|
|
154
|
+
|
|
155
|
+
WinHelm inspects command lines executed via `terminal_run` or `terminal_task_start` against regex patterns targeting destructive or risky actions:
|
|
156
|
+
|
|
157
|
+
| Category | Blocked Patterns |
|
|
158
|
+
| :--- | :--- |
|
|
159
|
+
| **Disk & Partition Formatting** | `format\s+`, `format-volume`, `diskpart`, `clear-disk`, `initialize-disk` |
|
|
160
|
+
| **Recursive Root Deletion** | `rmdir\s+/[sS]`, `del\s+/[fF]/[sS]/[qQ]\s+[cC]:\\`, `remove-item\s+.*-recurse\s+.*[cC]:\\` |
|
|
161
|
+
| **Registry & Boot Tampering** | `reg\s+delete\s+hklm`, `bcdedit`, `bootrec` |
|
|
162
|
+
| **Account & Privilege Escalation** | `net\s+user\s+.*\/add`, `takeown\s+/[fF]`, `icacls\s+.*\/grant` |
|
|
163
|
+
| **Credential Dumping** | `mimikatz`, `procdump\s+.*lsass`, `comsvcs\.dll` |
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## 8. Secret Redaction & Log Sanitization
|
|
168
|
+
|
|
169
|
+
Before log entries are displayed on the Web Monitor Dashboard or written to disk, all text is piped through [sanitizer.ts](../src/utils/sanitizer.ts):
|
|
170
|
+
|
|
171
|
+
- **Bearer Tokens**: `Bearer ************`
|
|
172
|
+
- **OpenAI & Claude API Keys**: `sk-ant-************`, `sk-************`
|
|
173
|
+
- **GitHub Tokens**: `ghp_************`, `gho_************`
|
|
174
|
+
- **AWS Access Keys**: `AKIA************`
|
|
175
|
+
- **JSON Fields & Credentials**: `"authToken": "************"`, `"password": "************"`, `"x-api-key": "************"`
|
|
176
|
+
- **Password Objects**: `{ "password": "************" }`
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## 9. Audit Logging & Export
|
|
181
|
+
|
|
182
|
+
All executed commands, exit codes, durations, and tool errors are sequentially logged to daily audit logs in `logs/winhelm-YYYY-MM-DD.log`.
|
|
183
|
+
|
|
184
|
+
You can export audit logs at any time via the Web Monitor Dashboard buttons ("📥 Export JSON" / "📥 Export CSV") or programmatically via the HTTP endpoint:
|
|
185
|
+
```
|
|
186
|
+
GET /api/monitor/export?format=json
|
|
187
|
+
GET /api/monitor/export?format=csv
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Logs older than 7 days are automatically pruned to prevent disk consumption.
|