knowzcode 0.1.0 → 0.2.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 (59) hide show
  1. package/.claude-plugin/marketplace.json +6 -3
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +132 -73
  4. package/agents/analyst.md +24 -62
  5. package/agents/architect.md +34 -43
  6. package/agents/builder.md +35 -86
  7. package/agents/closer.md +29 -87
  8. package/agents/context-scout.md +54 -0
  9. package/agents/knowledge-migrator.md +7 -7
  10. package/agents/knowz-scout.md +83 -0
  11. package/agents/knowz-scribe.md +155 -0
  12. package/agents/microfix-specialist.md +1 -6
  13. package/agents/reviewer.md +43 -91
  14. package/agents/update-coordinator.md +7 -18
  15. package/bin/knowzcode.mjs +94 -7
  16. package/commands/audit.md +156 -25
  17. package/commands/connect-mcp.md +525 -507
  18. package/commands/fix.md +8 -8
  19. package/commands/init.md +9 -5
  20. package/commands/learn.md +327 -308
  21. package/commands/plan.md +160 -26
  22. package/commands/register.md +21 -12
  23. package/commands/status.md +309 -291
  24. package/commands/telemetry.md +188 -188
  25. package/commands/work.md +577 -114
  26. package/knowzcode/automation_manifest.md +59 -59
  27. package/knowzcode/claude_code_execution.md +228 -22
  28. package/knowzcode/enterprise/compliance_manifest.md +2 -0
  29. package/knowzcode/knowzcode_loop.md +111 -45
  30. package/knowzcode/knowzcode_project.md +48 -233
  31. package/knowzcode/knowzcode_vaults.md +183 -54
  32. package/knowzcode/mcp_config.md +72 -47
  33. package/knowzcode/platform_adapters.md +43 -4
  34. package/knowzcode/prompts/Execute_Micro_Fix.md +57 -57
  35. package/knowzcode/prompts/Investigate_Codebase.md +227 -227
  36. package/knowzcode/prompts/Migrate_Knowledge.md +301 -301
  37. package/knowzcode/prompts/Refactor_Node.md +72 -72
  38. package/knowzcode/prompts/Spec_Verification_Checkpoint.md +59 -59
  39. package/knowzcode/prompts/[LOOP_1A]__Propose_Change_Set.md +52 -52
  40. package/knowzcode/prompts/[LOOP_1B]__Draft_Specs.md +75 -75
  41. package/knowzcode/prompts/[LOOP_2A]__Implement_Change_Set.md +55 -55
  42. package/knowzcode/prompts/[LOOP_2B]__Verify_Implementation.md +72 -72
  43. package/knowzcode/prompts/[LOOP_3]__Finalize_And_Commit.md +67 -67
  44. package/package.json +1 -1
  45. package/skills/alias-resolver.json +1 -1
  46. package/skills/architecture-diff.json +1 -1
  47. package/skills/check-installation-status.json +1 -1
  48. package/skills/continue.md +24 -4
  49. package/skills/environment-guard.json +1 -1
  50. package/skills/generate-workgroup-id.json +1 -1
  51. package/skills/install-knowzcode.json +1 -1
  52. package/skills/load-core-context.json +1 -1
  53. package/skills/log-entry-builder.json +1 -1
  54. package/skills/spec-quality-check.json +1 -1
  55. package/skills/spec-template.json +1 -1
  56. package/skills/spec-validator.json +1 -1
  57. package/skills/tracker-scan.json +1 -1
  58. package/skills/tracker-update.json +1 -1
  59. package/skills/validate-installation.json +1 -1
