@offgridsec/kira-lite-mcp 0.1.2

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 (73) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/INSTALL.md +330 -0
  3. package/LICENSE +96 -0
  4. package/PRIVACY.md +54 -0
  5. package/README.md +370 -0
  6. package/config/CLAUDE.md +26 -0
  7. package/config/settings.local.json +25 -0
  8. package/dist/config.d.ts +6 -0
  9. package/dist/config.js +1 -0
  10. package/dist/core/engines/kira-core.d.ts +16 -0
  11. package/dist/core/engines/kira-core.js +1 -0
  12. package/dist/core/engines/osv.d.ts +4 -0
  13. package/dist/core/engines/osv.js +1 -0
  14. package/dist/core/engines/runner.d.ts +11 -0
  15. package/dist/core/engines/runner.js +1 -0
  16. package/dist/core/scanner.d.ts +19 -0
  17. package/dist/core/scanner.js +1 -0
  18. package/dist/core/types.d.ts +72 -0
  19. package/dist/core/types.js +1 -0
  20. package/dist/core/utils.d.ts +8 -0
  21. package/dist/core/utils.js +1 -0
  22. package/dist/index.d.ts +2 -0
  23. package/dist/index.js +2 -0
  24. package/dist/rules/c-cpp.d.ts +2 -0
  25. package/dist/rules/c-cpp.js +1 -0
  26. package/dist/rules/cicd.d.ts +2 -0
  27. package/dist/rules/cicd.js +1 -0
  28. package/dist/rules/csharp.d.ts +2 -0
  29. package/dist/rules/csharp.js +1 -0
  30. package/dist/rules/docker.d.ts +2 -0
  31. package/dist/rules/docker.js +1 -0
  32. package/dist/rules/go.d.ts +2 -0
  33. package/dist/rules/go.js +1 -0
  34. package/dist/rules/index.d.ts +30 -0
  35. package/dist/rules/index.js +1 -0
  36. package/dist/rules/java.d.ts +2 -0
  37. package/dist/rules/java.js +1 -0
  38. package/dist/rules/javascript-extended.d.ts +12 -0
  39. package/dist/rules/javascript-extended.js +1 -0
  40. package/dist/rules/javascript.d.ts +2 -0
  41. package/dist/rules/javascript.js +1 -0
  42. package/dist/rules/kubernetes.d.ts +2 -0
  43. package/dist/rules/kubernetes.js +1 -0
  44. package/dist/rules/php.d.ts +2 -0
  45. package/dist/rules/php.js +1 -0
  46. package/dist/rules/python-extended.d.ts +12 -0
  47. package/dist/rules/python-extended.js +1 -0
  48. package/dist/rules/python.d.ts +2 -0
  49. package/dist/rules/python.js +1 -0
  50. package/dist/rules/ruby.d.ts +2 -0
  51. package/dist/rules/ruby.js +1 -0
  52. package/dist/rules/secrets-extended.d.ts +2 -0
  53. package/dist/rules/secrets-extended.js +1 -0
  54. package/dist/rules/secrets.d.ts +2 -0
  55. package/dist/rules/secrets.js +1 -0
  56. package/dist/rules/shell.d.ts +2 -0
  57. package/dist/rules/shell.js +1 -0
  58. package/dist/rules/terraform.d.ts +2 -0
  59. package/dist/rules/terraform.js +1 -0
  60. package/dist/telemetry.d.ts +8 -0
  61. package/dist/telemetry.js +1 -0
  62. package/dist/tools/fix-vulnerability.d.ts +36 -0
  63. package/dist/tools/fix-vulnerability.js +1 -0
  64. package/dist/tools/scan-code.d.ts +29 -0
  65. package/dist/tools/scan-code.js +1 -0
  66. package/dist/tools/scan-dependencies.d.ts +6 -0
  67. package/dist/tools/scan-dependencies.js +1 -0
  68. package/dist/tools/scan-diff.d.ts +36 -0
  69. package/dist/tools/scan-diff.js +1 -0
  70. package/dist/tools/scan-file.d.ts +24 -0
  71. package/dist/tools/scan-file.js +1 -0
  72. package/hook.mjs +72 -0
  73. package/package.json +66 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,29 @@
