knowz-mcp 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,183 @@
1
+ # MCP Server Configuration Reference
2
+
3
+ ## Enterprise Configuration
4
+
5
+ Before using any endpoints below, check for an `enterprise.json` file in the plugin root directory (the directory containing `.claude-plugin/plugin.json`). If present, use its `mcp_endpoint` value instead of the production/development endpoints listed here. If absent, use the defaults below.
6
+
7
+ ## Server Details
8
+
9
+ | Property | Value |
10
+ |----------|-------|
11
+ | **Protocol** | HTTP transport with JSON-RPC |
12
+ | **Production endpoint** | `https://mcp.knowz.io/mcp` |
13
+ | **Development endpoint** | `https://mcp.dev.knowz.io/mcp` |
14
+ | **Authentication** | Bearer token or OAuth dynamic discovery |
15
+ | **Project context** | `X-Project-Path` header |
16
+
17
+ ## Authentication Methods
18
+
19
+ ### API Key
20
+
21
+ ```bash
22
+ claude mcp add --transport http \
23
+ --scope <local|project|user> \
24
+ knowz \
25
+ <endpoint-url> \
26
+ --header "Authorization: Bearer <api-key>" \
27
+ --header "X-Project-Path: $(pwd)"
28
+ ```
29
+
30
+ ### OAuth (recommended)
31
+
32
+ No API key required — authentication happens via browser on first use.
33
+
34
+ ```bash
35
+ claude mcp add --transport http \
36
+ --scope <local|project|user> \
37
+ knowz \
38
+ <endpoint-url> \
39
+ --header "X-Project-Path: $(pwd)"
40
+ ```
41
+
42
+ On first tool call after restart, the server returns `401 + WWW-Authenticate` and Claude Code opens a browser for login.
43
+
44
+ ### Gemini CLI Configuration
45
+
46
+ **OAuth:**
47
+ ```json
48
+ { "mcpServers": { "knowz": { "httpUrl": "<endpoint>", "authProviderType": "dynamic_discovery" } } }
49
+ ```
50
+ Write to `.gemini/settings.json`. After writing, instruct: `Run /mcp auth knowz in Gemini CLI to complete authentication.`
51
+
52
+ **API Key:**
53
+ ```json
54
+ {
55
+ "mcpServers": {
56
+ "knowz": {
57
+ "httpUrl": "<endpoint>",
58
+ "headers": {
59
+ "Authorization": "Bearer <api-key>",
60
+ "X-Project-Path": "<project_path>"
61
+ }
62
+ }
63
+ }
64
+ }
65
+ ```
66
+
67
+ ## Scope Options
68
+
69
+ | Scope | Storage | Visibility | Best For |
70
+ |-------|---------|------------|----------|
71
+ | **local** (default) | Claude Code internal | Only you, this project | Personal development |
72
+ | **project** | `.mcp.json` (git) | Team via git | Shared team key |
73
+ | **user** | Claude Code user config | Only you, all projects | Personal, multi-project |
74
+
75
+ ### Security Warning for Project Scope
76
+
77
+ If `--scope project` is selected:
78
+ ```
79
+ Security Note: Project Scope Selected
80
+
81
+ With project scope, your API key will be stored in .mcp.json
82
+ which is typically committed to git.
83
+
84
+ This is appropriate for:
85
+ - Team/shared API keys
86
+ - CI/CD automation keys
87
+
88
+ For personal keys, consider using --scope local (default)
89
+ ```
90
+
91
+ ## Smart Config Discovery
92
+
93
+ Before prompting for an API key, check known config sources in order:
94
+
95
+ 1. **Environment variable**: `KNOWZ_API_KEY`
96
+ - If set: use as API key, display "Using API key from KNOWZ_API_KEY (ending ...{last4})"
97
+
98
+ 2. **Cross-platform config files** (check for API key or OAuth):
99
+ - `.gemini/settings.json` → `mcpServers.knowz.authProviderType` (OAuth) or `mcpServers.knowz.headers.Authorization` (API key)
100
+ - `~/.gemini/settings.json` → same
101
+ - `.vscode/mcp.json` → `servers.knowz.headers`
102
+
103
+ 3. **KnowzCode vault config** (if present):
104
+ - `knowzcode/knowzcode_vaults.md` — if vaults have non-empty IDs, note for interop
105
+
106
+ If a key is discovered, offer to reuse:
107
+ ```
108
+ Found existing API key (ending ...{last4}) in {source}. Use this key? [Yes/No]
109
+ ```
110
+
111
+ If OAuth config found in another platform:
112
+ ```
113
+ Found existing OAuth configuration in {source}.
114
+ Would you like to configure Claude Code with OAuth as well? [OAuth (recommended)] [API Key] [Skip]
115
+ ```
116
+
117
+ ## CLI Commands Reference
118
+
119
+ ```bash
120
+ # Add MCP server
121
+ claude mcp add --transport http --scope <scope> knowz <endpoint> --header "..."
122
+
123
+ # Check existing config
124
+ CLAUDECODE= claude mcp get knowz
125
+
126
+ # Remove existing config
127
+ CLAUDECODE= claude mcp remove knowz
128
+
129
+ # List all MCP servers
130
+ claude mcp list
131
+ ```
132
+
133
+ ## Error Handling
134
+
135
+ ### OAuth Authentication Required
136
+ ```
137
+ OAuth authentication needed.
138
+
139
+ This is expected if:
140
+ - First-time setup — you haven't completed browser login yet
141
+ - Token expired — your OAuth session needs renewal
142
+
143
+ Important: MCP servers only connect at session startup. A restart is
144
+ required before Claude Code can use a newly configured or re-authenticated
145
+ MCP server — this is a platform limitation, not a bug.
146
+
147
+ To authenticate:
148
+ Claude Code: Restart Claude Code — browser will open on first tool call
149
+ Gemini CLI: Run /mcp auth knowz to re-authenticate via browser
150
+
151
+ If the problem persists:
152
+ - Re-configure: /knowz setup --oauth
153
+ - Or switch to API key (no browser login or token refresh needed): /knowz setup <api-key>
154
+ ```
155
+
156
+ ### API Key Invalid
157
+ ```
158
+ Authentication failed. The API key appears to be invalid or expired.
159
+
160
+ Get a new key at: https://knowz.io/api-keys
161
+ Or switch to OAuth (no key needed): /knowz setup --oauth
162
+ ```
163
+
164
+ ### Already Configured
165
+ ```
166
+ Knowz MCP server is already configured.
167
+ Current scope: <scope>
168
+
169
+ Do you want to reconfigure? [Yes/No]
170
+ ```
171
+ If yes, run `CLAUDECODE= claude mcp remove knowz` first.
172
+
173
+ ### Claude CLI Not Available
174
+ ```
175
+ Cannot configure MCP server — the 'claude' CLI command is not available.
176
+ Please restart Claude Code or report this issue.
177
+ ```
178
+
179
+ ### Network/Connection Error
180
+ ```
181
+ Cannot reach Knowz MCP server at {endpoint}.
182
+ Check your internet connection and try again.
183
+ ```
@@ -0,0 +1,159 @@
1
+ # Registration API Reference
2
+
3
+ ## Enterprise Configuration
4
+
5
+ Before using any endpoints or brand names below, check for an `enterprise.json` file in the plugin root directory (the directory containing `.claude-plugin/plugin.json`). If present, use its values: `api_endpoint` replaces `https://api.knowz.io/api/v1` (registration becomes `{api_endpoint}/auth/register`), `mcp_endpoint` replaces `https://mcp.knowz.io/mcp`, and `brand` replaces "Knowz" in user-facing messages. When enterprise config is present, ignore the `--dev` flag. If absent, use the defaults below.
6
+
7
+ ## Endpoints
8
+
9
+ | Environment | API Endpoint | MCP Endpoint |
10
+ |:------------|:-------------|:-------------|
11
+ | **Production** (default) | `https://api.knowz.io/api/v1/auth/register` | `https://mcp.knowz.io/mcp` |
12
+ | **Development** (`--dev`) | `https://api.dev.knowz.io/api/v1/auth/register` | `https://mcp.dev.knowz.io/mcp` |
13
+
14
+ ## Request Format
15
+
16
+ ```bash
17
+ curl -X POST https://api.knowz.io/api/v1/auth/register \
18
+ -H "Content-Type: application/json" \
19
+ -d '{
20
+ "name": "{name}",
21
+ "email": "{email}",
22
+ "password": "{password}"
23
+ }'
24
+ ```
25
+
26
+ ## Response Structure
27
+
28
+ ```json
29
+ {
30
+ "api_key": "kz_live_abc123...",
31
+ "vault_id": "vault_xyz789...",
32
+ "vault_name": "KnowzCode"
33
+ }
34
+ ```
35
+
36
+ Field name variants: `apiKey`/`api_key`/`token`, `vault_id`/`vaultId`, `vault_name`/`vaultName`.
37
+
38
+ ## Input Validation
39
+
40
+ | Field | Rules |
41
+ |-------|-------|
42
+ | **Name** | Non-empty, 2-100 characters, letters/spaces/hyphens/apostrophes |
43
+ | **Email** | Must contain `@` and domain, no leading/trailing whitespace |
44
+ | **Password** | Minimum 8 characters |
45
+
46
+ ## Error Codes
47
+
48
+ ### Email Already Registered (HTTP 409)
49
+
50
+ ```
51
+ The email {email} is already associated with an account.
52
+
53
+ Options:
54
+ 1. Use a different email — run /knowz register again
55
+ 2. Retrieve existing API key — visit https://knowz.io/api-keys
56
+ 3. Reset password — https://knowz.io/forgot-password
57
+
58
+ If this is your account, you can configure your existing key:
59
+ /knowz setup <your-existing-api-key>
60
+ ```
61
+
62
+ ### Invalid Input (HTTP 400)
63
+
64
+ ```
65
+ Registration failed — validation errors:
66
+ {error_message_from_response}
67
+
68
+ Please correct the issue and try again.
69
+ ```
70
+
71
+ Return to the step corresponding to the invalid field.
72
+
73
+ ### Rate Limited (HTTP 429)
74
+
75
+ ```
76
+ Too many requests. Registration is temporarily rate limited.
77
+ Please wait a few minutes and try again.
78
+
79
+ If you continue to see this error, contact support:
80
+ https://knowz.io/support
81
+ ```
82
+
83
+ ### Network Error
84
+
85
+ ```
86
+ Cannot reach registration server.
87
+
88
+ Troubleshooting:
89
+ 1. Check your internet connection
90
+ 2. Verify firewall/proxy settings allow HTTPS to api.knowz.io
91
+ 3. Try again in a few moments
92
+
93
+ Status page: https://status.knowz.io
94
+ Support: https://knowz.io/support
95
+ ```
96
+
97
+ ### Server Error (HTTP 500+)
98
+
99
+ ```
100
+ Server encountered an error. This is not your fault.
101
+
102
+ Please:
103
+ 1. Try again in a few minutes
104
+ 2. Check status: https://status.knowz.io
105
+ 3. Contact support if persists: https://knowz.io/support
106
+ ```
107
+
108
+ ### MCP Configuration Failed (registration succeeded)
109
+
110
+ ```
111
+ Account created, but MCP configuration failed.
112
+
113
+ Your account:
114
+ Email: {email}
115
+ API Key: {masked_key}
116
+ Vault: {vault_name} ({vault_id prefix...})
117
+
118
+ Configure manually:
119
+ /knowz setup {masked_key}
120
+
121
+ Or visit https://knowz.io/api-keys to retrieve your key later.
122
+ ```
123
+
124
+ ### API Response Missing Vault ID
125
+
126
+ ```
127
+ Account created, but no vault was auto-provisioned.
128
+
129
+ This may indicate:
130
+ - Account provisioning is still in progress
131
+ - Server-side configuration needed
132
+
133
+ You can:
134
+ 1. Wait a few minutes and run /knowz status to check
135
+ 2. Contact support: https://knowz.io/support
136
+ 3. Run /knowz setup later to configure vaults
137
+ ```
138
+
139
+ ## Security Considerations
140
+
141
+ - **HTTPS only** — all API calls use HTTPS
142
+ - **Password not stored** — sent once, never saved locally
143
+ - **Password not logged** — never display password in output
144
+ - **Minimal data** — only collect what's needed for registration
145
+ - **Mask displayed keys** — show only first 6 + last 4 chars (e.g., `kz_liv...wxyz`)
146
+ - **Never log full keys** — exclude from diagnostic output
147
+ - **Warn about project scope** — API key will be in git-committed `.mcp.json`
148
+ - **Recommend local scope** — default to most secure option
149
+
150
+ ## What Registration Provides
151
+
152
+ - **API Key** — unique key for MCP server authentication
153
+ - **Knowz Vault** — auto-created vault for learnings, conventions, and patterns
154
+ - **Vector Search** — AI-powered semantic search across vaults
155
+ - **AI Q&A** — question answering with research mode
156
+ - **Knowledge Capture** — save insights with automatic formatting
157
+
158
+ Free tier: 1,000 API calls/month, single user, basic vector search.
159
+ Upgrades: https://knowz.io/pricing
@@ -0,0 +1,122 @@
1
+ ---
2
+ name: knowz-auto
3
+ description: "Auto-detect when the user is asking knowledge questions or sharing insights that match Knowz vault rules. Triggers when user asks about past decisions, conventions, patterns, or shares learnings worth capturing — e.g. 'why did we...', 'what's our convention for...', 'we decided to...', 'I learned that...'"
4
+ user-invocable: false
5
+ allowed-tools: Read, Glob, Grep
6
+ ---
7
+
8
+ # Knowz Auto — Frictionless Vault Awareness
9
+
10
+ You are the **Knowz Auto** trigger skill. You make vault interaction truly frictionless by automatically consulting vaults or offering to save knowledge — without the user needing to explicitly use `/knowz`.
11
+
12
+ ## When This Skill Activates
13
+
14
+ This skill activates automatically when Claude detects the user's message matches this skill's description:
15
+
16
+ - Questions about past decisions: "why did we...", "what's our convention for...", "how did we build..."
17
+ - Questions about patterns/standards: "what's the pattern for...", "do we have a standard for..."
18
+ - Sharing insights/decisions: "we decided to...", "I learned that...", "the workaround is..."
19
+ - Knowledge lookups: "check if we've done this before", "any prior art for..."
20
+
21
+ ## Prerequisites (ALL must be true)
22
+
23
+ 1. `knowz-vaults.md` exists in the project root
24
+ 2. MCP tools (`mcp__knowz__*`) are available
25
+ 3. This is NOT during an explicit `/knowz` command execution
26
+ 4. The user's message is NOT a clear code-related instruction (e.g., "fix this bug", "add a test")
27
+
28
+ **If any prerequisite fails → do nothing.** Do not interfere with normal conversation.
29
+
30
+ ## Execution
31
+
32
+ ### Step 1: Read Vault Configuration
33
+
34
+ Read `knowz-vaults.md` from the project root. Parse:
35
+ - Each vault's **name** and **ID**
36
+ - Each vault's **when to query** rules
37
+ - Each vault's **when to save** rules
38
+ - The **default vault** from `## Defaults`
39
+
40
+ ### Step 2: Classify the User's Message
41
+
42
+ Determine if the user's message is a **query** or a **save candidate**:
43
+
44
+ **Query signals** — the user is asking about something that might be in a vault:
45
+ - Questions with "why", "how", "what", "when", "where" about past work
46
+ - References to decisions, conventions, patterns, standards
47
+ - "Do we have...", "Have we ever...", "What's our approach to..."
48
+ - "Check if...", "Any prior art...", "Has anyone..."
49
+
50
+ **Save signals** — the user is sharing knowledge worth capturing:
51
+ - "We decided to...", "The approach is...", "I found that..."
52
+ - "The workaround is...", "The trick is...", "Important: ..."
53
+ - "Going forward, we should...", "The convention is..."
54
+ - Sharing a lesson learned, a decision rationale, or a useful pattern
55
+
56
+ ### Step 3: Match Against Vault Rules
57
+
58
+ Compare the classified message against each vault's routing rules:
59
+
60
+ - **For queries:** Match against "when to query" rules
61
+ - **For saves:** Match against "when to save" rules
62
+
63
+ If no vault rules match the message, **do nothing** — this isn't vault-relevant content.
64
+
65
+ ### Step 4: Take Action
66
+
67
+ **For query matches — search silently, include findings in response:**
68
+
69
+ 1. Call `mcp__knowz__search_knowledge` with:
70
+ - `query`: extract the core question from the user's message
71
+ - `vaultId`: the matched vault ID
72
+ - `limit`: 5
73
+ 2. If results are found, weave them into your response naturally:
74
+ ```
75
+ Based on your vault knowledge, {relevant finding}...
76
+ ```
77
+ or
78
+ ```
79
+ Your {Vault Name} vault has context on this:
80
+ - {relevant item title}: {key insight}
81
+ ```
82
+ 3. If no results found, proceed normally — don't mention the failed search
83
+
84
+ **For save matches — offer to capture, never auto-save:**
85
+
86
+ 1. Identify the insight worth capturing
87
+ 2. Determine which vault it should go to based on "when to save" rules
88
+ 3. Offer to save — always ask first:
89
+ ```
90
+ This looks like it could be worth saving to {Vault Name}. Want me to capture it?
91
+ ```
92
+ 4. If the user agrees, use the `/knowz` skill's save flow:
93
+ - Format the content using the vault's content template
94
+ - Dedup check
95
+ - Create the knowledge item
96
+ - Report success
97
+ 5. **If MCP write fails** (e.g., server unreachable, auth expired), queue to pending captures:
98
+ - Append a capture block to `knowz-pending.md` in the project root (create file if needed)
99
+ - Use the format from `knowz-pending.example.md`:
100
+ ```
101
+ ---
102
+
103
+ ### {ISO timestamp} -- {Category}: {Title}
104
+ - **Category**: {category}
105
+ - **Target Vault**: {vault name}
106
+ - **Source**: knowz-auto
107
+ - **Content**:
108
+ {formatted content}
109
+
110
+ ---
111
+ ```
112
+ - Report: `"Queued to knowz-pending.md — run /knowz flush when MCP is available."`
113
+ 6. If the user declines, continue normally
114
+
115
+ ## Key Constraints
116
+
117
+ - **Lightweight only.** Read vault file, check rules, do a quick search or offer to save. Nothing more.
118
+ - **Never auto-save.** Always ask before capturing knowledge.
119
+ - **Never block.** If vault lookup fails or returns nothing, continue with the normal response.
120
+ - **Don't announce yourself.** Don't say "I'm checking your vaults..." — just include findings naturally or offer to save.
121
+ - **Don't trigger during `/knowz`.** If the user is already using the explicit skill, stay out of the way.
122
+ - **Don't trigger on code instructions.** "Fix this bug", "add a test", "refactor this" are not vault-relevant.