vybsafe-mcp 0.0.0-stage → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +29 -2
  2. package/pack.js +43 -0
  3. package/package.json +11 -4
  4. package/server.js +86 -0
package/README.md CHANGED
@@ -1,3 +1,30 @@
1
- # Temporary Holding Version
1
+ # VybSafe for AI agents
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Lets Cursor, Claude Code, Windsurf or Claude Desktop scan your project with VybSafe and fix what it finds.
4
+
5
+ 1. Create an API key on the Tools page of your VybSafe account.
6
+ 2. Add the server.
7
+
8
+ Cursor (Settings, MCP, Add new server) or Claude Desktop config:
9
+
10
+ ```json
11
+ {
12
+ "mcpServers": {
13
+ "vybsafe": {
14
+ "command": "npx",
15
+ "args": ["-y", "vybsafe-mcp"],
16
+ "env": { "VYBSAFE_KEY": "vyb_live_your_key_here" }
17
+ }
18
+ }
19
+ }
20
+ ```
21
+
22
+ Claude Code:
23
+
24
+ ```
25
+ claude mcp add vybsafe -e VYBSAFE_KEY=vyb_live_your_key_here -- npx -y vybsafe-mcp
26
+ ```
27
+
28
+ 3. Ask your agent: "Scan this project with VybSafe and fix what it finds."
29
+
30
+ Tools: `vybsafe_scan_project`, `vybsafe_scan_site`, `vybsafe_projects`, `vybsafe_findings`. Full explanations and fixes need the Pro plan.
package/pack.js ADDED
@@ -0,0 +1,43 @@
1
+ // Collects a project's source files into a zip in memory, ready to send to VybSafe.
2
+ // Never includes .env files, git history, node_modules, build output or binary files.
3
+ import fs from 'node:fs';
4
+ import path from 'node:path';
5
+ import { zipSync, strToU8 } from 'fflate';
6
+
7
+ const SKIP_DIRS = new Set(['node_modules', '.git', '.next', '.vercel', 'dist', 'build', 'out', 'coverage', '.turbo', '.cache', 'vendor', '.svelte-kit', '.nuxt', '.output', '.expo', 'android', 'ios', '__pycache__', '.venv', 'venv']);
8
+ const TEXT_EXT = /\.(js|jsx|ts|tsx|mjs|cjs|json|sql|html|htm|vue|svelte|rules|yml|yaml|toml|prisma|md|mdx|css)$/i;
9
+ const NEVER = /(^|\/)\.env($|\.)|\.(pem|key|p12|pfx)$|(^|\/)(id_rsa|id_ed25519)/i;
10
+ const MAX_FILE = 600 * 1024;
11
+ export const MAX_TOTAL = 3.8 * 1024 * 1024;
12
+
13
+ export function packProject(root) {
14
+ const files = {};
15
+ let total = 0;
16
+ let skippedLarge = 0;
17
+ const walk = (dir, rel) => {
18
+ let entries;
19
+ try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch { return; }
20
+ for (const e of entries) {
21
+ const r = rel ? rel + '/' + e.name : e.name;
22
+ if (e.isSymbolicLink()) continue;
23
+ if (e.isDirectory()) { if (!SKIP_DIRS.has(e.name) && !e.name.startsWith('.git')) walk(path.join(dir, e.name), r); continue; }
24
+ if (!e.isFile() || NEVER.test(r)) continue;
25
+ if (!TEXT_EXT.test(e.name) && !/^(firestore\.rules|storage\.rules)$/.test(e.name)) continue;
26
+ if (/(package-lock\.json|yarn\.lock|pnpm-lock\.yaml)$/.test(e.name) && rel) continue;
27
+ const full = path.join(dir, e.name);
28
+ const size = fs.statSync(full).size;
29
+ if (size > MAX_FILE) { skippedLarge++; continue; }
30
+ if (total + size > MAX_TOTAL * 3) { skippedLarge++; continue; }
31
+ files['project/' + r] = fs.readFileSync(full);
32
+ total += size;
33
+ }
34
+ };
35
+ walk(root, '');
36
+ const count = Object.keys(files).length;
37
+ if (!count) throw new Error('No source files found here. Run this inside your project folder.');
38
+ const zip = zipSync(files, { level: 6 });
39
+ if (zip.length > MAX_TOTAL) throw new Error('This project is too large to send from the terminal (over 4 MB zipped). Upload it on the VybSafe website instead.');
40
+ return { zip, count, skippedLarge };
41
+ }
42
+
43
+ export { strToU8 };
package/package.json CHANGED
@@ -1,6 +1,13 @@
1
1
  {
2
2
  "name": "vybsafe-mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.1",
4
+ "description": "VybSafe for AI agents (Cursor, Claude Code, Windsurf, Claude Desktop). Scan the project and get plain-English fixes.",
5
+ "type": "module",
6
+ "bin": { "vybsafe-mcp": "server.js" },
7
+ "files": ["server.js", "pack.js", "README.md"],
8
+ "engines": { "node": ">=18.18" },
9
+ "dependencies": { "@modelcontextprotocol/sdk": "^1.32.2", "fflate": "^0.8.2", "zod": "^3.23.8" },
10
+ "keywords": ["mcp", "security", "vybsafe", "cursor", "claude"],
11
+ "author": "The Esbron Group",
12
+ "license": "UNLICENSED"
13
+ }
package/server.js ADDED
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env node
2
+ // VybSafe for AI agents. Add it to Cursor, Claude Code, Windsurf or Claude Desktop, then ask:
3
+ // "scan this project with VybSafe and fix what it finds".
4
+ // Needs VYBSAFE_KEY (create one on the Tools page of your VybSafe account).
5
+ import path from 'node:path';
6
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
7
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
8
+ import { z } from 'zod';
9
+ import { packProject } from './pack.js';
10
+
11
+ const KEY = process.env.VYBSAFE_KEY || '';
12
+ const BASE = (process.env.VYBSAFE_API || 'https://vybsafe.vercel.app').replace(/\/+$/, '');
13
+
14
+ async function call(pathname, init = {}) {
15
+ if (!KEY) throw new Error('VYBSAFE_KEY is not set. Create a key on the VybSafe Tools page and add it to this server\'s settings.');
16
+ let r;
17
+ try {
18
+ r = await fetch(BASE + pathname, { ...init, headers: { authorization: 'Bearer ' + KEY, 'user-agent': 'vybsafe-mcp', ...(init.headers || {}) }, signal: AbortSignal.timeout(90000) });
19
+ } catch (e) {
20
+ if (e?.name === 'TimeoutError' || e?.name === 'AbortError') throw new Error('VybSafe took too long to answer. Try again in a minute.');
21
+ throw new Error(`Couldn't reach VybSafe at ${BASE}. Check your internet connection, or set VYBSAFE_API if you use a different address.`);
22
+ }
23
+ const j = await r.json().catch(() => ({}));
24
+ if (r.status === 401) throw new Error(j.error || 'VybSafe did not accept your key. Create a new key on the VybSafe Tools page and update VYBSAFE_KEY.');
25
+ if (!r.ok) throw new Error(j.error || 'VybSafe answered ' + r.status);
26
+ return j;
27
+ }
28
+
29
+ function report(res) {
30
+ const lines = [`VybSafe score: ${res.score}/100. ${res.critical} critical, ${res.warning} warnings, ${res.passed} checks passed.`];
31
+ if (!res.findings?.length) lines.push('No open issues.');
32
+ for (const f of res.findings || []) {
33
+ lines.push('', `[${f.severity.toUpperCase()}] ${f.title}`);
34
+ if (f.file) lines.push(`Where: ${f.file}${f.line ? ':' + f.line : ''}`);
35
+ if (f.explain) lines.push(`What it means: ${f.explain}`);
36
+ if (f.risk) lines.push(`Risk: ${f.risk}`);
37
+ if (f.fix) lines.push(`How to fix: ${f.fix}`);
38
+ if (f.prompt) lines.push(`Fix instructions: ${f.prompt}`);
39
+ }
40
+ if (res.note) lines.push('', res.note);
41
+ if (res.findings?.some((f) => f.prompt)) lines.push('', 'Fix the critical issues first, keep each change minimal, then run vybsafe_scan_project again to confirm. If a secret key was exposed, tell the user to replace it with the provider, because fixing the code is not enough.');
42
+ if (res.dashboard) lines.push('', `Full results: ${res.dashboard}`);
43
+ return lines.join('\n');
44
+ }
45
+
46
+ const text = (t) => ({ content: [{ type: 'text', text: t }] });
47
+ const safe = (fn) => async (args) => { try { return text(await fn(args)); } catch (e) { return { ...text('VybSafe error: ' + e.message), isError: true }; } };
48
+
49
+ const server = new McpServer({ name: 'vybsafe', version: '1.0.1' });
50
+
51
+ server.registerTool('vybsafe_scan_project', {
52
+ title: 'Scan this project with VybSafe',
53
+ description: 'Security-scan the source code of a project folder with VybSafe. Returns each problem found, where it is, and how to fix it. Never sends .env files, node_modules or git history. Run it again after fixing to confirm.',
54
+ inputSchema: { folder: z.string().optional().describe('Project folder. Defaults to the current working directory.'), builder: z.enum(['lovable', 'cursor', 'bolt', 'v0', 'claude', 'other']).optional() },
55
+ }, safe(async ({ folder, builder }) => {
56
+ const root = path.resolve(folder || process.cwd());
57
+ const { zip } = packProject(root);
58
+ const q = new URLSearchParams({ name: path.basename(root), builder: builder || 'other' });
59
+ return report(await call('/api/v1/scan?' + q, { method: 'POST', body: zip, headers: { 'content-type': 'application/zip' } }));
60
+ }));
61
+
62
+ server.registerTool('vybsafe_scan_site', {
63
+ title: 'Scan a live site with VybSafe',
64
+ description: 'Check a live website the way an attacker would see it from the outside: headers, exposed files, keys in the page, HTTPS and data-law basics.',
65
+ inputSchema: { url: z.string().describe('The site address, for example https://my-app.vercel.app') },
66
+ }, safe(async ({ url }) => report(await call('/api/v1/scan', { method: 'POST', body: JSON.stringify({ url }), headers: { 'content-type': 'application/json' } }))));
67
+
68
+ server.registerTool('vybsafe_projects', {
69
+ title: 'List VybSafe projects',
70
+ description: 'List the projects in this VybSafe account with their latest score.',
71
+ inputSchema: {},
72
+ }, safe(async () => {
73
+ const { projects } = await call('/api/v1/projects');
74
+ return projects.length ? projects.map((p) => `${p.name} (${p.id}): score ${p.last_score ?? '-'}, ${p.last_critical ?? '-'} critical`).join('\n') : 'No projects yet.';
75
+ }));
76
+
77
+ server.registerTool('vybsafe_findings', {
78
+ title: 'Open issues for a VybSafe project',
79
+ description: 'Get the open issues for one VybSafe project, with fix instructions.',
80
+ inputSchema: { projectId: z.string().describe('Project id from vybsafe_projects') },
81
+ }, safe(async ({ projectId }) => {
82
+ const r = await call('/api/v1/projects/' + encodeURIComponent(projectId) + '/findings');
83
+ return report({ score: r.score, critical: r.findings.filter((f) => f.severity === 'critical').length, warning: r.findings.filter((f) => f.severity !== 'critical').length, passed: '-', findings: r.findings, note: r.note });
84
+ }));
85
+
86
+ await server.connect(new StdioServerTransport());