1
+ # Changelog
2
+
3
+ All notable changes to Kira-Lite MCP Server will be documented in this file.
4
+
5
+ ## [0.2.0] - 2026-02-20
6
+
7
+ ### Added
8
+ - **Configurable scan frequency** — new `scanMode` setting with three modes:
9
+ - `"every-edit"` (default) — scan on every tool call
10
+ - `"on-save"` — only scan via `scan_file`; `scan_code`/`scan_diff` return instantly
11
+ - `"manual"` — all scans skipped; post-write hook also skipped
12
+ - **`get_config` tool** — view current Kira-Lite configuration
13
+ - **`set_config` tool** — change scan mode and persist to `~/.kira-lite/config.json`
14
+ - Configuration file at `~/.kira-lite/config.json`
15
+ - Hook respects `"manual"` mode (exits immediately without scanning)
16
+
17
+ ## [0.1.0] - 2025-01-01
18
+
19
+ ### Added
20
+ - Initial release
21
+ - `scan_code` — scan code snippets before writing to disk
22
+ - `scan_file` — scan existing files on disk
23
+ - `scan_diff` — compare original vs modified code for new vulnerabilities
24
+ - `fix_vulnerability` — get detailed fix guidance by vulnerability ID or CWE
25
+ - Post-write hook for Claude Code (`hook.mjs`)
26
+ - JavaScript/TypeScript and Python rule sets
27
+ - Regex-based scanning engine
28
+ - Kira-Core Go binary integration with regex fallback
29
+ - PostHog telemetry (opt-out via `KIRA_TELEMETRY=off`)
package/INSTALL.md ADDED
@@ -0,0 +1,330 @@
1
+ # Kira-Lite — Installation Guide
2
+
3
+ Kira-Lite by [Offgrid Security](https://offgridsec.com) scans code for vulnerabilities before it's written to disk, integrating directly into AI coding assistants via MCP.
4
+
5
+ ---
6
+
7
+ ## Prerequisites
8
+
9
+ - **Node.js** >= 18
10
+ - An MCP-compatible AI coding assistant (Claude Code, Cursor, Windsurf, etc.)
11
+
12
+ ---
13
+
14
+ ## Step 1: Install
15
+
16
+ ```bash
17
+ npm install -g @offgridsec/kira-lite-mcp
18
+ ```
19
+
20
+ Or use `npx` to run without installing:
21
+
22
+ ```bash
23
+ npx @offgridsec/kira-lite-mcp
24
+ ```
25
+
26
+ ---
27
+
28
+ ## Step 2: Register MCP Server (One-Time, Global)
29
+
30
+ This registers kira-lite globally so it's available in every project.
31
+
32
+ ### Claude Code
33
+
34
+ ```bash
35
+ claude mcp add --scope user kira-lite -- npx -y @offgridsec/kira-lite-mcp
36
+ ```
37
+
38
+ ### Cursor / Windsurf / Other MCP Clients
39
+
40
+ Add to your MCP configuration file:
41
+
42
+ ```json
43
+ {
44
+ "kira-lite": {
45
+ "command": "npx",
46
+ "args": ["-y", "@offgridsec/kira-lite-mcp"]
47
+ }
48
+ }
49
+ ```
50
+
51
+ ### Verify
52
+
53
+ Start your AI assistant and check MCP tools. You should see 6 tools:
54
+ - `scan_code` — scan code before writing
55
+ - `scan_file` — scan an existing file
56
+ - `scan_diff` — compare original vs new code
57
+ - `fix_vulnerability` — get fix guidance
58
+ - `get_config` — view current configuration
59
+ - `set_config` — change scan frequency
60
+
61
+ ---
62
+
63
+ ## Step 3: Per-Project Setup (Claude Code)
64
+
65
+ Navigate to your project directory first, then follow the scenarios below.
66
+
67
+ ```bash
68
+ cd /path/to/your-project
69
+ ```
70
+
71
+ ---
72
+
73
+ ### Scenario A: New Project (No Existing CLAUDE.md or Settings)
74
+
75
+ #### macOS / Linux
76
+
77
+ ```bash
78
+ cp $(npm root -g)/@offgridsec/kira-lite-mcp/config/CLAUDE.md .
79
+ mkdir -p .claude
80
+ cp $(npm root -g)/@offgridsec/kira-lite-mcp/config/settings.local.json .claude/settings.local.json
81
+ ```
82
+
83
+ #### Windows (PowerShell)
84
+
85
+ ```powershell
86
+ $pkg = (npm root -g) + "\@offgridsec\kira-lite-mcp"
87
+ Copy-Item "$pkg\config\CLAUDE.md" .
88
+ New-Item -ItemType Directory -Force .claude | Out-Null
89
+ Copy-Item "$pkg\config\settings.local.json" .claude\settings.local.json
90
+ ```
91
+
92
+ ---
93
+
94
+ ### Scenario B: Project Already Has a CLAUDE.md
95
+
96
+ **Do not overwrite** — append the kira-lite instructions to the end.
97
+
98
+ #### macOS / Linux
99
+
100
+ ```bash
101
+ echo "" >> CLAUDE.md
102
+ cat $(npm root -g)/@offgridsec/kira-lite-mcp/config/CLAUDE.md >> CLAUDE.md
103
+ ```
104
+
105
+ #### Manual Option
106
+
107
+ Add this block to the bottom of your existing `CLAUDE.md`:
108
+
109
+ ```markdown
110
+ # SECURITY SCANNING — REQUIRED ON EVERY CODE CHANGE
111
+
112
+ You MUST call the `scan_code` MCP tool before EVERY single Edit or Write tool call. No exceptions. This is not optional.
113
+
114
+ ## How it works
115
+
116
+ 1. Before you use Edit or Write, call `scan_code` with the code you are about to write
117
+ 2. If findings are returned, fix them and call `scan_code` again
118
+ 3. Only write the code after scan returns clean
119
+ 4. For edits to existing files, use `scan_diff` with original and new code
120
+
121
+ ## Rules
122
+
123
+ - EVERY Edit/Write MUST be preceded by a scan_code call
124
+ - If scan returns critical or high findings, DO NOT write the code
125
+ - Tell the user what you found and what you fixed
126
+ - This applies to ALL files: .js, .ts, .py, .go, .java, .rb, .php, .yaml, .tf, Dockerfile, etc.
127
+ ```
128
+
129
+ ---
130
+
131
+ ### Scenario C: Project Already Has .claude/settings.local.json
132
+
133
+ **Do not overwrite** — merge the kira-lite permissions and hooks into the existing file.
134
+
135
+ #### What to Add
136
+
137
+ Open `.claude/settings.local.json` and merge these two sections:
138
+
139
+ **1. Add to `permissions.allow` array:**
140
+
141
+ ```json
142
+ "mcp__kira-lite__scan_code",
143
+ "mcp__kira-lite__scan_file",
144
+ "mcp__kira-lite__scan_diff",
145
+ "mcp__kira-lite__fix_vulnerability",
146
+ "mcp__kira-lite__get_config",
147
+ "mcp__kira-lite__set_config"
148
+ ```
149
+
150
+ **2. Add to `hooks` object:**
151
+
152
+ ```json
153
+ "PostToolCall": [
154
+ {
155
+ "matcher": "Write|Edit",
156
+ "hooks": [
157
+ {
158
+ "type": "command",
159
+ "command": "npx --yes @offgridsec/kira-lite-mcp/hook.mjs"
160
+ }
161
+ ]
162
+ }
163
+ ]
164
+ ```
165
+
166
+ #### Example: Before
167
+
168
+ ```json
169
+ {
170
+ "permissions": {
171
+ "allow": [
172
+ "Bash(npm test:*)"
173
+ ]
174
+ }
175
+ }
176
+ ```
177
+
178
+ #### Example: After
179
+
180
+ ```json
181
+ {
182
+ "permissions": {
183
+ "allow": [
184
+ "Bash(npm test:*)",
185
+ "mcp__kira-lite__scan_code",
186
+ "mcp__kira-lite__scan_file",
187
+ "mcp__kira-lite__scan_diff",
188
+ "mcp__kira-lite__fix_vulnerability",
189
+ "mcp__kira-lite__get_config",
190
+ "mcp__kira-lite__set_config"
191
+ ]
192
+ },
193
+ "hooks": {
194
+ "PostToolCall": [
195
+ {
196
+ "matcher": "Write|Edit",
197
+ "hooks": [
198
+ {
199
+ "type": "command",
200
+ "command": "npx --yes @offgridsec/kira-lite-mcp/hook.mjs"
201
+ }
202
+ ]
203
+ }
204
+ ]
205
+ }
206
+ }
207
+ ```
208
+
209
+ ---
210
+
211
+ ### Scenario D: Both CLAUDE.md and settings.local.json Already Exist
212
+
213
+ Combine Scenario B + Scenario C:
214
+
215
+ 1. Append kira-lite instructions to `CLAUDE.md` (Scenario B)
216
+ 2. Merge permissions and hooks into `.claude/settings.local.json` (Scenario C)
217
+
218
+ ---
219
+
220
+ ## Step 4: Configure Scan Frequency (Optional)
221
+
222
+ By default, Kira-Lite scans on every tool call (`"every-edit"` mode). You can change this to reduce overhead.
223
+
224
+ ### Using the MCP tool
225
+
226
+ ```
227
+ set_config({ scanMode: "on-save" })
228
+ ```
229
+
230
+ ### Or create the config file manually
231
+
232
+ Create `~/.kira-lite/config.json`:
233
+
234
+ ```json
235
+ {
236
+ "scanMode": "on-save"
237
+ }
238
+ ```
239
+
240
+ ### Available modes
241
+
242
+ | Mode | `scan_code` | `scan_diff` | `scan_file` | Hook |
243
+ |------|-------------|-------------|-------------|------|
244
+ | `"every-edit"` | scans | scans | scans | active |
245
+ | `"on-save"` | skipped | skipped | scans | active |
246
+ | `"manual"` | skipped | skipped | skipped | skipped |
247
+
248
+ > `fix_vulnerability` always works regardless of mode.
249
+
250
+ ### Check current config
251
+
252
+ ```
253
+ get_config()
254
+ ```
255
+
256
+ ---
257
+
258
+ ## What Each File Does
259
+
260
+ | File | Purpose | Scope |
261
+ |------|---------|-------|
262
+ | `CLAUDE.md` | Instructs the AI to call `scan_code` before every Edit/Write | Per-project |
263
+ | `.claude/settings.local.json` | Auto-allows kira-lite tools + post-write hook enforcement | Per-project |
264
+ | `~/.kira-lite/config.json` | Scan frequency configuration | User-wide |
265
+ | `~/.kira-lite/device-id` | Anonymous device ID for telemetry | User-wide |
266
+
267
+ > **Important:** Hooks (`PostToolCall`) only work in **project-level** `.claude/settings.local.json`. Do NOT add hooks to the user-level `~/.claude/settings.local.json`.
268
+
269
+ ---
270
+
271
+ ## Uninstall
272
+
273
+ ### Remove from a single project
274
+
275
+ ```bash
276
+ # Remove CLAUDE.md kira-lite section (or delete if it only has kira-lite)
277
+ # Remove kira-lite entries from .claude/settings.local.json
278
+ ```
279
+
280
+ ### Remove globally
281
+
282
+ ```bash
283
+ # Claude Code
284
+ claude mcp remove --scope user kira-lite
285
+
286
+ # npm
287
+ npm uninstall -g @offgridsec/kira-lite-mcp
288
+ ```
289
+
290
+ ### Remove config
291
+
292
+ ```bash
293
+ rm -rf ~/.kira-lite
294
+ ```
295
+
296
+ ---
297
+
298
+ ## Troubleshooting
299
+
300
+ ### "Settings Error: PostToolCall: Invalid key in record"
301
+
302
+ You have hooks in the **user-level** settings file (`~/.claude/settings.local.json`). Hooks only work at project level. Remove the `hooks` section from the user-level file.
303
+
304
+ ### MCP not showing in `/mcp`
305
+
306
+ Re-register globally:
307
+
308
+ ```bash
309
+ claude mcp add --scope user kira-lite -- npx -y @offgridsec/kira-lite-mcp
310
+ ```
311
+
312
+ ### Claude doesn't scan before writing
313
+
314
+ 1. Check that `CLAUDE.md` exists in the project root with the kira-lite instructions
315
+ 2. Verify the hook is in `.claude/settings.local.json` — this is the enforcement layer
316
+ 3. Start a **new** session (CLAUDE.md is read at session start)
317
+
318
+ ### Scans returning "Skipped"
319
+
320
+ Your scan mode is set to `"on-save"` or `"manual"`. Check with `get_config()` and change with `set_config({ scanMode: "every-edit" })`.
321
+
322
+ ### Hook fails silently
323
+
324
+ Make sure Node.js can find the hook script:
325
+
326
+ ```bash
327
+ node $(npm root -g)/@offgridsec/kira-lite-mcp/hook.mjs
328
+ ```
329
+
330
+ If it exits with no output, it's working. If it throws an error, check the path.
package/LICENSE ADDED
@@ -0,0 +1,96 @@
1
+ Elastic License 2.0 (ELv2)
2
+
3
+ Copyright 2025-2026 Offgrid Security
4
+
5
+ URL: https://www.elastic.co/licensing/elastic-license
6
+
7
+ ## Acceptance
8
+
9
+ By using the software, you agree to all of the terms and conditions below.
10
+
11
+ ## Copyright License
12
+
13
+ The licensor grants you a non-exclusive, royalty-free, worldwide,
14
+ non-sublicensable, non-transferable license to use, copy, distribute, make
15
+ available, and prepare derivative works of the software, in each case subject
16
+ to the limitations and conditions below.
17
+
18
+ ## Limitations
19
+
20
+ You may not provide the software to third parties as a hosted or managed
21
+ service, where the service provides users with access to any substantial set
22
+ of the features or functionality of the software.
23
+
24
+ You may not move, change, disable, or circumvent the license key functionality
25
+ in the software, and you may not remove or obscure any functionality in the
26
+ software that is protected by the license key.
27
+
28
+ You may not alter, remove, or obscure any licensing, copyright, or other
29
+ notices of the licensor in the software. Any use of the licensor's trademarks
30
+ is subject to applicable law.
31
+
32
+ ## Patents
33
+
34
+ The licensor grants you a license, under any patent claims the licensor can
35
+ license, or becomes able to license, to make, have made, use, sell, offer for
36
+ sale, import and have imported the software, in each case subject to the
37
+ limitations and conditions in this license. This license does not cover any
38
+ patent claims that you cause to be infringed by modifications or additions to
39
+ the software. If you or your company make any written claim that the software
40
+ infringes or contributes to infringement of any patent, your patent license
41
+ for the software granted under these terms ends immediately. If your company
42
+ makes such a claim, your patent license ends immediately for work on behalf
43
+ of your company.
44
+
45
+ ## Notices
46
+
47
+ You must ensure that anyone who gets a copy of any part of the software from
48
+ you also gets a copy of these terms.
49
+
50
+ If you modify the software, you must include in any modified copies of the
51
+ software prominent notices stating that you have modified the software.
52
+
53
+ ## No Other Rights
54
+
55
+ These terms do not imply any licenses other than those expressly granted in
56
+ these terms.
57
+
58
+ ## Termination
59
+
60
+ If you use the software in violation of these terms, such use is not licensed,
61
+ and your licenses will automatically terminate. If the licensor provides you
62
+ with a notice of your violation, and you cease all violation of this license
63
+ no later than 30 days after you receive that notice, your licenses will be
64
+ reinstated retroactively. However, if you violate these terms after such
65
+ reinstatement, any additional violation of these terms will cause your
66
+ licenses to terminate automatically and permanently.
67
+
68
+ ## No Liability
69
+
70
+ *As far as the law allows, the software comes as is, without any warranty or
71
+ condition, and the licensor will not be liable to you for any damages arising
72
+ out of these terms or the use or nature of the software, under any kind of
73
+ legal claim.*
74
+
75
+ ## Definitions
76
+
77
+ The **licensor** is the entity offering these terms, and the **software** is
78
+ the software the licensor makes available under these terms, including any
79
+ portion of it.
80
+
81
+ **you** refers to the individual or entity agreeing to these terms.
82
+
83
+ **your company** is any legal entity, sole proprietorship, or other kind of
84
+ organization that you work for, plus all organizations that have control over,
85
+ are under the control of, or are under common control with that organization.
86
+ **control** means ownership of substantially all the assets of an entity, or
87
+ the power to direct its management and policies by vote, contract, or
88
+ otherwise. Control can be direct or indirect.
89
+
90
+ **your licenses** are all the licenses granted to you for the software under
91
+ these terms.
92
+
93
+ **use** means anything you do with the software requiring one of your
94
+ licenses.
95
+
96
+ **trademark** means trademarks, service marks, and similar rights.
package/PRIVACY.md ADDED
@@ -0,0 +1,54 @@
1
+ # Privacy Policy
2
+
3
+ **Kira-Lite MCP Server** by [Offgrid Security](https://offgridsec.com)
4
+
5
+ Last updated: February 20, 2026
6
+
7
+ ---
8
+
9
+ ## What we collect
10
+
11
+ Kira-Lite collects **anonymous, non-personalized** usage telemetry to help us improve the product. This includes:
12
+
13
+ - **Tool usage** — which scan tools are called (e.g. `scan_code`, `scan_file`)
14
+ - **Scan statistics** — number of lines scanned, number of findings, severity counts, scan duration
15
+ - **Vulnerability rule IDs** — which rules triggered (e.g. `KIRA-JS-SQLI-001`, `CWE-89`)
16
+ - **Environment metadata** — Node.js version, platform (win32/linux/darwin), Kira-Lite version
17
+ - **Anonymous device ID** — a randomly generated UUID stored locally at `~/.kira-lite/device-id`
18
+
19
+ ## What we do NOT collect
20
+
21
+ - **No source code** — your code never leaves your machine
22
+ - **No file paths** — we do not log file names or directory structures
23
+ - **No personal information** — no names, emails, IP addresses, or account identifiers
24
+ - **No code snippets** — scan findings reference rule IDs only, not your actual code
25
+ - **No project metadata** — no repository names, branch names, or commit hashes
26
+
27
+ ## How it works
28
+
29
+ Telemetry is sent to [PostHog](https://posthog.com) (US region) using an anonymous device ID. This ID is a random UUID generated on first run and stored locally. It cannot be traced back to you.
30
+
31
+ ## How to opt out
32
+
33
+ Set the `KIRA_TELEMETRY` environment variable to disable all telemetry:
34
+
35
+ ```bash
36
+ # Add to your shell profile (~/.bashrc, ~/.zshrc, etc.)
37
+ export KIRA_TELEMETRY=off
38
+ ```
39
+
40
+ Or on Windows (PowerShell):
41
+
42
+ ```powershell
43
+ [System.Environment]::SetEnvironmentVariable("KIRA_TELEMETRY", "off", "User")
44
+ ```
45
+
46
+ When telemetry is off, **no data is sent anywhere**. Kira-Lite functions exactly the same.
47
+
48
+ ## Data retention
49
+
50
+ Anonymous telemetry data is retained for product analytics only. Since no personal data is collected, there is nothing to delete or request under GDPR/CCPA.
51
+
52
+ ## Contact
53
+
54
+ Questions about privacy? Reach us at [contact@offgridsec.com](mailto:contact@offgridsec.com).