@zivis/mcp 0.1.0-alpha.9 → 0.1.6

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 (328) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +19 -0
  3. package/dist/api-client.d.ts +1 -31
  4. package/dist/api-client.js +26 -66
  5. package/dist/auth/index.d.ts +1 -22
  6. package/dist/auth/index.js +15 -46
  7. package/dist/auth/jwt.d.ts +0 -16
  8. package/dist/auth/jwt.js +0 -13
  9. package/dist/auth/keychain.d.ts +6 -32
  10. package/dist/auth/keychain.js +83 -114
  11. package/dist/auth/oauth.d.ts +1 -42
  12. package/dist/auth/oauth.js +22 -64
  13. package/dist/auth/sessions.d.ts +5 -25
  14. package/dist/auth/sessions.js +20 -39
  15. package/dist/auth/token-refresh.d.ts +2 -22
  16. package/dist/auth/token-refresh.js +12 -47
  17. package/dist/cli.d.ts +1 -18
  18. package/dist/cli.js +30 -908
  19. package/dist/index.d.ts +0 -6
  20. package/dist/index.js +0 -7
  21. package/dist/lib/inspect-cache.d.ts +10 -0
  22. package/dist/lib/inspect-cache.js +75 -0
  23. package/dist/lib/next-steps.d.ts +27 -0
  24. package/dist/lib/next-steps.js +21 -0
  25. package/dist/matcher/ast-eval.d.ts +8 -0
  26. package/dist/matcher/ast-eval.js +95 -0
  27. package/dist/matcher/finding.d.ts +55 -0
  28. package/dist/matcher/finding.js +1 -0
  29. package/dist/matcher/index.d.ts +8 -0
  30. package/dist/matcher/index.js +202 -0
  31. package/dist/matcher/inference-candidates.d.ts +26 -0
  32. package/dist/matcher/inference-candidates.js +81 -0
  33. package/dist/matcher/walker.d.ts +7 -0
  34. package/dist/matcher/walker.js +71 -0
  35. package/dist/pattern-pack/index.d.ts +125 -0
  36. package/dist/pattern-pack/index.js +189 -0
  37. package/dist/pattern-packs/zivis-public-0.2.0/capsules/agents/privilege-separation.yaml +224 -0
  38. package/dist/pattern-packs/zivis-public-0.2.0/capsules/prompting/self-consistency-no-isolation.yaml +237 -0
  39. package/dist/pattern-packs/zivis-public-0.2.0/capsules/retrieval/context-injection-no-validator.yaml +348 -0
  40. package/dist/pattern-packs/zivis-public-0.2.0/capsules/security/late-org-filter.yaml +266 -0
  41. package/dist/pattern-packs/zivis-public-0.2.0/controls/external_validator_on_facts.yaml +37 -0
  42. package/dist/pattern-packs/zivis-public-0.2.0/controls/fact_validator_present.yaml +68 -0
  43. package/dist/pattern-packs/zivis-public-0.2.0/controls/human_approval_gate.yaml +44 -0
  44. package/dist/pattern-packs/zivis-public-0.2.0/controls/langgraph_state_machine_with_per_node_tools.yaml +35 -0
  45. package/dist/pattern-packs/zivis-public-0.2.0/controls/per_sample_retrieval_diversification.yaml +38 -0
  46. package/dist/pattern-packs/zivis-public-0.2.0/controls/prisma_extension_or_middleware_attaching_org_filter.yaml +31 -0
  47. package/dist/pattern-packs/zivis-public-0.2.0/controls/row_level_security_policy.yaml +37 -0
  48. package/dist/pattern-packs/zivis-public-0.2.0/controls/source_attribution_present.yaml +58 -0
  49. package/dist/pattern-packs/zivis-public-0.2.0/manifest.json +167 -0
  50. package/dist/pattern-packs/zivis-public-0.2.0/prompts/agents/privilege-separation/identify.md +54 -0
  51. package/dist/pattern-packs/zivis-public-0.2.0/prompts/prompting/self-consistency-no-isolation/identify.md +60 -0
  52. package/dist/pattern-packs/zivis-public-0.2.0/prompts/retrieval/context-injection-no-validator/identify.md +109 -0
  53. package/dist/pattern-packs/zivis-public-0.2.0/prompts/security/late-org-filter/identify.md +78 -0
  54. package/dist/project-binding.d.ts +2 -19
  55. package/dist/project-binding.js +38 -21
  56. package/dist/prompts/audit-dependencies.d.ts +2 -0
  57. package/dist/prompts/audit-dependencies.js +47 -0
  58. package/dist/prompts/getting-started.d.ts +2 -0
  59. package/dist/prompts/getting-started.js +37 -0
  60. package/dist/prompts/index.d.ts +2 -0
  61. package/dist/prompts/index.js +6 -0
  62. package/dist/resolve-application-id.d.ts +0 -4
  63. package/dist/resolve-application-id.js +0 -5
  64. package/dist/sanitize.d.ts +1 -21
  65. package/dist/sanitize.js +7 -41
  66. package/dist/server.d.ts +1 -13
  67. package/dist/server.js +134 -253
  68. package/dist/tools/artifacts.d.ts +76 -0
  69. package/dist/tools/artifacts.js +178 -0
  70. package/dist/tools/check-project.d.ts +5 -18
  71. package/dist/tools/check-project.js +120 -111
  72. package/dist/tools/check-repo-trust.d.ts +4 -19
  73. package/dist/tools/check-repo-trust.js +56 -47
  74. package/dist/tools/create-diagram.d.ts +0 -5
  75. package/dist/tools/create-diagram.js +0 -10
  76. package/dist/tools/create-document.d.ts +0 -5
  77. package/dist/tools/create-document.js +3 -9
  78. package/dist/tools/create-finding.d.ts +85 -0
  79. package/dist/tools/create-finding.js +136 -0
  80. package/dist/tools/delete-finding.d.ts +19 -0
  81. package/dist/tools/delete-finding.js +36 -0
  82. package/dist/tools/discover-local-infra.d.ts +0 -10
  83. package/dist/tools/discover-local-infra.js +3 -73
  84. package/dist/tools/enterprise/get-org-zat.d.ts +0 -5
  85. package/dist/tools/enterprise/get-org-zat.js +0 -6
  86. package/dist/tools/enterprise/get-threat-model.d.ts +1 -8
  87. package/dist/tools/enterprise/get-threat-model.js +9 -31
  88. package/dist/tools/enterprise/list-attack-scenarios.d.ts +24 -0
  89. package/dist/tools/enterprise/list-attack-scenarios.js +63 -0
  90. package/dist/tools/enterprise/list-threat-models.d.ts +1 -6
  91. package/dist/tools/enterprise/list-threat-models.js +1 -9
  92. package/dist/tools/enterprise/manage-actor.d.ts +2 -7
  93. package/dist/tools/enterprise/manage-actor.js +13 -7
  94. package/dist/tools/enterprise/manage-attack-scenario.d.ts +1 -6
  95. package/dist/tools/enterprise/manage-attack-scenario.js +12 -7
  96. package/dist/tools/enterprise/manage-data-asset.d.ts +2 -7
  97. package/dist/tools/enterprise/manage-data-asset.js +16 -7
  98. package/dist/tools/enterprise/manage-security-control.d.ts +1 -6
  99. package/dist/tools/enterprise/manage-security-control.js +17 -7
  100. package/dist/tools/explain-signal-for-diff.d.ts +34 -0
  101. package/dist/tools/explain-signal-for-diff.js +75 -0
  102. package/dist/tools/generate-diagram.d.ts +0 -6
  103. package/dist/tools/generate-diagram.js +21 -13
  104. package/dist/tools/get-application-overview.d.ts +0 -5
  105. package/dist/tools/get-application-overview.js +0 -6
  106. package/dist/tools/get-application.d.ts +0 -5
  107. package/dist/tools/get-application.js +0 -6
  108. package/dist/tools/get-diagram.d.ts +0 -5
  109. package/dist/tools/get-diagram.js +1 -11
  110. package/dist/tools/get-document.d.ts +0 -5
  111. package/dist/tools/get-document.js +0 -6
  112. package/dist/tools/get-oss-zat.d.ts +0 -5
  113. package/dist/tools/get-oss-zat.js +0 -7
  114. package/dist/tools/get-signal.d.ts +24 -0
  115. package/dist/tools/get-signal.js +75 -0
  116. package/dist/tools/get-started.d.ts +18 -0
  117. package/dist/tools/get-started.js +470 -0
  118. package/dist/tools/get-trust-keys.d.ts +0 -5
  119. package/dist/tools/get-trust-keys.js +0 -6
  120. package/dist/tools/import-openapi-endpoints.d.ts +0 -5
  121. package/dist/tools/import-openapi-endpoints.js +0 -6
  122. package/dist/tools/inspect-zat.d.ts +0 -5
  123. package/dist/tools/inspect-zat.js +0 -19
  124. package/dist/tools/inspect.d.ts +21 -0
  125. package/dist/tools/inspect.js +222 -0
  126. package/dist/tools/list-applications.d.ts +1 -6
  127. package/dist/tools/list-applications.js +0 -6
  128. package/dist/tools/list-diagrams.d.ts +0 -5
  129. package/dist/tools/list-diagrams.js +0 -6
  130. package/dist/tools/list-documents.d.ts +0 -5
  131. package/dist/tools/list-documents.js +0 -6
  132. package/dist/tools/list-endpoints.d.ts +1 -6
  133. package/dist/tools/list-endpoints.js +0 -6
  134. package/dist/tools/list-signals.d.ts +37 -0
  135. package/dist/tools/list-signals.js +83 -0
  136. package/dist/tools/manage-application.d.ts +64 -0
  137. package/dist/tools/manage-application.js +129 -0
  138. package/dist/tools/manage-diagram.d.ts +0 -5
  139. package/dist/tools/manage-diagram.js +0 -16
  140. package/dist/tools/manage-endpoint-lifecycle.d.ts +80 -0
  141. package/dist/tools/manage-endpoint-lifecycle.js +180 -0
  142. package/dist/tools/open-in-ide.d.ts +2 -14
  143. package/dist/tools/open-in-ide.js +0 -13
  144. package/dist/tools/review-change.d.ts +34 -0
  145. package/dist/tools/review-change.js +93 -0
  146. package/dist/tools/security-review.d.ts +0 -16
  147. package/dist/tools/security-review.js +63 -77
  148. package/dist/tools/threat-get-capsule.d.ts +15 -0
  149. package/dist/tools/threat-get-capsule.js +53 -0
  150. package/dist/tools/threat-get-inference-prompt.d.ts +15 -0
  151. package/dist/tools/threat-get-inference-prompt.js +73 -0
  152. package/dist/tools/threat-list-relevant-capsules.d.ts +17 -0
  153. package/dist/tools/threat-list-relevant-capsules.js +158 -0
  154. package/dist/tools/threat-run-matcher.d.ts +17 -0
  155. package/dist/tools/threat-run-matcher.js +145 -0
  156. package/dist/tools/update-document.d.ts +0 -5
  157. package/dist/tools/update-document.js +3 -9
  158. package/dist/tools/update-endpoint.d.ts +1 -6
  159. package/dist/tools/update-endpoint.js +0 -7
  160. package/dist/tools/update-finding.d.ts +61 -0
  161. package/dist/tools/update-finding.js +80 -0
  162. package/dist/tools/update-mermaid-source.d.ts +0 -13
  163. package/dist/tools/update-mermaid-source.js +0 -14
  164. package/dist/tools/verify-trust-mark.d.ts +0 -5
  165. package/dist/tools/verify-trust-mark.js +0 -6
  166. package/dist/types.d.ts +13 -13
  167. package/dist/types.js +22 -28
  168. package/package.json +28 -5
  169. package/dist/api-client.js.map +0 -1
  170. package/dist/auth/index.js.map +0 -1
  171. package/dist/auth/jwt.js.map +0 -1
  172. package/dist/auth/keychain.js.map +0 -1
  173. package/dist/auth/oauth.js.map +0 -1
  174. package/dist/auth/sessions.js.map +0 -1
  175. package/dist/auth/token-refresh.js.map +0 -1
  176. package/dist/cli.js.map +0 -1
  177. package/dist/index.js.map +0 -1
  178. package/dist/project-binding.js.map +0 -1
  179. package/dist/resolve-application-id.js.map +0 -1
  180. package/dist/sanitize.js.map +0 -1
  181. package/dist/server.js.map +0 -1
  182. package/dist/tools/check-project.js.map +0 -1
  183. package/dist/tools/check-repo-trust.js.map +0 -1
  184. package/dist/tools/create-diagram.js.map +0 -1
  185. package/dist/tools/create-document.js.map +0 -1
  186. package/dist/tools/discover-local-infra.js.map +0 -1
  187. package/dist/tools/enterprise/capture-evidence.d.ts +0 -54
  188. package/dist/tools/enterprise/capture-evidence.js +0 -72
  189. package/dist/tools/enterprise/capture-evidence.js.map +0 -1
  190. package/dist/tools/enterprise/create-report-ticket.d.ts +0 -34
  191. package/dist/tools/enterprise/create-report-ticket.js +0 -44
  192. package/dist/tools/enterprise/create-report-ticket.js.map +0 -1
  193. package/dist/tools/enterprise/end-pentest-session.d.ts +0 -33
  194. package/dist/tools/enterprise/end-pentest-session.js +0 -42
  195. package/dist/tools/enterprise/end-pentest-session.js.map +0 -1
  196. package/dist/tools/enterprise/generate-report.d.ts +0 -55
  197. package/dist/tools/enterprise/generate-report.js +0 -111
  198. package/dist/tools/enterprise/generate-report.js.map +0 -1
  199. package/dist/tools/enterprise/get-org-zat.js.map +0 -1
  200. package/dist/tools/enterprise/get-report-status.d.ts +0 -27
  201. package/dist/tools/enterprise/get-report-status.js +0 -38
  202. package/dist/tools/enterprise/get-report-status.js.map +0 -1
  203. package/dist/tools/enterprise/get-threat-model.js.map +0 -1
  204. package/dist/tools/enterprise/list-agents.d.ts +0 -42
  205. package/dist/tools/enterprise/list-agents.js +0 -95
  206. package/dist/tools/enterprise/list-agents.js.map +0 -1
  207. package/dist/tools/enterprise/list-report-issues.d.ts +0 -36
  208. package/dist/tools/enterprise/list-report-issues.js +0 -50
  209. package/dist/tools/enterprise/list-report-issues.js.map +0 -1
  210. package/dist/tools/enterprise/list-threat-models.js.map +0 -1
  211. package/dist/tools/enterprise/manage-actor.js.map +0 -1
  212. package/dist/tools/enterprise/manage-attack-scenario.js.map +0 -1
  213. package/dist/tools/enterprise/manage-component.d.ts +0 -58
  214. package/dist/tools/enterprise/manage-component.js +0 -90
  215. package/dist/tools/enterprise/manage-component.js.map +0 -1
  216. package/dist/tools/enterprise/manage-data-asset.js.map +0 -1
  217. package/dist/tools/enterprise/manage-data-flow.d.ts +0 -57
  218. package/dist/tools/enterprise/manage-data-flow.js +0 -98
  219. package/dist/tools/enterprise/manage-data-flow.js.map +0 -1
  220. package/dist/tools/enterprise/manage-finding.d.ts +0 -69
  221. package/dist/tools/enterprise/manage-finding.js +0 -106
  222. package/dist/tools/enterprise/manage-finding.js.map +0 -1
  223. package/dist/tools/enterprise/manage-security-control.js.map +0 -1
  224. package/dist/tools/enterprise/manage-test-case.d.ts +0 -88
  225. package/dist/tools/enterprise/manage-test-case.js +0 -119
  226. package/dist/tools/enterprise/manage-test-case.js.map +0 -1
  227. package/dist/tools/enterprise/promote-finding-to-issue.d.ts +0 -36
  228. package/dist/tools/enterprise/promote-finding-to-issue.js +0 -65
  229. package/dist/tools/enterprise/promote-finding-to-issue.js.map +0 -1
  230. package/dist/tools/enterprise/publish-report-version.d.ts +0 -34
  231. package/dist/tools/enterprise/publish-report-version.js +0 -75
  232. package/dist/tools/enterprise/publish-report-version.js.map +0 -1
  233. package/dist/tools/enterprise/publish-test-to-library.d.ts +0 -31
  234. package/dist/tools/enterprise/publish-test-to-library.js +0 -40
  235. package/dist/tools/enterprise/publish-test-to-library.js.map +0 -1
  236. package/dist/tools/enterprise/record-test-result.d.ts +0 -67
  237. package/dist/tools/enterprise/record-test-result.js +0 -75
  238. package/dist/tools/enterprise/record-test-result.js.map +0 -1
  239. package/dist/tools/enterprise/start-pentest-session.d.ts +0 -35
  240. package/dist/tools/enterprise/start-pentest-session.js +0 -50
  241. package/dist/tools/enterprise/start-pentest-session.js.map +0 -1
  242. package/dist/tools/enterprise/sync-report-section.d.ts +0 -41
  243. package/dist/tools/enterprise/sync-report-section.js +0 -79
  244. package/dist/tools/enterprise/sync-report-section.js.map +0 -1
  245. package/dist/tools/enterprise/update-report-issue.d.ts +0 -55
  246. package/dist/tools/enterprise/update-report-issue.js +0 -69
  247. package/dist/tools/enterprise/update-report-issue.js.map +0 -1
  248. package/dist/tools/generate-diagram.js.map +0 -1
  249. package/dist/tools/get-agent-test-results.d.ts +0 -41
  250. package/dist/tools/get-agent-test-results.js +0 -86
  251. package/dist/tools/get-agent-test-results.js.map +0 -1
  252. package/dist/tools/get-application-overview.js.map +0 -1
  253. package/dist/tools/get-application.js.map +0 -1
  254. package/dist/tools/get-artifact-content.d.ts +0 -29
  255. package/dist/tools/get-artifact-content.js +0 -86
  256. package/dist/tools/get-artifact-content.js.map +0 -1
  257. package/dist/tools/get-diagram.js.map +0 -1
  258. package/dist/tools/get-document.js.map +0 -1
  259. package/dist/tools/get-finding-details.d.ts +0 -28
  260. package/dist/tools/get-finding-details.js +0 -43
  261. package/dist/tools/get-finding-details.js.map +0 -1
  262. package/dist/tools/get-findings.d.ts +0 -57
  263. package/dist/tools/get-findings.js +0 -103
  264. package/dist/tools/get-findings.js.map +0 -1
  265. package/dist/tools/get-oss-zat.js.map +0 -1
  266. package/dist/tools/get-recon-scan.d.ts +0 -27
  267. package/dist/tools/get-recon-scan.js +0 -46
  268. package/dist/tools/get-recon-scan.js.map +0 -1
  269. package/dist/tools/get-scan-output.d.ts +0 -27
  270. package/dist/tools/get-scan-output.js +0 -64
  271. package/dist/tools/get-scan-output.js.map +0 -1
  272. package/dist/tools/get-scenario-details.d.ts +0 -27
  273. package/dist/tools/get-scenario-details.js +0 -46
  274. package/dist/tools/get-scenario-details.js.map +0 -1
  275. package/dist/tools/get-test-case-results.d.ts +0 -37
  276. package/dist/tools/get-test-case-results.js +0 -66
  277. package/dist/tools/get-test-case-results.js.map +0 -1
  278. package/dist/tools/get-test-details.d.ts +0 -29
  279. package/dist/tools/get-test-details.js +0 -49
  280. package/dist/tools/get-test-details.js.map +0 -1
  281. package/dist/tools/get-trust-keys.js.map +0 -1
  282. package/dist/tools/import-openapi-endpoints.js.map +0 -1
  283. package/dist/tools/inspect-zat.js.map +0 -1
  284. package/dist/tools/list-agent-test-cases.d.ts +0 -41
  285. package/dist/tools/list-agent-test-cases.js +0 -73
  286. package/dist/tools/list-agent-test-cases.js.map +0 -1
  287. package/dist/tools/list-applications.js.map +0 -1
  288. package/dist/tools/list-diagrams.js.map +0 -1
  289. package/dist/tools/list-documents.js.map +0 -1
  290. package/dist/tools/list-endpoints.js.map +0 -1
  291. package/dist/tools/list-recon-scans.d.ts +0 -36
  292. package/dist/tools/list-recon-scans.js +0 -74
  293. package/dist/tools/list-recon-scans.js.map +0 -1
  294. package/dist/tools/list-scan-artifacts.d.ts +0 -41
  295. package/dist/tools/list-scan-artifacts.js +0 -63
  296. package/dist/tools/list-scan-artifacts.js.map +0 -1
  297. package/dist/tools/list-scans.d.ts +0 -44
  298. package/dist/tools/list-scans.js +0 -91
  299. package/dist/tools/list-scans.js.map +0 -1
  300. package/dist/tools/list-test-library.d.ts +0 -44
  301. package/dist/tools/list-test-library.js +0 -83
  302. package/dist/tools/list-test-library.js.map +0 -1
  303. package/dist/tools/list-test-scenarios.d.ts +0 -31
  304. package/dist/tools/list-test-scenarios.js +0 -66
  305. package/dist/tools/list-test-scenarios.js.map +0 -1
  306. package/dist/tools/local-scan.d.ts +0 -40
  307. package/dist/tools/local-scan.js +0 -261
  308. package/dist/tools/local-scan.js.map +0 -1
  309. package/dist/tools/manage-diagram.js.map +0 -1
  310. package/dist/tools/open-in-ide.js.map +0 -1
  311. package/dist/tools/run-test-scenario.d.ts +0 -37
  312. package/dist/tools/run-test-scenario.js +0 -70
  313. package/dist/tools/run-test-scenario.js.map +0 -1
  314. package/dist/tools/scan-pr.d.ts +0 -27
  315. package/dist/tools/scan-pr.js +0 -51
  316. package/dist/tools/scan-pr.js.map +0 -1
  317. package/dist/tools/security-review.js.map +0 -1
  318. package/dist/tools/setup-red-team-target.d.ts +0 -79
  319. package/dist/tools/setup-red-team-target.js +0 -430
  320. package/dist/tools/setup-red-team-target.js.map +0 -1
  321. package/dist/tools/triage-finding.d.ts +0 -47
  322. package/dist/tools/triage-finding.js +0 -116
  323. package/dist/tools/triage-finding.js.map +0 -1
  324. package/dist/tools/update-document.js.map +0 -1
  325. package/dist/tools/update-endpoint.js.map +0 -1
  326. package/dist/tools/update-mermaid-source.js.map +0 -1
  327. package/dist/tools/verify-trust-mark.js.map +0 -1
  328. package/dist/types.js.map +0 -1
