hyper-mcp 0.4.0

A fast, secure MCP server that extends its capabilities through WebAssembly plugins
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
# Skip Tools Pattern Guide

This guide provides comprehensive documentation for using the `skip_tools` configuration in hyper-mcp, which allows you to filter out unwanted tools using powerful regex patterns.

## Overview

The `skip_tools` field in your plugin's `runtime_config` allows you to specify a list of regex patterns that will be used to exclude tools from being loaded at runtime. This is useful for:

- Removing debug tools in production environments
- Filtering out deprecated or experimental tools
- Excluding tools that conflict with your workflow
- Customizing the available tool set per environment

## How It Works

### Automatic Pattern Anchoring

All patterns in `skip_tools` are automatically anchored to match the entire tool name. This means:

```yaml
skip_tools:
  - "debug"  # Becomes "^debug$" - matches exactly "debug"
```

This prevents unintended partial matches. If you want to match parts of tool names, use explicit wildcards:

```yaml
skip_tools:
  - "debug.*"  # Matches "debug", "debugger", "debug_info", etc.
```

### Regex Compilation

All patterns are compiled into a single optimized `RegexSet` for efficient matching:
- O(1) lookup time regardless of pattern count
- Single compilation at startup
- Memory-efficient pattern storage

## Basic Patterns

### Exact Matches

Match specific tool names exactly:

```yaml
skip_tools:
  - "debug_tool"      # Matches only "debug_tool"
  - "test_runner"     # Matches only "test_runner"
  - "admin_panel"     # Matches only "admin_panel"
```

### Prefix Matching

Match tools that start with a specific string:

```yaml
skip_tools:
  - "debug.*"         # Matches "debug", "debugger", "debug_info"
  - "test_.*"         # Matches "test_unit", "test_integration", "test_e2e"
  - "dev_.*"          # Matches "dev_server", "dev_tools", "dev_helper"
```

### Suffix Matching

Match tools that end with a specific string:

```yaml
skip_tools:
  - ".*_test"         # Matches "unit_test", "integration_test", "load_test"
  - ".*_backup"       # Matches "data_backup", "config_backup", "db_backup"
  - ".*_deprecated"   # Matches "old_deprecated", "legacy_deprecated"
```

### Contains Matching

Match tools that contain a specific substring:

```yaml
skip_tools:
  - ".*debug.*"       # Matches "pre_debug_tool", "debug", "tool_debug_info"
  - ".*temp.*"        # Matches "temp_file", "cleanup_temp", "temp_storage_tool"
```

## Advanced Patterns

### Character Classes

Use character classes for flexible matching:

```yaml
skip_tools:
  - "tool_[0-9]+"           # Matches "tool_1", "tool_42", "tool_999"
  - "test_[a-z]+"           # Matches "test_unit", "test_api", "test_db"
  - "[A-Z][a-z]+Tool"       # Matches "DebugTool", "TestTool", "AdminTool"
  - "log_[0-9]{4}_[0-9]{2}" # Matches "log_2023_12", "log_2024_01"
```

### Alternation (OR Logic)

Match multiple alternatives:

```yaml
skip_tools:
  - "test_(unit|integration|e2e)"     # Matches "test_unit", "test_integration", "test_e2e"
  - "(debug|trace|log)_.*"            # Matches tools starting with "debug_", "trace_", or "log_"
  - ".*(temp|tmp|cache).*"            # Matches tools containing "temp", "tmp", or "cache"
  - "system_(admin|user|guest)_.*"    # Matches tools for different user types
```

### Quantifiers

Control how many characters or groups to match:

```yaml
skip_tools:
  - "tool_v[0-9]+"          # Matches "tool_v1", "tool_v10", "tool_v123"
  - "backup_[0-9]{8}"       # Matches exactly 8 digits: "backup_20240101"
  - "temp_[a-f0-9]{6,}"     # Matches 6+ hex chars: "temp_abc123", "temp_def456789"
  - "log_[0-9]{4}-[0-9]{2}" # Matches "log_2024-01", "log_2023-12"
```

### Negation with Character Classes

Skip tools that DON'T match certain patterns:

