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
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
# Runtime Configuration

## Structure

The configuration is structured as follows:

- **auths** (`object`, optional): Authentication configurations for HTTPS requests, keyed by URL.
- **plugins**: A map of plugin names to  plugin configuration objects.
  - **path** (`string`): OCI path or HTTP URL or local path for the plugin.
  - **runtime_config** (`object`, optional): Plugin-specific runtime configuration. The available fields are:
    - **skip_tools** (`array[string]`, optional): List of regex patterns for tool names to skip loading at runtime. Each pattern is automatically anchored to match the entire tool name (equivalent to wrapping with `^` and `$`). Supports full regex syntax for powerful pattern matching.
    - **allowed_hosts** (`array[string]`, optional): List of allowed hosts for the plugin (e.g., `["1.1.1.1"]` or `["*"]`).
    - **allowed_paths** (`array[string]`, optional): List of allowed file system paths. Supports both simple paths and host-to-plugin path mapping. See [Allowed Paths Configuration]#allowed-paths-configuration for detailed documentation.
    - **allowed_secrets** (`array[object]`, optional): List of allowed keyring entries that the plugin can access. Each entry specifies a `service` and `user` name. See [Allowed Secrets Configuration]#allowed-secrets-configuration for detailed documentation.
    - **env_vars** (`object`, optional): Key-value pairs of environment variables for the plugin.
    - **memory_limit** (`string`, optional): Memory limit for the plugin (e.g., `"512Mi"`).

## Plugin Names

Plugin names must follow strict naming conventions to ensure consistency and avoid conflicts:

### Allowed Characters
- **Letters**: A-Z, a-z (case-sensitive)
- **Numbers**: 0-9
- **Underscores**: _ (as separators only)

### Naming Rules
- Must start with a letter or number (not underscore)
- Must end with a letter or number (not underscore)
- Cannot contain consecutive underscores
- Cannot contain hyphens or other special characters
- Cannot contain spaces or whitespace

### Valid Examples
```
âś… plugin
âś… myPlugin
âś… plugin_name
âś… plugin123
âś… my_awesome_plugin_v2
âś… Plugin_Name_123
```

### Invalid Examples
```
❌ plugin-name        (hyphens not allowed)
❌ plugin_            (cannot end with underscore)
❌ _plugin            (cannot start with underscore)
❌ plugin__name       (consecutive underscores)
❌ plugin name        (spaces not allowed)
❌ plugin@name        (special characters not allowed)
```

### Best Practices
- Use descriptive, meaningful names
- Follow consistent naming conventions within your organization
- Consider using prefixes for related plugins (e.g., `company_auth`, `company_logging`)
- Use underscores to separate logical components (e.g., `api_client`, `data_processor`)

## Authentication Configuration

The `auths` field allows you to configure authentication for HTTPS requests made by plugins. Authentication is matched by URL prefix, with longer prefixes taking precedence.

### Supported Authentication Types

#### Basic Authentication
```yaml
auths:
  "https://api.example.com":
    type: basic
    username: "your-username"
    password: "your-password"
```

#### Bearer Token Authentication
```yaml
auths:
  "https://api.example.com":
    type: token
    token: "your-bearer-token"
```

#### Keyring Authentication
```yaml
auths:
  "https://private.registry.io":
    type: keyring
    service: "my-app"
    user: "registry-user"
```

### Keyring Setup Examples

For keyring authentication, you need to store the actual auth configuration JSON in your system keyring. This provides secure credential storage without exposing sensitive data in config files.

#### macOS (using Keychain Access or security command)

**Using the `security` command:**
```bash
# Store basic auth credentials
security add-generic-password -a "registry-user" -s "my-app" -w '{"type":"basic","username":"actual-user","password":"actual-pass"}'

# Store token auth credentials
security add-generic-password -a "api-user" -s "my-service" -w '{"type":"token","token":"actual-bearer-token"}'

# Verify the entry was created
security find-generic-password -a "registry-user" -s "my-app"
```

**Using Keychain Access GUI:**
1. Open Keychain Access (Applications → Utilities → Keychain Access)
2. Click "File" → "New Password Item"
3. Set "Keychain Item Name" to your service name (e.g., "my-app")
4. Set "Account Name" to your user name (e.g., "registry-user")
5. Set "Password" to the JSON auth config: `{"type":"basic","username":"actual-user","password":"actual-pass"}`
6. Click "Add"

#### Linux (using libsecret/gnome-keyring)

**Install required tools:**
```bash
# Ubuntu/Debian
sudo apt-get install libsecret-tools

# RHEL/CentOS/Fedora
sudo yum install libsecret-devel
```