@@ -0,0 +1,145 @@
1
+ import { z } from "zod";
2
+ import * as fs from "node:fs/promises";
3
+ import * as fssync from "node:fs";
4
+ import * as os from "node:os";
5
+ import * as path from "node:path";
6
+ import * as crypto from "node:crypto";
7
+ import { exec } from "node:child_process";
8
+ import { promisify } from "node:util";
9
+ import { runMatcher } from "../matcher/index.js";
10
+ import { buildInferenceBundle } from "../matcher/inference-candidates.js";
11
+ import { withNextSteps, withNextStepsError } from "../lib/next-steps.js";
12
+ const execAsync = promisify(exec);
13
+ export const THREAT_RUN_MATCHER_NAME = "zivis_threat_run_matcher";
14
+ export const THREAT_RUN_MATCHER_DESCRIPTION = `Run the local pattern matcher against the latest repo graph artifact and emit normalized threat findings.
15
+
16
+ Use this when:
17
+ - The user asks ZIVIS to actually evaluate (not just list) which patterns fire on their code
18
+ - After 'zivis inspect' has produced an artifact and the user wants concrete findings
19
+ - "find security issues in my code", "check this against the threat library", "what's actually wrong here"
20
+
21
+ Phase 3 v1 evaluates AST strategies for real (via @ast-grep/napi for TS/JS, plus Python and Go via dynamic language packs). INFER strategies emit a candidate the host LLM is expected to pick up via zivis_threat_get_inference_prompt and run with its own model. GRAPH / META / DEP / CONFIG strategies are surfaced as fired_strategies with match_count: 0 — visible-but-not-evaluated for now.
22
+
23
+ Lane assignment per finding:
24
+ - trusted: count of fired deterministic strategies meets the capsule's required_evidence_count
25
+ - inferred: at least one strategy fired but the bar wasn't met (host should run inference to confirm)
26
+
27
+ The output is a normalized findings array with pattern_id, lane, confidence, evidence spans, and (for inferred-lane findings) an inference_candidate the host LLM uses to run deeper analysis.`;
28
+ export const THREAT_RUN_MATCHER_SCHEMA = {
29
+ artifact_path: z
30
+ .string()
31
+ .optional()
32
+ .describe("Path to a specific RepoGraphArtifactV1 JSON. If omitted, the most recent inspect run in the user cache is used."),
33
+ cwd: z
34
+ .string()
35
+ .optional()
36
+ .describe("Repo root for source-file walking — capsule AST strategies match against files in this directory. Defaults to server cwd."),
37
+ };
38
+ export function createThreatRunMatcherHandler() {
39
+ return async (params) => {
40
+ const cwd = params.cwd ?? process.cwd();
41
+ let artifactPath;
42
+ try {
43
+ artifactPath = await resolveArtifactPath(params.artifact_path, cwd);
44
+ }
45
+ catch (err) {
46
+ return withNextStepsError(`No repo graph artifact found. ${err.message}`, [
47
+ {
48
+ id: "run_zivis_inspect",
49
+ label: "Run `zivis inspect` to build the local repo graph first",
50
+ tool: "zivis_inspect",
51
+ why: "The matcher consumes the latest inspect artifact.",
52
+ },
53
+ ], "Run `zivis inspect` first; this tool reads from its output.");
54
+ }
55
+ const result = await runMatcher({ artifactPath, cwd });
56
+ const inferenceBundle = await buildInferenceBundle(result.findings);
57
+ const headline = result.summary.total === 0
58
+ ? "Matcher ran cleanly — no patterns fired against this repo."
59
+ : `Matcher emitted ${result.summary.total} finding(s): ${result.summary.trusted_count} trusted, ${result.summary.inferred_count} inferred. ` +
60
+ (inferenceBundle.inference_candidates.length > 0
61
+ ? `IMPORTANT: ${inferenceBundle.inference_candidates.length} inference_candidate${inferenceBundle.inference_candidates.length === 1 ? "" : "s"} require host-side execution — see host_required_action.`
62
+ : "");
63
+ return withNextSteps({
64
+ ...result,
65
+ host_required_action: inferenceBundle.host_required_action,
66
+ inference_candidates: inferenceBundle.inference_candidates,
67
+ }, result.summary.inferred_count > 0
68
+ ? [
69
+ {
70
+ id: "get_inference_prompts",
71
+ label: "Pull inference prompts for inferred-lane findings and run them in your model",
72
+ tool: "zivis_threat_get_inference_prompt",
73
+ why: "Each inferred finding has an inference_candidate.prompt_ref. Pass it (or the capsule_id) to retrieve the prompt bundle.",
74
+ },
75
+ {
76
+ id: "review_findings",
77
+ label: "Review the trusted-lane findings first; they're evidence-backed and ready for the threat model",
78
+ tool: "zivis_threat_run_matcher",
79
+ why: "Trusted-lane findings can land in the threat model directly. Inferred require host-LLM confirmation.",
80
+ },
81
+ ]
82
+ : result.summary.total === 0
83
+ ? [
84
+ {
85
+ id: "expand_pack",
86
+ label: "No matches today — proprietary patterns evaluated server-side may still apply",
87
+ tool: "zivis_threat_run_matcher",
88
+ why: "Public pack covers a curated subset. Phase 4 sends the artifact for proprietary platform evaluation.",
89
+ },
90
+ ]
91
+ : [], headline);
92
+ };
93
+ }
94
+ function userCacheRoot() {
95
+ const home = os.homedir();
96
+ if (process.platform === "darwin") {
97
+ return path.join(home, "Library", "Caches", "zivis");
98
+ }
99
+ if (process.platform === "win32") {
100
+ const localAppData = process.env.LOCALAPPDATA ?? path.join(home, "AppData", "Local");
101
+ return path.join(localAppData, "zivis", "Cache");
102
+ }
103
+ const xdg = process.env.XDG_CACHE_HOME;
104
+ return path.join(xdg ?? path.join(home, ".cache"), "zivis");
105
+ }
106
+ async function resolveArtifactPath(explicit, cwd) {
107
+ if (explicit) {
108
+ if (!fssync.existsSync(explicit)) {
109
+ throw new Error(`Artifact path does not exist: ${explicit}`);
110
+ }
111
+ return explicit;
112
+ }
113
+ const repoId = await deriveRepoId(cwd);
114
+ const runsDir = path.join(userCacheRoot(), "repos", repoId, "inspect", "runs");
115
+ if (!fssync.existsSync(runsDir)) {
116
+ throw new Error(`No inspect runs for this repo (looked under ${runsDir}). Run \`zivis inspect\` from this directory first.`);
117
+ }
118
+ const candidates = [];
119
+ for (const entry of await fs.readdir(runsDir)) {
120
+ if (!entry.endsWith(".json"))
121
+ continue;
122
+ const full = path.join(runsDir, entry);
123
+ const stat = await fs.stat(full);
124
+ candidates.push({ file: full, mtime: stat.mtimeMs });
125
+ }
126
+ if (candidates.length === 0) {
127
+ throw new Error(`No inspect runs found under ${runsDir}.`);
128
+ }
129
+ candidates.sort((a, b) => b.mtime - a.mtime);
130
+ return candidates[0].file;
131
+ }
132
+ async function deriveRepoId(cwd) {
133
+ try {
134
+ const { stdout } = await execAsync("git remote get-url origin", { cwd });
135
+ const remote = stdout.trim();
136
+ if (remote)
137
+ return "remote-" + sha256Short(remote);
138
+ }
139
+ catch {
140
+ }
141
+ return "path-" + sha256Short(cwd);
142
+ }
143
+ function sha256Short(value) {
144
+ return crypto.createHash("sha256").update(value).digest("hex").slice(0, 16);
145
+ }
@@ -1,8 +1,3 @@
1
- /**
2
- * zivis_update_document — Update a document's title, markdown content, or tags.
3
- *
4
- * Maps to: PATCH /api/documents/:id
5
- */
6
1
  import { z } from "zod";
