@amsterdamdatalabs/enact-extensions 0.1.0 → 0.1.1

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.
Files changed (152) hide show
  1. package/README.md +94 -20
  2. package/dist/index.d.ts +3 -3
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +2 -2
  5. package/dist/index.js.map +1 -1
  6. package/dist/install.d.ts +89 -0
  7. package/dist/install.d.ts.map +1 -1
  8. package/dist/install.js +219 -18
  9. package/dist/install.js.map +1 -1
  10. package/dist/validate/index.d.ts +21 -0
  11. package/dist/validate/index.d.ts.map +1 -1
  12. package/dist/validate/index.js +77 -0
  13. package/dist/validate/index.js.map +1 -1
  14. package/extensions/cmux/.agents/plugin.json +37 -0
  15. package/extensions/cmux/skills/cmux/SKILL.md +82 -0
  16. package/extensions/cmux/skills/cmux/agents/openai.yaml +4 -0
  17. package/extensions/cmux/skills/cmux/references/handles-and-identify.md +35 -0
  18. package/extensions/cmux/skills/cmux/references/panes-surfaces.md +37 -0
  19. package/extensions/cmux/skills/cmux/references/trigger-flash-and-health.md +23 -0
  20. package/extensions/cmux/skills/cmux/references/windows-workspaces.md +31 -0
  21. package/extensions/cmux/skills/cmux-vm-monitor/SKILL.md +122 -0
  22. package/extensions/cmux/skills/cmux-vm-monitor/agents/openai.yaml +4 -0
  23. package/extensions/cmux/skills/cmux-vm-monitor/references/cmux-commands.md +66 -0
  24. package/extensions/cmux/skills/cmux-vm-monitor/scripts/codex_vm_monitor.sh +45 -0
  25. package/extensions/cmux/skills/cmux-workspace/SKILL.md +93 -0
  26. package/extensions/dev-state/.agents/plugin.json +35 -0
  27. package/extensions/dev-state/skills/dev-state-plan-graduation/SKILL.md +194 -0
  28. package/extensions/dev-state/skills/dev-state-plan-graduation/agents/openai.yaml +4 -0
  29. package/extensions/dev-state/skills/dev-state-plan-graduation/references/reference.md +130 -0
  30. package/extensions/devops/.agents/plugin.json +36 -0
  31. package/extensions/devops/skills/azure-devops-cli/SKILL.md +431 -0
  32. package/extensions/devops/skills/azure-devops-cli/agents/openai.yaml +4 -0
  33. package/extensions/devops/skills/ci-pipeline-strategy/SKILL.md +217 -0
  34. package/extensions/devops/skills/ci-pipeline-strategy/agents/openai.yaml +4 -0
  35. package/{plugins/net-revenue-management/.codex-plugin → extensions/net-revenue-management/.agents}/plugin.json +10 -6
  36. package/extensions/plugin-dev/.agents/plugin.json +42 -0
  37. package/extensions/plugin-dev/.mcp.json +3 -0
  38. package/extensions/plugin-dev/agents/agent-creator.md +199 -0
  39. package/extensions/plugin-dev/agents/plugin-validator.md +91 -0
  40. package/extensions/plugin-dev/agents/skill-reviewer.md +212 -0
  41. package/extensions/plugin-dev/commands/_archive/create-marketplace.md +427 -0
  42. package/extensions/plugin-dev/commands/_archive/plugin-dev-guide.md +12 -0
  43. package/extensions/plugin-dev/commands/create-plugin.md +498 -0
  44. package/extensions/plugin-dev/commands/start.md +81 -0
  45. package/extensions/plugin-dev/hooks/hooks.json +3 -0
  46. package/extensions/plugin-dev/skills/agent-development/SKILL.md +641 -0
  47. package/extensions/plugin-dev/skills/agent-development/examples/agent-creation-prompt.md +250 -0
  48. package/extensions/plugin-dev/skills/agent-development/examples/complete-agent-examples.md +461 -0
  49. package/extensions/plugin-dev/skills/agent-development/references/advanced-agent-fields.md +246 -0
  50. package/extensions/plugin-dev/skills/agent-development/references/agent-creation-system-prompt.md +216 -0
  51. package/extensions/plugin-dev/skills/agent-development/references/permission-modes-rules.md +226 -0
  52. package/extensions/plugin-dev/skills/agent-development/references/system-prompt-design.md +464 -0
  53. package/extensions/plugin-dev/skills/agent-development/references/triggering-examples.md +474 -0
  54. package/extensions/plugin-dev/skills/agent-development/scripts/create-agent-skeleton.sh +176 -0
  55. package/extensions/plugin-dev/skills/agent-development/scripts/test-agent-trigger.sh +227 -0
  56. package/extensions/plugin-dev/skills/agent-development/scripts/validate-agent.sh +227 -0
  57. package/extensions/plugin-dev/skills/command-development/SKILL.md +763 -0
  58. package/extensions/plugin-dev/skills/command-development/examples/plugin-commands.md +612 -0
  59. package/extensions/plugin-dev/skills/command-development/examples/simple-commands.md +527 -0
  60. package/extensions/plugin-dev/skills/command-development/references/advanced-workflows.md +762 -0
  61. package/extensions/plugin-dev/skills/command-development/references/documentation-patterns.md +769 -0
  62. package/extensions/plugin-dev/skills/command-development/references/frontmatter-reference.md +508 -0
  63. package/extensions/plugin-dev/skills/command-development/references/interactive-commands.md +966 -0
  64. package/extensions/plugin-dev/skills/command-development/references/marketplace-considerations.md +943 -0
  65. package/extensions/plugin-dev/skills/command-development/references/plugin-features-reference.md +637 -0
  66. package/extensions/plugin-dev/skills/command-development/references/plugin-integration.md +191 -0
  67. package/extensions/plugin-dev/skills/command-development/references/skill-tool.md +447 -0
  68. package/extensions/plugin-dev/skills/command-development/references/testing-strategies.md +723 -0
  69. package/extensions/plugin-dev/skills/command-development/scripts/check-frontmatter.sh +234 -0
  70. package/extensions/plugin-dev/skills/command-development/scripts/validate-command.sh +160 -0
  71. package/extensions/plugin-dev/skills/hook-development/SKILL.md +861 -0
  72. package/extensions/plugin-dev/skills/hook-development/examples/load-context.sh +55 -0
  73. package/extensions/plugin-dev/skills/hook-development/examples/validate-bash.sh +57 -0
  74. package/extensions/plugin-dev/skills/hook-development/examples/validate-write.sh +48 -0
  75. package/extensions/plugin-dev/skills/hook-development/references/advanced.md +871 -0
  76. package/extensions/plugin-dev/skills/hook-development/references/hook-input-schemas.md +145 -0
  77. package/extensions/plugin-dev/skills/hook-development/references/migration.md +392 -0
  78. package/extensions/plugin-dev/skills/hook-development/references/patterns.md +430 -0
  79. package/extensions/plugin-dev/skills/hook-development/scripts/README.md +181 -0
  80. package/extensions/plugin-dev/skills/hook-development/scripts/hook-linter.sh +153 -0
  81. package/extensions/plugin-dev/skills/hook-development/scripts/test-hook.sh +276 -0
  82. package/extensions/plugin-dev/skills/hook-development/scripts/validate-hook-schema.sh +159 -0
  83. package/extensions/plugin-dev/skills/mcp-integration/SKILL.md +775 -0
  84. package/extensions/plugin-dev/skills/mcp-integration/examples/http-server.json +20 -0
  85. package/extensions/plugin-dev/skills/mcp-integration/examples/sse-server.json +19 -0
  86. package/extensions/plugin-dev/skills/mcp-integration/examples/stdio-server.json +38 -0
  87. package/extensions/plugin-dev/skills/mcp-integration/examples/ws-server.json +26 -0
  88. package/extensions/plugin-dev/skills/mcp-integration/references/authentication.md +601 -0
  89. package/extensions/plugin-dev/skills/mcp-integration/references/server-discovery.md +190 -0
  90. package/extensions/plugin-dev/skills/mcp-integration/references/server-types.md +572 -0
  91. package/extensions/plugin-dev/skills/mcp-integration/references/tool-usage.md +623 -0
  92. package/extensions/plugin-dev/skills/plugin-dev-guide/SKILL.md +222 -0
  93. package/extensions/plugin-dev/skills/plugin-structure/SKILL.md +705 -0
  94. package/extensions/plugin-dev/skills/plugin-structure/examples/advanced-plugin.md +774 -0
  95. package/extensions/plugin-dev/skills/plugin-structure/examples/minimal-plugin.md +83 -0
  96. package/extensions/plugin-dev/skills/plugin-structure/examples/standard-plugin.md +611 -0
  97. package/extensions/plugin-dev/skills/plugin-structure/references/advanced-topics.md +289 -0
  98. package/extensions/plugin-dev/skills/plugin-structure/references/component-patterns.md +592 -0
  99. package/extensions/plugin-dev/skills/plugin-structure/references/github-actions.md +233 -0
  100. package/extensions/plugin-dev/skills/plugin-structure/references/headless-ci-mode.md +193 -0
  101. package/extensions/plugin-dev/skills/plugin-structure/references/manifest-reference.md +625 -0
  102. package/extensions/plugin-dev/skills/plugin-structure/references/output-styles.md +116 -0
  103. package/extensions/plugin-dev/skills/skill-development/SKILL.md +564 -0
  104. package/extensions/plugin-dev/skills/skill-development/examples/complete-skill.md +465 -0
  105. package/extensions/plugin-dev/skills/skill-development/examples/frontmatter-templates.md +167 -0
  106. package/extensions/plugin-dev/skills/skill-development/examples/minimal-skill.md +111 -0
  107. package/extensions/plugin-dev/skills/skill-development/references/advanced-frontmatter.md +225 -0
  108. package/extensions/plugin-dev/skills/skill-development/references/commands-vs-skills.md +39 -0
  109. package/extensions/plugin-dev/skills/skill-development/references/skill-creation-workflow.md +379 -0
  110. package/extensions/plugin-dev/skills/skill-development/references/skill-creator-original.md +210 -0
  111. package/package.json +8 -11
  112. package/scripts/enact-extensions.mjs +751 -16
  113. package/scripts/hooks/session-start-drift-check.mjs +58 -0
  114. package/scripts/lib/build-index.mjs +50 -0
  115. package/scripts/lib/bundle-hash.mjs +137 -0
  116. package/scripts/lib/hooks.mjs +389 -0
  117. package/scripts/lib/ledger.mjs +162 -0
  118. package/scripts/lib/list-bundles.mjs +70 -0
  119. package/scripts/lib/outdated.mjs +144 -0
  120. package/scripts/lib/provision-mcp.mjs +369 -0
  121. package/scripts/lib/resolve-bundle.mjs +121 -0
  122. package/scripts/lib/run-install.mjs +321 -39
  123. package/scripts/lib/run-uninstall.mjs +220 -0
  124. package/scripts/lib/run-update.mjs +152 -0
  125. package/scripts/lib/run-validate.mjs +12 -18
  126. package/scripts/lib/serve.mjs +454 -0
  127. package/scripts/postinstall.mjs +63 -0
  128. package/scripts/setup-enact-context.sh +2 -2
  129. package/spec/index.json +59 -0
  130. package/web/assets/README.md +111 -0
  131. package/web/assets/logo-full.png +0 -0
  132. package/web/assets/logo-slim.png +0 -0
  133. package/web/assets/tokens/base.css +45 -0
  134. package/web/assets/tokens/colors.css +248 -0
  135. package/web/assets/tokens/effects.css +24 -0
  136. package/web/assets/tokens/fonts.css +8 -0
  137. package/web/assets/tokens/index.css +18 -0
  138. package/web/assets/tokens/spacing.css +50 -0
  139. package/web/index.html +1188 -0
  140. package/.agents/plugins/marketplace.json +0 -20
  141. package/catalog/enact-context.json +0 -9
  142. package/catalog/enact-factory.json +0 -7
  143. package/catalog/enact-operator.json +0 -7
  144. package/catalog/enact-wiki.json +0 -7
  145. package/catalog/net-revenue-management.json +0 -8
  146. package/scripts/rename-supervisor-to-operator.pl +0 -66
  147. package/scripts/sync-manifests.mjs +0 -23
  148. package/scripts/validate-catalog.mjs +0 -37
  149. package/scripts/validate-plugin.mjs +0 -10
  150. /package/{plugins → extensions}/net-revenue-management/.mcp.json +0 -0
  151. /package/{plugins → extensions}/net-revenue-management/skills/net-revenue-risks/SKILL.md +0 -0
  152. /package/{plugins → extensions}/net-revenue-management/skills/net-revenue-scenario/SKILL.md +0 -0
