@de-otio/repo-aegis-mcp 0.2.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 (46) hide show
  1. package/README.md +96 -0
  2. package/dist/index.d.ts +3 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +15 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/server.d.ts +16 -0
  7. package/dist/server.d.ts.map +1 -0
  8. package/dist/server.js +42 -0
  9. package/dist/server.js.map +1 -0
  10. package/dist/server.test.d.ts +2 -0
  11. package/dist/server.test.d.ts.map +1 -0
  12. package/dist/server.test.js +171 -0
  13. package/dist/server.test.js.map +1 -0
  14. package/dist/tools/_util.d.ts +26 -0
  15. package/dist/tools/_util.d.ts.map +1 -0
  16. package/dist/tools/_util.js +33 -0
  17. package/dist/tools/_util.js.map +1 -0
  18. package/dist/tools/audit.d.ts +20 -0
  19. package/dist/tools/audit.d.ts.map +1 -0
  20. package/dist/tools/audit.js +317 -0
  21. package/dist/tools/audit.js.map +1 -0
  22. package/dist/tools/check.d.ts +3 -0
  23. package/dist/tools/check.d.ts.map +1 -0
  24. package/dist/tools/check.js +133 -0
  25. package/dist/tools/check.js.map +1 -0
  26. package/dist/tools/engagements.d.ts +3 -0
  27. package/dist/tools/engagements.d.ts.map +1 -0
  28. package/dist/tools/engagements.js +89 -0
  29. package/dist/tools/engagements.js.map +1 -0
  30. package/dist/tools/first-touch.d.ts +26 -0
  31. package/dist/tools/first-touch.d.ts.map +1 -0
  32. package/dist/tools/first-touch.js +49 -0
  33. package/dist/tools/first-touch.js.map +1 -0
  34. package/dist/tools/first-touch.test.d.ts +2 -0
  35. package/dist/tools/first-touch.test.d.ts.map +1 -0
  36. package/dist/tools/first-touch.test.js +224 -0
  37. package/dist/tools/first-touch.test.js.map +1 -0
  38. package/dist/tools/markers.d.ts +3 -0
  39. package/dist/tools/markers.d.ts.map +1 -0
  40. package/dist/tools/markers.js +121 -0
  41. package/dist/tools/markers.js.map +1 -0
  42. package/dist/tools/status.d.ts +11 -0
  43. package/dist/tools/status.d.ts.map +1 -0
  44. package/dist/tools/status.js +68 -0
  45. package/dist/tools/status.js.map +1 -0
  46. package/package.json +35 -0
