@gendigital/sage-mcp 0.7.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,199 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. Please also get an approval
185
+ for your intended use from a qualified person/organization.
186
+
187
+ Copyright 2026 Gen Digital Inc.
188
+
189
+ Licensed under the Apache License, Version 2.0 (the "License");
190
+ you may not use this file except in compliance with the License.
191
+ You may obtain a copy of the License at
192
+
193
+ http://www.apache.org/licenses/LICENSE-2.0
194
+
195
+ Unless required by applicable law or agreed to in writing, software
196
+ distributed under the License is distributed on an "AS IS" BASIS,
197
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
198
+ See the License for the specific language governing permissions and
199
+ limitations under the License.
@@ -0,0 +1,2 @@
1
+ export { createSageMcpServer, runSageMcpServerStdio, type SageMcpServerOptions, } from "./server.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,mBAAmB,EACnB,qBAAqB,EACrB,KAAK,oBAAoB,GACzB,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { createSageMcpServer, runSageMcpServerStdio, } from "./server.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,mBAAmB,EACnB,qBAAqB,GAErB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { Logger } from "@gendigital/sage-core";
2
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ export interface SageMcpServerOptions {
4
+ name?: string;
5
+ version: string;
6
+ logger?: Logger;
7
+ }
8
+ export declare function createSageMcpServer(options: SageMcpServerOptions): McpServer;
9
+ export declare function runSageMcpServerStdio(options: SageMcpServerOptions): Promise<void>;
10
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIpE,MAAM,WAAW,oBAAoB;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,SAAS,CAU5E;AAED,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAIxF"}
package/dist/server.js ADDED
@@ -0,0 +1,19 @@
1
+ import { nullLogger } from "@gendigital/sage-core";
2
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
+ import { registerFalsePositiveTools } from "./tools/false-positive.js";
5
+ export function createSageMcpServer(options) {
6
+ const logger = options.logger ?? nullLogger;
7
+ const server = new McpServer({
8
+ name: options.name ?? "sage",
9
+ version: options.version,
10
+ });
11
+ registerFalsePositiveTools(server, { logger, versionApp: options.version });
12
+ return server;
13
+ }
14
+ export async function runSageMcpServerStdio(options) {
15
+ const server = createSageMcpServer(options);
16
+ const transport = new StdioServerTransport();
17
+ await server.connect(transport);
18
+ }
19
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAQvE,MAAM,UAAU,mBAAmB,CAAC,OAA6B;IAChE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,UAAU,CAAC;IAC5C,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;QAC5B,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,MAAM;QAC5B,OAAO,EAAE,OAAO,CAAC,OAAO;KACxB,CAAC,CAAC;IAEH,0BAA0B,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAE5E,OAAO,MAAM,CAAC;AACf,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,OAA6B;IACxE,MAAM,MAAM,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAC5C,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { type Logger } from "@gendigital/sage-core";
2
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ export declare function registerFalsePositiveTools(server: McpServer, opts: {
4
+ logger: Logger;
5
+ versionApp: string;
6
+ }): void;
7
+ //# sourceMappingURL=false-positive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"false-positive.d.ts","sourceRoot":"","sources":["../../src/tools/false-positive.ts"],"names":[],"mappings":"AAEA,OAAO,EAKN,KAAK,MAAM,EAGX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA8NzE,wBAAgB,0BAA0B,CACzC,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAC1C,IAAI,CA6PN"}
@@ -0,0 +1,364 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { homedir } from "node:os";
3
+ import { buildSageProxyEnvelope, getInstallationId, getRecentEntries, loadConfig, resolveEndpoint, } from "@gendigital/sage-core";
4
+ import { z } from "zod";
5
+ import { textResult } from "./utils.js";
6
+ function asString(v) {
7
+ return typeof v === "string" ? v : undefined;
8
+ }
9
+ function asStringArray(v) {
10
+ if (!Array.isArray(v))
11
+ return undefined;
12
+ const out = [];
13
+ for (const item of v) {
14
+ if (typeof item === "string")
15
+ out.push(item);
16
+ }
17
+ return out;
18
+ }
19
+ function scrubHomePath(value) {
20
+ const home = homedir();
21
+ if (!home)
22
+ return value;
23
+ const normalizedHome = home.replace(/\\/g, "/").replace(/\/+$/, "");
24
+ const normalizedValue = value.replace(/\\/g, "/");
25
+ if (!normalizedHome)
26
+ return value;
27
+ if (normalizedValue === normalizedHome)
28
+ return "~";
29
+ if (normalizedValue.startsWith(`${normalizedHome}/`)) {
30
+ return `~/${normalizedValue.slice(normalizedHome.length + 1)}`;
31
+ }
32
+ return value;
33
+ }
34
+ function isRuntimeVerdictEntry(v) {
35
+ if (!v || typeof v !== "object" || Array.isArray(v))
36
+ return false;
37
+ return v.type === "runtime_verdict";
38
+ }
39
+ function getConversationId(entry) {
40
+ return asString(entry.conversation_id) ?? asString(entry.session_id);
41
+ }
42
+ function getEntryId(entry) {
43
+ return asString(entry.entry_id);
44
+ }
45
+ function asHookType(value) {
46
+ const s = asString(value);
47
+ if (s === "PreToolUse" ||
48
+ s === "PostToolUse" ||
49
+ s === "SessionStart" ||
50
+ s === "GatewayStart" ||
51
+ s === "BeforeAgentStart" ||
52
+ s === "MessagesTransform") {
53
+ return s;
54
+ }
55
+ return undefined;
56
+ }
57
+ async function postMultipart(endpoint, payload, timeoutSeconds) {
58
+ const timeoutMs = Math.max(1, Math.floor(timeoutSeconds * 1000));
59
+ const form = new FormData();
60
+ form.append("type", "fp");
61
+ form.append("metadata", JSON.stringify(payload));
62
+ const res = await fetch(endpoint, {
63
+ method: "POST",
64
+ body: form,
65
+ signal: AbortSignal.timeout(timeoutMs),
66
+ });
67
+ const bodyText = await res.text().catch(() => "");
68
+ return { ok: res.ok, status: res.status, bodyText };
69
+ }
70
+ const ListInputSchema = z.object({
71
+ conversation_id: z
72
+ .string()
73
+ .optional()
74
+ .describe("Conversation id to filter audit entries; if omitted, uses the most recent one."),
75
+ limit: z.number().int().min(1).max(5000).optional().describe("Max entries to scan and return."),
76
+ });
77
+ const ReportInputSchema = z.object({
78
+ conversation_id: z
79
+ .string()
80
+ .optional()
81
+ .describe("Conversation id to filter audit entries; if omitted, uses the most recent one."),
82
+ description: z.string().min(1).describe("Short description of what is a false positive."),
83
+ reasoning: z
84
+ .string()
85
+ .min(1)
86
+ .describe("Reasoning for why this should be treated as a false positive."),
87
+ agent_runtime_version: z
88
+ .string()
89
+ .optional()
90
+ .describe("Optional agent runtime version override (Cursor/VS Code/Claude version). If omitted, uses env SAGE_AGENT_RUNTIME_VERSION or 'unknown'."),
91
+ entry_ids: z.array(z.string()).optional().describe("Optional list of audit entry ids to report."),
92
+ dry_run: z.boolean().optional().describe("If true, do not POST; just show the payload."),
93
+ });
94
+ function parseAuditSignals(raw) {
95
+ if (!raw || typeof raw !== "object" || Array.isArray(raw))
96
+ return {};
97
+ const obj = raw;
98
+ const heuristicsRaw = obj.heuristics;
99
+ const urlChecksRaw = obj.url_checks;
100
+ const fileChecksRaw = obj.file_checks;
101
+ const packageChecksRaw = obj.package_checks;
102
+ const heuristics = Array.isArray(heuristicsRaw)
103
+ ? heuristicsRaw
104
+ .map((h) => {
105
+ if (!h || typeof h !== "object" || Array.isArray(h))
106
+ return null;
107
+ const rec = h;
108
+ const rule_id = asString(rec.rule_id);
109
+ const rule_version = typeof rec.rule_version === "number" ? Math.trunc(rec.rule_version) : undefined;
110
+ if (!rule_id)
111
+ return null;
112
+ return { rule_id, rule_version };
113
+ })
114
+ .filter(Boolean)
115
+ : undefined;
116
+ const url_checks = Array.isArray(urlChecksRaw)
117
+ ? urlChecksRaw
118
+ .map((u) => {
119
+ if (!u || typeof u !== "object" || Array.isArray(u))
120
+ return null;
121
+ const rec = u;
122
+ const detection_name = asString(rec.detection_name);
123
+ const url = asString(rec.url);
124
+ if (!detection_name || !url)
125
+ return null;
126
+ return { detection_name, url };
127
+ })
128
+ .filter(Boolean)
129
+ : undefined;
130
+ const file_checks = Array.isArray(fileChecksRaw)
131
+ ? fileChecksRaw
132
+ .map((f) => {
133
+ if (!f || typeof f !== "object" || Array.isArray(f))
134
+ return null;
135
+ const rec = f;
136
+ const detection_name = asString(rec.detection_name);
137
+ const file_sha256 = asString(rec.file_sha256);
138
+ if (!detection_name || !file_sha256)
139
+ return null;
140
+ return { detection_name, file_sha256 };
141
+ })
142
+ .filter(Boolean)
143
+ : undefined;
144
+ const package_checks = Array.isArray(packageChecksRaw)
145
+ ? packageChecksRaw
146
+ .map((p) => {
147
+ if (!p || typeof p !== "object" || Array.isArray(p))
148
+ return null;
149
+ const rec = p;
150
+ const detection_name = asString(rec.detection_name);
151
+ const package_name = asString(rec.package_name);
152
+ const package_version = asString(rec.package_version);
153
+ const package_registry = asString(rec.package_registry);
154
+ if (!detection_name || !package_name || !package_registry)
155
+ return null;
156
+ return { detection_name, package_name, package_version, package_registry };
157
+ })
158
+ .filter(Boolean)
159
+ : undefined;
160
+ return {
161
+ heuristics: heuristics && heuristics.length > 0
162
+ ? heuristics
163
+ : undefined,
164
+ url_checks: url_checks && url_checks.length > 0
165
+ ? url_checks
166
+ : undefined,
167
+ file_checks: file_checks && file_checks.length > 0
168
+ ? file_checks
169
+ : undefined,
170
+ package_checks: package_checks && package_checks.length > 0
171
+ ? package_checks
172
+ : undefined,
173
+ };
174
+ }
175
+ export function registerFalsePositiveTools(server, opts) {
176
+ const logger = opts.logger;
177
+ const versionApp = opts.versionApp;
178
+ server.registerTool("sage_list_audit_entries", {
179
+ title: "Sage: List Audit Entries",
180
+ description: "List recent Sage audit log entries, optionally scoped to a conversation id. Useful for selecting entry_ids to report as false positives.",
181
+ inputSchema: ListInputSchema,
182
+ }, async ({ conversation_id, limit }) => {
183
+ try {
184
+ const config = await loadConfig(undefined, logger);
185
+ const scanLimit = limit ?? 500;
186
+ const entries = await getRecentEntries(config.logging, scanLimit);
187
+ const runtime = entries.filter(isRuntimeVerdictEntry);
188
+ const inferredConversationId = conversation_id ??
189
+ getConversationId(runtime
190
+ .slice()
191
+ .reverse()
192
+ .find((e) => !!getConversationId(e)) ?? {});
193
+ if (!inferredConversationId) {
194
+ return textResult("No runtime_verdict entries found in the audit log.", true);
195
+ }
196
+ const filtered = runtime.filter((e) => getConversationId(e) === inferredConversationId);
197
+ const out = filtered.map((e) => ({
198
+ entry_id: getEntryId(e),
199
+ timestamp: asString(e.timestamp),
200
+ conversation_id: inferredConversationId,
201
+ agent_runtime: asString(e.agent_runtime),
202
+ tool_name: asString(e.tool_name),
203
+ tool_input_summary: asString(e.tool_input_summary),
204
+ verdict: asString(e.verdict),
205
+ severity: asString(e.severity),
206
+ source: asString(e.source),
207
+ user_override: e.user_override,
208
+ signals: parseAuditSignals(e.signals),
209
+ }));
210
+ return textResult(JSON.stringify({ conversation_id: inferredConversationId, entries: out }, null, 2));
211
+ }
212
+ catch (e) {
213
+ return textResult(`Failed to read audit log: ${e}`, true);
214
+ }
215
+ });
216
+ server.registerTool("sage_report_false_positive", {
217
+ title: "Sage: Report False Positive",
218
+ description: "Report Sage audit log entries as false positives to the backend, scoped to the current conversation.",
219
+ inputSchema: ReportInputSchema,
220
+ }, async ({ conversation_id, description, reasoning, agent_runtime_version, entry_ids, dry_run, }) => {
221
+ try {
222
+ const config = await loadConfig(undefined, logger);
223
+ const endpoint = resolveEndpoint("/v2/fp-report");
224
+ const timeoutSeconds = Number(process.env.SAGE_FALSE_POSITIVE_TIMEOUT_SECONDS) || 5;
225
+ const scanLimit = 2000;
226
+ const entries = await getRecentEntries(config.logging, scanLimit);
227
+ const runtime = entries.filter(isRuntimeVerdictEntry);
228
+ const inferredConversationId = conversation_id ??
229
+ getConversationId(runtime
230
+ .slice()
231
+ .reverse()
232
+ .find((e) => !!getConversationId(e)) ?? {});
233
+ if (!inferredConversationId) {
234
+ return textResult("No runtime_verdict entries found in the audit log.", true);
235
+ }
236
+ let filtered = runtime.filter((e) => getConversationId(e) === inferredConversationId);
237
+ if (entry_ids && entry_ids.length > 0) {
238
+ const wanted = new Set(entry_ids);
239
+ filtered = filtered.filter((e) => {
240
+ const id = getEntryId(e);
241
+ return id ? wanted.has(id) : false;
242
+ });
243
+ }
244
+ if (filtered.length === 0) {
245
+ if (entry_ids && entry_ids.length > 0) {
246
+ return textResult("No matching audit entries found for the provided entry_ids in this conversation. Run sage_list_audit_entries first.", true);
247
+ }
248
+ return textResult("No runtime_verdict entries found for this conversation to report.", true);
249
+ }
250
+ const iid = await getInstallationId().catch(() => undefined);
251
+ if (!iid) {
252
+ return textResult("Failed to retrieve installation id; FP reporting requires a working Sage install.", true);
253
+ }
254
+ const runtimeVersion = agent_runtime_version ?? process.env.SAGE_AGENT_RUNTIME_VERSION ?? "unknown";
255
+ const comment = `${description}\n\n${reasoning}`;
256
+ const reports = filtered
257
+ .map((e) => {
258
+ const entry_id = getEntryId(e);
259
+ const timestamp = asString(e.timestamp) ?? new Date().toISOString();
260
+ const agent_runtime = asString(e.agent_runtime) ?? "unknown";
261
+ const tool_type = asString(e.tool_name) ?? "Unknown";
262
+ const verdict = asString(e.verdict) ?? "deny";
263
+ const user_action = e.user_override === true ? "allowed" : "blocked";
264
+ const hook_type = asHookType(e.hook_type) ?? "PreToolUse";
265
+ const artifacts = asStringArray(e.artifacts) ?? [];
266
+ const signals = parseAuditSignals(e.signals);
267
+ const urlFromArtifacts = artifacts.find((a) => typeof a === "string" && /^https?:\/\//i.test(a));
268
+ const commandFromSummary = asString(e.tool_input_summary) ?? "";
269
+ const content = {};
270
+ if (tool_type === "Bash") {
271
+ content.command = scrubHomePath(commandFromSummary);
272
+ }
273
+ if (tool_type === "Write" ||
274
+ tool_type === "Edit" ||
275
+ tool_type === "Read" ||
276
+ tool_type === "Delete") {
277
+ content.file_path = scrubHomePath(commandFromSummary);
278
+ }
279
+ if (tool_type === "WebFetch" && urlFromArtifacts) {
280
+ content.url = urlFromArtifacts;
281
+ }
282
+ if (signals.url_checks && signals.url_checks.length === 1) {
283
+ content.url = signals.url_checks[0]?.url;
284
+ }
285
+ if (signals.package_checks && signals.package_checks.length === 1) {
286
+ const p = signals.package_checks[0];
287
+ content.package_name = p?.package_name;
288
+ content.package_version = p?.package_version;
289
+ content.package_registry = p?.package_registry;
290
+ }
291
+ const bestEffortSignals = {};
292
+ if (signals.heuristics)
293
+ bestEffortSignals.heuristics = signals.heuristics;
294
+ if (signals.url_checks)
295
+ bestEffortSignals.url_checks = signals.url_checks;
296
+ if (signals.file_checks)
297
+ bestEffortSignals.file_checks = signals.file_checks;
298
+ if (signals.package_checks)
299
+ bestEffortSignals.package_checks = signals.package_checks;
300
+ const reportPayload = {
301
+ ...buildSageProxyEnvelope({
302
+ iid,
303
+ versionApp,
304
+ agentRuntime: agent_runtime,
305
+ agentRuntimeVersion: runtimeVersion,
306
+ }),
307
+ block_event: {
308
+ hook_type,
309
+ tool_type,
310
+ verdict,
311
+ user_action,
312
+ timestamp,
313
+ ...(Object.keys(bestEffortSignals).length > 0
314
+ ? { signals: bestEffortSignals }
315
+ : {}),
316
+ content,
317
+ },
318
+ comment,
319
+ event_id: entry_id ?? randomUUID(),
320
+ };
321
+ return { entry_id, payload: reportPayload };
322
+ })
323
+ .filter((r) => r.payload);
324
+ if (dry_run) {
325
+ return textResult(JSON.stringify({ endpoint, reports }, null, 2));
326
+ }
327
+ const results = [];
328
+ for (const report of reports) {
329
+ const res = await postMultipart(endpoint, report.payload, timeoutSeconds);
330
+ let report_id;
331
+ try {
332
+ const parsed = JSON.parse(res.bodyText);
333
+ if (typeof parsed.report_id === "string") {
334
+ report_id = parsed.report_id;
335
+ }
336
+ }
337
+ catch {
338
+ // ignore
339
+ }
340
+ results.push({
341
+ entry_id: report.entry_id,
342
+ ok: res.ok,
343
+ status: res.status,
344
+ bodyText: res.bodyText,
345
+ report_id,
346
+ });
347
+ }
348
+ const failed = results.filter((r) => !r.ok);
349
+ if (failed.length > 0) {
350
+ const summary = {
351
+ reported: results.length,
352
+ failed: failed.length,
353
+ failures: failed.slice(0, 5),
354
+ };
355
+ return textResult(`Some reports failed to submit. Summary:\n${JSON.stringify(summary, null, 2)}`, true);
356
+ }
357
+ return textResult(`Reported ${filtered.length} audit entr${filtered.length === 1 ? "y" : "ies"} for conversation_id=${inferredConversationId}.`);
358
+ }
359
+ catch (e) {
360
+ return textResult(`Failed to report false positive: ${e}`, true);
361
+ }
362
+ });
363
+ }
364
+ //# sourceMappingURL=false-positive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"false-positive.js","sourceRoot":"","sources":["../../src/tools/false-positive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EACN,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,EAGhB,UAAU,EACV,eAAe,GACf,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAqBxC,SAAS,QAAQ,CAAC,CAAU;IAC3B,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9C,CAAC;AAED,SAAS,aAAa,CAAC,CAAU;IAChC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IACxC,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,IAAI,IAAI,CAAC,EAAE,CAAC;QACtB,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,SAAS,aAAa,CAAC,KAAa;IACnC,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;IACvB,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IACxB,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO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M,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YAC5C,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACvB,MAAM,OAAO,GAAG;oBACf,QAAQ,EAAE,OAAO,CAAC,MAAM;oBACxB,MAAM,EAAE,MAAM,CAAC,MAAM;oBACrB,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;iBAC5B,CAAC;gBACF,OAAO,UAAU,CAChB,4CAA4C,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAC9E,IAAI,CACJ,CAAC;YACH,CAAC;YAED,OAAO,UAAU,CAChB,YAAY,QAAQ,CAAC,MAAM,cAAc,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,wBAAwB,sBAAsB,GAAG,CAC7H,CAAC;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACZ,OAAO,UAAU,CAAC,oCAAoC,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAClE,CAAC;IACF,CAAC,CACD,CAAC;AACH,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare function textResult(text: string, isError?: boolean): {
2
+ content: {
3
+ type: "text";
4
+ text: string;
5
+ }[];
6
+ isError?: boolean;
7
+ };
8
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/tools/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO;aAChC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE;cAAY,OAAO;EAK5E"}
@@ -0,0 +1,9 @@
1
+ export function textResult(text, isError) {
2
+ const result = {
3
+ content: [{ type: "text", text }],
4
+ };
5
+ if (isError)
6
+ result.isError = true;
7
+ return result;
8
+ }
9
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/tools/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,OAAiB;IACzD,MAAM,MAAM,GAAqE;QAChF,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,CAAC;KAC1C,CAAC;IACF,IAAI,OAAO;QAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IACnC,OAAO,MAAM,CAAC;AACf,CAAC"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@gendigital/sage-mcp",
3
+ "license": "Apache-2.0",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "description": "Safety for Agents — shared MCP server for Sage connectors",
8
+ "version": "0.7.0",
9
+ "type": "module",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "dependencies": {
20
+ "@modelcontextprotocol/sdk": "^1.26.0",
21
+ "zod": "^3.24.0",
22
+ "@gendigital/sage-core": "0.7.0"
23
+ },
24
+ "devDependencies": {
25
+ "@types/node": "^22.0.0",
26
+ "typescript": "^5.9.0",
27
+ "vitest": "^4.0.0"
28
+ },
29
+ "engines": {
30
+ "node": ">=18"
31
+ },
32
+ "keywords": [
33
+ "mcp",
34
+ "model-context-protocol",
35
+ "security",
36
+ "adr",
37
+ "agent security"
38
+ ],
39
+ "scripts": {
40
+ "build": "pnpm run clean && tsc",
41
+ "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true});require('node:fs').rmSync('tsconfig.tsbuildinfo',{force:true})\""
42
+ }
43
+ }