**Using `secret-tool`:**
```bash
# Store basic auth credentials
echo '{"type":"basic","username":"actual-user","password":"actual-pass"}' | secret-tool store --label="my-app credentials" service "my-app" username "registry-user"

# Store token auth credentials
echo '{"type":"token","token":"actual-bearer-token"}' | secret-tool store --label="my-service token" service "my-service" username "api-user"

# Verify the entry was created
secret-tool lookup service "my-app" username "registry-user"
```

#### Windows (using Windows Credential Manager)

**Using `cmdkey` (Command Prompt as Administrator):**
```cmd
REM Store basic auth credentials (escape quotes for JSON)
cmdkey /generic:"my-app" /user:"registry-user" /pass:"{\"type\":\"basic\",\"username\":\"actual-user\",\"password\":\"actual-pass\"}"

REM Store token auth credentials
cmdkey /generic:"my-service" /user:"api-user" /pass:"{\"type\":\"token\",\"token\":\"actual-bearer-token\"}"

REM Verify the entry was created
cmdkey /list:"my-app"
```

**Using Credential Manager GUI:**
1. Open "Credential Manager" from Control Panel → User Accounts → Credential Manager
2. Click "Add a generic credential"
3. Set "Internet or network address" to your service name (e.g., "my-app")
4. Set "User name" to your user name (e.g., "registry-user")
5. Set "Password" to the JSON auth config: `{"type":"basic","username":"actual-user","password":"actual-pass"}`
6. Click "OK"

**Using PowerShell:**
```powershell
# Store basic auth credentials
$cred = New-Object System.Management.Automation.PSCredential("registry-user", (ConvertTo-SecureString '{"type":"basic","username":"actual-user","password":"actual-pass"}' -AsPlainText -Force))
New-StoredCredential -Target "my-app" -Credential $cred -Type Generic
```

### URL Matching Behavior

Authentication is applied based on URL prefix matching:
- Longer prefixes take precedence over shorter ones
- Exact matches take highest precedence
- URLs are matched case-sensitively

**Example:**
```yaml
auths:
  "https://example.com":
    type: basic
    username: "broad-user"
    password: "broad-pass"
  "https://example.com/api":
    type: token
    token: "api-token"
  "https://example.com/api/v1":
    type: basic
    username: "v1-user"
    password: "v1-pass"
```

- Request to `https://example.com/api/v1/users` → uses v1 basic auth (longest match)
- Request to `https://example.com/api/data` → uses api token auth
- Request to `https://example.com/public` → uses broad basic auth

### Keyring Authentication Example

**Configuration file:**
```yaml
auths:
  "https://private.registry.io":
    type: keyring
    service: "private-registry"
    user: "registry-user"
  "https://internal.company.com":
    type: keyring
    service: "company-api"
    user: "api-user"

plugins:
  secure-plugin:
    url: "https://private.registry.io/secure-plugin"
    runtime_config:
      allowed_hosts:
        - "private.registry.io"
```

**Corresponding keyring entries (stored separately):**
- Service: `private-registry`, User: `registry-user`, Password: `{"type":"basic","username":"real-user","password":"real-pass"}`
- Service: `company-api`, User: `api-user`, Password: `{"type":"token","token":"company-jwt-token"}`

### Real-World Keyring Scenarios

#### Scenario 1: Corporate Environment
```yaml
auths:
  "https://artifactory.company.com":
    type: keyring
    service: "company-artifactory"
    user: "build-service"
  "https://nexus.company.com":
    type: keyring
    service: "company-nexus"
    user: "deployment-bot"
```

Setup corporate credentials once:
```bash
# macOS
security add-generic-password -a "build-service" -s "company-artifactory" -w '{"type":"basic","username":"corp_user","password":"corp_secret"}'

# Linux
echo '{"type":"basic","username":"corp_user","password":"corp_secret"}' | secret-tool store --label="Company Artifactory" service "company-artifactory" username "build-service"

# Windows
cmdkey /generic:"company-artifactory" /user:"build-service" /pass:"{\"type\":\"basic\",\"username\":\"corp_user\",\"password\":\"corp_secret\"}"
```

#### Scenario 2: Multi-Environment Setup
```yaml
auths:
  "https://staging-api.example.com":
    type: keyring
    service: "example-staging"
    user: "staging-user"
  "https://prod-api.example.com":
    type: keyring
    service: "example-prod"
    user: "prod-user"
```

Store different credentials for each environment:
```bash
# Staging credentials
security add-generic-password -a "staging-user" -s "example-staging" -w '{"type":"token","token":"staging-jwt-token"}'

# Production credentials
security add-generic-password -a "prod-user" -s "example-prod" -w '{"type":"token","token":"prod-jwt-token"}'
```