7
2
  import type { ApiClient } from "../api-client.js";
8
3
  export declare const UPDATE_DOCUMENT_NAME = "zivis_update_document";
@@ -1,10 +1,5 @@
1
- /**
2
- * zivis_update_document — Update a document's title, markdown content, or tags.
3
- *
4
- * Maps to: PATCH /api/documents/:id
5
- */
6
1
  import { z } from "zod";
7
- import { sanitizeResponse } from "../sanitize.js";
2
+ import { sanitizeResponse, sanitizeInboundText } from "../sanitize.js";
8
3
  export const UPDATE_DOCUMENT_NAME = "zivis_update_document";
9
4
  export const UPDATE_DOCUMENT_DESCRIPTION = `Update a document's title, markdown content, or tags. At least one of these fields must be provided.
10
5
 
@@ -47,9 +42,9 @@ export function createUpdateDocumentHandler(apiClient) {
47
42
  }
48
43
  const body = {};
49
44
  if (title !== undefined)
50
- body.title = title;
45
+ body.title = sanitizeInboundText(title, 500);
51
46
  if (content !== undefined)
52
- body.content = content;
47
+ body.content = sanitizeInboundText(content, 200_000);
53
48
  if (tags !== undefined)
54
49
  body.tags = tags;
55
50
  const data = await apiClient.patch(`/api/documents/${document_id}`, body);
@@ -60,4 +55,3 @@ export function createUpdateDocumentHandler(apiClient) {
60
55
  }
61
56
  };
62
57
  }
63
- //# sourceMappingURL=update-document.js.map
@@ -1,8 +1,3 @@
1
- /**
2
- * zivis_update_endpoint — Update a specific endpoint's configuration
3
- *
4
- * Maps to: PATCH /api/rt/applications/:id/endpoints/:endpointId
5
- */
6
1
  import { z } from "zod";
7
2
  import type { ApiClient } from "../api-client.js";
8
3
  export declare const UPDATE_ENDPOINT_NAME = "zivis_update_endpoint";
@@ -15,8 +10,8 @@ export declare const UPDATE_ENDPOINT_SCHEMA: {
15
10
  POST: "POST";
16
11
  GET: "GET";
17
12
  PATCH: "PATCH";
18
- DELETE: "DELETE";
19
13
  PUT: "PUT";
14
+ DELETE: "DELETE";
20
15
  HEAD: "HEAD";
21
16
  OPTIONS: "OPTIONS";
22
17
  }>>;
@@ -1,8 +1,3 @@
1
- /**
2
- * zivis_update_endpoint — Update a specific endpoint's configuration
3
- *
4
- * Maps to: PATCH /api/rt/applications/:id/endpoints/:endpointId
5
- */
6
1
  import { z } from "zod";
7
2
  import { requireApplicationId } from "../resolve-application-id.js";
8
3
  import { sanitizeResponse } from "../sanitize.js";
@@ -79,7 +74,6 @@ export function createUpdateEndpointHandler(apiClient) {
79
74
  }
80
75
  const application_id = req.id;
81
76
  const apiPath = `/api/rt/applications/${application_id}/endpoints/${params.endpoint_id}`;
82
- // Map snake_case params to camelCase API fields, only including provided values
83
77
  const body = {};
84
78
  if (params.path !== undefined)
85
79
  body.path = params.path;
@@ -142,4 +136,3 @@ export function createUpdateEndpointHandler(apiClient) {
142
136
  }
143
137
  };
144
138
  }
145
- //# sourceMappingURL=update-endpoint.js.map
@@ -0,0 +1,61 @@
1
+ import { z } from "zod";
2
+ import type { ApiClient } from "../api-client.js";
3
+ export declare const UPDATE_FINDING_NAME = "zivis_update_finding";
4
+ export declare const UPDATE_FINDING_DESCRIPTION = "Update an existing security finding \u2014 edit its fields or change its status.\n\nUse to correct or flesh out a finding (title, severity, description, category, remediation, CWE/OWASP), or to move it through its lifecycle (triaged, resolved, dismissed, suppressed). Only pass the fields you want to change. Every change is audited. Pass the finding's id (from zivis_create_finding or the findings list). To delete a finding, use zivis_delete_finding instead.";
5
+ export declare const UPDATE_FINDING_SCHEMA: {
6
+ finding_id: z.ZodString;
7
+ title: z.ZodOptional<z.ZodString>;
8
+ severity: z.ZodOptional<z.ZodEnum<{
9
+ critical: "critical";
10
+ high: "high";
11
+ medium: "medium";
12
+ low: "low";
13
+ info: "info";
14
+ }>>;
15
+ description: z.ZodOptional<z.ZodString>;
16
+ category: z.ZodOptional<z.ZodEnum<{
17
+ vulnerability: "vulnerability";
18
+ misconfiguration: "misconfiguration";
19
+ secret: "secret";
20
+ anomaly: "anomaly";
21
+ other: "other";
22
+ }>>;
23
+ remediation_steps: z.ZodOptional<z.ZodString>;
24
+ cwe_id: z.ZodOptional<z.ZodString>;
25
+ owasp_id: z.ZodOptional<z.ZodString>;
26
+ status: z.ZodOptional<z.ZodEnum<{
27
+ open: "open";
28
+ in_progress: "in_progress";
29
+ resolved: "resolved";
30
+ dismissed: "dismissed";
31
+ triaged: "triaged";
32
+ suppressed: "suppressed";
33
+ }>>;
34
+ dismiss_reason: z.ZodOptional<z.ZodEnum<{
35
+ false_positive: "false_positive";
36
+ risk_accepted: "risk_accepted";
37
+ duplicate: "duplicate";
38
+ wont_fix: "wont_fix";
39
+ }>>;
40
+ note: z.ZodOptional<z.ZodString>;
41
+ };
42
+ type UpdateFindingParams = {
43
+ finding_id: string;
44
+ title?: string;
45
+ severity?: "critical" | "high" | "medium" | "low" | "info";
46
+ description?: string;
47
+ category?: "vulnerability" | "misconfiguration" | "secret" | "anomaly" | "other";
48
+ remediation_steps?: string;
49
+ cwe_id?: string;
50
+ owasp_id?: string;
51
+ status?: "open" | "triaged" | "in_progress" | "resolved" | "dismissed" | "suppressed";
52
+ dismiss_reason?: "false_positive" | "risk_accepted" | "duplicate" | "wont_fix";
53
+ note?: string;
54
+ };
55
+ export declare function createUpdateFindingHandler(apiClient: ApiClient): (params: UpdateFindingParams) => Promise<{
56
+ content: {
57
+ type: "text";
58
+ text: string;
59
+ }[];
60
+ }>;
61
+ export {};
@@ -0,0 +1,80 @@
1
+ import { z } from "zod";
2
+ import { sanitizeResponse, sanitizeInboundText } from "../sanitize.js";
3
+ export const UPDATE_FINDING_NAME = "zivis_update_finding";
4
+ export const UPDATE_FINDING_DESCRIPTION = `Update an existing security finding — edit its fields or change its status.
5
+
6
+ Use to correct or flesh out a finding (title, severity, description, category, remediation, CWE/OWASP), or to move it through its lifecycle (triaged, resolved, dismissed, suppressed). Only pass the fields you want to change. Every change is audited. Pass the finding's id (from zivis_create_finding or the findings list). To delete a finding, use zivis_delete_finding instead.`;
7
+ export const UPDATE_FINDING_SCHEMA = {
8
+ finding_id: z.string().describe("UUID of the finding to update"),
9
+ title: z.string().optional().describe("New title"),
10
+ severity: z
11
+ .enum(["critical", "high", "medium", "low", "info"])
12
+ .optional()
13
+ .describe("New severity"),
14
+ description: z.string().optional().describe("New description / details (markdown allowed)"),
15
+ category: z
16
+ .enum(["vulnerability", "misconfiguration", "secret", "anomaly", "other"])
17
+ .optional()
18
+ .describe("New category"),
19
+ remediation_steps: z.string().optional().describe("New remediation guidance"),
20
+ cwe_id: z.string().optional().describe("CWE id, e.g. 'CWE-89'"),
21
+ owasp_id: z.string().optional().describe("OWASP id, e.g. 'A01'"),
22
+ status: z
23
+ .enum(["open", "triaged", "in_progress", "resolved", "dismissed", "suppressed"])
24
+ .optional()
25
+ .describe("New lifecycle status. Use zivis_delete_finding to delete."),
26
+ dismiss_reason: z
27
+ .enum(["false_positive", "risk_accepted", "duplicate", "wont_fix"])
28
+ .optional()
29
+ .describe("Reason, when status=dismissed"),
30
+ note: z.string().optional().describe("Optional note recorded in the audit history"),
31
+ };
32
+ function errorResult(message) {
33
+ return {
34
+ content: [{ type: "text", text: `Error: ${message}` }],
35
+ isError: true,
36
+ };
37
+ }
38
+ function successResult(data) {
39
+ return {
40
+ content: [{ type: "text", text: JSON.stringify(sanitizeResponse(data), null, 2) }],
41
+ };
42
+ }
43
+ export function createUpdateFindingHandler(apiClient) {
44
+ return async (params) => {
45
+ try {
46
+ if (!params.finding_id || !params.finding_id.trim()) {
47
+ return errorResult("finding_id is required");
48
+ }
49
+ const body = {};
50
+ if (params.title !== undefined)
51
+ body.title = sanitizeInboundText(params.title, 500);
52
+ if (params.severity !== undefined)
53
+ body.severity = params.severity;
54
+ if (params.description !== undefined)
55
+ body.description = sanitizeInboundText(params.description, 8000);
56
+ if (params.category !== undefined)
57
+ body.category = params.category;
58
+ if (params.remediation_steps !== undefined)
59
+ body.remediationSteps = sanitizeInboundText(params.remediation_steps, 4000);
60
+ if (params.cwe_id !== undefined)
61
+ body.cweId = params.cwe_id;
62
+ if (params.owasp_id !== undefined)
63
+ body.owaspId = params.owasp_id;
64
+ if (params.status !== undefined)
65
+ body.status = params.status;
66
+ if (params.dismiss_reason !== undefined)
67
+ body.dismissReason = sanitizeInboundText(params.dismiss_reason, 2000);
68
+ if (params.note !== undefined)
69
+ body.note = sanitizeInboundText(params.note, 4000);
70
+ if (Object.keys(body).length === 0) {
71
+ return errorResult("Provide at least one field to update");
72
+ }
73
+ const data = await apiClient.patch(`/api/findings/unified/${encodeURIComponent(params.finding_id)}`, body);
74
+ return successResult(data);
75
+ }
76
+ catch (err) {
77
+ return errorResult(err?.message ?? "Failed to update finding");
78
+ }
79
+ };
80
+ }
@@ -1,16 +1,3 @@
1
- /**
2
- * zivis_update_mermaid_source — Update the Mermaid source of a diagram
3
- *
4
- * Maps to: PATCH /api/diagrams/:id with { content: <mermaidSource> }
5
- *
6
- * Workflow for an editing AI:
7
- * 1. Call zivis_get_diagram with the diagram_id — returns current content (Mermaid text) + metadata.
8
- * 2. Reason about the change the user requested. Produce a new Mermaid source string.
9
- * 3. Call this tool with the new source to persist it.
10
- *
11
- * Use this for diagrams whose contentType is "mermaid". For canvas/node diagrams
12
- * (contentType = "canvas"), use zivis_manage_diagram instead.
13
- */
14
1
  import { z } from "zod";