```yaml
skip_tools:
  - "[^a-z].*"              # Skip tools starting with non-lowercase letters
  - ".*[^0-9]$"             # Skip tools not ending with numbers
  - "tool_[^v].*"           # Skip tools starting with "tool_" but not "tool_v"
```

## Common Use Cases

### Environment-Specific Filtering

#### Development Environment
```yaml
skip_tools:
  - "prod_.*"               # Skip production tools
  - "deploy_.*"             # Skip deployment tools
  - "monitor_.*"            # Skip monitoring tools
```

#### Production Environment
```yaml
skip_tools:
  - "debug.*"               # Skip all debug tools
  - "test_.*"               # Skip all test tools
  - "dev_.*"                # Skip development tools
  - "mock_.*"               # Skip mock/stub tools
  - ".*_experimental"       # Skip experimental features
```

#### Testing Environment
```yaml
skip_tools:
  - "prod_.*"               # Skip production tools
  - "deploy_.*"             # Skip deployment tools
  - ".*_live"               # Skip live/production tools
```

### Tool Category Filtering

#### Skip Administrative Tools
```yaml
skip_tools:
  - "admin_.*"
  - "system_admin_.*"
  - "user_management_.*"
  - "permission_.*"
```

#### Skip Deprecated Tools
```yaml
skip_tools:
  - ".*_deprecated"
  - ".*_old"
  - "legacy_.*"
  - "v[0-9]_.*"             # Skip versioned legacy tools
```

#### Skip Resource-Heavy Tools
```yaml
skip_tools:
  - ".*_benchmark"
  - "load_test_.*"
  - "stress_.*"
  - "heavy_.*"
```

### Version-Based Filtering

```yaml
skip_tools:
  - ".*_v[0-9]"             # Skip v1, v2, etc. (keep latest)
  - ".*_beta"               # Skip beta tools
  - ".*_alpha"              # Skip alpha tools
  - "tool_[0-9]+\\.[0-9]+"  # Skip versioned tools like "tool_1.0"
```

## Special Character Escaping

When matching literal special characters, escape them with backslashes:

```yaml
skip_tools:
  - "file\\.exe"            # Matches "file.exe" literally
  - "script\\?"             # Matches "script?" literally
  - "temp\\*data"           # Matches "temp*data" literally
  - "path\\\\tool"          # Matches "path\tool" literally (double escape for backslash)
  - "price\\$calculator"    # Matches "price$calculator" literally
  - "regex\\[test\\]"       # Matches "regex[test]" literally
```

## Configuration Examples

### Simple Configuration
```yaml
plugins:
  my_plugin:
    url: "oci://registry.io/my-plugin:latest"
    runtime_config:
      skip_tools:
        - "debug_tool"
        - "test_runner"
```

### Comprehensive Configuration
```yaml
plugins:
  production_plugin:
    url: "oci://registry.io/prod-plugin:latest"
    runtime_config:
      skip_tools:
        # Exact matches
        - "debug_console"
        - "test_runner"

        # Pattern matches
        - "dev_.*"              # All dev tools
        - ".*_test"             # All test tools
        - "temp_.*"             # All temp tools
        - "mock_.*"             # All mock tools

        # Advanced patterns
        - "tool_v[0-9]"         # Versioned tools
        - "admin_(user|role)_.*" # Specific admin tools
        - "[0-9]+_backup"       # Numbered backups

      allowed_hosts: ["api.example.com"]
      memory_limit: "512Mi"
```

### Multi-Environment Setup
```yaml
# config.dev.yaml
plugins:
  app_plugin:
    url: "oci://registry.io/app-plugin:dev"
    runtime_config:
      skip_tools:
        - "prod_.*"
        - "deploy_.*"

---
# config.prod.yaml
plugins:
  app_plugin:
    url: "oci://registry.io/app-plugin:latest"
    runtime_config:
      skip_tools:
        - "debug.*"
        - "test_.*"
        - "dev_.*"
        - ".*_experimental"
```

## Best Practices

### 1. Start Simple, Then Refine
```yaml
# Start with broad patterns
skip_tools:
  - "debug.*"
  - "test_.*"

# Refine to be more specific as needed
skip_tools:
  - "debug_(console|panel)"  # Only skip specific debug tools
  - "test_(unit|integration)" # Only skip specific test types
```