package/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # @de-otio/repo-aegis-mcp
2
+
3
+ > Model Context Protocol server wrapping repo-aegis as agent-readable tools.
4
+
5
+ This package exposes the [repo-aegis](https://github.com/de-otio/repo-aegis)
6
+ core library as a typed [MCP](https://modelcontextprotocol.io/) tool surface
7
+ so a coding agent (Claude Code, Cursor, Aider, Cline, …) can drive it
8
+ without shelling out to the CLI. Every tool returns the same JSON shape
9
+ that `repo-aegis <command> --json` does, so the
10
+ [agent operator guide](../../doc/agent-guide.md) — including its
11
+ quick-reference table — applies unchanged.
12
+
13
+ The server runs in-process: tool calls invoke `@de-otio/repo-aegis-core`
14
+ directly. No subprocess spawn, no `--verbose` flag exposed, no path to
15
+ literal markers.
16
+
17
+ ## Configuration (Claude Code)
18
+
19
+ In `~/.claude/settings.json`:
20
+
21
+ ```json
22
+ {
23
+ "mcpServers": {
24
+ "repo-aegis": {
25
+ "command": "repo-aegis-mcp"
26
+ }
27
+ }
28
+ }
29
+ ```
30
+
31
+ Once published to npm and installed globally, Claude Code (and any other
32
+ MCP client) will spawn the bin over stdio and discover the tools below.
33
+
34
+ For local development:
35
+
36
+ ```json
37
+ {
38
+ "mcpServers": {
39
+ "repo-aegis": {
40
+ "command": "node",
41
+ "args": ["/abs/path/to/repo-aegis/packages/mcp/dist/index.js"]
42
+ }
43
+ }
44
+ }
45
+ ```
46
+
47
+ ## Tools
48
+
49
+ | Tool | What it does |
50
+ |---|---|
51
+ | `repo_aegis_status` | Repo class + allowed engagements + deny-set summary. Same shape as `repo-aegis status --json`. Call this first when landing in a new repo. |
52
+ | `repo_aegis_check_path` | Scan a single file against the scoped deny set. Same shape as `repo-aegis check --path <file> --json`. |
53
+ | `repo_aegis_check_staged` | Scan the staged diff. Same shape as `repo-aegis check --staged --json`. Pre-commit gate. |
54
+ | `repo_aegis_engagements_list` | List engagements in the registry (id, name, dates, markerCount). Same shape as `repo-aegis engagements list --json`. |
55
+ | `repo_aegis_engagements_show` | Show one engagement's metadata. Same shape as `repo-aegis engagements show <id> --json`. |
56
+ | `repo_aegis_markers_test` | Probe a string against the scoped deny set; returns engagement attribution + redacted previews. Same shape as `repo-aegis markers test <s> --json`. |
57
+ | `repo_aegis_markers_list` | List active marker files (engagement-id + redacted pattern previews). Same shape as `repo-aegis markers list --json`. |
58
+ | `repo_aegis_audit` | Composite repo audit (marker scan, lockfile, fixtures, remote-vs-class). Same shape as `repo-aegis audit --json`. |
59
+ | `aegis_classify_first_touch` | JIT classify a previously-unclassified repo from its git remote + the engagement registry's `githubOrgs` / `personalOrgs`. Returns `status: already-classified | applied | needs-confirmation | skipped` with `[SEC H-5]` redacted org names for ambiguous cases. |
60
+
61
+ Three CLI flags are deliberately **not** exposed over MCP:
62
+
63
+ - `--verbose` — the literal-reveal path is for a human at a terminal
64
+ only. Hooks and agents must never see literal markers.
65
+ - `audit --org` — sends seed substrings (potentially customer-derived)
66
+ to GitHub code-search; cross-border data transfer requiring explicit
67
+ human consent.
68
+ - `audit --published` / `audit --history` — long-running or
69
+ archive-extracting; CLI workflows.
70
+
71
+ Mutating operations (`engagements add` / `end` / `remove`, `allow`,
72
+ `deny`, `init`, `install …`) are also intentionally not exposed: those
73
+ are user-confirmed compliance operations that should land at the
74
+ terminal, not through an agent.
75
+
76
+ ## Redaction policy
77
+
78
+ This applies everywhere in this server, by construction:
79
+
80
+ - Every tool that scans content passes `revealMatches: false` to core's
81
+ `scanFile` / `scanStagedDiff` etc. (it's also the default — the
82
+ explicit setting is for audit clarity).
83
+ - Every tool that exposes registry patterns redacts via
84
+ `core.redactMatch` before the value crosses the MCP boundary.
85
+ - The `--verbose` CLI path is not exposed as an MCP input.
86
+ - The `markers list` tool returns previews (`{ index, preview }`),
87
+ never literal patterns.
88
+
89
+ If a tool result you receive ever contains a literal marker string,
90
+ that's a bug — please file an issue.
91
+
92
+ ## License
93
+
94
+ GPL-3.0-or-later. Copyright (C) 2026 Richard Myers and contributors.
95
+
96
+ A De Otio tool — https://de-otio.org.
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ // SPDX-License-Identifier: GPL-3.0-or-later
3
+ // Copyright (C) 2026 Richard Myers and contributors.
4
+ // Bin entry for the repo-aegis MCP server. Spawns the McpServer over stdio
5
+ // and waits forever — the parent (Claude Code, Cursor, etc.) drives it via
6
+ // JSON-RPC over stdin/stdout.
7
+ //
8
+ // Keep this file tiny. The server itself is built in `server.ts` so it can
9
+ // be imported from tests without triggering stdio attach.
10
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
11
+ import { buildServer } from "./server.js";
12
+ const server = buildServer();
13
+ const transport = new StdioServerTransport();
14
+ await server.connect(transport);
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,4CAA4C;AAC5C,qDAAqD;AACrD,2EAA2E;AAC3E,2EAA2E;AAC3E,8BAA8B;AAC9B,EAAE;AACF,2EAA2E;AAC3E,0DAA0D;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;AAC7B,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ /**
3
+ * Build a new {@link McpServer} with every repo-aegis tool registered.
4
+ *
5
+ * Pure factory — no I/O, no transport, no side effects until the caller
6
+ * invokes `server.connect(transport)`. Tests use this entrypoint with an
7
+ * in-memory transport pair; the bin entry uses it with stdio.
8
+ *
9
+ * **Redaction policy**: every tool calls into `@de-otio/repo-aegis-core`
10
+ * with `revealMatches: false` (the core default, but explicit in our
11
+ * tools). MCP clients are agents, and agents must never see literal
12
+ * matched markers — that's the whole point of redacting hits in the
13
+ * first place.
14
+ */
15
+ export declare function buildServer(): McpServer;
16
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAkBpE;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,IAAI,SAAS,CASvC"}
package/dist/server.js ADDED
@@ -0,0 +1,42 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ // Copyright (C) 2026 Richard Myers and contributors.
3
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
+ import { registerStatusTool } from "./tools/status.js";
5
+ import { registerCheckTools } from "./tools/check.js";
6
+ import { registerMarkersTools } from "./tools/markers.js";
7
+ import { registerEngagementsTools } from "./tools/engagements.js";
8
+ import { registerAuditTool } from "./tools/audit.js";
9
+ import { registerFirstTouchTool } from "./tools/first-touch.js";
10
+ /**
11
+ * Server identity. Bumping `version` is a coordinated change with the
12
+ * package.json `version` field — both must move together so a connected
13
+ * client can detect changes via `serverInfo`.
14
+ */
15
+ const SERVER_INFO = {
16
+ name: "repo-aegis-mcp",
17
+ version: "0.0.1",
18
+ };
19
+ /**
20
+ * Build a new {@link McpServer} with every repo-aegis tool registered.
21
+ *
22
+ * Pure factory — no I/O, no transport, no side effects until the caller
23
+ * invokes `server.connect(transport)`. Tests use this entrypoint with an
24
+ * in-memory transport pair; the bin entry uses it with stdio.
25
+ *
26
+ * **Redaction policy**: every tool calls into `@de-otio/repo-aegis-core`
27
+ * with `revealMatches: false` (the core default, but explicit in our
28
+ * tools). MCP clients are agents, and agents must never see literal
29
+ * matched markers — that's the whole point of redacting hits in the
30
+ * first place.
31
+ */
32
+ export function buildServer() {
33
+ const server = new McpServer(SERVER_INFO);
34
+ registerStatusTool(server);
35
+ registerCheckTools(server);
36
+ registerMarkersTools(server);
37
+ registerEngagementsTools(server);
38
+ registerAuditTool(server);
39
+ registerFirstTouchTool(server);
40
+ return server;
41
+ }
42
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,qDAAqD;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEhE;;;;GAIG;AACH,MAAM,WAAW,GAAG;IAClB,IAAI,EAAE,gBAAgB;IACtB,OAAO,EAAE,OAAO;CACR,CAAC;AAEX;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW;IACzB,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,WAAW,CAAC,CAAC;IAC1C,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC3B,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC3B,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC7B,wBAAwB,CAAC,MAAM,CAAC,CAAC;IACjC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC1B,sBAAsB,CAAC,MAAM,CAAC,CAAC;IAC/B,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=server.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.test.d.ts","sourceRoot":"","sources":["../src/server.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,171 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ // Copyright (C) 2026 Richard Myers and contributors.
3
+ // Smoke test for the MCP server: boot it with an in-memory transport pair,
4
+ // list tools, and call one tool end-to-end. Verifies that:
5
+ // - every tool the server should register is actually registered;
6
+ // - a non-trivial tool (status) returns valid JSON of the expected shape;
7
+ // - the redaction policy holds (no literal markers in any output).
8
+ //
9
+ // Skips gracefully if the MCP SDK isn't installed in node_modules — useful
10
+ // in environments where the workspace install hasn't run yet.
11
+ import { describe, it, before, after } from "node:test";
12
+ import assert from "node:assert/strict";
13
+ import { execFileSync } from "node:child_process";
14
+ import { mkdirSync, mkdtempSync, rmSync, writeFileSync, } from "node:fs";
15
+ import { tmpdir } from "node:os";
16
+ import { join } from "node:path";
17
+ const EXPECTED_TOOLS = [
18
+ "repo_aegis_status",
19
+ "repo_aegis_check_path",
20
+ "repo_aegis_check_staged",
21
+ "repo_aegis_engagements_list",
22
+ "repo_aegis_engagements_show",
23
+ "repo_aegis_markers_test",
24
+ "repo_aegis_markers_list",
25
+ "repo_aegis_audit",
26
+ "aegis_classify_first_touch",
27
+ ];
28
+ async function loadHarness() {
29
+ try {
30
+ const [{ buildServer }, { Client }, { InMemoryTransport }] = await Promise.all([
31
+ import("./server.js"),
32
+ import("@modelcontextprotocol/sdk/client/index.js"),
33
+ import("@modelcontextprotocol/sdk/inMemory.js"),
34
+ ]);
35
+ return { buildServer, Client, InMemoryTransport };
36
+ }
37
+ catch {
38
+ return null;
39
+ }
40
+ }
41
+ const harness = await loadHarness();
42
+ if (!harness) {
43
+ describe("repo-aegis MCP server (skipped: SDK not installed)", () => {
44
+ it("skips when @modelcontextprotocol/sdk isn't resolvable", { skip: true }, () => {
45
+ /* skipped */
46
+ });
47
+ });
48
+ }
49
+ else {
50
+ const { buildServer, Client, InMemoryTransport } = harness;
51
+ let tmp;
52
+ let home;
53
+ let repo;
54
+ before(async () => {
55
+ tmp = mkdtempSync(join(tmpdir(), "repo-aegis-mcp-test-"));
56
+ home = join(tmp, "home");
57
+ const markersDir = join(home, "markers");
58
+ const stateDir = join(home, "state");
59
+ mkdirSync(markersDir, { recursive: true });
60
+ mkdirSync(stateDir, { recursive: true });
61
+ // No engagements / no marker files: status should report an empty
62
+ // deny set and zero patterns. We do NOT scaffold a registry.yaml here
63
+ // because we're testing the "fresh install" path; loadRegistry's
64
+ // RegistryNotFoundError is silently absorbed by the status tool.
65
+ process.env["REPO_AEGIS_HOME"] = home;
66
+ repo = join(tmp, "repo");
67
+ mkdirSync(repo, { recursive: true });
68
+ execFileSync("git", ["init", "-q"], { cwd: repo });
69
+ execFileSync("git", ["config", "user.name", "test"], { cwd: repo });
70
+ execFileSync("git", ["config", "user.email", "test@example.com"], { cwd: repo });
71
+ // Class: private-strict (default). No engagements.
72
+ });
73
+ after(() => {
74
+ delete process.env["REPO_AEGIS_HOME"];
75
+ rmSync(tmp, { recursive: true, force: true });
76
+ });
77
+ describe("repo-aegis MCP server", () => {
78
+ it("registers every expected tool", async () => {
79
+ const server = buildServer();
80
+ const client = new Client({ name: "test-client", version: "0.0.0" });
81
+ const [serverTransport, clientTransport] = InMemoryTransport.createLinkedPair();
82
+ await Promise.all([server.connect(serverTransport), client.connect(clientTransport)]);
83
+ try {
84
+ const list = await client.listTools();
85
+ const names = list.tools.map(t => t.name).sort();
86
+ for (const expected of EXPECTED_TOOLS) {
87
+ assert.ok(names.includes(expected), `expected tool ${expected} to be registered; got ${names.join(", ")}`);
88
+ }
89
+ }
90
+ finally {
91
+ await client.close();
92
+ await server.close();
93
+ }
94
+ });
95
+ it("repo_aegis_status returns the canonical shape against a tmp git repo", async () => {
96
+ const server = buildServer();
97
+ const client = new Client({ name: "test-client", version: "0.0.0" });
98
+ const [serverTransport, clientTransport] = InMemoryTransport.createLinkedPair();
99
+ await Promise.all([server.connect(serverTransport), client.connect(clientTransport)]);
100
+ try {
101
+ const result = await client.callTool({
102
+ name: "repo_aegis_status",
103
+ arguments: { cwd: repo },
104
+ });
105
+ assert.equal(result.isError, undefined);
106
+ const content = result.content;
107
+ assert.ok(content && content.length > 0, "expected content array");
108
+ const text = content[0].text;
109
+ assert.ok(typeof text === "string", "expected text content");
110
+ const parsed = JSON.parse(text);
111
+ assert.equal(parsed.repo.isGitRepo, true);
112
+ assert.equal(parsed.repo.class, "private-strict");
113
+ assert.deepEqual(parsed.repo.engagements, []);
114
+ assert.equal(parsed.denySet.patternCount, 0);
115
+ assert.deepEqual(parsed.allowedEngagements, []);
116
+ }
117
+ finally {
118
+ await client.close();
119
+ await server.close();
120
+ }
121
+ });
122
+ it("repo_aegis_markers_test redacts the input and returns no hits when deny set is empty", async () => {
123
+ const server = buildServer();
124
+ const client = new Client({ name: "test-client", version: "0.0.0" });
125
+ const [serverTransport, clientTransport] = InMemoryTransport.createLinkedPair();
126
+ await Promise.all([server.connect(serverTransport), client.connect(clientTransport)]);
127
+ try {
128
+ const result = await client.callTool({
129
+ name: "repo_aegis_markers_test",
130
+ arguments: { input: "some-private-string", cwd: repo },
131
+ });
132
+ assert.equal(result.isError, undefined);
133
+ const content = result.content;
134
+ const parsed = JSON.parse(content[0].text);
135
+ // Input must be redacted in the response — never returned verbatim.
136
+ assert.notEqual(parsed.input, "some-private-string");
137
+ assert.ok(parsed.input.length > 0);
138
+ assert.deepEqual(parsed.hits, []);
139
+ // Avoid asserting "input does not contain literal" too eagerly — the
140
+ // redactMatch preview keeps a short prefix. The important invariant
141
+ // is "not equal to literal", which we check above.
142
+ void writeFileSync; // keep import used
143
+ }
144
+ finally {
145
+ await client.close();
146
+ await server.close();
147
+ }
148
+ });
149
+ it("repo_aegis_engagements_list returns REGISTRY_NOT_FOUND when no registry exists", async () => {
150
+ const server = buildServer();
151
+ const client = new Client({ name: "test-client", version: "0.0.0" });
152
+ const [serverTransport, clientTransport] = InMemoryTransport.createLinkedPair();
153
+ await Promise.all([server.connect(serverTransport), client.connect(clientTransport)]);
154
+ try {
155
+ const result = await client.callTool({
156
+ name: "repo_aegis_engagements_list",
157
+ arguments: {},
158
+ });
159
+ assert.equal(result.isError, true);
160
+ const content = result.content;
161
+ const parsed = JSON.parse(content[0].text);
162
+ assert.equal(parsed.code, "REGISTRY_NOT_FOUND");
163
+ }
164
+ finally {
165
+ await client.close();
166
+ await server.close();
167
+ }
168
+ });
169
+ });
170
+ }
171
+ //# sourceMappingURL=server.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.test.js","sourceRoot":"","sources":["../src/server.test.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,qDAAqD;AACrD,2EAA2E;AAC3E,2DAA2D;AAC3D,oEAAoE;AACpE,4EAA4E;AAC5E,qEAAqE;AACrE,EAAE;AACF,2EAA2E;AAC3E,8DAA8D;AAC9D,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,SAAS,EACT,WAAW,EACX,MAAM,EACN,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,cAAc,GAAG;IACrB,mBAAmB;IACnB,uBAAuB;IACvB,yBAAyB;IACzB,6BAA6B;IAC7B,6BAA6B;IAC7B,yBAAy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,EAAE,CAAC;YACvB,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,gFAAgF,EAAE,KAAK,IAAI,EAAE;YAC9F,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;YAC7B,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;YACrE,MAAM,CAAC,eAAe,EAAE,eAAe,CAAC,GAAG,iBAAiB,CAAC,gBAAgB,EAAE,CAAC;YAChF,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;YACtF,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC;oBACnC,IAAI,EAAE,6BAA6B;oBACnC,SAAS,EAAE,EAAE;iBACd,CAAC,CAAC;gBACH,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;gBACnC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAgD,CAAC;gBACxE,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAE,CAAC,IAAI,CAAqC,CAAC;gBAChF,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;YAClD,CAAC;oBAAS,CAAC;gBACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;gBACrB,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;YACvB,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
2
+ /**
3
+ * Wrap a JSON-shaped value as the canonical MCP tool result.
4
+ *
5
+ * Every repo-aegis MCP tool returns the same JSON shape that the CLI
6
+ * emits with `--json`, so the agent-guide quick-reference table applies
7
+ * unchanged. We expose it via two channels:
8
+ * 1. `content[0].text` — pretty-printed JSON, the legacy-compatible
9
+ * surface every MCP client can read.
10
+ * 2. `structuredContent` — the parsed object, for clients that prefer
11
+ * the typed shape over re-parsing the text.
12
+ */
13
+ export declare function jsonResult(value: unknown): CallToolResult;
14
+ /**
15
+ * Wrap a thrown Error as an MCP tool error result. Tools should let
16
+ * unexpected errors propagate (the SDK will translate them), but for
17
+ * known/expected failure modes (e.g. registry-not-found, not-a-git-repo)
18
+ * we'd rather return a structured error than a generic JSON-RPC error
19
+ * so the agent can read `code` and act on it.
20
+ */
21
+ export declare function errorResult(payload: {
22
+ code?: string;
23
+ error: string;
24
+ details?: unknown;
25
+ }): CallToolResult;
26
+ //# sourceMappingURL=_util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_util.d.ts","sourceRoot":"","sources":["../../src/tools/_util.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEzE;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAMzD;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,cAAc,CAMxG"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Wrap a JSON-shaped value as the canonical MCP tool result.
3
+ *
4
+ * Every repo-aegis MCP tool returns the same JSON shape that the CLI
5
+ * emits with `--json`, so the agent-guide quick-reference table applies
6
+ * unchanged. We expose it via two channels:
7
+ * 1. `content[0].text` — pretty-printed JSON, the legacy-compatible
8
+ * surface every MCP client can read.
9
+ * 2. `structuredContent` — the parsed object, for clients that prefer
10
+ * the typed shape over re-parsing the text.
11
+ */
12
+ export function jsonResult(value) {
13
+ const text = JSON.stringify(value, null, 2);
14
+ return {
15
+ content: [{ type: "text", text }],
16
+ structuredContent: value,
17
+ };
18
+ }
19
+ /**
20
+ * Wrap a thrown Error as an MCP tool error result. Tools should let
21
+ * unexpected errors propagate (the SDK will translate them), but for
22
+ * known/expected failure modes (e.g. registry-not-found, not-a-git-repo)
23
+ * we'd rather return a structured error than a generic JSON-RPC error
24
+ * so the agent can read `code` and act on it.
25
+ */
26
+ export function errorResult(payload) {
27
+ return {
28
+ content: [{ type: "text", text: JSON.stringify(payload, null, 2) }],
29
+ structuredContent: payload,
30
+ isError: true,
31
+ };
32
+ }
33
+ //# sourceMappingURL=_util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_util.js","sourceRoot":"","sources":["../../src/tools/_util.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC5C,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QACjC,iBAAiB,EAAE,KAAgC;KACpD,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,OAA4D;IACtF,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;QACnE,iBAAiB,EAAE,OAAkC;QACrD,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ /**
3
+ * `repo_aegis_audit` — composite repo health check.
4
+ *
5
+ * Runs the same default checks as `repo-aegis audit --json` minus the
6
+ * network-dependent / archive-extracting flags (`--org`, `--published`,
7
+ * `--history`). Those are intentionally omitted from the MCP surface:
8
+ *
9
+ * - `--org` is a cross-border data transfer and requires explicit
10
+ * human consent (`--accept-cross-border` or the matching env var).
11
+ * The agent must never opt the user in to that.
12
+ * - `--published` extracts archives to a temp dir; that's a CLI
13
+ * workflow, not an interactive-agent one.
14
+ * - `--history` is slow (full git-log sweep per pattern). If the user
15
+ * wants it, they run the CLI directly.
16
+ *
17
+ * Hits are returned with `matchPreview` already redacted by core.
18
+ */
19
+ export declare function registerAuditTool(server: McpServer): void;
20
+ //# sourceMappingURL=audit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/tools/audit.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA0QzE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA2CzD"}