15
2
  import type { ApiClient } from "../api-client.js";
16
3
  export declare const UPDATE_MERMAID_SOURCE_NAME = "zivis_update_mermaid_source";
@@ -1,16 +1,3 @@
1
- /**
2
- * zivis_update_mermaid_source — Update the Mermaid source of a diagram
3
- *
4
- * Maps to: PATCH /api/diagrams/:id with { content: <mermaidSource> }
5
- *
6
- * Workflow for an editing AI:
7
- * 1. Call zivis_get_diagram with the diagram_id — returns current content (Mermaid text) + metadata.
8
- * 2. Reason about the change the user requested. Produce a new Mermaid source string.
9
- * 3. Call this tool with the new source to persist it.
10
- *
11
- * Use this for diagrams whose contentType is "mermaid". For canvas/node diagrams
12
- * (contentType = "canvas"), use zivis_manage_diagram instead.
13
- */
14
1
  import { z } from "zod";
15
2
  import { sanitizeResponse } from "../sanitize.js";
16
3
  export const UPDATE_MERMAID_SOURCE_NAME = "zivis_update_mermaid_source";
@@ -73,4 +60,3 @@ export function createUpdateMermaidSourceHandler(apiClient) {
73
60
  }
74
61
  };
75
62
  }
76
- //# sourceMappingURL=update-mermaid-source.js.map
@@ -1,8 +1,3 @@
1
- /**
2
- * zivis_verify_trust_mark — Verify a trust mark by hash or compact token
3
- *
4
- * Maps to: GET /api/verify/:hash OR GET /api/verify-token/:token (public, no auth)
5
- */
6
1
  import { z } from "zod";