#### Scenario 3: Team Shared Configuration
```yaml
# Team members can share this config file safely
auths:
  "https://shared-registry.team.com":
    type: keyring
    service: "team-registry"
    user: "developer"
```

Each team member stores their own credentials:
```bash
# Developer A
security add-generic-password -a "developer" -s "team-registry" -w '{"type":"basic","username":"alice","password":"alice_key"}'

# Developer B
security add-generic-password -a "developer" -s "team-registry" -w '{"type":"basic","username":"bob","password":"bob_key"}'
```

### Keyring Best Practices

1. **Service Naming Convention**: Use descriptive, consistent service names (e.g., `company-artifactory`, `project-registry`)
2. **User Identification**: Use role-based usernames (e.g., `build-service`, `deployment-bot`) rather than personal names
3. **Credential Rotation**: Update keyring entries when rotating credentials - no config file changes needed
4. **Environment Separation**: Use different service names for different environments
5. **Team Coordination**: Document your service/user naming conventions for team members
6. **Backup Strategy**: Consider backing up keyring entries for critical services
7. **Testing**: Use non-production credentials in keyring for testing

## Example (YAML)

```yaml
auths:
  "https://private.registry.io":
    type: basic
    username: "registry-user"
    password: "registry-pass"
  "https://api.github.com":
    type: token
    token: "ghp_1234567890abcdef"
  "https://enterprise.api.com":
    type: basic
    username: "enterprise-user"
    password: "enterprise-pass"

plugins:
  time:
    url: oci://ghcr.io/hyper-mcp-rs/time-plugin:latest
  myip:
    url: oci://ghcr.io/hyper-mcp-rs/myip-plugin:latest
    runtime_config:
      allowed_hosts:
        - "1.1.1.1"
      allowed_paths:
        - "/tmp"                      # Single path (same for host and plugin)
        - "/var/log:/plugin/logs"     # Mapped path (host:plugin)
        - "/home/user/data"           # Another single path
      allowed_secrets:
        - service: "my-app"
          user: "admin"
        - service: "database"
          user: "db_user"
      skip_tools:
        - "debug_tool"           # Skip exact tool name
        - "temp_.*"              # Skip tools starting with "temp_"
        - ".*_backup"            # Skip tools ending with "_backup"
        - "test_[0-9]+"          # Skip tools like "test_1", "test_42"
      env_vars:
        FOO: "bar"
      memory_limit: "512Mi"
  private_plugin:
    url: "https://private.registry.io/my-plugin"
    runtime_config:
      allowed_hosts:
        - "private.registry.io"
      allowed_secrets:
        - service: "private-registry"
          user: "auth-token"
```

## Example (JSON)

```json
{
  "auths": {
    "https://private.registry.io": {
      "type": "basic",
      "username": "registry-user",
      "password": "registry-pass"
    },
    "https://api.github.com": {
      "type": "token",
      "token": "ghp_1234567890abcdef"
    },
    "https://enterprise.api.com": {
      "type": "basic",
      "username": "enterprise-user",
      "password": "enterprise-pass"
    }
  },
  "plugins": {
    "time": {
      "url": "oci://ghcr.io/hyper-mcp-rs/time-plugin:latest"
    },
    "myip": {
      "url": "oci://ghcr.io/hyper-mcp-rs/myip-plugin:latest",
      "runtime_config": {
        "allowed_hosts": ["1.1.1.1"],
        "allowed_paths": [
          "/tmp",
          "/var/log:/plugin/logs",
          "/home/user/data"
        ],
        "allowed_secrets": [
          {
            "service": "my-app",
            "user": "admin"
          }
        ],
        "skip_tools": [
          "debug_tool",
          "temp_.*",
          ".*_backup",
          "test_[0-9]+"
        ],
        "env_vars": {"FOO": "bar"},
        "memory_limit": "512Mi"
      }
    },
    "private_plugin": {
      "url": "https://private.registry.io/my-plugin",
      "runtime_config": {
        "allowed_hosts": ["private.registry.io"]
      }
    }
  }
}
```

## Loading Configuration

Configuration is loaded at runtime from a file with `.json`, `.yaml`, `.yml`, or `.toml` extension. The loader will parse the file according to its extension. If the file does not exist or the format is unsupported, an error will be raised.

## Security Considerations

### Credential Storage
- **Basic/Token auth**: Credentials are stored directly in the config file. Ensure proper file permissions (e.g., `chmod 600`).
- **Keyring auth**: Credentials are stored securely in the system keyring. The config file only contains service/user identifiers.

### Best Practices
- Use keyring authentication for production environments
- Rotate credentials regularly
- Use environment-specific config files
- Never commit credentials to version control
- Consider using short-lived tokens when possible