### 2. Use Comments for Complex Patterns
```yaml
skip_tools:
  - "tool_[0-9]+"             # Skip numbered tools (tool_1, tool_2, etc.)
  - ".*_(alpha|beta|rc[0-9]+)" # Skip pre-release versions
  - "temp_[0-9]{8}_.*"        # Skip dated temporary tools
```

### 3. Group Related Patterns
```yaml
skip_tools:
  # Debug and development tools
  - "debug.*"
  - "dev_.*"
  - ".*_dev"

  # Testing tools
  - "test_.*"
  - ".*_test"
  - "mock_.*"

  # Administrative tools
  - "admin_.*"
  - "system_.*"
```

### 4. Consider Performance
```yaml
# Good: Specific patterns
skip_tools:
  - "debug_tool"
  - "test_runner"

# Less optimal: Overly broad patterns that might match many tools
skip_tools:
  - ".*"  # This would skip everything - not useful
```

## Troubleshooting

### Pattern Not Working?

1. **Check anchoring**: Remember patterns are auto-anchored
   ```yaml
   # This matches only "debug" exactly
   - "debug"

   # This matches "debug", "debugger", "debug_tool", etc.
   - "debug.*"
   ```

2. **Escape special characters**:
   ```yaml
   # Wrong: Will treat . as wildcard
   - "file.exe"

   # Correct: Escapes the literal dot
   - "file\\.exe"
   ```

3. **Test your patterns**: Use a regex tester to validate complex patterns

### Debugging Skip Rules

Enable debug logging to see which tools are being skipped:

```bash
RUST_LOG=debug hyper-mcp --config config.yaml
```

## Migration from Old Format

If you were using simple string arrays before:

```yaml
# Old format (if it existed)
skip_tools: ["debug_tool", "test_runner"]

# New format (same result, but now with regex support)
skip_tools: ["debug_tool", "test_runner"]

# New format with patterns (more powerful)
skip_tools: ["debug.*", "test_.*"]
```

## Error Handling

### Invalid Regex Patterns

If you provide an invalid regex pattern, configuration loading will fail:

```yaml
# This will cause an error - unclosed bracket
skip_tools:
  - "tool_[invalid"
```

Error message will indicate the problematic pattern and suggest corrections.

### Empty Patterns

These configurations are all valid:

```yaml
# No skip_tools field - no tools skipped
runtime_config:
  allowed_hosts: ["*"]

# Empty array - no tools skipped
runtime_config:
  skip_tools: []

# Null value - no tools skipped
runtime_config:
  skip_tools: null
```

## Performance Characteristics

- **Startup**: O(n) pattern compilation where n = number of patterns
- **Runtime**: O(1) tool name checking regardless of pattern count
- **Memory**: Minimal overhead, patterns compiled into efficient state machine
- **Scalability**: Handles hundreds of patterns efficiently

## Advanced Topics

### Complex Business Logic

```yaml
skip_tools:
  # Skip tools for specific environments
  - "prod_(?!api_).*"         # Skip prod tools except prod_api_*
  - "test_(?!smoke_).*"       # Skip test tools except smoke tests

  # Skip based on naming conventions
  - "[A-Z]{2,}_.*"            # Skip tools starting with 2+ capitals
  - ".*_[0-9]{4}[0-9]{2}[0-9]{2}" # Skip daily-dated tools
```

### Integration with External Tools

You can generate `skip_tools` patterns dynamically:

```bash
# Generate patterns from external source
echo "skip_tools:" > config.yaml
external-tool --list-deprecated | sed 's/^/  - "/' | sed 's/$/\"/' >> config.yaml
```

### Conditional Configuration

Use different configs for different scenarios:

```yaml
# Base configuration
base_skip_patterns: &base_skip
  - "debug.*"
  - "test_.*"

# Environment-specific additions
prod_additional: &prod_additional
  - "dev_.*"
  - ".*_experimental"

plugins:
  my_plugin:
    runtime_config:
      skip_tools:
        - *base_skip
        - *prod_additional  # YAML doesn't support this directly,
                            # but you can use templating tools
```

This guide should help you make full use of the powerful `skip_tools` pattern matching capabilities in hyper-mcp!