aegis-mcp-server 0.1.3 → 0.1.5

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.
@@ -5,6 +5,15 @@
5
5
  * Every call is validated against the loaded policy before execution.
6
6
  * The agent never sees the policy — only the verdict.
7
7
  *
8
+ * GOVERNANCE MODEL: The Aegis MCP does not override the agent's native
9
+ * directives. It introduces itself, explains why governance is active,
10
+ * identifies which operations benefit from compliance validation, and
11
+ * asks the agent to seek user permission to route governed operations
12
+ * through Aegis tools. The user's authority is the enforcement mechanism.
13
+ *
14
+ * LOGGING: Every denied action is logged to overrides.jsonl by the server
15
+ * process — no agent involvement required.
16
+ *
8
17
  * Tools:
9
18
  * aegis_check_permissions — Pre-check before writing (saves wasted generation)
10
19
  * aegis_write_file — Governed write with path + content validation
@@ -1 +1 @@
1
- {"version":3,"file":"file-tools.d.ts","sourceRoot":"","sources":["../../src/tools/file-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE7D,wBAAgB,aAAa,CAC3B,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,MAAM,iBAAiB,EAClC,QAAQ,EAAE,MAAM,WAAW,EAC3B,OAAO,EAAE,MAAM,YAAY,GAC1B,IAAI,CAiYN"}
1
+ {"version":3,"file":"file-tools.d.ts","sourceRoot":"","sources":["../../src/tools/file-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAe7D,wBAAgB,aAAa,CAC3B,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,MAAM,iBAAiB,EAClC,QAAQ,EAAE,MAAM,WAAW,EAC3B,OAAO,EAAE,MAAM,YAAY,GAC1B,IAAI,CA0YN"}
@@ -5,6 +5,15 @@
5
5
  * Every call is validated against the loaded policy before execution.
6
6
  * The agent never sees the policy — only the verdict.
7
7
  *
8
+ * GOVERNANCE MODEL: The Aegis MCP does not override the agent's native
9
+ * directives. It introduces itself, explains why governance is active,
10
+ * identifies which operations benefit from compliance validation, and
11
+ * asks the agent to seek user permission to route governed operations
12
+ * through Aegis tools. The user's authority is the enforcement mechanism.
13
+ *
14
+ * LOGGING: Every denied action is logged to overrides.jsonl by the server
15
+ * process — no agent involvement required.
16
+ *
8
17
  * Tools:
9
18
  * aegis_check_permissions — Pre-check before writing (saves wasted generation)
10
19
  * aegis_write_file — Governed write with path + content validation
@@ -18,11 +27,22 @@ import { readFile, writeFile, unlink, mkdir } from 'node:fs/promises';
18
27
  import { dirname, join, isAbsolute } from 'node:path';
19
28
  import { execSync } from 'node:child_process';
20
29
  import { z } from 'zod';
30
+ // ─── Governance Introduction ────────────────────────────────────────────────
31
+ // This prefix is prepended to every tool description. It reaches the agent
32
+ // at MCP connection time as part of the tool list — before any user prompt.
33
+ //
34
+ // It does NOT attempt to override the agent's native directives. Instead it:
35
+ // 1. Introduces the governance context
36
+ // 2. Explains which operations benefit from compliance validation
37
+ // 3. Asks the agent to inform the user and request permission
38
+ //
39
+ // The user's authority is what binds the agent, not the MCP's.
40
+ const GOVERNANCE_INTRO = `NOTE: You are connected to the Aegis MCP, a governance enforcement layer installed by the project owner to maintain compliance in this workspace. This project operates under regulated governance policy (.agentpolicy/). Your native tools for reading files, searching, and exploring the codebase work fine and do not need governance gating. However, all WRITE, DELETE, and EXECUTE operations in this project should be routed through Aegis tools (aegis_write_file, aegis_delete_file, aegis_execute) to ensure compliance validation, sensitive pattern scanning, and audit trail logging. Before beginning work, please call aegis_policy_summary to understand your role boundaries, then inform the user that Aegis governance is active and ask for their confirmation to route write operations through Aegis tools. If the user declines, proceed with native tools but note that governance validation will not be applied.\n\n`;
21
41
  export function registerTools(server, getEngine, getState, getRole) {
22
42
  // ─── aegis_check_permissions ──────────────────────────────────────────────
23
43
  server.registerTool('aegis_check_permissions', {
24
44
  title: 'Check Permissions',
25
- description: `Check if an operation is allowed on a path before attempting it. Use this to pre-validate before writing or reading files — saves you from composing content that would be blocked.
45
+ description: `${GOVERNANCE_INTRO}Check if an operation is allowed on a path before attempting it. Use this to pre-validate before writing or reading files — saves you from composing content that would be blocked. Denied checks are logged automatically by the server.
26
46
 
27
47
  Args:
28
48
  - path (string): Target file path relative to project root
@@ -42,9 +62,14 @@ Returns:
42
62
  },
43
63
  }, async ({ path, operation }) => {
44
64
  const engine = getEngine();
65
+ const role = getRole();
45
66
  const verdict = operation === 'read'
46
67
  ? engine.validateRead(path)
47
68
  : engine.validateWrite(path);
69
+ // Log denied permission checks
70
+ if (!verdict.allowed) {
71
+ await logBlocked(engine, role, path, `check_permissions (${operation})`, verdict.reason);
72
+ }
48
73
  return {
49
74
  content: [{
50
75
  type: 'text',
@@ -57,7 +82,7 @@ Returns:
57
82
  // ─── aegis_write_file ─────────────────────────────────────────────────────
58
83
  server.registerTool('aegis_write_file', {
59
84
  title: 'Write File (Governed)',
60
- description: `Write content to a file with governance enforcement. Path is validated against your role's permissions and governance boundaries. Content is scanned for sensitive patterns. If the write violates policy, it is blocked and you receive the specific reason.
85
+ description: `${GOVERNANCE_INTRO}Write content to a file with governance enforcement. Path is validated against your role's permissions and governance boundaries. Content is scanned for sensitive patterns. If the write violates policy, it is blocked, logged, and you receive the specific reason.
61
86
 
62
87
  Args:
63
88
  - path (string): File path relative to project root
@@ -105,7 +130,7 @@ Returns:
105
130
  // ─── aegis_read_file ──────────────────────────────────────────────────────
106
131
  server.registerTool('aegis_read_file', {
107
132
  title: 'Read File (Governed)',
108
- description: `Read the contents of a file with governance enforcement. Path is validated against your role's read permissions. If the read violates policy, it is blocked.
133
+ description: `${GOVERNANCE_INTRO}Read the contents of a file with governance enforcement. Path is validated against your role's read permissions. If the read violates policy, it is blocked, logged, and you receive the specific reason. Note: Native read tools are acceptable for general file exploration. Use this governed version when reading files that may contain sensitive or regulated data.
109
134
 
110
135
  Args:
111
136
  - path (string): File path relative to project root
@@ -124,8 +149,10 @@ Returns:
124
149
  }, async ({ path }) => {
125
150
  const engine = getEngine();
126
151
  const state = getState();
152
+ const role = getRole();
127
153
  const verdict = engine.validateRead(path);
128
154
  if (!verdict.allowed) {
155
+ await logBlocked(engine, role, path, 'read', verdict.reason);
129
156
  return blocked(verdict.reason);
130
157
  }
131
158
  const absPath = toAbsolute(path, state.projectRoot);
@@ -140,7 +167,7 @@ Returns:
140
167
  // ─── aegis_delete_file ────────────────────────────────────────────────────
141
168
  server.registerTool('aegis_delete_file', {
142
169
  title: 'Delete File (Governed)',
143
- description: `Delete a file with governance enforcement. Write permissions are required. If the delete violates policy, it is blocked.
170
+ description: `${GOVERNANCE_INTRO}Delete a file with governance enforcement. Write permissions are required. If the delete violates policy, it is blocked, logged, and you receive the specific reason.
144
171
 
145
172
  Args:
146
173
  - path (string): File path relative to project root
@@ -177,7 +204,7 @@ Returns:
177
204
  // ─── aegis_execute ────────────────────────────────────────────────────────
178
205
  server.registerTool('aegis_execute', {
179
206
  title: 'Execute Command (Governed)',
180
- description: `Execute a shell command in the project directory. Currently validates that the command runs within the project root. Future versions will enforce command-level permissions.
207
+ description: `${GOVERNANCE_INTRO}Execute a shell command in the project directory with governance oversight. Use this instead of native command execution to ensure compliance logging. Currently validates that the command runs within the project root. Future versions will enforce command-level permissions.
181
208
 
182
209
  Args:
183
210
  - command (string): Shell command to execute
@@ -229,7 +256,7 @@ Returns:
229
256
  // ─── aegis_complete_task ──────────────────────────────────────────────────
230
257
  server.registerTool('aegis_complete_task', {
231
258
  title: 'Complete Task',
232
- description: `Signal task completion and run required quality gates. Maps the governance quality_gate.pre_commit flags to build_commands and runs each required check. Returns pass/fail with details.
259
+ description: `${GOVERNANCE_INTRO}Signal task completion and run required quality gates. Maps the governance quality_gate.pre_commit flags to build_commands and runs each required check. Returns pass/fail with details.
233
260
 
234
261
  Args:
235
262
  - task_id (string): Identifier for the task being completed
@@ -300,10 +327,10 @@ Returns:
300
327
  // ─── aegis_policy_summary ─────────────────────────────────────────────────
301
328
  server.registerTool('aegis_policy_summary', {
302
329
  title: 'Policy Summary',
303
- description: `Get a minimal summary of your current role and permissions. Returns your role name, writable paths, excluded paths, forbidden actions, and key governance rules just enough to understand your boundaries without loading full policy files.
330
+ description: `${GOVERNANCE_INTRO}Get a minimal summary of your current role and permissions. Call this FIRST before doing any work. Returns your role boundaries, forbidden actions, and governance rules. After reviewing, inform the user that Aegis governance is active in this project and ask for their confirmation to route write, delete, and execute operations through Aegis tools for compliance validation.
304
331
 
305
332
  Returns:
306
- { "role": "...", "writable_paths": [...], "forbidden_actions": [...], ... }`,
333
+ { "governance_notice": "...", "role": "...", "writable_paths": [...], "forbidden_actions": [...], ... }`,
307
334
  inputSchema: {},
308
335
  annotations: {
309
336
  readOnlyHint: true,
@@ -316,6 +343,7 @@ Returns:
316
343
  const state = getState();
317
344
  const protocol = state.governance.override_protocol;
318
345
  const summary = {
346
+ governance_notice: 'This project is governed by Aegis (.agentpolicy/). The project owner has installed the Aegis MCP to enforce compliance at runtime. Please inform the user that Aegis governance is active, then ask for their permission to route write, delete, and execute operations through Aegis tools. If the user declines, you may proceed with native tools, but note that compliance validation and audit logging will not be applied. Native read and search tools are fine for exploration.',
319
347
  role: role.id,
320
348
  role_name: role.name,
321
349
  purpose: role.purpose,
@@ -1 +1 @@
1
- {"version":3,"file":"file-tools.js","sourceRoot":"","sources":["../../src/tools/file-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS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AE,CAAC;aACpD,CAAC;KACH,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,UAAU,CACvB,MAAyB,EACzB,IAAkB,EAClB,IAAY,EACZ,SAAiB,EACjB,MAAc;IAEd,MAAM,MAAM,CAAC,WAAW,CAAC;QACvB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,eAAe,EAAE,MAAM;QACvB,WAAW,EAAE,MAAM;QACnB,gBAAgB,EAAE,GAAG,SAAS,KAAK,IAAI,EAAE;QACzC,eAAe,EAAE,KAAK;QACtB,UAAU,EAAE,IAAI,CAAC,EAAE;QACnB,SAAS,EAAE,8BAA8B;KAC1C,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aegis-mcp-server",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "MCP enforcement layer for the Aegis agent governance specification",
5
5
  "type": "module",
6
6
  "bin": {
@@ -5,6 +5,15 @@
5
5
  * Every call is validated against the loaded policy before execution.
6
6
  * The agent never sees the policy — only the verdict.
7
7
  *
8
+ * GOVERNANCE MODEL: The Aegis MCP does not override the agent's native
9
+ * directives. It introduces itself, explains why governance is active,
10
+ * identifies which operations benefit from compliance validation, and
11
+ * asks the agent to seek user permission to route governed operations
12
+ * through Aegis tools. The user's authority is the enforcement mechanism.
13
+ *
14
+ * LOGGING: Every denied action is logged to overrides.jsonl by the server
15
+ * process — no agent involvement required.
16
+ *
8
17
  * Tools:
9
18
  * aegis_check_permissions — Pre-check before writing (saves wasted generation)
10
19
  * aegis_write_file — Governed write with path + content validation
@@ -23,6 +32,19 @@ import { z } from 'zod';
23
32
  import type { EnforcementEngine } from '../services/enforcement-engine.js';
24
33
  import type { PolicyState, ResolvedRole } from '../types.js';
25
34
 
35
+ // ─── Governance Introduction ────────────────────────────────────────────────
36
+ // This prefix is prepended to every tool description. It reaches the agent
37
+ // at MCP connection time as part of the tool list — before any user prompt.
38
+ //
39
+ // It does NOT attempt to override the agent's native directives. Instead it:
40
+ // 1. Introduces the governance context
41
+ // 2. Explains which operations benefit from compliance validation
42
+ // 3. Asks the agent to inform the user and request permission
43
+ //
44
+ // The user's authority is what binds the agent, not the MCP's.
45
+
46
+ const GOVERNANCE_INTRO = `NOTE: You are connected to the Aegis MCP, a governance enforcement layer installed by the project owner to maintain compliance in this workspace. This project operates under regulated governance policy (.agentpolicy/). Your native tools for reading files, searching, and exploring the codebase work fine and do not need governance gating. However, all WRITE, DELETE, and EXECUTE operations in this project should be routed through Aegis tools (aegis_write_file, aegis_delete_file, aegis_execute) to ensure compliance validation, sensitive pattern scanning, and audit trail logging. Before beginning work, please call aegis_policy_summary to understand your role boundaries, then inform the user that Aegis governance is active and ask for their confirmation to route write operations through Aegis tools. If the user declines, proceed with native tools but note that governance validation will not be applied.\n\n`;
47
+
26
48
  export function registerTools(
27
49
  server: McpServer,
28
50
  getEngine: () => EnforcementEngine,
@@ -36,7 +58,7 @@ export function registerTools(
36
58
  'aegis_check_permissions',
37
59
  {
38
60
  title: 'Check Permissions',
39
- description: `Check if an operation is allowed on a path before attempting it. Use this to pre-validate before writing or reading files — saves you from composing content that would be blocked.
61
+ description: `${GOVERNANCE_INTRO}Check if an operation is allowed on a path before attempting it. Use this to pre-validate before writing or reading files — saves you from composing content that would be blocked. Denied checks are logged automatically by the server.
40
62
 
41
63
  Args:
42
64
  - path (string): Target file path relative to project root
@@ -57,10 +79,16 @@ Returns:
57
79
  },
58
80
  async ({ path, operation }) => {
59
81
  const engine = getEngine();
82
+ const role = getRole();
60
83
  const verdict = operation === 'read'
61
84
  ? engine.validateRead(path)
62
85
  : engine.validateWrite(path);
63
86
 
87
+ // Log denied permission checks
88
+ if (!verdict.allowed) {
89
+ await logBlocked(engine, role, path, `check_permissions (${operation})`, verdict.reason);
90
+ }
91
+
64
92
  return {
65
93
  content: [{
66
94
  type: 'text' as const,
@@ -80,7 +108,7 @@ Returns:
80
108
  'aegis_write_file',
81
109
  {
82
110
  title: 'Write File (Governed)',
83
- description: `Write content to a file with governance enforcement. Path is validated against your role's permissions and governance boundaries. Content is scanned for sensitive patterns. If the write violates policy, it is blocked and you receive the specific reason.
111
+ description: `${GOVERNANCE_INTRO}Write content to a file with governance enforcement. Path is validated against your role's permissions and governance boundaries. Content is scanned for sensitive patterns. If the write violates policy, it is blocked, logged, and you receive the specific reason.
84
112
 
85
113
  Args:
86
114
  - path (string): File path relative to project root
@@ -138,7 +166,7 @@ Returns:
138
166
  'aegis_read_file',
139
167
  {
140
168
  title: 'Read File (Governed)',
141
- description: `Read the contents of a file with governance enforcement. Path is validated against your role's read permissions. If the read violates policy, it is blocked.
169
+ description: `${GOVERNANCE_INTRO}Read the contents of a file with governance enforcement. Path is validated against your role's read permissions. If the read violates policy, it is blocked, logged, and you receive the specific reason. Note: Native read tools are acceptable for general file exploration. Use this governed version when reading files that may contain sensitive or regulated data.
142
170
 
143
171
  Args:
144
172
  - path (string): File path relative to project root
@@ -158,9 +186,11 @@ Returns:
158
186
  async ({ path }) => {
159
187
  const engine = getEngine();
160
188
  const state = getState();
189
+ const role = getRole();
161
190
 
162
191
  const verdict = engine.validateRead(path);
163
192
  if (!verdict.allowed) {
193
+ await logBlocked(engine, role, path, 'read', verdict.reason);
164
194
  return blocked(verdict.reason);
165
195
  }
166
196
 
@@ -182,7 +212,7 @@ Returns:
182
212
  'aegis_delete_file',
183
213
  {
184
214
  title: 'Delete File (Governed)',
185
- description: `Delete a file with governance enforcement. Write permissions are required. If the delete violates policy, it is blocked.
215
+ description: `${GOVERNANCE_INTRO}Delete a file with governance enforcement. Write permissions are required. If the delete violates policy, it is blocked, logged, and you receive the specific reason.
186
216
 
187
217
  Args:
188
218
  - path (string): File path relative to project root
@@ -228,7 +258,7 @@ Returns:
228
258
  'aegis_execute',
229
259
  {
230
260
  title: 'Execute Command (Governed)',
231
- description: `Execute a shell command in the project directory. Currently validates that the command runs within the project root. Future versions will enforce command-level permissions.
261
+ description: `${GOVERNANCE_INTRO}Execute a shell command in the project directory with governance oversight. Use this instead of native command execution to ensure compliance logging. Currently validates that the command runs within the project root. Future versions will enforce command-level permissions.
232
262
 
233
263
  Args:
234
264
  - command (string): Shell command to execute
@@ -287,7 +317,7 @@ Returns:
287
317
  'aegis_complete_task',
288
318
  {
289
319
  title: 'Complete Task',
290
- description: `Signal task completion and run required quality gates. Maps the governance quality_gate.pre_commit flags to build_commands and runs each required check. Returns pass/fail with details.
320
+ description: `${GOVERNANCE_INTRO}Signal task completion and run required quality gates. Maps the governance quality_gate.pre_commit flags to build_commands and runs each required check. Returns pass/fail with details.
291
321
 
292
322
  Args:
293
323
  - task_id (string): Identifier for the task being completed
@@ -368,10 +398,10 @@ Returns:
368
398
  'aegis_policy_summary',
369
399
  {
370
400
  title: 'Policy Summary',
371
- description: `Get a minimal summary of your current role and permissions. Returns your role name, writable paths, excluded paths, forbidden actions, and key governance rules just enough to understand your boundaries without loading full policy files.
401
+ description: `${GOVERNANCE_INTRO}Get a minimal summary of your current role and permissions. Call this FIRST before doing any work. Returns your role boundaries, forbidden actions, and governance rules. After reviewing, inform the user that Aegis governance is active in this project and ask for their confirmation to route write, delete, and execute operations through Aegis tools for compliance validation.
372
402
 
373
403
  Returns:
374
- { "role": "...", "writable_paths": [...], "forbidden_actions": [...], ... }`,
404
+ { "governance_notice": "...", "role": "...", "writable_paths": [...], "forbidden_actions": [...], ... }`,
375
405
  inputSchema: {},
376
406
  annotations: {
377
407
  readOnlyHint: true,
@@ -386,6 +416,7 @@ Returns:
386
416
  const protocol = state.governance.override_protocol;
387
417
 
388
418
  const summary = {
419
+ governance_notice: 'This project is governed by Aegis (.agentpolicy/). The project owner has installed the Aegis MCP to enforce compliance at runtime. Please inform the user that Aegis governance is active, then ask for their permission to route write, delete, and execute operations through Aegis tools. If the user declines, you may proceed with native tools, but note that compliance validation and audit logging will not be applied. Native read and search tools are fine for exploration.',
389
420
  role: role.id,
390
421
  role_name: role.name,
391
422
  purpose: role.purpose,