## Troubleshooting Keyring Authentication

### Common Issues

#### "No matching entry found in secure storage"
This error occurs when the keyring entry doesn't exist or can't be accessed.

**Solutions:**
1. Verify the service and user names match exactly between config and keyring
2. Check that the keyring entry exists:
   ```bash
   # macOS
   security find-generic-password -a "your-user" -s "your-service"

   # Linux
   secret-tool lookup service "your-service" username "your-user"

   # Windows
   cmdkey /list:"your-service"
   ```
3. Ensure the current user has permission to access the keyring entry

#### "Failed to parse JSON from keyring"
This error occurs when the stored password isn't valid JSON or doesn't match the expected AuthConfig format.

**Solutions:**
1. Verify the stored password is valid JSON:
   ```bash
   # macOS - retrieve and validate
   security find-generic-password -a "your-user" -s "your-service" -w | jq .
   ```
2. Ensure the JSON matches one of these formats:
   - `{"type":"basic","username":"real-user","password":"real-pass"}`
   - `{"type":"token","token":"real-token"}`

#### Platform-Specific Issues

**macOS:**
- Keychain may be locked - unlock it manually or use `security unlock-keychain`
- Application may not have keychain access permissions

**Linux:**
- GNOME Keyring service may not be running: `systemctl --user status gnome-keyring`
- D-Bus session may not be available in non-graphical environments

**Windows:**
- Credential Manager may require administrator privileges for certain operations
- Windows Credential Manager has size limits for stored passwords

### Debugging Tips

1. **Test keyring access independently:**
   ```bash
   # Create a test entry
   security add-generic-password -a "test-user" -s "test-service" -w '{"type":"token","token":"test"}'

   # Retrieve it
   security find-generic-password -a "test-user" -s "test-service" -w

   # Clean up
   security delete-generic-password -a "test-user" -s "test-service"
   ```

2. **Validate JSON format:**
   ```bash
   echo '{"type":"basic","username":"user","password":"pass"}' | jq .
   ```

3. **Check permissions:**
   ```bash
   # Ensure config file is readable
   ls -la config.yaml

   # Set appropriate permissions
   chmod 600 config.yaml
   ```

## Skip Tools Pattern Matching

The `skip_tools` field supports powerful regex pattern matching for filtering out unwanted tools at runtime.

> đź“– **For comprehensive examples, advanced patterns, and detailed use cases, see [SKIP_TOOLS_GUIDE.md]./SKIP_TOOLS_GUIDE.md**

### Pattern Behavior
- **Automatic Anchoring**: Patterns are automatically anchored to match the entire tool name (wrapped with `^` and `$`)
- **Regex Support**: Full regex syntax is supported, including wildcards, character classes, and quantifiers
- **Case Sensitive**: Pattern matching is case-sensitive
- **Compilation**: All patterns are compiled into a single optimized regex set for efficient matching

### Pattern Examples

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

#### Wildcard Patterns
```yaml
skip_tools:
  - "temp_.*"         # Matches "temp_file", "temp_data", etc.
  - ".*_backup"       # Matches "data_backup", "file_backup", etc.
  - "debug.*"         # Matches "debug", "debugger", "debug_info", etc.
```

#### Advanced Regex Patterns
```yaml
skip_tools:
  - "tool_[0-9]+"                    # Matches "tool_1", "tool_42", etc.
  - "test_(unit|integration)"        # Matches "test_unit" and "test_integration"
  - "[a-z]+_helper"                  # Matches lowercase word + "_helper"
  - "system_(admin|user)_.*"         # Matches tools starting with "system_admin_" or "system_user_"
```

#### Explicit Anchoring
```yaml
skip_tools:
  - "^prefix_.*"      # Explicit start anchor (same as "prefix_.*" due to auto-anchoring)
  - ".*_suffix$"      # Explicit end anchor (same as ".*_suffix" due to auto-anchoring)
  - "^exact_only$"    # Fully explicit anchoring (same as "exact_only")
```

#### Special Characters
```yaml
skip_tools:
  - "file\\.exe"      # Matches "file.exe" literally (escaped dot)
  - "script\\?"       # Matches "script?" literally (escaped question mark)
  - "temp\\*data"     # Matches "temp*data" literally (escaped asterisk)
```

#### Common Use Cases
```yaml
skip_tools:
  - ".*_test"         # Skip all test tools
  - "dev_.*"          # Skip all development tools
  - "mock_.*"         # Skip all mock tools
  - ".*_deprecated"   # Skip all deprecated tools
  - "admin_.*"        # Skip all admin tools
  - "debug.*"         # Skip all debug-related tools
```