@@ -0,0 +1,20 @@
1
+ {
2
+ "_comment": "Example HTTP MCP server configuration for REST APIs",
3
+ "rest-api": {
4
+ "type": "http",
5
+ "url": "https://api.example.com/mcp",
6
+ "headers": {
7
+ "Authorization": "Bearer ${API_TOKEN}",
8
+ "Content-Type": "application/json",
9
+ "X-API-Version": "2024-01-01"
10
+ }
11
+ },
12
+ "internal-service": {
13
+ "type": "http",
14
+ "url": "https://api.example.com/mcp",
15
+ "headers": {
16
+ "Authorization": "Bearer ${API_TOKEN}",
17
+ "X-Service-Name": "claude-plugin"
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "_comment": "Example SSE MCP server configuration for hosted cloud services",
3
+ "asana": {
4
+ "type": "sse",
5
+ "url": "https://mcp.asana.com/sse"
6
+ },
7
+ "github": {
8
+ "type": "sse",
9
+ "url": "https://mcp.github.com/sse"
10
+ },
11
+ "custom-service": {
12
+ "type": "sse",
13
+ "url": "https://mcp.example.com/sse",
14
+ "headers": {
15
+ "X-API-Version": "v1",
16
+ "X-Client-ID": "${CLIENT_ID}"
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,38 @@
1
+ {
2
+ "_comment": "Example stdio MCP server configuration for local file system access",
3
+ "filesystem": {
4
+ "command": "npx",
5
+ "args": [
6
+ "-y",
7
+ "@modelcontextprotocol/server-filesystem",
8
+ "${CLAUDE_PROJECT_DIR}"
9
+ ],
10
+ "env": {
11
+ "LOG_LEVEL": "info"
12
+ }
13
+ },
14
+ "database": {
15
+ "command": "${CLAUDE_PLUGIN_ROOT}/servers/db-server.js",
16
+ "args": [
17
+ "--config",
18
+ "${CLAUDE_PLUGIN_ROOT}/config/db.json"
19
+ ],
20
+ "env": {
21
+ "DATABASE_URL": "${DATABASE_URL}",
22
+ "DB_POOL_SIZE": "10"
23
+ }
24
+ },
25
+ "custom-tools": {
26
+ "command": "python",
27
+ "args": [
28
+ "-m",
29
+ "my_mcp_server",
30
+ "--port",
31
+ "8080"
32
+ ],
33
+ "env": {
34
+ "API_KEY": "${CUSTOM_API_KEY}",
35
+ "DEBUG": "false"
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "_comment": "Example WebSocket MCP server configuration for real-time bidirectional communication",
3
+ "realtime-service": {
4
+ "type": "ws",
5
+ "url": "wss://mcp.example.com/ws",
6
+ "headers": {
7
+ "Authorization": "Bearer ${TOKEN}"
8
+ }
9
+ },
10
+ "streaming-data": {
11
+ "type": "ws",
12
+ "url": "wss://stream.example.com/mcp",
13
+ "headers": {
14
+ "X-API-Key": "${API_KEY}",
15
+ "X-Client-ID": "${CLIENT_ID}"
16
+ }
17
+ },
18
+ "live-updates": {
19
+ "type": "ws",
20
+ "url": "wss://live.example.com/mcp/v1",
21
+ "headers": {
22
+ "Authorization": "Bearer ${WS_TOKEN}",
23
+ "X-Connection-Type": "persistent"
24
+ }
25
+ }
26
+ }
@@ -0,0 +1,601 @@
1
+ # MCP Authentication Patterns
2
+
3
+ Complete guide to authentication methods for MCP servers in Claude Code plugins.
4
+
5
+ ## Overview
6
+
7
+ MCP servers support multiple authentication methods depending on the server type and service requirements. Choose the method that best matches your use case and security requirements.
8
+
9
+ ## OAuth (Automatic)
10
+
11
+ ### How It Works
12
+
13
+ Claude Code automatically handles the complete OAuth 2.0 flow (with PKCE) for SSE and HTTP servers:
14
+
15
+ 1. User attempts to use MCP tool
16
+ 2. Claude Code detects authentication is needed
17
+ 3. Initiates OAuth 2.0 Authorization Code flow with PKCE (Proof Key for Code Exchange)
18
+ 4. Opens browser for OAuth consent
19
+ 5. User authorizes in browser
20
+ 6. Claude Code exchanges the authorization code for tokens
21
+ 7. Tokens stored securely by Claude Code
22
+ 8. Automatic token refresh using refresh tokens
23
+
24
+ PKCE provides additional security for public clients by preventing authorization code interception attacks. Claude Code also supports pre-configured OAuth credentials for MCP servers that provide them.
25
+
26
+ ### Configuration
27
+
28
+ ```json
29
+ {
30
+ "service": {
31
+ "type": "sse",
32
+ "url": "https://mcp.example.com/sse"
33
+ }
34
+ }
35
+ ```
36
+
37
+ No additional auth configuration needed! Claude Code handles everything.
38
+
39
+ ### Supported Services
40
+
41
+ **Known OAuth-enabled MCP servers:**
42
+
43
+ - Asana: `https://mcp.asana.com/sse`
44
+ - GitHub (when available)
45
+ - Google services (when available)
46
+ - Custom OAuth servers
47
+
48
+ ### OAuth Scopes
49
+
50
+ OAuth scopes are determined by the MCP server. Users see required scopes during the consent flow.
51
+
52
+ **Document required scopes in your README:**
53
+
54
+ ```markdown
55
+ ## Authentication
56
+
57
+ This plugin requires the following Asana permissions:
58
+
59
+ - Read tasks and projects
60
+ - Create and update tasks
61
+ - Access workspace data
62
+ ```
63
+
64
+ ### Token Storage
65
+
66
+ Tokens are stored securely by Claude Code:
67
+
68
+ - Not accessible to plugins
69
+ - Encrypted at rest
70
+ - Automatic refresh
71
+ - Cleared on sign-out
72
+
73
+ ### Troubleshooting OAuth
74
+
75
+ **Authentication loop:**
76
+
77
+ - Clear cached tokens (sign out and sign in)
78
+ - Check OAuth redirect URLs
79
+ - Verify server OAuth configuration
80
+
81
+ **Scope issues:**
82
+
83
+ - User may need to re-authorize for new scopes
84
+ - Check server documentation for required scopes
85
+
86
+ **Token expiration:**
87
+
88
+ - Claude Code auto-refreshes
89
+ - If refresh fails, prompts re-authentication
90
+
91
+ ## CLI OAuth Setup
92
+
93
+ For MCP servers requiring OAuth 2.0, use CLI flags to pre-configure credentials:
94
+
95
+ ```bash
96
+ claude mcp add --transport http my-service https://api.example.com/mcp \
97
+ --client-id "your-client-id" \
98
+ --client-secret \
99
+ --callback-port 8080
100
+ ```
101
+
102
+ - `--client-id` — OAuth client ID
103
+ - `--client-secret` — prompts for secret (hidden input); or set `MCP_CLIENT_SECRET` env var
104
+ - `--callback-port` — local port for OAuth callback (default varies by server)
105
+
106
+ For interactive OAuth setup, use the `/mcp` command within Claude Code to authenticate via browser.
107
+
108
+ ## Token-Based Authentication
109
+
110
+ ### Bearer Tokens
111
+
112
+ Most common for HTTP and WebSocket servers.
113
+
114
+ **Configuration:**
115
+
116
+ ```json
117
+ {
118
+ "api": {
119
+ "type": "http",
120
+ "url": "https://api.example.com/mcp",
121
+ "headers": {
122
+ "Authorization": "Bearer ${API_TOKEN}"
123
+ }
124
+ }
125
+ }
126
+ ```
127
+
128
+ **Environment variable:**
129
+
130
+ ```bash
131
+ export API_TOKEN="your-secret-token-here"
132
+ ```
133
+
134
+ ### API Keys
135
+
136
+ Alternative to Bearer tokens, often in custom headers.
137
+
138
+ **Configuration:**
139
+
140
+ ```json
141
+ {
142
+ "api": {
143
+ "type": "http",
144
+ "url": "https://api.example.com/mcp",
145
+ "headers": {
146
+ "X-API-Key": "${API_KEY}",
147
+ "X-API-Secret": "${API_SECRET}"
148
+ }
149
+ }
150
+ }
151
+ ```
152
+
153
+ ### Custom Headers
154
+
155
+ Services may use custom authentication headers.
156
+
157
+ **Configuration:**
158
+
159
+ ```json
160
+ {
161
+ "service": {
162
+ "type": "sse",
163
+ "url": "https://mcp.example.com/sse",
164
+ "headers": {
165
+ "X-Auth-Token": "${AUTH_TOKEN}",
166
+ "X-User-ID": "${USER_ID}",
167
+ "X-Tenant-ID": "${TENANT_ID}"
168
+ }
169
+ }
170
+ }
171
+ ```
172
+
173
+ ### Documenting Token Requirements
174
+
175
+ Always document in your README:
176
+
177
+ ```markdown
178
+ ## Setup
179
+
180
+ ### Required Environment Variables
181
+
182
+ Set these environment variables before using the plugin:
183
+
184
+ \`\`\`bash
185
+ export API_TOKEN="your-token-here"
186
+ export API_SECRET="your-secret-here"
187
+ \`\`\`
188
+
189
+ ### Obtaining Tokens
190
+
191
+ 1. Visit https://api.example.com/tokens
192
+ 2. Create a new API token
193
+ 3. Copy the token and secret
194
+ 4. Set environment variables as shown above
195
+
196
+ ### Token Permissions
197
+
198
+ The API token needs the following permissions:
199
+
200
+ - Read access to resources
201
+ - Write access for creating items
202
+ - Delete access (optional, for cleanup operations)
203
+ \`\`\`
204
+ ```
205
+
206
+ ## Environment Variable Authentication (stdio)
207
+
208
+ ### Passing Credentials to Server
209
+
210
+ For stdio servers, pass credentials via environment variables:
211
+
212
+ ```json
213
+ {
214
+ "database": {
215
+ "command": "python",
216
+ "args": ["-m", "mcp_server_db"],
217
+ "env": {
218
+ "DATABASE_URL": "${DATABASE_URL}",
219
+ "DB_USER": "${DB_USER}",
220
+ "DB_PASSWORD": "${DB_PASSWORD}"
221
+ }
222
+ }
223
+ }
224
+ ```
225
+
226
+ ### User Environment Variables
227
+
228
+ ```bash
229
+ # User sets these in their shell
230
+ export DATABASE_URL="postgresql://localhost/mydb"
231
+ export DB_USER="myuser"
232
+ export DB_PASSWORD="mypassword"
233
+ ```
234
+
235
+ ### Documentation Template
236
+
237
+ ```markdown
238
+ ## Database Configuration
239
+
240
+ Set these environment variables:
241
+
242
+ \`\`\`bash
243
+ export DATABASE_URL="postgresql://host:port/database"
244
+ export DB_USER="username"
245
+ export DB_PASSWORD="password"
246
+ \`\`\`
247
+
248
+ Or create a `.env` file (add to `.gitignore`):
249
+
250
+ \`\`\`
251
+ DATABASE_URL=postgresql://localhost:5432/mydb
252
+ DB_USER=myuser
253
+ DB_PASSWORD=mypassword
254
+ \`\`\`
255
+
256
+ Load with: \`source .env\` or \`export $(cat .env | xargs)\`
257
+ \`\`\`
258
+ ```
259
+
260
+ ## Dynamic Headers
261
+
262
+ ### Headers Helper Script
263
+
264
+ For tokens that change or expire, use a helper script:
265
+
266
+ ```json
267
+ {
268
+ "api": {
269
+ "type": "sse",
270
+ "url": "https://api.example.com",
271
+ "headersHelper": "${CLAUDE_PLUGIN_ROOT}/scripts/get-headers.sh"
272
+ }
273
+ }
274
+ ```
275
+
276
+ **Script (get-headers.sh):**
277
+
278
+ ```bash
279
+ #!/bin/bash
280
+ # Generate dynamic authentication headers
281
+
282
+ # Fetch fresh token
283
+ TOKEN=$(get-fresh-token-from-somewhere)
284
+
285
+ # Output JSON headers
286
+ cat <<EOF
287
+ {
288
+ "Authorization": "Bearer $TOKEN",
289
+ "X-Timestamp": "$(date -Iseconds)"
290
+ }
291
+ EOF
292
+ ```
293
+
294
+ ### Use Cases for Dynamic Headers
295
+
296
+ - Short-lived tokens that need refresh
297
+ - Tokens with HMAC signatures
298
+ - Time-based authentication
299
+ - Dynamic tenant/workspace selection
300
+
301
+ ## Security Best Practices
302
+
303
+ ### DO
304
+
305
+ ✅ **Use environment variables:**
306
+
307
+ ```json
308
+ {
309
+ "headers": {
310
+ "Authorization": "Bearer ${API_TOKEN}"
311
+ }
312
+ }
313
+ ```
314
+
315
+ ✅ **Document required variables in README**
316
+
317
+ ✅ **Use HTTPS/WSS always**
318
+
319
+ ✅ **Implement token rotation**
320
+
321
+ ✅ **Store tokens securely (env vars, not files)**
322
+
323
+ ✅ **Let OAuth handle authentication when available**
324
+
325
+ ### DON'T
326
+
327
+ ❌ **Hardcode tokens:**
328
+
329
+ ```json
330
+ {
331
+ "headers": {
332
+ "Authorization": "Bearer sk-abc123..." // NEVER!
333
+ }
334
+ }
335
+ ```
336
+
337
+ ❌ **Commit tokens to git**
338
+
339
+ ❌ **Share tokens in documentation**
340
+
341
+ ❌ **Use HTTP instead of HTTPS**
342
+
343
+ ❌ **Store tokens in plugin files**
344
+
345
+ ❌ **Log tokens or sensitive headers**
346
+
347
+ ## Multi-Tenancy Patterns
348
+
349
+ ### Workspace/Tenant Selection
350
+
351
+ **Via environment variable:**
352
+
353
+ ```json
354
+ {
355
+ "api": {
356
+ "type": "http",
357
+ "url": "https://api.example.com/mcp",
358
+ "headers": {
359
+ "Authorization": "Bearer ${API_TOKEN}",
360
+ "X-Workspace-ID": "${WORKSPACE_ID}"
361
+ }
362
+ }
363
+ }
364
+ ```
365
+
366
+ **Via URL:**
367
+
368
+ ```json
369
+ {
370
+ "api": {
371
+ "type": "http",
372
+ "url": "https://${TENANT_ID}.api.example.com/mcp"
373
+ }
374
+ }
375
+ ```
376
+
377
+ ### Per-User Configuration
378
+
379
+ Users set their own workspace:
380
+
381
+ ```bash
382
+ export WORKSPACE_ID="my-workspace-123"
383
+ export TENANT_ID="my-company"
384
+ ```
385
+
386
+ ## Authentication Troubleshooting
387
+
388
+ ### Common Issues
389
+
390
+ **401 Unauthorized:**
391
+
392
+ - Check token is set correctly
393
+ - Verify token hasn't expired
394
+ - Check token has required permissions
395
+ - Ensure header format is correct
396
+
397
+ **403 Forbidden:**
398
+
399
+ - Token valid but lacks permissions
400
+ - Check scope/permissions
401
+ - Verify workspace/tenant ID
402
+ - May need admin approval
403
+
404
+ **Token not found:**
405
+
406
+ ```bash
407
+ # Check environment variable is set
408
+ echo $API_TOKEN
409
+
410
+ # If empty, set it
411
+ export API_TOKEN="your-token"
412
+ ```
413
+
414
+ **Token in wrong format:**
415
+
416
+ ```json
417
+ // Correct
418
+ "Authorization": "Bearer sk-abc123"
419
+
420
+ // Wrong
421
+ "Authorization": "sk-abc123"
422
+ ```
423
+
424
+ ### Debugging Authentication
425
+
426
+ **Enable debug mode:**
427
+
428
+ ```bash
429
+ claude --debug
430
+ ```
431
+
432
+ Look for:
433
+
434
+ - Authentication header values (sanitized)
435
+ - OAuth flow progress
436
+ - Token refresh attempts
437
+ - Authentication errors
438
+
439
+ **Test authentication separately:**
440
+
441
+ ```bash
442
+ # Test HTTP endpoint
443
+ curl -H "Authorization: Bearer $API_TOKEN" \
444
+ https://api.example.com/mcp/health
445
+
446
+ # Should return 200 OK
447
+ ```
448
+
449
+ ## Migration Patterns
450
+
451
+ ### From Hardcoded to Environment Variables
452
+
453
+ **Before:**
454
+
455
+ ```json
456
+ {
457
+ "headers": {
458
+ "Authorization": "Bearer sk-hardcoded-token"
459
+ }
460
+ }
461
+ ```
462
+
463
+ **After:**
464
+
465
+ ```json
466
+ {
467
+ "headers": {
468
+ "Authorization": "Bearer ${API_TOKEN}"
469
+ }
470
+ }
471
+ ```
472
+
473
+ **Migration steps:**
474
+
475
+ 1. Add environment variable to plugin README
476
+ 2. Update configuration to use ${VAR}
477
+ 3. Test with variable set
478
+ 4. Remove hardcoded value
479
+ 5. Commit changes
480
+
481
+ ### From Basic Auth to OAuth
482
+
483
+ **Before:**
484
+
485
+ ```json
486
+ {
487
+ "headers": {
488
+ "Authorization": "Basic ${BASE64_CREDENTIALS}"
489
+ }
490
+ }
491
+ ```
492
+
493
+ **After:**
494
+
495
+ ```json
496
+ {
497
+ "type": "sse",
498
+ "url": "https://mcp.example.com/sse"
499
+ }
500
+ ```
501
+
502
+ **Benefits:**
503
+
504
+ - Better security
505
+ - No credential management
506
+ - Automatic token refresh
507
+ - Scoped permissions
508
+
509
+ ## Advanced Authentication
510
+
511
+ ### Mutual TLS (mTLS)
512
+
513
+ Some enterprise services require client certificates.
514
+
515
+ **Not directly supported in MCP configuration.**
516
+
517
+ **Workaround:** Wrap in stdio server that handles mTLS:
518
+
519
+ ```json
520
+ {
521
+ "secure-api": {
522
+ "command": "${CLAUDE_PLUGIN_ROOT}/servers/mtls-wrapper",
523
+ "args": ["--cert", "${CLIENT_CERT}", "--key", "${CLIENT_KEY}"],
524
+ "env": {
525
+ "API_URL": "https://secure.example.com"
526
+ }
527
+ }
528
+ }
529
+ ```
530
+
531
+ ### JWT Tokens
532
+
533
+ Generate JWT tokens dynamically with headers helper:
534
+
535
+ ```bash
536
+ #!/bin/bash
537
+ # generate-jwt.sh
538
+
539
+ # Generate JWT (using library or API call)
540
+ JWT=$(generate-jwt-token)
541
+
542
+ echo "{\"Authorization\": \"Bearer $JWT\"}"
543
+ ```
544
+
545
+ ```json
546
+ {
547
+ "headersHelper": "${CLAUDE_PLUGIN_ROOT}/scripts/generate-jwt.sh"
548
+ }
549
+ ```
550
+
551
+ ### HMAC Signatures
552
+
553
+ For APIs requiring request signing:
554
+
555
+ ```bash
556
+ #!/bin/bash
557
+ # generate-hmac.sh
558
+
559
+ TIMESTAMP=$(date -Iseconds)
560
+ SIGNATURE=$(echo -n "$TIMESTAMP" | openssl dgst -sha256 -hmac "$SECRET_KEY" | cut -d' ' -f2)
561
+
562
+ cat <<EOF
563
+ {
564
+ "X-Timestamp": "$TIMESTAMP",
565
+ "X-Signature": "$SIGNATURE",
566
+ "X-API-Key": "$API_KEY"
567
+ }
568
+ EOF
569
+ ```
570
+
571
+ ## Best Practices Summary
572
+
573
+ ### For Plugin Developers
574
+
575
+ 1. **Prefer OAuth** when service supports it
576
+ 2. **Use environment variables** for tokens
577
+ 3. **Document all required variables** in README
578
+ 4. **Provide setup instructions** with examples
579
+ 5. **Never commit credentials**
580
+ 6. **Use HTTPS/WSS only**
581
+ 7. **Test authentication thoroughly**
582
+
583
+ ### For Plugin Users
584
+
585
+ 1. **Set environment variables** before using plugin
586
+ 2. **Keep tokens secure** and private
587
+ 3. **Rotate tokens regularly**
588
+ 4. **Use different tokens** for dev/prod
589
+ 5. **Don't commit .env files** to git
590
+ 6. **Review OAuth scopes** before authorizing
591
+
592
+ ## Conclusion
593
+
594
+ Choose the authentication method that matches your MCP server's requirements:
595
+
596
+ - **OAuth** for cloud services (easiest for users)
597
+ - **Bearer tokens** for API services
598
+ - **Environment variables** for stdio servers
599
+ - **Dynamic headers** for complex auth flows
600
+
601
+ Always prioritize security and provide clear setup documentation for users.