security-mcp 1.0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 security-mcp contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,295 @@
1
+ # security-mcp
2
+
3
+ [![npm version](https://img.shields.io/npm/v/security-mcp.svg)](https://www.npmjs.com/package/security-mcp)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
5
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D20-brightgreen.svg)](https://nodejs.org)
6
+ [![CI](https://github.com/AbrahamOO/security-mcp/actions/workflows/security-gate.yml/badge.svg)](https://github.com/AbrahamOO/security-mcp/actions)
7
+
8
+ **AI security MCP server and automated gate for Claude Code, GitHub Copilot, Cursor, Codex, Replit, and any MCP-compatible editor** -- enforcing OWASP, MITRE ATT&CK, NIST 800-53, Zero Trust, PCI DSS 4.0, and 20+ security frameworks on every code change before it ships.
9
+
10
+ ---
11
+
12
+ ## Quick Start
13
+
14
+ Install the MCP security server into all detected editors with one command:
15
+
16
+ ```bash
17
+ npx security-mcp install
18
+ ```
19
+
20
+ Target a specific editor:
21
+
22
+ ```bash
23
+ npx security-mcp install --claude-code
24
+ npx security-mcp install --cursor
25
+ npx security-mcp install --vscode
26
+ ```
27
+
28
+ Preview what would be installed without writing anything:
29
+
30
+ ```bash
31
+ npx security-mcp install --dry-run
32
+ ```
33
+
34
+ After installation, restart your editor. The `security-mcp` MCP server starts automatically.
35
+
36
+ In **Claude Code**, invoke the skill directly:
37
+
38
+ ```text
39
+ /security-review
40
+ ```
41
+
42
+ ---
43
+
44
+ ## What It Does
45
+
46
+ `security-mcp` gives your AI coding assistant the knowledge and tools of a **Principal Security Engineer** who has internalized every major security framework. It operates at four levels:
47
+
48
+ ### 1. MCP Server (Real-Time Tools)
49
+
50
+ The MCP server exposes tools that your AI can call during any coding session:
51
+
52
+ | Tool | What It Does |
53
+ | --- | --- |
54
+ | `security.get_system_prompt` | Returns the full elite security prompt (optionally filtered by stack, cloud provider, or payment processor) |
55
+ | `security.threat_model` | Generates a complete STRIDE + PASTA + ATT&CK + D3FEND threat model template for any described feature |
56
+ | `security.checklist` | Returns the pre-release security checklist, filterable by surface (web, api, mobile, ai, infra, payments) |
57
+ | `security.generate_policy` | Generates a `security-policy.json` tailored to your project surfaces and cloud provider |
58
+ | `security.run_pr_gate` | Runs the security policy gate against the current Git diff and reports findings |
59
+ | `repo.read_file` | Reads a file from the workspace |
60
+ | `repo.search` | Searches the codebase for patterns |
61
+
62
+ ### 2. MCP Prompts
63
+
64
+ Two reusable prompts are registered in the MCP server:
65
+
66
+ - **`security-engineer`** - Loads the full security system prompt, turning your AI into a Principal Security Engineer persona for the session.
67
+ - **`threat-model-template`** - Accepts a `feature` argument and returns a ready-to-fill threat model template.
68
+
69
+ ### 3. Claude Code Skill
70
+
71
+ The `/security-review` skill is a 24-section, 900-line security directive that embeds the complete security framework directly into Claude Code's context. It covers:
72
+
73
+ - STRIDE + PASTA + LINDDUN + DREAD threat modeling
74
+ - MITRE ATT&CK (Enterprise, Cloud, Mobile) coverage table
75
+ - MITRE D3FEND countermeasure mapping
76
+ - MITRE ATLAS adversarial ML threat coverage
77
+ - Zero Trust architecture enforcement (NIST 800-207)
78
+ - Cloud security rules (GCP, AWS, Azure) with absolute prohibitions
79
+ - Container and Kubernetes hardening (CIS Benchmark Level 2)
80
+ - Supply chain security (SLSA L3, SBOM, Sigstore)
81
+ - DevSecOps pipeline gates (SAST, SCA, IaC, DAST)
82
+ - Input validation - three-layer defense for every field type
83
+ - AI/LLM security (prompt injection defense, RAG access control, output validation)
84
+ - PCI DSS 4.0 payment flow controls
85
+ - GDPR/CCPA/HIPAA data flow compliance
86
+ - Vulnerability SLAs (CRITICAL: 24h, HIGH: 7d, MEDIUM: 30d)
87
+ - Pre-release security checklist (Section 22E)
88
+
89
+ ### 4. Security Gate (CI/CD)
90
+
91
+ The policy gate runs in CI and blocks PRs that violate security policy:
92
+
93
+ ```bash
94
+ npx security-mcp ci:pr-gate
95
+ ```
96
+
97
+ Gate checks cover hardcoded secrets, dependency vulnerabilities, IaC misconfigurations,
98
+ auth and authorization gaps, SSRF and CSRF exposure, and AI/LLM output bounding.
99
+
100
+ ---
101
+
102
+ ## Supported Editors
103
+
104
+ | Editor | Installation Method | Config Location |
105
+ | --- | --- | --- |
106
+ | Claude Code | `npx security-mcp install --claude-code` | `~/.claude/settings.json` |
107
+ | Cursor (global) | `npx security-mcp install --cursor` | `~/.cursor/mcp.json` |
108
+ | Cursor (workspace) | `npx security-mcp install --cursor` | `.cursor/mcp.json` |
109
+ | VS Code | `npx security-mcp install --vscode` | User `settings.json` |
110
+ | GitHub Copilot | Manual config (see below) | `.vscode/settings.json` |
111
+ | Codex | Manual config (see below) | Editor config |
112
+ | Replit | Manual config (see below) | `.replit` config |
113
+ | Any MCP-compatible | `npx security-mcp config` for snippet | Paste into editor config |
114
+
115
+ ---
116
+
117
+ ## Security Frameworks Covered
118
+
119
+ - OWASP Top 10 (Web + API)
120
+ - OWASP ASVS Level 2/3
121
+ - OWASP MASVS (Mobile)
122
+ - OWASP SAMM
123
+ - OWASP Top 10 for LLMs
124
+ - MITRE ATT&CK Enterprise v14+
125
+ - MITRE ATT&CK Cloud
126
+ - MITRE ATT&CK Mobile
127
+ - MITRE CAPEC
128
+ - MITRE D3FEND
129
+ - MITRE ATLAS (adversarial ML)
130
+ - NIST 800-53 Rev 5
131
+ - NIST CSF 2.0
132
+ - NIST 800-207 (Zero Trust Architecture)
133
+ - NIST 800-218 (SSDF)
134
+ - NIST AI RMF
135
+ - NIST 800-190 (Container Security)
136
+ - PCI DSS 4.0
137
+ - SOC 2 Type II
138
+ - ISO/IEC 27001:2022
139
+ - ISO/IEC 42001:2023 (AI Management)
140
+ - GDPR / CCPA / HIPAA
141
+ - CIS Benchmarks Level 2
142
+ - CSA CCM v4
143
+ - SLSA Level 3
144
+ - FedRAMP Moderate
145
+ - CVSS v4.0 + EPSS
146
+ - CWE/SANS Top 25
147
+
148
+ ---
149
+
150
+ ## Manual Configuration
151
+
152
+ ### Claude Code (`~/.claude/settings.json`)
153
+
154
+ ```json
155
+ {
156
+ "mcpServers": {
157
+ "security-mcp": {
158
+ "command": "npx",
159
+ "args": ["-y", "security-mcp", "serve"]
160
+ }
161
+ }
162
+ }
163
+ ```
164
+
165
+ ### Cursor (`~/.cursor/mcp.json` or `.cursor/mcp.json`)
166
+
167
+ ```json
168
+ {
169
+ "mcpServers": {
170
+ "security-mcp": {
171
+ "command": "npx",
172
+ "args": ["-y", "security-mcp", "serve"]
173
+ }
174
+ }
175
+ }
176
+ ```
177
+
178
+ ### VS Code / GitHub Copilot (`settings.json`)
179
+
180
+ ```json
181
+ {
182
+ "mcp.servers": {
183
+ "security-mcp": {
184
+ "command": "npx",
185
+ "args": ["-y", "security-mcp", "serve"]
186
+ }
187
+ }
188
+ }
189
+ ```
190
+
191
+ Print the recommended config snippet for any editor:
192
+
193
+ ```bash
194
+ npx security-mcp config
195
+ ```
196
+
197
+ ---
198
+
199
+ ## Security Policy
200
+
201
+ Copy the default security policy to your project and customize it:
202
+
203
+ ```bash
204
+ cp node_modules/security-mcp/defaults/security-policy.json .mcp/policies/security-policy.json
205
+ cp node_modules/security-mcp/defaults/evidence-map.json .mcp/mappings/evidence-map.json
206
+ ```
207
+
208
+ Or generate a policy tailored to your project via the MCP tool:
209
+
210
+ ```text
211
+ Ask your AI: "Run security.generate_policy with surfaces=[web, api, ai] and cloud=aws"
212
+ ```
213
+
214
+ ---
215
+
216
+ ## CI/CD Integration
217
+
218
+ Add the security gate to your GitHub Actions workflow:
219
+
220
+ ```yaml
221
+ name: Security Gate
222
+
223
+ on:
224
+ pull_request:
225
+ branches: [main, master]
226
+
227
+ jobs:
228
+ security-gate:
229
+ runs-on: ubuntu-latest
230
+ steps:
231
+ - uses: actions/checkout@v4
232
+ with:
233
+ fetch-depth: 0
234
+
235
+ - uses: actions/setup-node@v4
236
+ with:
237
+ node-version: '20'
238
+
239
+ - name: Run security gate
240
+ run: npx -y security-mcp ci:pr-gate
241
+ env:
242
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
243
+ ```
244
+
245
+ The gate exits non-zero on CRITICAL or HIGH findings, blocking the PR merge.
246
+
247
+ ---
248
+
249
+ ## Threat Modeling
250
+
251
+ Ask your AI to generate a threat model for any feature:
252
+
253
+ ```text
254
+ Run security.threat_model with feature="user authentication with OAuth 2.0" and surfaces=["web", "api"]
255
+ ```
256
+
257
+ The tool returns a complete STRIDE + PASTA + ATT&CK + D3FEND template covering:
258
+
259
+ - Asset inventory and trust boundaries
260
+ - STRIDE analysis per component and trust boundary
261
+ - ATT&CK technique mapping with D3FEND countermeasures
262
+ - NIST 800-53 Rev 5 control IDs
263
+ - Residual risk register with owner and review date
264
+ - Pre-release security checklist
265
+
266
+ ---
267
+
268
+ ## Non-Negotiable Rules (Always Enforced)
269
+
270
+ The security persona enforces these rules without exception:
271
+
272
+ - No `0.0.0.0/0` ingress or egress rules anywhere
273
+ - All internal services communicate via private VPC paths only (VPC endpoints, PrivateLink)
274
+ - Secrets stored only in a dedicated secret manager - never in code, env files, or logs
275
+ - TLS 1.3 for all in-transit data; TLS 1.0/1.1 strictly prohibited
276
+ - Argon2id (or bcrypt cost 14+) for password hashing - no MD5, SHA-1, or unsalted hashes
277
+ - Server-side schema validation (Zod, Yup, Valibot) on every API input
278
+ - No inline JavaScript; CSP nonce-based only
279
+ - FIDO2/WebAuthn passkey for admin and privileged operations
280
+ - Threat model required before implementing auth, payment, or AI features
281
+ - Zero Trust: never trust, always verify - every request, every token, every service call
282
+
283
+ ---
284
+
285
+ ## Contributing
286
+
287
+ See [CONTRIBUTING.md](CONTRIBUTING.md).
288
+
289
+ ## Security Disclosure
290
+
291
+ See [SECURITY.md](SECURITY.md) for responsible disclosure policy.
292
+
293
+ ## License
294
+
295
+ [MIT](LICENSE) - security-mcp contributors
@@ -0,0 +1,126 @@
1
+ {
2
+ "_description": "Maps security gate evidence IDs to file glob patterns. Copy to .mcp/mappings/evidence-map.json and customize for your project layout.",
3
+ "deny_by_default_authz": [
4
+ "src/**/auth*.ts",
5
+ "src/**/auth*.js",
6
+ "src/**/middleware*.ts",
7
+ "src/**/middleware*.js",
8
+ "middleware.ts",
9
+ "middleware.js",
10
+ "app/api/**",
11
+ "src/api/**",
12
+ "server/middleware/**"
13
+ ],
14
+ "service_to_service_auth": [
15
+ "src/**/service*.ts",
16
+ "src/**/client*.ts",
17
+ "infra/**",
18
+ "k8s/**",
19
+ "helm/**"
20
+ ],
21
+ "no_hardcoded_secrets": [
22
+ "**/*.ts",
23
+ "**/*.js",
24
+ "**/*.py",
25
+ "**/*.go",
26
+ "**/*.java",
27
+ "**/*.env*",
28
+ "**/*.yaml",
29
+ "**/*.yml",
30
+ "**/*.json",
31
+ "**/*.toml",
32
+ "**/*.ini",
33
+ "**/*.conf"
34
+ ],
35
+ "secret_manager_refs": [
36
+ "infra/**",
37
+ "terraform/**",
38
+ "k8s/**",
39
+ "helm/**",
40
+ "src/**",
41
+ "app/**"
42
+ ],
43
+ "tls_config_verified": [
44
+ "infra/**",
45
+ "terraform/**",
46
+ "k8s/**",
47
+ "helm/**",
48
+ "src/**/tls*.ts",
49
+ "src/**/ssl*.ts",
50
+ "nginx/**",
51
+ "caddy/**"
52
+ ],
53
+ "security_headers_present": [
54
+ "middleware.ts",
55
+ "middleware.js",
56
+ "src/**/middleware*.ts",
57
+ "src/**/security*.ts",
58
+ "src/**/headers*.ts",
59
+ "next.config.*",
60
+ "nginx/**",
61
+ "caddy/**",
62
+ "infra/**"
63
+ ],
64
+ "csrf_protection_present": [
65
+ "app/api/**",
66
+ "src/api/**",
67
+ "server/routes/**",
68
+ "src/**/csrf*.ts",
69
+ "src/**/csrf*.js"
70
+ ],
71
+ "csrf_tests_present": [
72
+ "**/*.test.ts",
73
+ "**/*.spec.ts",
74
+ "**/*.test.js",
75
+ "**/*.spec.js",
76
+ "tests/**",
77
+ "test/**",
78
+ "__tests__/**"
79
+ ],
80
+ "ssrf_guard_present": [
81
+ "src/**/ssrf*.ts",
82
+ "src/**/ssrf*.js",
83
+ "src/**/http-client*.ts",
84
+ "src/**/fetch*.ts",
85
+ "src/**/url-validator*.ts",
86
+ "src/**/request*.ts",
87
+ "lib/**/http*.ts",
88
+ "lib/**/fetch*.ts"
89
+ ],
90
+ "ssrf_tests_present": [
91
+ "**/*.test.ts",
92
+ "**/*.spec.ts",
93
+ "tests/**",
94
+ "test/**"
95
+ ],
96
+ "ios_ats_strict": [
97
+ "**/Info.plist",
98
+ "ios/**"
99
+ ],
100
+ "android_nsc_strict": [
101
+ "**/network_security_config.xml",
102
+ "**/AndroidManifest.xml",
103
+ "android/**"
104
+ ],
105
+ "release_not_debuggable": [
106
+ "**/AndroidManifest.xml",
107
+ "**/build.gradle",
108
+ "**/build.gradle.kts",
109
+ "android/**"
110
+ ],
111
+ "json_schema_validation": [
112
+ "ai/**",
113
+ "ml/**",
114
+ "src/**/ai*.ts",
115
+ "src/**/llm*.ts",
116
+ "src/**/agent*.ts",
117
+ "src/**/schema*.ts"
118
+ ],
119
+ "tool_allowlist_router": [
120
+ "ai/**",
121
+ "ml/**",
122
+ "src/**/tool-router*.ts",
123
+ "src/**/tool*.ts",
124
+ "src/**/agent*.ts"
125
+ ]
126
+ }
@@ -0,0 +1,93 @@
1
+ {
2
+ "name": "security-policy",
3
+ "version": "1.0.0",
4
+ "description": "Default security gate policy for security-mcp. Copy to .mcp/policies/security-policy.json and customize for your project.",
5
+ "required_checks": {
6
+ "secrets_scan": { "severity_block": ["HIGH", "CRITICAL"] },
7
+ "dependency_scan": { "severity_block": ["CRITICAL"] },
8
+ "sast": { "severity_block": ["CRITICAL"] },
9
+ "iac_scan": { "severity_block": ["HIGH", "CRITICAL"] }
10
+ },
11
+ "requirements": [
12
+ {
13
+ "id": "ZERO_TRUST",
14
+ "type": "gate",
15
+ "description": "All services enforce authentication + authorization. No implicit trust for any request.",
16
+ "evidence": ["deny_by_default_authz", "service_to_service_auth"]
17
+ },
18
+ {
19
+ "id": "SECRET_MANAGER_ONLY",
20
+ "type": "gate",
21
+ "description": "Secrets stored only in a dedicated secret manager. Never in code, env files, logs, or images.",
22
+ "evidence": ["no_hardcoded_secrets", "secret_manager_refs"]
23
+ },
24
+ {
25
+ "id": "TLS_13",
26
+ "type": "gate",
27
+ "description": "TLS 1.3 mandatory for all in-transit data. TLS 1.0/1.1 strictly prohibited.",
28
+ "evidence": ["tls_config_verified"]
29
+ },
30
+ {
31
+ "id": "CSP_NO_INLINE",
32
+ "type": "gate",
33
+ "description": "Content Security Policy enforced. No unsafe-inline, no unsafe-eval. Nonce-based CSP only.",
34
+ "evidence": ["security_headers_present"]
35
+ },
36
+ {
37
+ "id": "CSRF",
38
+ "type": "gate",
39
+ "description": "CSRF protection on all state-mutating endpoints.",
40
+ "evidence": ["csrf_protection_present", "csrf_tests_present"]
41
+ },
42
+ {
43
+ "id": "SSRF",
44
+ "type": "gate",
45
+ "description": "SSRF guards on all server-side HTTP calls. Private IP ranges and metadata endpoints blocked.",
46
+ "evidence": ["ssrf_guard_present", "ssrf_tests_present"]
47
+ },
48
+ {
49
+ "id": "MOBILE_MASVS",
50
+ "type": "gate",
51
+ "description": "Mobile apps meet OWASP MASVS L2. iOS ATS strict, Android NSC strict, release builds not debuggable.",
52
+ "evidence": ["ios_ats_strict", "android_nsc_strict", "release_not_debuggable"]
53
+ },
54
+ {
55
+ "id": "AI_BOUNDED_OUTPUTS",
56
+ "type": "gate",
57
+ "description": "AI/LLM outputs validated against JSON schema. Tool calls routed through an allowlist.",
58
+ "evidence": ["json_schema_validation", "tool_allowlist_router"]
59
+ }
60
+ ],
61
+ "artifacts_required": [
62
+ {
63
+ "pattern": "security/threat-models/*.md",
64
+ "description": "A threat model document is required for any change touching these paths.",
65
+ "on_changes": [
66
+ "src/**",
67
+ "app/**",
68
+ "api/**",
69
+ "server/**",
70
+ "infra/**",
71
+ "terraform/**",
72
+ "k8s/**",
73
+ "helm/**",
74
+ "mobile/**",
75
+ "ios/**",
76
+ "android/**",
77
+ "ai/**",
78
+ "ml/**"
79
+ ]
80
+ }
81
+ ],
82
+ "vulnerability_slas": {
83
+ "CRITICAL": "24h",
84
+ "HIGH": "7d",
85
+ "MEDIUM": "30d",
86
+ "LOW": "90d",
87
+ "CISA_KEV": "24h"
88
+ },
89
+ "exceptions": {
90
+ "require_ticket": true,
91
+ "approval_roles": ["SecurityLead", "GRC", "CTO"]
92
+ }
93
+ }
@@ -0,0 +1,17 @@
1
+ import { runPrGate } from "../gate/policy.js";
2
+ async function main() {
3
+ const baseRef = process.env.SECURITY_GATE_BASE_REF || "origin/main";
4
+ const headRef = process.env.SECURITY_GATE_HEAD_REF || "HEAD";
5
+ const policyPath = process.env.SECURITY_GATE_POLICY || ".mcp/policies/security-policy.json";
6
+ const result = await runPrGate({ baseRef, headRef, policyPath });
7
+ // Print result for Actions logs
8
+ console.log(JSON.stringify(result, null, 2));
9
+ if (result.status !== "PASS") {
10
+ process.exit(2);
11
+ }
12
+ }
13
+ // eslint-disable-next-line unicorn/prefer-top-level-await
14
+ main().catch((err) => {
15
+ console.error("security gate crashed:", err);
16
+ process.exit(3);
17
+ });
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * security-mcp CLI
4
+ *
5
+ * Subcommands:
6
+ * serve Start the MCP server over stdio (used by editors)
7
+ * install Auto-detect editors and write MCP + skill configs
8
+ * config Print MCP config JSON for manual editor setup
9
+ * --version
10
+ * --help
11
+ */
12
+ import { createRequire } from "module";
13
+ import { fileURLToPath } from "url";
14
+ import { dirname, resolve } from "path";
15
+ import { runInstall } from "./install.js";
16
+ import { main as runServer } from "../mcp/server.js";
17
+ const __dirname = dirname(fileURLToPath(import.meta.url));
18
+ const require = createRequire(import.meta.url);
19
+ function getVersion() {
20
+ try {
21
+ const pkg = require(resolve(__dirname, "../../package.json"));
22
+ return pkg.version;
23
+ }
24
+ catch {
25
+ return "unknown";
26
+ }
27
+ }
28
+ const VERSION = getVersion();
29
+ const HELP = `
30
+ security-mcp v${VERSION}
31
+
32
+ AI security MCP server and gate for Claude Code, Cursor, Copilot, Codex, Replit, and any MCP-compatible editor.
33
+
34
+ USAGE
35
+ npx security-mcp <command> [options]
36
+
37
+ COMMANDS
38
+ serve Start the MCP server over stdio (default for editors)
39
+ install Auto-detect installed editors and write MCP configs
40
+ config Print MCP config JSON for manual editor setup
41
+
42
+ OPTIONS (install)
43
+ --claude-code Write config for Claude Code only
44
+ --cursor Write config for Cursor only
45
+ --vscode Write config for VS Code only
46
+ --global Write to global editor config (default)
47
+ --dry-run Print what would change without writing
48
+
49
+ OPTIONS (general)
50
+ --version Print version
51
+ --help Print this help
52
+
53
+ EXAMPLES
54
+ # Start MCP server (called automatically by editors):
55
+ npx -y security-mcp serve
56
+
57
+ # Install into all detected editors:
58
+ npx security-mcp install
59
+
60
+ # Install into Claude Code only:
61
+ npx security-mcp install --claude-code
62
+
63
+ # Preview install without writing:
64
+ npx security-mcp install --dry-run
65
+
66
+ # Print JSON config snippet:
67
+ npx security-mcp config
68
+
69
+ EDITOR CONFIG (add manually if install fails):
70
+ {
71
+ "mcpServers": {
72
+ "security-mcp": {
73
+ "command": "npx",
74
+ "args": ["-y", "security-mcp", "serve"]
75
+ }
76
+ }
77
+ }
78
+
79
+ Claude Code: ~/.claude/settings.json
80
+ Cursor: ~/.cursor/mcp.json or .cursor/mcp.json
81
+ VS Code: .vscode/mcp.json (workspace)
82
+
83
+ MORE INFO
84
+ https://github.com/AbrahamOO/security-mcp
85
+ `;
86
+ const CONFIG_SNIPPET = {
87
+ mcpServers: {
88
+ "security-mcp": {
89
+ command: "npx",
90
+ args: ["-y", "security-mcp", "serve"]
91
+ }
92
+ }
93
+ };
94
+ async function main() {
95
+ const args = process.argv.slice(2);
96
+ if (args.includes("--version") || args.includes("-v")) {
97
+ process.stdout.write(`security-mcp v${VERSION}\n`);
98
+ process.exit(0);
99
+ }
100
+ if (args.includes("--help") || args.includes("-h")) {
101
+ process.stdout.write(HELP);
102
+ process.exit(0);
103
+ }
104
+ const command = args[0] ?? "serve";
105
+ switch (command) {
106
+ case "serve": {
107
+ // MCP stdio server - never write to stdout except via MCP protocol
108
+ await runServer();
109
+ break;
110
+ }
111
+ case "install": {
112
+ const options = {
113
+ claudeCode: args.includes("--claude-code"),
114
+ cursor: args.includes("--cursor"),
115
+ vscode: args.includes("--vscode"),
116
+ dryRun: args.includes("--dry-run"),
117
+ // If no editor flag specified, install to all detected
118
+ all: !args.includes("--claude-code") && !args.includes("--cursor") && !args.includes("--vscode")
119
+ };
120
+ await runInstall(options);
121
+ break;
122
+ }
123
+ case "config": {
124
+ process.stdout.write(JSON.stringify(CONFIG_SNIPPET, null, 2) + "\n");
125
+ process.stdout.write("\nAdd the above to your editor's MCP config file.\n");
126
+ process.stdout.write(" Claude Code: ~/.claude/settings.json\n");
127
+ process.stdout.write(" Cursor: ~/.cursor/mcp.json\n");
128
+ process.stdout.write(" VS Code: .vscode/mcp.json\n");
129
+ break;
130
+ }
131
+ default: {
132
+ process.stderr.write(`Unknown command: ${command}\nRun with --help for usage.\n`);
133
+ process.exit(1);
134
+ }
135
+ }
136
+ }
137
+ main().catch((err) => {
138
+ process.stderr.write(`Error: ${err instanceof Error ? err.message : String(err)}\n`);
139
+ process.exit(1);
140
+ });