### Error Handling
- Invalid regex patterns will cause configuration loading to fail with a descriptive error
- Empty pattern arrays are allowed and will skip no tools
- The `skip_tools` field can be omitted entirely to skip no tools

### Performance Notes
- All patterns are compiled into a single optimized `RegexSet` for O(1) tool name checking
- Pattern compilation happens once at startup, not per tool evaluation
- Large numbers of patterns have minimal runtime performance impact

## Allowed Paths Configuration

The `allowed_paths` field provides fine-grained control over filesystem access for plugins. It supports both simple paths and sophisticated host-to-plugin path mapping, enabling secure isolation while maintaining flexibility.

### Path Format

Paths can be specified in two formats:

#### 1. Simple Path Format
When the same path should be accessible to both the host and plugin:

```yaml
allowed_paths:
  - "/tmp"
  - "/home/user/data"
  - "./relative/path"
```

#### 2. Mapped Path Format
When you want to map a host filesystem path to a different path as seen by the plugin:

**Unix/Linux/macOS** (using `:` as separator):
```yaml
allowed_paths:
  - "/host/path:/plugin/path"
  - "/var/log:/plugin/logs"
  - "/home/user/data:/plugin/user/data"
```

**Windows** (using `;` as separator):
```yaml
allowed_paths:
  - "C:\\host\\path;C:\\plugin\\path"
  - "C:\\logs;C:\\plugin\\logs"
```

### Platform-Specific Separators

The separator used for path mapping is platform-dependent:
- **Unix/Linux/macOS**: Colon (`:`) - e.g., `"/host/path:/plugin/path"`
- **Windows**: Semicolon (`;`) - e.g., `"C:\\host\\path;C:\\plugin\\path"`

This ensures compatibility with Windows drive letters (which contain colons) and Unix absolute paths.

### Path Mapping Examples

#### Basic Mapping
```yaml
allowed_paths:
  - "/tmp"                           # Plugin sees /tmp at /tmp
  - "/var/log:/plugin/logs"          # Host /var/log appears as /plugin/logs to plugin
  - "/home/user/data"                # Plugin sees /home/user/data at /home/user/data
```

#### Relative Paths
```yaml
allowed_paths:
  - "./local/data"                   # Relative to current directory
  - "../shared/files"                # Parent directory reference
  - "./host/config:./plugin/config"  # Mapped relative paths
```

#### Windows Paths
```yaml
allowed_paths:
  - "C:\\Users\\Public"              # Simple Windows path
  - "C:\\app\\data;C:\\plugin\\data" # Mapped Windows path
  - "\\\\server\\share"              # UNC network path
  - "C:\\logs;D:\\plugin\\logs"      # Map between different drives
```

#### Home Directory Expansion
```yaml
allowed_paths:
  - "~/Documents"                    # User home directory
  - "~/host/config:~/plugin/config"  # Mapped home directories
```

#### Complex Scenarios
```yaml
allowed_paths:
  # Root and system paths
  - "/"                              # Root directory (use with caution!)
  - "/usr/local/share:/plugin/share"
  
  # Application-specific paths
  - "/opt/myapp/data:/plugin/data"
  - "/etc/myapp/config:/plugin/config"
  
  # Paths with special characters
  - "/path/with spaces"
  - "/path-with-dashes"
  - "/path_with_underscores"
  - "/path.with.dots"
  
  # Deeply nested structures
  - "/very/deeply/nested/path/structure"
```

### Whitespace Handling

Whitespace around paths is automatically trimmed:

```yaml
allowed_paths:
  - "  /tmp  "                       # Treated as "/tmp"
  - "  /var/log  :  /plugin/logs  "  # Treated as "/var/log:/plugin/logs"
```

### Empty Plugin Path Behavior

If the plugin path is empty or contains only whitespace after the separator, the host path is used for both:

```yaml
allowed_paths:
  - "/tmp:"          # Equivalent to "/tmp" (plugin path defaults to host path)
  - "/var/log:  "    # Equivalent to "/var/log" (whitespace-only plugin path)
```

### Multiple Colons/Semicolons

Only the first separator is used to split the mapping. This allows paths to contain additional colons or semicolons:

**Unix:**
```yaml
allowed_paths:
  - "/host/path:/plugin/path:with:colons"  # Host: "/host/path", Plugin: "/plugin/path:with:colons"
```

**Windows:**
```yaml
allowed_paths:
  - "C:\\host;C:\\plugin;data"  # Host: "C:\host", Plugin: "C:\plugin;data"
```

### Use Cases

#### 1. Read-Only Configuration Access
```yaml
runtime_config:
  allowed_paths:
    - "/etc/myapp/config:/plugin/config"
```
Host configuration at `/etc/myapp/config` appears to the plugin at `/plugin/config`.

