@greenarmor/ges-mcp-server 1.0.1 → 1.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.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/server.d.ts +21 -0
- package/dist/server.js +3 -3
- package/dist/server.test.d.ts +1 -0
- package/dist/server.test.js +152 -0
- package/package.json +18 -16
- package/LICENSE +0 -21
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/server.d.ts
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import type { Finding } from "@greenarmor/ges-audit-engine";
|
|
3
|
+
export type AutoFixAction = {
|
|
4
|
+
type: "create" | "modify" | "append" | "npm-install";
|
|
5
|
+
filePath: string;
|
|
6
|
+
content?: string;
|
|
7
|
+
search?: string;
|
|
8
|
+
replace?: string;
|
|
9
|
+
description: string;
|
|
10
|
+
ruleId: string;
|
|
11
|
+
};
|
|
12
|
+
export type AutoFixResult = {
|
|
13
|
+
applied: boolean;
|
|
14
|
+
action: AutoFixAction;
|
|
15
|
+
error?: string;
|
|
16
|
+
};
|
|
2
17
|
export interface MCPRequest {
|
|
3
18
|
jsonrpc: string;
|
|
4
19
|
id?: number | string | null;
|
|
@@ -15,4 +30,10 @@ export interface MCPResponse {
|
|
|
15
30
|
data?: unknown;
|
|
16
31
|
};
|
|
17
32
|
}
|
|
33
|
+
export declare function createAutoFixPlan(root: string, findings: Finding[], filterRuleIds?: Set<string>): {
|
|
34
|
+
actions: AutoFixAction[];
|
|
35
|
+
warnings: string[];
|
|
36
|
+
};
|
|
37
|
+
export declare function applyAutoFixAction(root: string, action: AutoFixAction): AutoFixResult;
|
|
38
|
+
export declare function getNpmInstallsFromActions(actions: AutoFixAction[]): string[];
|
|
18
39
|
export declare function handleRequest(request: MCPRequest): MCPResponse | null;
|
package/dist/server.js
CHANGED
|
@@ -595,7 +595,7 @@ function generateImplementationSteps(control) {
|
|
|
595
595
|
}
|
|
596
596
|
return steps;
|
|
597
597
|
}
|
|
598
|
-
function createAutoFixPlan(root, findings, filterRuleIds) {
|
|
598
|
+
export function createAutoFixPlan(root, findings, filterRuleIds) {
|
|
599
599
|
const actions = [];
|
|
600
600
|
const warnings = [];
|
|
601
601
|
const processedRules = new Set();
|
|
@@ -669,7 +669,7 @@ function createAutoFixPlan(root, findings, filterRuleIds) {
|
|
|
669
669
|
}
|
|
670
670
|
return { actions, warnings };
|
|
671
671
|
}
|
|
672
|
-
function applyAutoFixAction(root, action) {
|
|
672
|
+
export function applyAutoFixAction(root, action) {
|
|
673
673
|
const fullPath = path.join(root, action.filePath);
|
|
674
674
|
try {
|
|
675
675
|
switch (action.type) {
|
|
@@ -1557,7 +1557,7 @@ function buildAuditModelFix(root) {
|
|
|
1557
1557
|
}
|
|
1558
1558
|
return [];
|
|
1559
1559
|
}
|
|
1560
|
-
function getNpmInstallsFromActions(actions) {
|
|
1560
|
+
export function getNpmInstallsFromActions(actions) {
|
|
1561
1561
|
const installs = new Set();
|
|
1562
1562
|
for (const a of actions) {
|
|
1563
1563
|
if (a.type !== "npm-install")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { handleRequest } from "./server.js";
|
|
3
|
+
function req(method, params, id = 1) {
|
|
4
|
+
return { jsonrpc: "2.0", id, method, params };
|
|
5
|
+
}
|
|
6
|
+
function callTool(name, args = {}, id = 1) {
|
|
7
|
+
return req("tools/call", { name, arguments: args }, id);
|
|
8
|
+
}
|
|
9
|
+
function getResultText(response) {
|
|
10
|
+
const r = response;
|
|
11
|
+
return r.result?.content?.[0]?.text ?? "";
|
|
12
|
+
}
|
|
13
|
+
describe("MCP Protocol", () => {
|
|
14
|
+
it("responds to initialize", () => {
|
|
15
|
+
const res = handleRequest(req("initialize"));
|
|
16
|
+
expect(res).not.toBeNull();
|
|
17
|
+
const result = res.result;
|
|
18
|
+
expect(result.protocolVersion).toBe("2024-11-05");
|
|
19
|
+
expect(result.serverInfo.name).toBe("gesf-mcp-server");
|
|
20
|
+
});
|
|
21
|
+
it("returns null for notifications/initialized", () => {
|
|
22
|
+
const res = handleRequest({ jsonrpc: "2.0", method: "notifications/initialized" });
|
|
23
|
+
expect(res).toBeNull();
|
|
24
|
+
});
|
|
25
|
+
it("returns null for notifications/cancelled", () => {
|
|
26
|
+
const res = handleRequest({ jsonrpc: "2.0", method: "notifications/cancelled" });
|
|
27
|
+
expect(res).toBeNull();
|
|
28
|
+
});
|
|
29
|
+
it("responds to ping", () => {
|
|
30
|
+
const res = handleRequest(req("ping"));
|
|
31
|
+
expect(res).not.toBeNull();
|
|
32
|
+
expect(res.result).toBeDefined();
|
|
33
|
+
});
|
|
34
|
+
it("returns null for ping notification", () => {
|
|
35
|
+
const res = handleRequest({ jsonrpc: "2.0", method: "ping" });
|
|
36
|
+
expect(res).toBeNull();
|
|
37
|
+
});
|
|
38
|
+
it("responds to tools/list with 17 tools", () => {
|
|
39
|
+
const res = handleRequest(req("tools/list"));
|
|
40
|
+
const tools = res.result.tools;
|
|
41
|
+
expect(tools.length).toBe(17);
|
|
42
|
+
});
|
|
43
|
+
it("returns error for unknown method", () => {
|
|
44
|
+
const res = handleRequest(req("unknown/method"));
|
|
45
|
+
expect(res.error).toBeDefined();
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
describe("tools/list content", () => {
|
|
49
|
+
it("includes all expected tool names", () => {
|
|
50
|
+
const res = handleRequest(req("tools/list"));
|
|
51
|
+
const tools = res.result.tools;
|
|
52
|
+
const names = tools.map((t) => t.name);
|
|
53
|
+
expect(names).toContain("check_compliance");
|
|
54
|
+
expect(names).toContain("check_project_status");
|
|
55
|
+
expect(names).toContain("list_missing_controls");
|
|
56
|
+
expect(names).toContain("list_framework_controls");
|
|
57
|
+
expect(names).toContain("run_audit");
|
|
58
|
+
expect(names).toContain("generate_compliance_report");
|
|
59
|
+
expect(names).toContain("generate_audit_report");
|
|
60
|
+
expect(names).toContain("fix_recommendation");
|
|
61
|
+
expect(names).toContain("auto_fix");
|
|
62
|
+
expect(names).toContain("implement_control");
|
|
63
|
+
expect(names).toContain("apply_control_override");
|
|
64
|
+
expect(names).toContain("generate_retention_policy");
|
|
65
|
+
expect(names).toContain("generate_incident_response");
|
|
66
|
+
expect(names).toContain("generate_risk_assessment");
|
|
67
|
+
expect(names).toContain("generate_dpa");
|
|
68
|
+
expect(names).toContain("generate_data_inventory");
|
|
69
|
+
expect(names).toContain("generate_processing_records");
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
describe("check_compliance tool", () => {
|
|
73
|
+
it("returns compliance score output", () => {
|
|
74
|
+
const res = handleRequest(callTool("check_compliance", { project_type: "saas" }));
|
|
75
|
+
const text = getResultText(res);
|
|
76
|
+
expect(text.length).toBeGreaterThan(0);
|
|
77
|
+
expect(text).toContain("GDPR");
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
describe("list_missing_controls tool", () => {
|
|
81
|
+
it("returns missing controls for GDPR", () => {
|
|
82
|
+
const res = handleRequest(callTool("list_missing_controls", { framework: "GDPR" }));
|
|
83
|
+
const text = getResultText(res);
|
|
84
|
+
expect(text.length).toBeGreaterThan(0);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
describe("list_framework_controls tool", () => {
|
|
88
|
+
it("returns all GDPR controls", () => {
|
|
89
|
+
const res = handleRequest(callTool("list_framework_controls", { framework: "GDPR" }));
|
|
90
|
+
const text = getResultText(res);
|
|
91
|
+
expect(text.length).toBeGreaterThan(0);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
describe("generate_retention_policy tool", () => {
|
|
95
|
+
it("generates a retention policy", () => {
|
|
96
|
+
const res = handleRequest(callTool("generate_retention_policy", { project_name: "TestApp" }));
|
|
97
|
+
const text = getResultText(res);
|
|
98
|
+
expect(text.length).toBeGreaterThan(0);
|
|
99
|
+
expect(text).toContain("Retention");
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
describe("generate_incident_response tool", () => {
|
|
103
|
+
it("generates an incident response plan", () => {
|
|
104
|
+
const res = handleRequest(callTool("generate_incident_response", { project_name: "TestApp" }));
|
|
105
|
+
const text = getResultText(res);
|
|
106
|
+
expect(text.length).toBeGreaterThan(0);
|
|
107
|
+
expect(text).toContain("Incident");
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
describe("generate_risk_assessment tool", () => {
|
|
111
|
+
it("generates a risk assessment", () => {
|
|
112
|
+
const res = handleRequest(callTool("generate_risk_assessment", { project_name: "TestApp" }));
|
|
113
|
+
const text = getResultText(res);
|
|
114
|
+
expect(text.length).toBeGreaterThan(0);
|
|
115
|
+
expect(text).toContain("Risk");
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
describe("generate_dpa tool", () => {
|
|
119
|
+
it("generates a DPA", () => {
|
|
120
|
+
const res = handleRequest(callTool("generate_dpa", { project_name: "TestApp" }));
|
|
121
|
+
const text = getResultText(res);
|
|
122
|
+
expect(text.length).toBeGreaterThan(0);
|
|
123
|
+
expect(text).toContain("Data Processing");
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
describe("generate_data_inventory tool", () => {
|
|
127
|
+
it("generates a data inventory", () => {
|
|
128
|
+
const res = handleRequest(callTool("generate_data_inventory", { project_name: "TestApp" }));
|
|
129
|
+
const text = getResultText(res);
|
|
130
|
+
expect(text.length).toBeGreaterThan(0);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
describe("generate_processing_records tool", () => {
|
|
134
|
+
it("generates processing records", () => {
|
|
135
|
+
const res = handleRequest(callTool("generate_processing_records", { project_name: "TestApp" }));
|
|
136
|
+
const text = getResultText(res);
|
|
137
|
+
expect(text.length).toBeGreaterThan(0);
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
describe("fix_recommendation tool", () => {
|
|
141
|
+
it("returns guidance for a control ID", () => {
|
|
142
|
+
const res = handleRequest(callTool("fix_recommendation", { control_id: "GDPR-ART32-002" }));
|
|
143
|
+
const text = getResultText(res);
|
|
144
|
+
expect(text.length).toBeGreaterThan(0);
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
describe("unknown tool", () => {
|
|
148
|
+
it("returns error for unknown tool name", () => {
|
|
149
|
+
const res = handleRequest(callTool("nonexistent_tool"));
|
|
150
|
+
expect(res.error).toBeDefined();
|
|
151
|
+
});
|
|
152
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@greenarmor/ges-mcp-server",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "GESF MCP Server - AI Compliance Assistant for GDPR, OWASP, NIST, CIS. Check compliance, generate policies, assess risks via MCP protocol.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -44,27 +44,29 @@
|
|
|
44
44
|
"access": "public",
|
|
45
45
|
"registry": "https://registry.npmjs.org/"
|
|
46
46
|
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "tsc",
|
|
49
|
+
"clean": "rm -rf dist bundle tsconfig.tsbuildinfo",
|
|
50
|
+
"prepublishOnly": "tsc",
|
|
51
|
+
"test": "vitest run"
|
|
52
|
+
},
|
|
47
53
|
"dependencies": {
|
|
48
|
-
"@greenarmor/ges-
|
|
49
|
-
"@greenarmor/ges-
|
|
50
|
-
"@greenarmor/ges-
|
|
51
|
-
"@greenarmor/ges-doc-generator": "
|
|
52
|
-
"@greenarmor/ges-
|
|
53
|
-
"@greenarmor/ges-
|
|
54
|
-
"@greenarmor/ges-
|
|
55
|
-
"@greenarmor/ges-
|
|
54
|
+
"@greenarmor/ges-audit-engine": "workspace:*",
|
|
55
|
+
"@greenarmor/ges-compliance-engine": "workspace:*",
|
|
56
|
+
"@greenarmor/ges-core": "workspace:*",
|
|
57
|
+
"@greenarmor/ges-doc-generator": "workspace:*",
|
|
58
|
+
"@greenarmor/ges-policy-engine": "workspace:*",
|
|
59
|
+
"@greenarmor/ges-report-generator": "workspace:*",
|
|
60
|
+
"@greenarmor/ges-rules-engine": "workspace:*",
|
|
61
|
+
"@greenarmor/ges-scoring-engine": "workspace:*"
|
|
56
62
|
},
|
|
57
63
|
"devDependencies": {
|
|
58
64
|
"@types/node": "^22.0.0",
|
|
59
65
|
"esbuild": "^0.28.0",
|
|
60
|
-
"typescript": "^6.0.0"
|
|
66
|
+
"typescript": "^6.0.0",
|
|
67
|
+
"vitest": "^4.1.8"
|
|
61
68
|
},
|
|
62
69
|
"engines": {
|
|
63
70
|
"node": ">=20.0.0"
|
|
64
|
-
},
|
|
65
|
-
"scripts": {
|
|
66
|
-
"build": "tsc",
|
|
67
|
-
"clean": "rm -rf dist bundle tsconfig.tsbuildinfo",
|
|
68
|
-
"test": "echo \"no tests yet\""
|
|
69
71
|
}
|
|
70
|
-
}
|
|
72
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025–2026 greenarmor
|
|
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.
|