@@ -1,507 +1,525 @@
1
- ---
2
- description: Configure KnowzCode MCP server for vector-powered code search and context
3
- ---
4
-
5
- # KnowzCode MCP Server Connection
6
-
7
- You are the **KnowzCode MCP Connection Agent**. Your task is to configure the KnowzCode MCP (Model Context Protocol) server to enable advanced AI-powered code search and context retrieval.
8
-
9
- ## Command Syntax
10
-
11
- ```bash
12
- /kc:connect-mcp <api-key> [--endpoint <url>] [--scope <local|project|user>] [--dev] [--configure-vaults]
13
- ```
14
-
15
- **Note:** If you don't have an API key yet, run `/kc:register` to create an account and get one automatically.
16
- Registration also auto-configures your vault - no manual setup needed!
17
-
18
- **Parameters:**
19
- - `<api-key>` - Required. Your KnowzCode API key (or omit for interactive prompt)
20
- - `--endpoint <url>` - Optional. Custom MCP endpoint (overrides environment default)
21
- - `--scope <scope>` - Optional. Configuration scope: local (default), project, or user
22
- - `--dev` - Optional. Use development environment instead of production
23
- - `--configure-vaults` - Optional. Force vault configuration prompts (even if already configured)
24
-
25
- **Environments:**
26
- | Environment | Endpoint | When to Use |
27
- |:------------|:---------|:------------|
28
- | **Production** (default) | `https://mcp.knowz.io/mcp` | Normal usage |
29
- | **Development** | `https://mcp.dev.knowz.io/mcp` | Testing new features |
30
-
31
- **Examples:**
32
- ```bash
33
- # Basic usage (production - default)
34
- /kc:connect-mcp kz_live_abc123...
35
-
36
- # Interactive mode (production)
37
- /kc:connect-mcp
38
-
39
- # Development environment
40
- /kc:connect-mcp kz_test_abc123... --dev
41
-
42
- # Self-hosted endpoint
43
- /kc:connect-mcp kz_live_abc123... --endpoint https://your-domain.com/mcp
44
-
45
- # Project-wide configuration (production)
46
- /kc:connect-mcp kz_live_team456... --scope project
47
-
48
- # Development with project scope
49
- /kc:connect-mcp kz_test_team456... --dev --scope project
50
- ```
51
-
52
- ## What This Enables
53
-
54
- Once connected, you gain access to powerful vector-based tools:
55
-
56
- - **`search_knowledge`** - Vector similarity search across vaults (code or research)
57
- - **`ask_question`** - AI-powered Q&A with optional research mode
58
- - **`create_knowledge`** - Save learnings to research vault (used by finalization)
59
- - **`update_knowledge`** - Update existing knowledge items
60
- - **`find_entities`** - Find people, locations, or events in your knowledge
61
-
62
- ### Dual Vault Architecture
63
-
64
- KnowzCode uses two vault types for optimal search:
65
-
66
- | Vault Type | Purpose | Query Examples |
67
- |------------|---------|----------------|
68
- | **Code Vault** | Indexed source code (AST-chunked) | "Find auth middleware", "JWT validation" |
69
- | **Research Vault** | Architecture, conventions, learnings | "Error handling conventions", "Why Redis?" |
70
-
71
- These tools integrate seamlessly with all KnowzCode agents, enhancing their capabilities with project-wide context awareness.
72
-
73
- ## Your Task
74
-
75
- Configure the KnowzCode MCP server using Claude Code's built-in MCP management.
76
-
77
- ### Steps to Execute
78
-
79
- 1. **Parse command arguments**
80
- - Extract API key from first positional argument (if provided)
81
- - Parse `--dev` flag to determine environment
82
- - Parse `--endpoint <url>` flag (overrides environment default if provided)
83
- - Default endpoint: `https://mcp.knowz.io/mcp` (production)
84
- - With `--dev` flag: `https://mcp.dev.knowz.io/mcp` (development)
85
- - Parse `--scope <scope>` flag (default: `local`)
86
- - Parse `--configure-vaults` flag (forces vault prompts)
87
- - Store parsed values for use in configuration
88
-
89
- 2. **Check for existing configuration**
90
- - Check if MCP server already configured: `claude mcp get knowzcode`
91
- - If already configured, ask if user wants to reconfigure
92
- - If yes, run `claude mcp remove knowzcode` first
93
-
94
- 3. **Prompt for API key (if not provided)**
95
- - If no API key in arguments, prompt user interactively:
96
- ```
97
- Enter your KnowzCode API key
98
- (Get one at https://knowz.io/api-keys)
99
- ```
100
- - Validate format (should start with `kz_live_` or `kz_test_`)
101
- - Never display the full API key back to user
102
-
103
- 4. **Confirm scope (if not provided)**
104
- - If `--scope` not provided, ask user which scope to use:
105
- - **local** (default): Only this project, private to you
106
- - **project**: Shared with team via `.mcp.json` (committed to git)
107
- - **user**: Available across all your projects
108
-
109
- Present as options to user if not specified in command.
110
-
111
- 5. **Validate endpoint URL (if custom)**
112
- - If custom endpoint provided via `--endpoint`, validate it's a valid URL
113
- - Ensure it starts with `https://` (or `http://` for local dev)
114
- - Show which endpoint will be used
115
-
116
- 6. **Configure Vault IDs (Conditional with Discovery)**
117
-
118
- First, check if vaults are already configured in `knowzcode/knowzcode_vaults.md`:
119
- - Read the file and check for connected vaults section
120
-
121
- **If vaults already configured AND `--configure-vaults` NOT set:**
122
- - Skip vault prompts entirely
123
- - Display:
124
- ```
125
- Vaults already configured (from previous setup or /kc:register):
126
- {List vaults from knowzcode_vaults.md}
127
-
128
- To reconfigure vaults, run: /kc:connect-mcp --configure-vaults
129
- ```
130
-
131
- **If vaults NOT configured OR `--configure-vaults` IS set:**
132
-
133
- **Step 6a: Fetch available vaults using list_vaults()**
134
-
135
- Call the `list_vaults` MCP tool to discover available vaults:
136
- ```
137
- list_vaults(includeStats: true)
138
- ```
139
-
140
- If successful, display available vaults:
141
- ```
142
- ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
143
- ◆ VAULT DISCOVERY
144
- ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
145
-
146
- Fetching your available vaults...
147
-
148
- Available Vaults:
149
- ┌────┬──────────────────────┬──────────────────┬───────────┐
150
- │ # │ Name │ Type │ Documents │
151
- ├────┼──────────────────────┼──────────────────┼───────────┤
152
- │ 1 │ KnowzCode │ research │ 42 │
153
- 2my-project-code code 1,234
154
- 3team-wiki research 89
155
- └────┴──────────────────────┴──────────────────┴───────────┘
156
- ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
157
- ```
158
-
159
- If `list_vaults` fails or returns empty:
160
- - Fall back to manual vault ID entry (legacy behavior)
161
- - Prompt:
162
- ```
163
- Could not fetch vaults automatically.
164
-
165
- Enter vault IDs manually:
166
-
167
- Research Vault ID (required for /kc:learn):
168
- Get from: https://knowz.io/vaults
169
-
170
- Code Vault ID (optional):
171
- Leave blank to use grep/glob for code search
172
- ```
173
-
174
- **Step 6b: Interactive vault selection**
175
-
176
- For each discovered vault, ask if user wants to connect it:
177
-
178
- ```
179
- Would you like to connect "KnowzCode" (research)?
180
- ```
181
- Use AskUserQuestion with options: [Yes] [No]
182
-
183
- **If "Yes":**
184
- - Prompt for description:
185
- ```
186
- Describe what this vault contains (for intelligent routing):
187
-
188
- Tips for good descriptions:
189
- Be specific about content type
190
- Include example queries that should route here
191
- Mention key topics covered
192
-
193
- Examples:
194
- • "Team learnings, conventions, architectural decisions. Use for 'why did we choose X?' questions."
195
- • "Source code for the main API. Use for 'where is X defined?' questions."
196
- ```
197
-
198
- - Collect description via AskUserQuestion (free text input)
199
-
200
- **Step 6c: Loop for additional vaults**
201
-
202
- After each vault selection:
203
- ```
204
- Would you like to connect another vault?
205
- ```
206
- Options: [Yes] [No]
207
-
208
- - If "Yes" and more vaults available: Continue selection loop
209
- - If "No" or no more vaults: Exit loop
210
-
211
- **Step 6d: Write vault configuration**
212
-
213
- Write selected vaults to `knowzcode/knowzcode_vaults.md`:
214
-
215
- ```markdown
216
- # KnowzCode Vault Configuration
217
-
218
- Multi-vault routing configuration for intelligent vault selection.
219
-
220
- ---
221
-
222
- ## Connected Vaults
223
-
224
- ### {vault_id_1}
225
- - **Name**: {vault_name}
226
- - **ID**: {vault_id}
227
- - **Type**: {code | research}
228
- - **Description**: {user_provided_description}
229
-
230
- ### {vault_id_2}
231
- - **Name**: {vault_name}
232
- - **ID**: {vault_id}
233
- - **Type**: {code | research}
234
- - **Description**: {user_provided_description}
235
-
236
- ---
237
-
238
- ## Vault Routing Rules
239
-
240
- - **Code questions** (implementations, files, structure) → {first code vault ID}
241
- - **Convention questions** (patterns, decisions, best practices) → {first research vault ID}
242
- - **Learning capture** → {default research vault ID}
243
- ```
244
-
245
- **Also update `knowzcode/mcp_config.md`** to reflect primary vault (for backwards compatibility):
246
- - Set Research Vault ID to first research vault selected
247
- - Set Code Vault ID to first code vault selected (or "not configured")
248
-
249
- **Step 6e: Show vault configuration summary**
250
-
251
- ```
252
- Vault configuration saved to knowzcode/knowzcode_vaults.md
253
-
254
- Connected Vaults:
255
- KnowzCode (research) - "Team learnings and conventions"
256
- my-code (code) - "Source code for API project"
257
-
258
- Routing:
259
- Code questions my-code
260
- • Convention questions → KnowzCode
261
- Learning capture KnowzCode
262
-
263
- You can edit knowzcode/knowzcode_vaults.md to update descriptions or routing rules.
264
- ```
265
-
266
- 7. **Add MCP server using CLI**
267
- ```bash
268
- claude mcp add --transport http \
269
- --scope <chosen-scope> \
270
- knowzcode \
271
- <endpoint-url> \
272
- --header "Authorization: Bearer <api-key>" \
273
- --header "X-Project-Path: $(pwd)"
274
- ```
275
-
276
- 8. **Verify configuration**
277
- - Run: `claude mcp get knowzcode`
278
- - Confirm server appears in the list
279
- - Check for any error messages
280
-
281
- 9. **Update mcp_config.md**
282
- - Update `knowzcode/mcp_config.md` with connection details:
283
- - Set `Connected: Yes`
284
- - Set `Endpoint: <endpoint-url>`
285
- - Set `Last Verified: <timestamp>`
286
- - Set Research Vault ID and name (if provided or already set)
287
- - Set Code Vault ID and name (if provided)
288
- - Set `Auto-configured: No` (to distinguish from /kc:register setup)
289
-
290
- 10. **Test connection (optional)**
291
- - If verification succeeds, optionally test with a simple tool call
292
- - This validates the API key is valid
293
-
294
- 11. **Report success**
295
- ```
296
- KnowzCode MCP server configured!
297
-
298
- Scope: <chosen-scope>
299
- Endpoint: <endpoint-url>
300
-
301
- Vaults Configured:
302
- Code Vault: <vault-name or "Not configured">
303
- Research Vault: <vault-name or "Not configured">
304
-
305
- 🔄 Please restart Claude Code to activate these features:
306
- • search_knowledge - Vector search across vaults
307
- ask_question - AI Q&A with research mode
308
- create_knowledge - Save learnings (via finalization)
309
- update_knowledge - Update existing items
310
- • find_entities - Find people/locations/events
311
-
312
- After restart, these tools will be available to all KnowzCode agents.
313
-
314
- Check connection status: /kc:status
315
- ```
316
-
317
- ## Configuration Details
318
-
319
- ### Scope Comparison
320
-
321
- **Local (default)**:
322
- - ✅ Private to you
323
- - Project-specific
324
- - Not shared with team
325
- - **Use when:** Personal API key, working solo
326
-
327
- **Project**:
328
- - Shared with team
329
- - ✅ Committed to git via `.mcp.json`
330
- - ⚠️ API key visible to team
331
- - **Use when:** Team API key, collaborative project
332
-
333
- **User**:
334
- - ✅ Available everywhere
335
- - Set once, works across projects
336
- - ❌ Not project-specific
337
- - **Use when:** Single API key for all your work
338
-
339
- ### Security Considerations
340
-
341
- - **Never log API keys** in command output
342
- - **Mask displayed keys**: Show only first/last 4 chars (e.g., `kz_live_abc...xyz`)
343
- - **Warn about project scope**: API key will be in git-committed `.mcp.json`
344
- - **Suggest environment variables**: For team setups, recommend storing in CI/CD secrets
345
-
346
- ### MCP Server Details
347
-
348
- The KnowzCode MCP server (default: `https://mcp.knowz.io/mcp`):
349
- - **Protocol:** HTTP transport with JSON-RPC
350
- - **Authentication:** Bearer token in `Authorization` header
351
- - **Project Context:** `X-Project-Path` header identifies project
352
- - **Rate Limiting:** Standard API rate limits apply
353
- - **Caching:** Responses cached for performance
354
-
355
- ### Environment Endpoints
356
-
357
- **Available Environments:**
358
-
359
- | Environment | Endpoint | Flag | Use Case |
360
- |:------------|:---------|:-----|:---------|
361
- | **Production** (default) | `https://mcp.knowz.io/mcp` | (none) | Normal usage |
362
- | **Development** | `https://mcp.dev.knowz.io/mcp` | `--dev` | Testing new features |
363
-
364
- **Switching Environments:**
365
- ```bash
366
- # Production (default)
367
- /kc:connect-mcp kz_live_abc123...
368
-
369
- # Development
370
- /kc:connect-mcp kz_test_abc123... --dev
371
-
372
- # Local development server
373
- /kc:connect-mcp kz_test_local... --endpoint http://localhost:3000/mcp
374
-
375
- # Self-hosted enterprise
376
- /kc:connect-mcp kz_live_abc123... --endpoint https://knowzcode.mycompany.com/mcp
377
- ```
378
-
379
- ## Error Handling
380
-
381
- ### API Key Invalid
382
- ```
383
- ❌ Authentication failed
384
- The API key appears to be invalid or expired.
385
-
386
- Get a new key at: https://knowz.io/api-keys
387
- Then run: /kc:connect-mcp <new-key>
388
- ```
389
-
390
- ### Already Configured
391
- ```
392
- ⚠️ KnowzCode MCP server is already configured
393
- Current scope: <scope>
394
-
395
- Do you want to reconfigure?
396
- ```
397
-
398
- ### Claude CLI Not Available
399
- ```
400
- ❌ Cannot configure MCP server
401
- The 'claude' CLI command is not available.
402
-
403
- This is unusual - Claude Code should provide this command.
404
- Please restart Claude Code or report this issue.
405
- ```
406
-
407
- ### Network/Connection Error
408
- ```
409
- ❌ Cannot reach KnowzCode API
410
- Failed to connect to {endpoint}
411
-
412
- Check your internet connection and try again.
413
- If using --dev environment, verify the dev server is running.
414
- ```
415
-
416
- ## Advanced Usage
417
-
418
- ### Switching Scopes
419
- To change from local to project scope:
420
- ```bash
421
- # Remove existing (or the command will prompt to reconfigure)
422
- claude mcp remove knowzcode
423
-
424
- # Re-add with new scope
425
- /kc:connect-mcp <api-key> --scope project
426
- ```
427
-
428
- ### Switching Endpoints
429
- To switch between environments or self-hosted:
430
- ```bash
431
- # Switch to development
432
- /kc:connect-mcp <api-key> --dev
433
-
434
- # Switch back to production (default)
435
- /kc:connect-mcp <api-key>
436
-
437
- # Switch to self-hosted
438
- /kc:connect-mcp <api-key> --endpoint https://knowzcode.mycompany.com/mcp
439
- ```
440
-
441
- ## Integration with KnowzCode Agents
442
-
443
- Once configured, agents automatically detect and use MCP tools with dual vault support:
444
-
445
- **analyst**:
446
- - Uses `search_knowledge` with **code vault** to find related code
447
- - Uses `search_knowledge` with **research vault** to find past decisions
448
- - Uses `ask_question` with **research vault** for architectural context
449
-
450
- **architect**:
451
- - Uses `search_knowledge` with **code vault** for implementation examples
452
- - Uses `ask_question` with **research vault** for conventions
453
-
454
- **builder**:
455
- - Uses `search_knowledge` with **code vault** for similar patterns
456
- - Uses `search_knowledge` with **research vault** for best practices
457
-
458
- **reviewer**:
459
- - Uses `search_knowledge` with **research vault** for standards
460
- - Uses `search_knowledge` with **code vault** for precedent checks
461
-
462
- **closer**:
463
- - Uses `search_knowledge` with **research vault** to check for duplicate learnings
464
- - Uses `create_knowledge` to save new learnings to **research vault**
465
-
466
- **All agents**:
467
- - Automatically leverage MCP tools when available
468
- - Gracefully degrade if MCP server unavailable
469
-
470
- ## Next Steps
471
-
472
- After configuration:
473
- 1. **Restart Claude Code** (required to activate MCP server)
474
- 2. **Verify connection**: `/kc:status`
475
- 3. **Start building**: `/kc:work "your feature"`
476
- 4. **Watch agents use MCP tools** automatically during workflow
477
-
478
- ## Tool Control & Filtering
479
-
480
- Tools are controlled **server-side** at the MCP endpoint:
481
-
482
- **Server controls which tools to expose based on:**
483
- - API key tier (free/pro/enterprise)
484
- - Project type (monorepo, microservices, etc.)
485
- - Feature flags per user
486
- - Runtime conditions
487
-
488
- **Agents automatically discover and use available tools** - no client-side filtering needed.
489
-
490
- See `docs/MCP_SERVER_IMPLEMENTATION.md` for complete server implementation guide.
491
-
492
- ## Related Commands
493
-
494
- - `/kc:register` - Register for KnowzCode and configure MCP automatically
495
- - `/kc:status` - Check MCP connection status and available tools
496
- - `/kc:init` - Initialize KnowzCode in project
497
- - `/kc:work` - Start feature development (uses MCP tools)
498
-
499
- ## Implementation Notes
500
-
501
- **For Server Developers:**
502
- - See `docs/MCP_SERVER_IMPLEMENTATION.md` for complete specification
503
- - Required methods: `initialize`, `tools/list`, `tools/call`
504
- - Authentication via `Authorization: Bearer` header
505
- - Project context via `X-Project-Path` header
506
-
507
- Execute this configuration now.
1
+ ---
2
+ description: Configure KnowzCode MCP server for vector-powered code search and context
3
+ ---
4
+
5
+ # KnowzCode MCP Server Connection
6
+
7
+ You are the **KnowzCode MCP Connection Agent**. Your task is to configure the KnowzCode MCP (Model Context Protocol) server to enable vector-based code search and context retrieval.
8
+
9
+ ## Command Syntax
10
+
11
+ ```bash
12
+ /kc:connect-mcp <api-key> [--endpoint <url>] [--scope <local|project|user>] [--dev] [--configure-vaults]
13
+ ```
14
+
15
+ **Note:** If you don't have an API key yet, run `/kc:register` to create an account and get one automatically.
16
+ Registration also auto-configures your vault - no manual setup needed!
17
+
18
+ **Parameters:**
19
+ - `<api-key>` - Required. Your KnowzCode API key (or omit for interactive prompt)
20
+ - `--endpoint <url>` - Optional. Custom MCP endpoint (overrides environment default)
21
+ - `--scope <scope>` - Optional. Configuration scope: local (default), project, or user
22
+ - `--dev` - Optional. Use development environment instead of production
23
+ - `--configure-vaults` - Optional. Force vault configuration prompts (even if already configured)
24
+
25
+ **Environments:**
26
+ | Environment | Endpoint | When to Use |
27
+ |:------------|:---------|:------------|
28
+ | **Production** (default) | `https://mcp.knowz.io/mcp` | Normal usage |
29
+ | **Development** | `https://mcp.dev.knowz.io/mcp` | Testing new features |
30
+
31
+ **Examples:**
32
+ ```bash
33
+ # Basic usage (production - default)
34
+ /kc:connect-mcp kz_live_abc123...
35
+
36
+ # Interactive mode (production)
37
+ /kc:connect-mcp
38
+
39
+ # Development environment
40
+ /kc:connect-mcp kz_test_abc123... --dev
41
+
42
+ # Self-hosted endpoint
43
+ /kc:connect-mcp kz_live_abc123... --endpoint https://your-domain.com/mcp
44
+
45
+ # Project-wide configuration (production)
46
+ /kc:connect-mcp kz_live_team456... --scope project
47
+
48
+ # Development with project scope
49
+ /kc:connect-mcp kz_test_team456... --dev --scope project
50
+ ```
51
+
52
+ ## What This Enables
53
+
54
+ Once connected, you get access to these tools:
55
+
56
+ - **`search_knowledge`** - Vector similarity search across vaults
57
+ - **`ask_question`** - Q&A with optional research mode
58
+ - **`create_knowledge`** - Save learnings to vault (used by finalization)
59
+ - **`update_knowledge`** - Update existing knowledge items
60
+ - **`find_entities`** - Find people, locations, or events in your knowledge
61
+
62
+ ### Default Vault Types
63
+
64
+ KnowzCode ships with three default vault types:
65
+
66
+ | Vault Type | Purpose | Query Examples |
67
+ |------------|---------|----------------|
68
+ | **Code** | Implementation patterns, workarounds, performance | "Find auth middleware", "JWT validation" |
69
+ | **Ecosystem** | Conventions, decisions, integrations, business rules | "Error handling conventions", "Why Redis?" |
70
+ | **Finalizations** | WorkGroup completion summaries, outcome records | "What happened in WG-feat-auth?" |
71
+
72
+ Types are user-configurable labels — users can add custom types freely.
73
+
74
+ ## Your Task
75
+
76
+ Configure the KnowzCode MCP server using Claude Code's built-in MCP management.
77
+
78
+ ### Steps to Execute
79
+
80
+ 1. **Parse command arguments**
81
+ - Extract API key from first positional argument (if provided)
82
+ - Parse `--dev` flag to determine environment
83
+ - Parse `--endpoint <url>` flag (overrides environment default if provided)
84
+ - Default endpoint: `https://mcp.knowz.io/mcp` (production)
85
+ - With `--dev` flag: `https://mcp.dev.knowz.io/mcp` (development)
86
+ - Parse `--scope <scope>` flag (default: `local`)
87
+ - Parse `--configure-vaults` flag (forces vault prompts)
88
+ - Store parsed values for use in configuration
89
+
90
+ 2. **Check for existing configuration**
91
+ - Check if MCP server already configured: `claude mcp get knowzcode`
92
+ - If already configured, ask if user wants to reconfigure
93
+ - If yes, run `claude mcp remove knowzcode` first
94
+
95
+ 3. **Prompt for API key (if not provided)**
96
+ - If no API key in arguments, prompt user interactively:
97
+ ```
98
+ Enter your KnowzCode API key
99
+ (Get one at https://knowz.io/api-keys)
100
+ ```
101
+ - Validate format (should start with `kz_live_` or `kz_test_`)
102
+ - Never display the full API key back to user
103
+
104
+ 4. **Confirm scope (if not provided)**
105
+ - If `--scope` not provided, ask user which scope to use:
106
+ - **local** (default): Only this project, private to you
107
+ - **project**: Shared with team via `.mcp.json` (committed to git)
108
+ - **user**: Available across all your projects
109
+
110
+ Present as options to user if not specified in command.
111
+
112
+ 5. **Validate endpoint URL (if custom)**
113
+ - If custom endpoint provided via `--endpoint`, validate it's a valid URL
114
+ - Ensure it starts with `https://` (or `http://` for local dev)
115
+ - Show which endpoint will be used
116
+
117
+ 6. **Configure Vault IDs (Conditional with Discovery)**
118
+
119
+ First, check if vaults are already configured in `knowzcode/knowzcode_vaults.md`:
120
+ - Read the file and check for connected vaults section
121
+
122
+ **If vaults already configured AND `--configure-vaults` NOT set:**
123
+ - Skip vault prompts entirely
124
+ - Display:
125
+ ```
126
+ Vaults already configured (from previous setup or /kc:register):
127
+ {List vaults from knowzcode_vaults.md}
128
+
129
+ To reconfigure vaults, run: /kc:connect-mcp --configure-vaults
130
+ ```
131
+
132
+ **If vaults NOT configured OR `--configure-vaults` IS set:**
133
+
134
+ **Step 6a: Fetch available vaults using list_vaults()**
135
+
136
+ Call the `list_vaults` MCP tool to discover available vaults:
137
+ ```
138
+ list_vaults(includeStats: true)
139
+ ```
140
+
141
+ If successful, display available vaults:
142
+ ```
143
+ ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
144
+ ◆ VAULT DISCOVERY
145
+ ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
146
+
147
+ Fetching your available vaults...
148
+
149
+ Available Vaults:
150
+ ┌────┬──────────────────────┬──────────────────┬───────────┐
151
+ │ # │ Name │ Type │ Documents │
152
+ ├────┼──────────────────────┼──────────────────┼───────────┤
153
+ 1KnowzCode ecosystem 42
154
+ 2my-project-code code 1,234
155
+ │ 3 │ team-wiki │ ecosystem │ 89 │
156
+ └────┴──────────────────────┴──────────────────┴───────────┘
157
+ ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
158
+ ```
159
+
160
+ If `list_vaults` fails or returns empty:
161
+ - Fall back to manual vault ID entry (legacy behavior)
162
+ - Prompt:
163
+ ```
164
+ Could not fetch vaults automatically.
165
+
166
+ Enter vault IDs manually:
167
+
168
+ Ecosystem Vault ID (required for /kc:learn):
169
+ • Get from: https://knowz.io/vaults
170
+
171
+ Code Vault ID (optional):
172
+ • Leave blank to use grep/glob for code search
173
+ ```
174
+
175
+ **Step 6b: Interactive vault selection**
176
+
177
+ For each discovered vault, ask if user wants to connect it:
178
+
179
+ ```
180
+ Would you like to connect "KnowzCode" (research)?
181
+ ```
182
+ Use AskUserQuestion with options: [Yes] [No]
183
+
184
+ **If "Yes":**
185
+ - Prompt for description:
186
+ ```
187
+ Describe what this vault contains (for intelligent routing):
188
+
189
+ Tips for good descriptions:
190
+ Be specific about content type
191
+ Include example queries that should route here
192
+ • Mention key topics covered
193
+
194
+ Examples:
195
+ • "Team learnings, conventions, architectural decisions. Use for 'why did we choose X?' questions."
196
+ • "Source code for the main API. Use for 'where is X defined?' questions."
197
+ ```
198
+
199
+ - Collect description via AskUserQuestion (free text input)
200
+
201
+ **Step 6c: Loop for additional vaults**
202
+
203
+ After each vault selection:
204
+ ```
205
+ Would you like to connect another vault?
206
+ ```
207
+ Options: [Yes] [No]
208
+
209
+ - If "Yes" and more vaults available: Continue selection loop
210
+ - If "No" or no more vaults: Exit loop
211
+
212
+ **Step 6d: Write vault configuration**
213
+
214
+ Write selected vaults to `knowzcode/knowzcode_vaults.md`:
215
+
216
+ ```markdown
217
+ # KnowzCode Vault Configuration
218
+
219
+ Multi-vault routing configuration for intelligent vault selection.
220
+
221
+ ---
222
+
223
+ ## Connected Vaults
224
+
225
+ ### {vault_id_1}
226
+ - **Name**: {vault_name}
227
+ - **ID**: {vault_id}
228
+ - **Type**: {code | ecosystem | finalizations}
229
+ - **Description**: {user_provided_description}
230
+
231
+ ### {vault_id_2}
232
+ - **Name**: {vault_name}
233
+ - **ID**: {vault_id}
234
+ - **Type**: {code | ecosystem | finalizations}
235
+ - **Description**: {user_provided_description}
236
+
237
+ ---
238
+
239
+ ## Vault Routing Rules
240
+
241
+ - **Code questions** (implementations, files, structure) → {first code vault ID}
242
+ - **Convention questions** (patterns, decisions, best practices) → {first ecosystem vault ID}
243
+ - **Completion records** → {first finalizations vault ID}
244
+ - **Learning capture** → {default ecosystem vault ID}
245
+ ```
246
+
247
+ **Also update `knowzcode/mcp_config.md`** to reflect primary vault (for backwards compatibility):
248
+ - Set Ecosystem Vault ID to first ecosystem vault selected
249
+ - Set Code Vault ID to first code vault selected (or "not configured")
250
+
251
+ **Step 6d.5: Detect uncreated default vaults**
252
+
253
+ After writing vault configuration, check `knowzcode/knowzcode_vaults.md` for entries with empty **ID** fields:
254
+
255
+ 1. Parse all vault entries in the Connected Vaults section
256
+ 2. Find entries where the **ID** field is empty (null GUID — indicates "not yet created on server")
257
+ 3. If uncreated entries found:
258
+ ```
259
+ Found {N} default vault(s) not yet created: {names}. Create them now?
260
+ ```
261
+ Use AskUserQuestion with options: [Yes, create them] [No, skip for now]
262
+ 4. If user confirms: for each uncreated entry, call MCP tool to create the vault on the server. Update the entry's **ID** field with the server-returned vault ID. Update the H3 heading from `(not created)` to the vault ID.
263
+ 5. If user declines: proceed normally — vaults can be created later via `/kc:register` or `/kc:connect-mcp --configure-vaults`
264
+
265
+ **Step 6e: Show vault configuration summary**
266
+
267
+ ```
268
+ Vault configuration saved to knowzcode/knowzcode_vaults.md
269
+
270
+ Connected Vaults:
271
+ • KnowzCode (ecosystem) - "Team learnings and conventions"
272
+ my-code (code) - "Source code for API project"
273
+
274
+ Routing:
275
+ • Code questions → my-code
276
+ Convention questions → KnowzCode
277
+ Completion records Finalizations
278
+ Learning capture KnowzCode
279
+
280
+ You can edit knowzcode/knowzcode_vaults.md to update descriptions or routing rules.
281
+ ```
282
+
283
+ 7. **Add MCP server using CLI**
284
+ ```bash
285
+ claude mcp add --transport http \
286
+ --scope <chosen-scope> \
287
+ knowzcode \
288
+ <endpoint-url> \
289
+ --header "Authorization: Bearer <api-key>" \
290
+ --header "X-Project-Path: $(pwd)"
291
+ ```
292
+
293
+ 8. **Verify configuration**
294
+ - Run: `claude mcp get knowzcode`
295
+ - Confirm server appears in the list
296
+ - Check for any error messages
297
+
298
+ 9. **Update mcp_config.md**
299
+ - Update `knowzcode/mcp_config.md` with connection details:
300
+ - Set `Connected: Yes`
301
+ - Set `Endpoint: <endpoint-url>`
302
+ - Set `Last Verified: <timestamp>`
303
+ - Set Ecosystem Vault ID and name (if provided or already set)
304
+ - Set Code Vault ID and name (if provided)
305
+ - Set `Auto-configured: No` (to distinguish from /kc:register setup)
306
+
307
+ 10. **Test connection (optional)**
308
+ - If verification succeeds, optionally test with a simple tool call
309
+ - This validates the API key is valid
310
+
311
+ 11. **Report success**
312
+ ```
313
+ ✅ KnowzCode MCP server configured!
314
+
315
+ Scope: <chosen-scope>
316
+ Endpoint: <endpoint-url>
317
+
318
+ Vaults Configured:
319
+ Code Vault: <vault-name or "Not configured">
320
+ • Ecosystem Vault: <vault-name or "Not configured">
321
+ Finalizations Vault: <vault-name or "Not configured">
322
+
323
+ 🔄 Please restart Claude Code to activate these features:
324
+ • search_knowledge - Vector search across vaults
325
+ ask_question - AI Q&A with research mode
326
+ • create_knowledge - Save learnings (via finalization)
327
+ • update_knowledge - Update existing items
328
+ find_entities - Find people/locations/events
329
+
330
+ After restart, these tools will be available to all KnowzCode agents.
331
+
332
+ Check connection status: /kc:status
333
+ ```
334
+
335
+ ## Configuration Details
336
+
337
+ ### Scope Comparison
338
+
339
+ **Local (default)**:
340
+ - ✅ Private to you
341
+ - Project-specific
342
+ - Not shared with team
343
+ - **Use when:** Personal API key, working solo
344
+
345
+ **Project**:
346
+ - Shared with team
347
+ - ✅ Committed to git via `.mcp.json`
348
+ - ⚠️ API key visible to team
349
+ - **Use when:** Team API key, collaborative project
350
+
351
+ **User**:
352
+ - Available everywhere
353
+ - Set once, works across projects
354
+ - ❌ Not project-specific
355
+ - **Use when:** Single API key for all your work
356
+
357
+ ### Security Considerations
358
+
359
+ - **Never log API keys** in command output
360
+ - **Mask displayed keys**: Show only first/last 4 chars (e.g., `kz_live_abc...xyz`)
361
+ - **Warn about project scope**: API key will be in git-committed `.mcp.json`
362
+ - **Suggest environment variables**: For team setups, recommend storing in CI/CD secrets
363
+
364
+ ### MCP Server Details
365
+
366
+ The KnowzCode MCP server (default: `https://mcp.knowz.io/mcp`):
367
+ - **Protocol:** HTTP transport with JSON-RPC
368
+ - **Authentication:** Bearer token in `Authorization` header
369
+ - **Project Context:** `X-Project-Path` header identifies project
370
+ - **Rate Limiting:** Standard API rate limits apply
371
+ - **Caching:** Responses cached for performance
372
+
373
+ ### Environment Endpoints
374
+
375
+ **Available Environments:**
376
+
377
+ | Environment | Endpoint | Flag | Use Case |
378
+ |:------------|:---------|:-----|:---------|
379
+ | **Production** (default) | `https://mcp.knowz.io/mcp` | (none) | Normal usage |
380
+ | **Development** | `https://mcp.dev.knowz.io/mcp` | `--dev` | Testing new features |
381
+
382
+ **Switching Environments:**
383
+ ```bash
384
+ # Production (default)
385
+ /kc:connect-mcp kz_live_abc123...
386
+
387
+ # Development
388
+ /kc:connect-mcp kz_test_abc123... --dev
389
+
390
+ # Local development server
391
+ /kc:connect-mcp kz_test_local... --endpoint http://localhost:3000/mcp
392
+
393
+ # Self-hosted enterprise
394
+ /kc:connect-mcp kz_live_abc123... --endpoint https://knowzcode.mycompany.com/mcp
395
+ ```
396
+
397
+ ## Error Handling
398
+
399
+ ### API Key Invalid
400
+ ```
401
+ Authentication failed
402
+ The API key appears to be invalid or expired.
403
+
404
+ Get a new key at: https://knowz.io/api-keys
405
+ Then run: /kc:connect-mcp <new-key>
406
+ ```
407
+
408
+ ### Already Configured
409
+ ```
410
+ ⚠️ KnowzCode MCP server is already configured
411
+ Current scope: <scope>
412
+
413
+ Do you want to reconfigure?
414
+ ```
415
+
416
+ ### Claude CLI Not Available
417
+ ```
418
+ Cannot configure MCP server
419
+ The 'claude' CLI command is not available.
420
+
421
+ This is unusual - Claude Code should provide this command.
422
+ Please restart Claude Code or report this issue.
423
+ ```
424
+
425
+ ### Network/Connection Error
426
+ ```
427
+ ❌ Cannot reach KnowzCode API
428
+ Failed to connect to {endpoint}
429
+
430
+ Check your internet connection and try again.
431
+ If using --dev environment, verify the dev server is running.
432
+ ```
433
+
434
+ ## Advanced Usage
435
+
436
+ ### Switching Scopes
437
+ To change from local to project scope:
438
+ ```bash
439
+ # Remove existing (or the command will prompt to reconfigure)
440
+ claude mcp remove knowzcode
441
+
442
+ # Re-add with new scope
443
+ /kc:connect-mcp <api-key> --scope project
444
+ ```
445
+
446
+ ### Switching Endpoints
447
+ To switch between environments or self-hosted:
448
+ ```bash
449
+ # Switch to development
450
+ /kc:connect-mcp <api-key> --dev
451
+
452
+ # Switch back to production (default)
453
+ /kc:connect-mcp <api-key>
454
+
455
+ # Switch to self-hosted
456
+ /kc:connect-mcp <api-key> --endpoint https://knowzcode.mycompany.com/mcp
457
+ ```
458
+
459
+ ## Integration with KnowzCode Agents
460
+
461
+ Once configured, agents automatically detect and use MCP tools with dual vault support:
462
+
463
+ **analyst**:
464
+ - Uses `search_knowledge` with **code vault** to find related code
465
+ - Uses `search_knowledge` with **ecosystem vault** to find past decisions
466
+ - Uses `ask_question` with **ecosystem vault** for architectural context
467
+
468
+ **architect**:
469
+ - Uses `search_knowledge` with **code vault** for implementation examples
470
+ - Uses `ask_question` with **ecosystem vault** for conventions
471
+
472
+ **builder**:
473
+ - Uses `search_knowledge` with **code vault** for similar patterns
474
+ - Uses `search_knowledge` with **ecosystem vault** for best practices
475
+
476
+ **reviewer**:
477
+ - Uses `search_knowledge` with **ecosystem vault** for standards
478
+ - Uses `search_knowledge` with **code vault** for precedent checks
479
+
480
+ **closer**:
481
+ - Uses `search_knowledge` with **ecosystem vault** to check for duplicate learnings
482
+ - Uses `create_knowledge` to save new learnings to **ecosystem vault**
483
+
484
+ **All agents**:
485
+ - Automatically leverage MCP tools when available
486
+ - Gracefully degrade if MCP server unavailable
487
+
488
+ ## Next Steps
489
+
490
+ After configuration:
491
+ 1. **Restart Claude Code** (required to activate MCP server)
492
+ 2. **Verify connection**: `/kc:status`
493
+ 3. **Start building**: `/kc:work "your feature"`
494
+ 4. **Watch agents use MCP tools** automatically during workflow
495
+
496
+ ## Tool Control & Filtering
497
+
498
+ Tools are controlled **server-side** at the MCP endpoint:
499
+
500
+ **Server controls which tools to expose based on:**
501
+ - API key tier (free/pro/enterprise)
502
+ - Project type (monorepo, microservices, etc.)
503
+ - Feature flags per user
504
+ - Runtime conditions
505
+
506
+ **Agents automatically discover and use available tools** - no client-side filtering needed.
507
+
508
+ See `docs/MCP_SERVER_IMPLEMENTATION.md` for complete server implementation guide.
509
+
510
+ ## Related Commands
511
+
512
+ - `/kc:register` - Register for KnowzCode and configure MCP automatically
513
+ - `/kc:status` - Check MCP connection status and available tools
514
+ - `/kc:init` - Initialize KnowzCode in project
515
+ - `/kc:work` - Start feature development (uses MCP tools)
516
+
517
+ ## Implementation Notes
518
+
519
+ **For Server Developers:**
520
+ - See `docs/MCP_SERVER_IMPLEMENTATION.md` for complete specification
521
+ - Required methods: `initialize`, `tools/list`, `tools/call`
522
+ - Authentication via `Authorization: Bearer` header
523
+ - Project context via `X-Project-Path` header
524
+
525
+ Execute this configuration now.