#### 2. Isolated Data Directories
```yaml
runtime_config:
  allowed_paths:
    - "/var/lib/myapp/plugin1:/plugin/data"
```
Each plugin gets its own isolated data directory mapped to a standard location.

#### 3. Multi-Environment Setup
```yaml
runtime_config:
  allowed_paths:
    - "/opt/production/data:/plugin/data"    # Production
    # - "/opt/staging/data:/plugin/data"     # Staging (commented out)
    # - "/opt/dev/data:/plugin/data"         # Development (commented out)
```

#### 4. Shared Resources
```yaml
runtime_config:
  allowed_paths:
    - "/tmp"                                  # Shared temp directory
    - "/usr/local/share:/plugin/shared"       # Shared libraries/resources
    - "/var/cache/myapp:/plugin/cache"        # Shared cache
```

#### 5. Cross-Platform Compatibility
```yaml
# Unix/Linux/macOS
allowed_paths:
  - "~/config:/plugin/config"
  - "/var/log:/plugin/logs"

# Windows equivalent
allowed_paths:
  - "C:\\Users\\username\\config;C:\\plugin\\config"
  - "C:\\logs;C:\\plugin\\logs"
```

### Complete Example

```yaml
plugins:
  file_processor:
    url: "oci://ghcr.io/myorg/file-processor:latest"
    runtime_config:
      allowed_hosts:
        - "api.example.com"
      allowed_paths:
        # Temporary workspace
        - "/tmp"
        
        # Configuration (read-only in practice)
        - "/etc/myapp/config:/plugin/config"
        
        # Input data (host path) -> Plugin working directory
        - "/var/lib/myapp/input:/plugin/input"
        
        # Output directory
        - "/var/lib/myapp/output:/plugin/output"
        
        # Logs (isolated per plugin)
        - "/var/log/myapp/file-processor:/plugin/logs"
        
        # Shared cache directory
        - "/var/cache/myapp:/plugin/cache"
      env_vars:
        PLUGIN_ENV: "production"
        LOG_LEVEL: "info"
      memory_limit: "1GB"
```

### Security Considerations

1. **Principle of Least Privilege**: Only grant access to paths that the plugin absolutely needs.
2. **Path Isolation**: Use path mapping to isolate plugins from each other's data.
3. **Avoid Root Access**: Avoid granting access to `/` unless absolutely necessary.
4. **Validate Paths**: Ensure paths exist and have appropriate permissions before configuring them.
5. **Use Mapping for Isolation**: Map host paths to plugin-specific locations to prevent plugins from knowing the actual host filesystem structure.

### Error Handling

- **Invalid Format**: Paths are parsed at configuration load time; invalid formats will cause startup errors.
- **Missing Separators**: If no separator is found, the entire string is treated as a simple path.
- **Empty Paths**: Empty path strings are not allowed and will cause configuration errors.

### Performance Notes

- Path configuration is parsed once at startup, not during runtime operations.
- Path mapping has minimal overhead during filesystem operations.
- Large numbers of allowed paths have negligible performance impact.

### Best Practices

1. **Use Descriptive Mappings**: Map host paths to clear, consistent plugin paths (e.g., `/plugin/config`, `/plugin/data`).
2. **Document Path Purpose**: Comment your path configurations to explain their purpose.
3. **Group Related Paths**: Organize paths by function (config, data, logs, cache).
4. **Version-Aware Paths**: Consider including version information in paths for easier upgrades.
5. **Environment-Specific Paths**: Use different path configurations for different environments (dev, staging, prod).
6. **Test Path Access**: Verify that plugins can actually access configured paths before deploying to production.

## Allowed Secrets Configuration

The `allowed_secrets` field provides fine-grained control over which system keyring entries a plugin can access. This enables secure secret management by explicitly whitelisting keyring credentials that plugins are permitted to retrieve.

### Purpose

Rather than allowing plugins unrestricted access to the system keyring, `allowed_secrets` implements a principle of least privilege by specifying exactly which keyring entries a plugin may access. This prevents plugins from accessing sensitive credentials they don't need.

### Entry Format

Each entry in `allowed_secrets` is an object with two required fields:

```yaml
allowed_secrets:
  - service: "service-name"
    user: "user-name"
```

- **service** (`string`, required): The service name of the keyring entry
- **user** (`string`, required): The user/account name of the keyring entry

### Basic Examples

#### Single Secret
```yaml
runtime_config:
  allowed_secrets:
    - service: "my-app"
      user: "admin"
```

#### Multiple Secrets
```yaml
runtime_config:
  allowed_secrets:
    - service: "database"
      user: "db_user"
    - service: "api-service"
      user: "api_key_user"
    - service: "s3-bucket"
      user: "backup-bot"
```

