@securecode-ai/mcp 0.1.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.
Files changed (103) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +71 -0
  3. package/dist/api/client.d.ts +22 -0
  4. package/dist/api/client.js +141 -0
  5. package/dist/api/client.js.map +1 -0
  6. package/dist/api/types.d.ts +129 -0
  7. package/dist/api/types.js +3 -0
  8. package/dist/api/types.js.map +1 -0
  9. package/dist/approval/auditLog.d.ts +3 -0
  10. package/dist/approval/auditLog.js +67 -0
  11. package/dist/approval/auditLog.js.map +1 -0
  12. package/dist/approval/broker.d.ts +11 -0
  13. package/dist/approval/broker.js +252 -0
  14. package/dist/approval/broker.js.map +1 -0
  15. package/dist/approval/types.d.ts +26 -0
  16. package/dist/approval/types.js +58 -0
  17. package/dist/approval/types.js.map +1 -0
  18. package/dist/attack/agentLoop.d.ts +21 -0
  19. package/dist/attack/agentLoop.js +148 -0
  20. package/dist/attack/agentLoop.js.map +1 -0
  21. package/dist/attack/executor.d.ts +17 -0
  22. package/dist/attack/executor.js +162 -0
  23. package/dist/attack/executor.js.map +1 -0
  24. package/dist/attack/policy.d.ts +26 -0
  25. package/dist/attack/policy.js +73 -0
  26. package/dist/attack/policy.js.map +1 -0
  27. package/dist/attack/protocol.d.ts +64 -0
  28. package/dist/attack/protocol.js +3 -0
  29. package/dist/attack/protocol.js.map +1 -0
  30. package/dist/attack/report.d.ts +16 -0
  31. package/dist/attack/report.js +54 -0
  32. package/dist/attack/report.js.map +1 -0
  33. package/dist/auth/credentialStore.d.ts +20 -0
  34. package/dist/auth/credentialStore.js +148 -0
  35. package/dist/auth/credentialStore.js.map +1 -0
  36. package/dist/auth/keychain.d.ts +14 -0
  37. package/dist/auth/keychain.js +267 -0
  38. package/dist/auth/keychain.js.map +1 -0
  39. package/dist/index.d.ts +2 -0
  40. package/dist/index.js +170 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/mcp/server.d.ts +2 -0
  43. package/dist/mcp/server.js +183 -0
  44. package/dist/mcp/server.js.map +1 -0
  45. package/dist/mcp/tools.d.ts +2 -0
  46. package/dist/mcp/tools.js +120 -0
  47. package/dist/mcp/tools.js.map +1 -0
  48. package/dist/mcp/types.d.ts +26 -0
  49. package/dist/mcp/types.js +3 -0
  50. package/dist/mcp/types.js.map +1 -0
  51. package/dist/project-map/astHelpers.d.ts +89 -0
  52. package/dist/project-map/astHelpers.js +468 -0
  53. package/dist/project-map/astHelpers.js.map +1 -0
  54. package/dist/project-map/cache.d.ts +11 -0
  55. package/dist/project-map/cache.js +86 -0
  56. package/dist/project-map/cache.js.map +1 -0
  57. package/dist/project-map/confidence.d.ts +50 -0
  58. package/dist/project-map/confidence.js +87 -0
  59. package/dist/project-map/confidence.js.map +1 -0
  60. package/dist/project-map/crossFile.d.ts +73 -0
  61. package/dist/project-map/crossFile.js +33 -0
  62. package/dist/project-map/crossFile.js.map +1 -0
  63. package/dist/project-map/detectors.d.ts +83 -0
  64. package/dist/project-map/detectors.js +376 -0
  65. package/dist/project-map/detectors.js.map +1 -0
  66. package/dist/project-map/layer1.d.ts +74 -0
  67. package/dist/project-map/layer1.js +928 -0
  68. package/dist/project-map/layer1.js.map +1 -0
  69. package/dist/project-map/layer2.d.ts +30 -0
  70. package/dist/project-map/layer2.js +249 -0
  71. package/dist/project-map/layer2.js.map +1 -0
  72. package/dist/project-map/mapBuilder.d.ts +17 -0
  73. package/dist/project-map/mapBuilder.js +164 -0
  74. package/dist/project-map/mapBuilder.js.map +1 -0
  75. package/dist/project-map/parserLoader.d.ts +61 -0
  76. package/dist/project-map/parserLoader.js +175 -0
  77. package/dist/project-map/parserLoader.js.map +1 -0
  78. package/dist/project-map/schemas.d.ts +28 -0
  79. package/dist/project-map/schemas.js +131 -0
  80. package/dist/project-map/schemas.js.map +1 -0
  81. package/dist/project-map/types.d.ts +232 -0
  82. package/dist/project-map/types.js +61 -0
  83. package/dist/project-map/types.js.map +1 -0
  84. package/dist/tools/attack.d.ts +2 -0
  85. package/dist/tools/attack.js +80 -0
  86. package/dist/tools/attack.js.map +1 -0
  87. package/dist/tools/fix.d.ts +2 -0
  88. package/dist/tools/fix.js +60 -0
  89. package/dist/tools/fix.js.map +1 -0
  90. package/dist/tools/map.d.ts +2 -0
  91. package/dist/tools/map.js +46 -0
  92. package/dist/tools/map.js.map +1 -0
  93. package/dist/tools/scan.d.ts +2 -0
  94. package/dist/tools/scan.js +55 -0
  95. package/dist/tools/scan.js.map +1 -0
  96. package/dist/utils/files.d.ts +8 -0
  97. package/dist/utils/files.js +79 -0
  98. package/dist/utils/files.js.map +1 -0
  99. package/package.json +53 -0
  100. package/resources/tree-sitter/tree-sitter-javascript.wasm +0 -0
  101. package/resources/tree-sitter/tree-sitter-python.wasm +0 -0
  102. package/resources/tree-sitter/tree-sitter-tsx.wasm +0 -0
  103. package/resources/tree-sitter/tree-sitter-typescript.wasm +0 -0
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TOOLS = void 0;
4
+ exports.TOOLS = [
5
+ {
6
+ name: 'securecode.scan',
7
+ description: 'Scan a source file or code string for vulnerabilities. Read-only: no approval needed. Returns findings (type, severity, location, message, evidence). Uses the SecureCode AI multi-phase pipeline (Scout discovery, Juror verification, Reconcile).',
8
+ inputSchema: {
9
+ type: 'object',
10
+ properties: {
11
+ code: {
12
+ type: 'string',
13
+ description: 'Source code to scan (if filePath is omitted).',
14
+ },
15
+ filePath: {
16
+ type: 'string',
17
+ description: 'Workspace-relative path to the file to scan (reads from disk within the workspace root).',
18
+ },
19
+ language: {
20
+ type: 'string',
21
+ description: 'Language id (javascript, typescript, python, php). Inferred from filePath if omitted.',
22
+ },
23
+ },
24
+ },
25
+ },
26
+ {
27
+ name: 'securecode.map',
28
+ description: 'Get or build the Project Map for the workspace — extracted endpoints, middleware, auth scheme, and ORM. Read-only: no approval needed. Actions: "endpoints" (default, returns the endpoint list), "status" (map metadata), "build" (rebuild the map from source).',
29
+ inputSchema: {
30
+ type: 'object',
31
+ properties: {
32
+ action: {
33
+ type: 'string',
34
+ enum: ['status', 'endpoints', 'build'],
35
+ description: 'What to do: "status" for map metadata, "endpoints" for the endpoint list (default), "build" to rebuild the map from source.',
36
+ },
37
+ },
38
+ },
39
+ },
40
+ {
41
+ name: 'securecode.fix',
42
+ description: 'Generate a patch for a specific vulnerability finding. REQUIRES human approval before executing. Returns the fixed code + diff + explanation. Does NOT auto-apply; the human reviews and applies the patch.',
43
+ inputSchema: {
44
+ type: 'object',
45
+ properties: {
46
+ code: {
47
+ type: 'string',
48
+ description: 'The source code containing the vulnerability.',
49
+ },
50
+ filePath: {
51
+ type: 'string',
52
+ description: 'Workspace-relative path to the file (reads from disk if code is omitted).',
53
+ },
54
+ language: {
55
+ type: 'string',
56
+ description: 'Language id (javascript, typescript, python, php).',
57
+ },
58
+ vulnerabilityType: {
59
+ type: 'string',
60
+ description: 'Vulnerability type (e.g. sql_injection, xss, missing_authorization).',
61
+ },
62
+ lineStart: {
63
+ type: 'number',
64
+ description: '1-indexed start line of the finding.',
65
+ },
66
+ lineEnd: {
67
+ type: 'number',
68
+ description: '1-indexed end line of the finding.',
69
+ },
70
+ evidenceSnippet: {
71
+ type: 'string',
72
+ description: 'The vulnerable code snippet.',
73
+ },
74
+ framework: {
75
+ type: 'string',
76
+ description: 'Optional framework hint (e.g. express, nextjs, fastapi).',
77
+ },
78
+ },
79
+ required: ['code', 'language', 'vulnerabilityType', 'lineStart', 'lineEnd', 'evidenceSnippet'],
80
+ },
81
+ },
82
+ {
83
+ name: 'securecode.attack',
84
+ description: 'Request an endpoint red-team attack against a localhost dev server. REQUIRES human approval. The target must be a mapped endpoint from the Project Map and the dev server must already be running on localhost. Beta: localhost targets only.',
85
+ inputSchema: {
86
+ type: 'object',
87
+ properties: {
88
+ filePath: {
89
+ type: 'string',
90
+ description: 'Workspace-relative path to the source file containing the endpoint.',
91
+ },
92
+ code: {
93
+ type: 'string',
94
+ description: 'Source code to analyze (if filePath is omitted).',
95
+ },
96
+ language: {
97
+ type: 'string',
98
+ description: 'Language id.',
99
+ },
100
+ vulnerabilityType: {
101
+ type: 'string',
102
+ description: 'Optional — skip auto-scan and attack this vulnerability type.',
103
+ },
104
+ lineStart: {
105
+ type: 'number',
106
+ description: 'Optional — 1-indexed start line of the finding to attack.',
107
+ },
108
+ lineEnd: {
109
+ type: 'number',
110
+ description: 'Optional — 1-indexed end line of the finding.',
111
+ },
112
+ evidenceSnippet: {
113
+ type: 'string',
114
+ description: 'Optional — vulnerable code snippet for the finding.',
115
+ },
116
+ },
117
+ },
118
+ },
119
+ ];
120
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":";;;AAEa,QAAA,KAAK,GAAc;IAC5B;QACI,IAAI,EAAE,iBAAiB;QACvB,WAAW,EACP,qPAAqP;QACzP,WAAW,EAAE;YACT,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACR,IAAI,EAAE;oBACF,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,+CAA+C;iBAC/D;gBACD,QAAQ,EAAE;oBACN,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,0FAA0F;iBAC1G;gBACD,QAAQ,EAAE;oBACN,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,uFAAuF;iBACvG;aACJ;SACJ;KACJ;IACD;QACI,IAAI,EAAE,gBAAgB;QACtB,WAAW,EACP,mQAAmQ;QACvQ,WAAW,EAAE;YACT,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACR,MAAM,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,CAAC;oBACtC,WAAW,EAAE,6HAA6H;iBAC7I;aACJ;SACJ;KACJ;IACD;QACI,IAAI,EAAE,gBAAgB;Q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EAAE,+DAA+D;iBAC/E;gBACD,SAAS,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,2DAA2D;iBAC3E;gBACD,OAAO,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,+CAA+C;iBAC/D;gBACD,eAAe,EAAE;oBACb,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,qDAAqD;iBACrE;aACJ;SACJ;KACJ;CACJ,CAAC"}
@@ -0,0 +1,26 @@
1
+ export interface JsonRpcRequest {
2
+ jsonrpc: '2.0';
3
+ id?: number | string | null;
4
+ method: string;
5
+ params?: unknown;
6
+ }
7
+ export interface JsonRpcResponse {
8
+ jsonrpc: '2.0';
9
+ id: number | string | null;
10
+ result?: unknown;
11
+ error?: {
12
+ code: number;
13
+ message: string;
14
+ data?: unknown;
15
+ };
16
+ }
17
+ export interface ToolDef {
18
+ name: string;
19
+ description: string;
20
+ inputSchema: Record<string, unknown>;
21
+ }
22
+ export interface ServerContext {
23
+ apiUrl: string;
24
+ apiToken: string;
25
+ workspaceRoot: string;
26
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/mcp/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Phase 4 — generic Tree-sitter AST helpers shared by Layer 1 (static
3
+ * extraction) and Layer 2 (dynamic detection). Keeping them in one place
4
+ * means the two layers share the same notion of "a call to X" and "a
5
+ * string literal at this position".
6
+ */
7
+ import { TreeSitterNode } from './parserLoader';
8
+ /** Walk the tree depth-first, yielding every named + unnamed node. */
9
+ export declare function walk(node: TreeSitterNode): Iterable<TreeSitterNode>;
10
+ /** Walk named nodes only (skips punctuation/brackets). */
11
+ export declare function walkNamed(node: TreeSitterNode): Iterable<TreeSitterNode>;
12
+ /** True iff node is a string-literal node (JS/TS/Python all share 'string'). */
13
+ export declare function isStringLiteral(node: TreeSitterNode): boolean;
14
+ /** True iff node is an identifier (variable reference). */
15
+ export declare function isIdentifier(node: TreeSitterNode): boolean;
16
+ /** Get the text of a string literal without the surrounding quotes. */
17
+ export declare function stringLiteralValue(node: TreeSitterNode, source: string): string;
18
+ /**
19
+ * Find the first ancestor matching a predicate.
20
+ */
21
+ export declare function firstAncestor(node: TreeSitterNode, pred: (n: TreeSitterNode) => boolean): TreeSitterNode | null;
22
+ /**
23
+ * For a call_expression like `app.get('/x', mw, handler)`, return the parts:
24
+ * { receiver: 'app', method: 'get', args: [nodes...] }
25
+ * Works for Python calls too (`app.get("/x", handler)`) because both
26
+ * grammars expose call_expression with function being a member_expression.
27
+ */
28
+ export interface CallParts {
29
+ /**
30
+ * The BASE identifier the call is rooted at ('app', 'router', 'res',
31
+ * 'prisma'), or null for a free call.
32
+ *
33
+ * This is the base of the whole access chain, not the immediately
34
+ * preceding expression: for `res.status(201).json(x)` the receiver is
35
+ * `res`, not the text `res.status(201)`. Callers universally want to ask
36
+ * "is this a call on the response object / the app / an imported module",
37
+ * and comparing against the literal preceding text answers that question
38
+ * wrongly the moment a chained call appears.
39
+ */
40
+ receiver: string | null;
41
+ /** The full receiver expression as written, for display. */
42
+ receiverText: string | null;
43
+ /** The method name ('get', 'use', 'post', ...). */
44
+ method: string;
45
+ /** Argument nodes (positional). */
46
+ args: TreeSitterNode[];
47
+ /** Source-line of the call (0-indexed). */
48
+ line: number;
49
+ }
50
+ /**
51
+ * Walk an access chain down to the identifier it is rooted at.
52
+ *
53
+ * `res.status(201)` -> `res`, `prisma.user` -> `prisma`,
54
+ * `supabase.from('x').select('*')` -> `supabase`. Returns null when the chain
55
+ * bottoms out in something that is not an identifier (a literal, `this`, an
56
+ * immediately-invoked function), in which case callers fall back to the text.
57
+ */
58
+ export declare function baseIdentifier(node: TreeSitterNode, source: string): string | null;
59
+ /** Parse a call node into CallParts. Returns null if not a recognizable call. */
60
+ export declare function callParts(callNode: TreeSitterNode, source: string): CallParts | null;
61
+ /**
62
+ * Resolve an identifier to a string value when it's defined as a
63
+ * simple const/variable assignment to a string literal IN THE SAME FILE.
64
+ * Used for intra-file dataflow confidence (0.6).
65
+ *
66
+ * `assignments` is a map of variableName -> stringLiteralValue, built by
67
+ * a pre-pass over the file.
68
+ */
69
+ export declare function resolveIdentifier(name: string, assignments: Map<string, string>): string | null;
70
+ /**
71
+ * Build a map of `name -> string literal value` for every
72
+ * const X = 'literal' / let X = 'literal' / X = 'literal'
73
+ * in the file. Also handles Python `X = 'literal'` at module level.
74
+ */
75
+ export declare function collectStringAssignments(root: TreeSitterNode, source: string): Map<string, string>;
76
+ /**
77
+ * Normalise a Python module reference into the same relative-path shape the
78
+ * JS/TS import specs use, so one resolver handles both.
79
+ *
80
+ * `.deps` -> `./deps`
81
+ * `..models` -> `../models`
82
+ * `.` -> `./`
83
+ * `sqlalchemy.orm` -> unchanged (absolute; matched by name, not resolved)
84
+ */
85
+ export declare function pythonModuleSpec(mod: string): string;
86
+ /** Collect every import in the file as { localName -> sourceSpec }. */
87
+ export declare function collectImports(root: TreeSitterNode, source: string): Map<string, string>;
88
+ /** Resolve a module spec like './middleware/auth' to an absolute file path. */
89
+ export declare function resolveModulePath(spec: string, fromFile: string, workspaceRoot: string): string | null;