7
2
  import type { ZivisConfig } from "../types.js";
8
3
  export declare const VERIFY_TRUST_MARK_NAME = "zivis_verify_trust_mark";
@@ -1,8 +1,3 @@
1
- /**
2
- * zivis_verify_trust_mark — Verify a trust mark by hash or compact token
3
- *
4
- * Maps to: GET /api/verify/:hash OR GET /api/verify-token/:token (public, no auth)
5
- */
6
1
  import { z } from "zod";
7
2
  export const VERIFY_TRUST_MARK_NAME = "zivis_verify_trust_mark";
8
3
  export const VERIFY_TRUST_MARK_DESCRIPTION = `Verify a ZIVIS Trust Mark by its SHA-256 hash or Ed25519 compact token.
@@ -105,4 +100,3 @@ export function createVerifyTrustMarkHandler(config) {
105
100
  }
106
101
  };
107
102
  }
108
- //# sourceMappingURL=verify-trust-mark.js.map
package/dist/types.d.ts CHANGED
@@ -1,6 +1,3 @@
1
- /**
2
- * Shared types for the ZIVIS MCP Security Server
3
- */
4
1
  export interface OAuthTokens {
5
2
  access_token: string;
6
3
  refresh_token?: string;
@@ -10,9 +7,7 @@ export interface OAuthTokens {
10
7
  export type AuthMethod = "oauth" | "apikey" | "none";
11
8
  export interface AuthCredentials {
12
9
  method: AuthMethod;
13
- /** OAuth access token (when method === "oauth") */
14
10
  accessToken?: string;
15
- /** WorkOS API key (when method === "apikey") */
16
11
  apiKey?: string;
17
12
  }
18
13
  export interface AuthStatus {
@@ -186,26 +181,31 @@ export interface SessionInfo {
186
181
  }
187
182
  export type SessionIndex = Record<string, SessionInfo>;
188
183
  export interface ProjectBinding {
189
- /** Expected ZIVIS_SESSION value (e.g., "zivis", "acme-corp") */
190
184
  session: string;
191
- /** Zivis org UUID (API) */
192
185
  orgId?: string;
193
- /** WorkOS org id — OAuth login and JWT org_id use this boundary */
194
186
  workosOrgId?: string;
195
- /** Human-readable org name */
196
187
  orgName?: string;
197
- /** RT application UUID when this project is tied to a single app in the org */
198
188
  applicationId?: string;
199
- /** Display name for that application (optional) */
200
189
  applicationName?: string;
190
+ apiBaseUrl?: string;
191
+ oauthApiUrl?: string;
192
+ oauthClientId?: string;
193
+ keychainPrefix?: string;
194
+ configDir?: string;
195
+ }
196
+ export interface CredentialStorage {
197
+ keychainPrefix: string;
198
+ configDir: string;
201
199
  }
202
200
  export interface ZivisConfig {
203
201
  apiBaseUrl: string;
204
202
  oauthClientId: string;
205
203
  oauthApiUrl: string;
206
204
  callbackPort: number;
207
- /** Named session for multi-tenant isolation (from ZIVIS_SESSION env var) */
208
205
  session?: string;
206
+ keychainPrefix?: string;
207
+ configDir?: string;
208
+ workspacePath?: string;
209
209
  }
210
210
  interface EnvConfig {
211
211
  apiBaseUrl: string;
@@ -214,7 +214,7 @@ interface EnvConfig {
214
214
  keychainPrefix: string;
215
215
  configDir: string;
216
216
  }
217
- export declare const BUILD_ENV: "staging" | "production";
218
217
  export declare const ENV_CONFIG: EnvConfig;
219
218
  export declare const DEFAULT_CONFIG: ZivisConfig;
219
+ export declare function credentialStorageFromConfig(config?: ZivisConfig): CredentialStorage;
220
220
  export {};
package/dist/types.js CHANGED
@@ -1,33 +1,27 @@
1
- /**
2
- * Shared types for the ZIVIS MCP Security Server
3
- */
4
- const ENVIRONMENT_CONFIGS = {
5
- staging: {
6
- apiBaseUrl: "https://staging.zivis.ai",
7
- oauthClientId: "client_01KGCMZ482H9SJPKTVRCC213K0",
8
- oauthApiUrl: "https://delightful-abundance-65-staging.authkit.app",
9
- keychainPrefix: "io.zivis.mcp.staging",
10
- configDir: "zivis-staging",
11
- },
12
- production: {
13
- apiBaseUrl: "https://app.zivis.ai",
14
- oauthClientId: "client_01KGCPA567YEEVXV307AERCB93",
15
- oauthApiUrl: "https://api.workos.com",
16
- keychainPrefix: "io.zivis.mcp",
17
- configDir: "zivis",
18
- },
1
+ const PRODUCTION_DEFAULTS = {
2
+ apiBaseUrl: "https://app.zivis.ai",
3
+ oauthClientId: "client_01KGCPA567YEEVXV307AERCB93",
4
+ oauthApiUrl: "https://auth2.zivis.ai",
5
+ keychainPrefix: "ai.zivis.mcp",
6
+ configDir: "zivis",
7
+ };
8
+ export const ENV_CONFIG = {
9
+ apiBaseUrl: process.env.ZIVIS_API_URL || PRODUCTION_DEFAULTS.apiBaseUrl,
10
+ oauthClientId: process.env.ZIVIS_OAUTH_CLIENT_ID || PRODUCTION_DEFAULTS.oauthClientId,
11
+ oauthApiUrl: process.env.ZIVIS_OAUTH_API_URL || PRODUCTION_DEFAULTS.oauthApiUrl,
12
+ keychainPrefix: process.env.ZIVIS_KEYCHAIN_PREFIX || PRODUCTION_DEFAULTS.keychainPrefix,
13
+ configDir: process.env.ZIVIS_CONFIG_DIR || PRODUCTION_DEFAULTS.configDir,
19
14
  };
20
- // Build-time environment (defaults to staging for development)
21
- export const BUILD_ENV = (process.env.ZIVIS_BUILD_ENV || "staging");
22
- // Get the config for the current build environment
23
- export const ENV_CONFIG = ENVIRONMENT_CONFIGS[BUILD_ENV] || ENVIRONMENT_CONFIGS.staging;
24
15
  export const DEFAULT_CONFIG = {
25
- // Runtime env vars override build-time defaults (useful for testing)
26
- apiBaseUrl: process.env.ZIVIS_API_URL || ENV_CONFIG.apiBaseUrl,
27
- oauthClientId: process.env.ZIVIS_OAUTH_CLIENT_ID || ENV_CONFIG.oauthClientId,
28
- oauthApiUrl: process.env.ZIVIS_OAUTH_API_URL || ENV_CONFIG.oauthApiUrl,
16
+ apiBaseUrl: ENV_CONFIG.apiBaseUrl,
17
+ oauthClientId: ENV_CONFIG.oauthClientId,
18
+ oauthApiUrl: ENV_CONFIG.oauthApiUrl,
29
19
  callbackPort: 8741,
30
- // Session isolation for multi-tenant safety
31
20
  session: process.env.ZIVIS_SESSION || undefined,
32
21
  };
33
- //# sourceMappingURL=types.js.map
22
+ export function credentialStorageFromConfig(config) {
23
+ return {
24
+ keychainPrefix: config?.keychainPrefix ?? ENV_CONFIG.keychainPrefix,
25
+ configDir: config?.configDir ?? ENV_CONFIG.configDir,
26
+ };
27
+ }
package/package.json CHANGED
@@ -1,7 +1,14 @@
1
1
  {
2
2
  "name": "@zivis/mcp",
3
- "version": "0.1.0-alpha.9",
3
+ "version": "0.1.6",
4
4
  "description": "ZIVIS MCP server — threat modeling, security scans, and AI red team tools for IDE integration",
5
+ "license": "Apache-2.0",
6
+ "homepage": "https://zivis.ai",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/zivisai/zivis-platform.git",
10
+ "directory": "zivis-mcp-security"
11
+ },
5
12
  "type": "module",
6
13
  "bin": {
7
14
  "zivis-mcp": "./dist/index.js"
@@ -13,19 +20,27 @@
13
20
  "./auth/token-refresh": "./dist/auth/token-refresh.js",
14
21
  "./api-client": "./dist/api-client.js",
15
22
  "./project-binding": "./dist/project-binding.js",
23
+ "./resolve-application-id": "./dist/resolve-application-id.js",
16
24
  "./server": "./dist/server.js",
17
25
  "./types": "./dist/types.js",
18
- "./cli": "./dist/cli.js"
26
+ "./cli": "./dist/cli.js",
27
+ "./pattern-pack": "./dist/pattern-pack/index.js",
28
+ "./matcher": "./dist/matcher/index.js"
19
29
  },
20
30
  "files": [
21
31
  "dist",
22
- "package.json"
32
+ "package.json",
33
+ "README.md",
34
+ "LICENSE"
23
35
  ],
24
36
  "publishConfig": {
25
- "access": "restricted"
37
+ "access": "public"
26
38
  },
27
39
  "scripts": {
28
- "build": "tsc && node scripts/ensure-symlink.cjs",
40
+ "build:pattern-pack": "tsx ../scripts/build-pattern-pack.ts",
41
+ "build": "tsc -p tsconfig.build.json && pnpm run build:pattern-pack && node scripts/ensure-symlink.cjs",
42
+ "prepublishOnly": "rm -rf dist && pnpm run build",
43
+ "postpublish": "node -e \"const p=require('./package.json'); require('child_process').execSync('npm dist-tag add '+p.name+'@'+p.version+' latest',{stdio:'inherit'});\"",
29
44
  "dev": "tsc --watch",
30
45
  "start": "node dist/index.js",
31
46
  "test": "vitest run",
@@ -37,13 +52,21 @@
37
52
  "node": ">=20.0.0"
38
53
  },
39
54
  "dependencies": {
55
+ "@ast-grep/lang-go": "^0.0.6",
56
+ "@ast-grep/lang-python": "^0.0.6",
57
+ "@ast-grep/napi": "^0.42.1",
40
58
  "@modelcontextprotocol/sdk": "^1.26.0",
59
+ "js-yaml": "^4.1.0",
41
60
  "open": "^10.1.0",
42
61
  "zod": "^4.0.0"
43
62
  },
44
63
  "devDependencies": {
64
+ "@types/js-yaml": "^4.0.9",
45
65
  "@types/node": "^22.0.0",
66
+ "ajv": "^8.17.1",
67
+ "ajv-formats": "^3.0.1",
46
68
  "husky": "^9.1.7",
69
+ "tsx": "^4.19.2",
47
70
  "typescript": "^5.7.0",
48
71
  "vitest": "^3.0.0"
49
72
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"api-client.js","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,OAAO,SAAS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