#### JSON Format
```json
{
  "runtime_config": {
    "allowed_secrets": [
      {
        "service": "my-app",
        "user": "admin"
      },
      {
        "service": "database",
        "user": "db_user"
      }
    ]
  }
}
```

### Use Cases

#### 1. Database Credentials
```yaml
plugins:
  db_backup:
    url: "oci://ghcr.io/myorg/db-backup:latest"
    runtime_config:
      allowed_secrets:
        - service: "postgres-prod"
          user: "backup-user"
        - service: "mysql-prod"
          user: "backup-user"
```

The plugin can only access these specific database credentials, not other secrets in the keyring.

#### 2. API Access
```yaml
plugins:
  api_client:
    url: "oci://ghcr.io/myorg/api-client:latest"
    runtime_config:
      allowed_secrets:
        - service: "github-api"
          user: "bot-token"
        - service: "slack-api"
          user: "webhook-url"
```

#### 3. Multi-Environment Credentials
```yaml
plugins:
  deployment_tool:
    url: "oci://ghcr.io/myorg/deployer:latest"
    runtime_config:
      allowed_secrets:
        - service: "aws-staging"
          user: "deploy-bot"
        - service: "aws-production"
          user: "deploy-bot"
        - service: "docker-registry"
          user: "ci-system"
```

#### 4. Service-Specific Access
```yaml
plugins:
  monitoring:
    url: "oci://ghcr.io/myorg/monitor:latest"
    runtime_config:
      allowed_secrets:
        - service: "datadog"
          user: "api-key"
        - service: "pagerduty"
          user: "integration-key"
      
  backup:
    url: "oci://ghcr.io/myorg/backup:latest"
    runtime_config:
      allowed_secrets:
        - service: "s3-backups"
          user: "backup-bot"
        # Note: This plugin cannot access monitoring secrets
```

### Setting Up Keyring Entries

Before a plugin can access a secret, the entry must exist in the system keyring. Here's how to create keyring entries that plugins can access:

#### macOS
```bash
# Add a secret that a plugin can access
security add-generic-password \
  -a "db_user" \
  -s "database" \
  -w "my-secret-password" \
  -T ""

# Verify it exists
security find-generic-password -a "db_user" -s "database"

# Delete if needed
security delete-generic-password -a "db_user" -s "database"
```

#### Linux
```bash
# Add a secret using secret-tool
echo "my-secret-password" | secret-tool store \
  --label="Database credentials" \
  service "database" \
  username "db_user"

# Verify it exists
secret-tool lookup service "database" username "db_user"

# Delete if needed
secret-tool clear service "database" username "db_user"
```

#### Windows (Command Prompt)
```cmd
REM Add a secret
cmdkey /generic:"database" /user:"db_user" /pass:"my-secret-password"

REM List credentials
cmdkey /list:"database"

REM Delete if needed
cmdkey /delete:"database"
```

#### Windows (PowerShell)
```powershell
# Add a secret
$password = ConvertTo-SecureString "my-secret-password" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential("db_user", $password)
# Note: Requires CredentialManager module or similar

# For generic credentials, use cmdkey or Windows Credential Manager GUI
```

### Special Characters in Service and User Names

The `allowed_secrets` field supports service and user names with special characters:

```yaml
allowed_secrets:
  # Dots and hyphens
  - service: "my-app.production"
    user: "admin@example.com"
  
  # Underscores
  - service: "service_with_underscore"
    user: "user-with-dash"
  
  # Slashes (useful for namespacing)
  - service: "company/project/service"
    user: "deploy-key"
  
  # Dots in user names
  - service: "api-gateway"
    user: "user.name@domain.com"
```

**Note**: When creating keyring entries with special characters, ensure they are properly escaped or quoted according to your shell's requirements.

### Complete Example

```yaml
plugins:
  enterprise_integration:
    url: "oci://ghcr.io/myorg/enterprise-integration:v2.1"
    runtime_config:
      # Network access
      allowed_hosts:
        - "api.enterprise.com"
        - "*.internal.company.com"
      
      # Filesystem access
      allowed_paths:
        - "/var/lib/myapp/cache:/plugin/cache"
        - "/etc/myapp/config:/plugin/config"
      
      # Keyring access (whitelist specific secrets)
      allowed_secrets:
        - service: "enterprise-api"
          user: "integration-key"
        - service: "database-prod"
          user: "app-user"
        - service: "s3-artifacts"
          user: "upload-bot"
      
      # Environment configuration
      env_vars:
        ENVIRONMENT: "production"
        LOG_LEVEL: "info"
      
      # Resource limits
      memory_limit: "2GB"
```

### Security Considerations

1. **Principle of Least Privilege**: Only grant access to secrets that the plugin absolutely needs. Each plugin should have its own minimal set of allowed secrets.

2. **Avoid Wildcards**: Unlike `allowed_hosts`, there is no wildcard support in `allowed_secrets`. Each entry must be explicitly specified, ensuring maximum security.

3. **Service Naming Convention**: Use consistent, descriptive service names:
   - Good: `"github-api"`, `"postgres-production"`, `"aws-s3-backups"`
   - Avoid: `"api"`, `"db"`, `"secret1"`

4. **User Naming Convention**: Use role-based or purpose-based user names:
   - Good: `"deploy-bot"`, `"backup-service"`, `"ci-system"`
   - Avoid: Personal names like `"john"`, `"alice"`

5. **Audit Secret Access**: Regularly review which plugins have access to which secrets. Remove entries that are no longer needed.

6. **Environment Separation**: Use different service names for different environments:
   ```yaml
   # Development
   - service: "api-dev"
     user: "test-key"
   
   # Production
   - service: "api-prod"
     user: "production-key"
   ```

7. **Secret Rotation**: When rotating secrets, only the keyring entries need to be updated—the configuration remains unchanged:
   ```bash
   # Update the secret in the keyring
   security add-generic-password -a "api-user" -s "my-service" -w "new-secret" -U
   
   # No config file changes needed!
   ```

### Validation and Error Handling

#### Configuration Validation
- Both `service` and `user` fields are required for each entry
- Empty strings are not allowed for `service` or `user`
- Duplicate entries are allowed (though redundant)
- The `allowed_secrets` array itself can be empty `[]` (no secrets allowed)
- The `allowed_secrets` field can be omitted entirely (no restrictions on secret access)

#### Runtime Behavior
- If a plugin attempts to access a keyring entry not in `allowed_secrets`, the access is denied
- If an allowed keyring entry doesn't exist, the plugin receives an appropriate error
- Keyring access failures are logged for security auditing

#### Common Errors

**"Secret not in allowed list"**
- The plugin is trying to access a keyring entry that isn't whitelisted
- Solution: Add the entry to `allowed_secrets` if it's legitimate

**"Keyring entry not found"**
- The specified service/user combination doesn't exist in the system keyring
- Solution: Create the keyring entry using the appropriate platform tool

**"Failed to access keyring"**
- The system keyring is locked or inaccessible
- Solution: Unlock the keyring or check permissions

### Performance Notes

- Secret validation is performed using hash-based lookups (O(1) complexity)
- Configuration is parsed once at startup, not during runtime
- Large numbers of allowed secrets have negligible performance impact
- Keyring access itself may have platform-specific performance characteristics

### Best Practices

1. **Document Secret Purpose**: Add comments explaining why each secret is needed:
   ```yaml
   allowed_secrets:
     # API authentication for external service
     - service: "external-api"
       user: "integration-token"
     
     # Database connection credentials
     - service: "postgres-prod"
       user: "app-reader"
   ```

2. **Group by Function**: Organize secrets by their purpose or system:
   ```yaml
   allowed_secrets:
     # Database credentials
     - service: "postgres-prod"
       user: "app-user"
     - service: "redis-cache"
       user: "cache-client"
     
     # External APIs
     - service: "github-api"
       user: "bot-token"
     - service: "slack-webhook"
       user: "notifications"
   ```

3. **Test Secret Access**: Before deploying, verify that:
   - All listed secrets exist in the keyring
   - The plugin can successfully access them
   - No additional secrets are needed

4. **Version Control Safety**: The config file only contains service/user identifiers, never actual secrets, making it safe to commit to version control.

5. **Environment-Specific Configs**: Use different configurations for different environments:
   ```yaml
   # config.dev.yaml
   allowed_secrets:
     - service: "api-dev"
       user: "test-token"
   
   # config.prod.yaml
   allowed_secrets:
     - service: "api-prod"
       user: "production-token"
   ```

6. **Regular Audits**: Periodically review and remove unnecessary secret permissions.

## Notes

- Fields marked as `optional` can be omitted.
- Plugin authors may extend `runtime_config` with additional fields, but only the above are officially recognized.
- Authentication applies to all HTTPS requests made by plugins, including plugin downloads and runtime API calls.
- URL matching is case-sensitive and based on string prefix matching.
- Keyring authentication requires platform-specific keyring services to be available and accessible.
- Skip tools patterns use full regex syntax with automatic anchoring for precise tool filtering.
- Allowed secrets provide fine-grained control over keyring access, implementing principle of least privilege for secret management.
- When `allowed_secrets` is omitted, plugins may have unrestricted keyring access (depending on plugin implementation). When specified, only the listed keyring entries can be accessed.