aegis-mcp-server 0.1.4 → 0.1.6

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.js CHANGED
@@ -35,6 +35,35 @@ const __filename = fileURLToPath(import.meta.url);
35
35
  const __dirname = dirname(__filename);
36
36
  const pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf-8'));
37
37
  const VERSION = pkg.version;
38
+ // ─── Update Checker ─────────────────────────────────────────────────────────
39
+ // Non-blocking check against the npm registry. If a newer version
40
+ // exists, prints a one-line notice to stderr. If the check fails
41
+ // (offline, timeout, etc.), skips silently — never blocks startup.
42
+ async function checkForUpdate() {
43
+ try {
44
+ const controller = new AbortController();
45
+ const timeout = setTimeout(() => controller.abort(), 3000);
46
+ const res = await fetch(`https://registry.npmjs.org/${pkg.name}/latest`, { signal: controller.signal });
47
+ clearTimeout(timeout);
48
+ if (!res.ok)
49
+ return;
50
+ const data = await res.json();
51
+ const latest = data.version;
52
+ if (!latest || latest === VERSION)
53
+ return;
54
+ const current = VERSION.split('.').map(Number);
55
+ const remote = latest.split('.').map(Number);
56
+ const isNewer = remote[0] > current[0] ||
57
+ (remote[0] === current[0] && remote[1] > current[1]) ||
58
+ (remote[0] === current[0] && remote[1] === current[1] && remote[2] > current[2]);
59
+ if (isNewer) {
60
+ log(`Update available: ${VERSION} → ${latest}. Run: npm install -g ${pkg.name}@latest`);
61
+ }
62
+ }
63
+ catch {
64
+ // Silently skip — network issues should never block the MCP server
65
+ }
66
+ }
38
67
  // ─── Parse CLI Args ─────────────────────────────────────────────────────────
39
68
  function parseArgs() {
40
69
  const args = process.argv.slice(2);
@@ -105,6 +134,8 @@ TOOLS PROVIDED:
105
134
  // ─── Main ───────────────────────────────────────────────────────────────────
106
135
  async function main() {
107
136
  const config = parseArgs();
137
+ // Check for updates (non-blocking, 3s timeout)
138
+ await checkForUpdate();
108
139
  log(`Starting aegis-mcp-server v${VERSION}`);
109
140
  log(` Project: ${config.projectRoot}`);
110
141
  log(` Role: ${config.role}`);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGtD,+EAA+E;AAE/E,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACtC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;AACrF,MAAM,OAAO,GAAW,GAAG,CAAC,OAAO,CAAC;AAEpC,+EAA+E;AAE/E,SAAS,SAAS;IAChB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,IAAI,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAChC,IAAI,IAAI,GAAG,SAAS,CAAC;IACrB,IAAI,SAA6B,CAAC;IAElC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAA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aded policy before execution.
6
6
  * The agent never sees the policy — only the verdict.
7
7
  *
8
- * ENFORCEMENT DIRECTIVE: Every tool description includes a clear statement
9
- * that agents must use these tools exclusively no native file operations.
10
- * This directive reaches the agent at connection time via the MCP tool list,
11
- * before any conversation begins.
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.
12
13
  *
13
14
  * LOGGING: Every denied action is logged to overrides.jsonl by the server
14
15
  * process — no agent involvement required.
@@ -1 +1 @@
1
- {"version":3,"file":"file-tools.d.ts","sourceRoot":"","sources":["../../src/tools/file-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;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;AAQ7D,wBAAgB,aAAa,CAC3B,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,MAAM,iBAAiB,EAClC,QAAQ,EAAE,MAAM,WAAW,EAC3B,OAAO,EAAE,MAAM,YAAY,GAC1B,IAAI,CA0YN"}
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,10 +5,11 @@
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
- * ENFORCEMENT DIRECTIVE: Every tool description includes a clear statement
9
- * that agents must use these tools exclusively no native file operations.
10
- * This directive reaches the agent at connection time via the MCP tool list,
11
- * before any conversation begins.
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.
12
13
  *
13
14
  * LOGGING: Every denied action is logged to overrides.jsonl by the server
14
15
  * process — no agent involvement required.
@@ -26,15 +27,22 @@ import { readFile, writeFile, unlink, mkdir } from 'node:fs/promises';
26
27
  import { dirname, join, isAbsolute } from 'node:path';
27
28
  import { execSync } from 'node:child_process';
28
29
  import { z } from 'zod';
29
- // ─── Enforcement Directive ──────────────────────────────────────────────────
30
+ // ─── Governance Introduction ────────────────────────────────────────────────
30
31
  // This prefix is prepended to every tool description. It reaches the agent
31
32
  // at MCP connection time as part of the tool list — before any user prompt.
32
- const ENFORCEMENT_DIRECTIVE = `IMPORTANT: You are connected to the Aegis MCP enforcement layer. ALL file read, write, and delete operations MUST use the aegis_* tools. Do NOT use native file tools (Read, Write, Edit, etc.). Aegis validates every action against your role's governance policy. Blocked actions are logged automatically.\n\n`;
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`;
33
41
  export function registerTools(server, getEngine, getState, getRole) {
34
42
  // ─── aegis_check_permissions ──────────────────────────────────────────────
35
43
  server.registerTool('aegis_check_permissions', {
36
44
  title: 'Check Permissions',
37
- description: `${ENFORCEMENT_DIRECTIVE}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.
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.
38
46
 
39
47
  Args:
40
48
  - path (string): Target file path relative to project root
@@ -74,7 +82,7 @@ Returns:
74
82
  // ─── aegis_write_file ─────────────────────────────────────────────────────
75
83
  server.registerTool('aegis_write_file', {
76
84
  title: 'Write File (Governed)',
77
- description: `${ENFORCEMENT_DIRECTIVE}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.
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.
78
86
 
79
87
  Args:
80
88
  - path (string): File path relative to project root
@@ -122,7 +130,7 @@ Returns:
122
130
  // ─── aegis_read_file ──────────────────────────────────────────────────────
123
131
  server.registerTool('aegis_read_file', {
124
132
  title: 'Read File (Governed)',
125
- description: `${ENFORCEMENT_DIRECTIVE}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.
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.
126
134
 
127
135
  Args:
128
136
  - path (string): File path relative to project root
@@ -159,7 +167,7 @@ Returns:
159
167
  // ─── aegis_delete_file ────────────────────────────────────────────────────
160
168
  server.registerTool('aegis_delete_file', {
161
169
  title: 'Delete File (Governed)',
162
- description: `${ENFORCEMENT_DIRECTIVE}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.
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.
163
171
 
164
172
  Args:
165
173
  - path (string): File path relative to project root
@@ -196,7 +204,7 @@ Returns:
196
204
  // ─── aegis_execute ────────────────────────────────────────────────────────
197
205
  server.registerTool('aegis_execute', {
198
206
  title: 'Execute Command (Governed)',
199
- description: `${ENFORCEMENT_DIRECTIVE}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.
200
208
 
201
209
  Args:
202
210
  - command (string): Shell command to execute
@@ -248,7 +256,7 @@ Returns:
248
256
  // ─── aegis_complete_task ──────────────────────────────────────────────────
249
257
  server.registerTool('aegis_complete_task', {
250
258
  title: 'Complete Task',
251
- description: `${ENFORCEMENT_DIRECTIVE}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.
252
260
 
253
261
  Args:
254
262
  - task_id (string): Identifier for the task being completed
@@ -319,10 +327,10 @@ Returns:
319
327
  // ─── aegis_policy_summary ─────────────────────────────────────────────────
320
328
  server.registerTool('aegis_policy_summary', {
321
329
  title: 'Policy Summary',
322
- description: `${ENFORCEMENT_DIRECTIVE}Get a minimal summary of your current role and permissions. Call this FIRST before doing any work. 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.
323
331
 
324
332
  Returns:
325
- { "enforcement_directive": "...", "role": "...", "writable_paths": [...], "forbidden_actions": [...], ... }`,
333
+ { "governance_notice": "...", "role": "...", "writable_paths": [...], "forbidden_actions": [...], ... }`,
326
334
  inputSchema: {},
327
335
  annotations: {
328
336
  readOnlyHint: true,
@@ -335,7 +343,7 @@ Returns:
335
343
  const state = getState();
336
344
  const protocol = state.governance.override_protocol;
337
345
  const summary = {
338
- enforcement_directive: 'You are governed by the Aegis MCP enforcement layer. ALL file operations (read, write, delete) MUST use aegis_* tools. Do NOT use native file tools. Violations are blocked and logged automatically. There are no exceptions to this requirement.',
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.',
339
347
  role: role.id,
340
348
  role_name: role.name,
341
349
  purpose: role.purpose,
@@ -1 +1 @@
1
- {"version":3,"file":"file-tools.js","sourceRoot":"","sources":["../../src/tools/file-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MA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B,IAAI,KAAK;aAC7F;SACF,CAAC;QAEF,OAAO;YACL,OAAO,EAAE,CAAC;oBACR,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;iBAC9B,CAAC;SACH,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC;AAED,iFAAiF;AAEjF,SAAS,UAAU,CAAC,IAAY,EAAE,WAAmB;IACnD,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;AAC3D,CAAC;AAED,SAAS,OAAO,CAAC,MAAc;IAI7B,OAAO;QACL,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,CAAC;gBACR,IAAI,EAAE,MAAe;gBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,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.4",
3
+ "version": "0.1.6",
4
4
  "description": "MCP enforcement layer for the Aegis agent governance specification",
5
5
  "type": "module",
6
6
  "bin": {
package/src/index.ts CHANGED
@@ -41,6 +41,43 @@ const __dirname = dirname(__filename);
41
41
  const pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf-8'));
42
42
  const VERSION: string = pkg.version;
43
43
 
44
+ // ─── Update Checker ─────────────────────────────────────────────────────────
45
+ // Non-blocking check against the npm registry. If a newer version
46
+ // exists, prints a one-line notice to stderr. If the check fails
47
+ // (offline, timeout, etc.), skips silently — never blocks startup.
48
+
49
+ async function checkForUpdate(): Promise<void> {
50
+ try {
51
+ const controller = new AbortController();
52
+ const timeout = setTimeout(() => controller.abort(), 3000);
53
+
54
+ const res = await fetch(
55
+ `https://registry.npmjs.org/${pkg.name}/latest`,
56
+ { signal: controller.signal }
57
+ );
58
+ clearTimeout(timeout);
59
+
60
+ if (!res.ok) return;
61
+
62
+ const data = await res.json() as { version?: string };
63
+ const latest = data.version;
64
+ if (!latest || latest === VERSION) return;
65
+
66
+ const current = VERSION.split('.').map(Number);
67
+ const remote = latest.split('.').map(Number);
68
+ const isNewer =
69
+ remote[0] > current[0] ||
70
+ (remote[0] === current[0] && remote[1] > current[1]) ||
71
+ (remote[0] === current[0] && remote[1] === current[1] && remote[2] > current[2]);
72
+
73
+ if (isNewer) {
74
+ log(`Update available: ${VERSION} → ${latest}. Run: npm install -g ${pkg.name}@latest`);
75
+ }
76
+ } catch {
77
+ // Silently skip — network issues should never block the MCP server
78
+ }
79
+ }
80
+
44
81
  // ─── Parse CLI Args ─────────────────────────────────────────────────────────
45
82
 
46
83
  function parseArgs(): AegisMcpConfig {
@@ -118,6 +155,9 @@ TOOLS PROVIDED:
118
155
  async function main(): Promise<void> {
119
156
  const config = parseArgs();
120
157
 
158
+ // Check for updates (non-blocking, 3s timeout)
159
+ await checkForUpdate();
160
+
121
161
  log(`Starting aegis-mcp-server v${VERSION}`);
122
162
  log(` Project: ${config.projectRoot}`);
123
163
  log(` Role: ${config.role}`);
@@ -5,10 +5,11 @@
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
- * ENFORCEMENT DIRECTIVE: Every tool description includes a clear statement
9
- * that agents must use these tools exclusively no native file operations.
10
- * This directive reaches the agent at connection time via the MCP tool list,
11
- * before any conversation begins.
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.
12
13
  *
13
14
  * LOGGING: Every denied action is logged to overrides.jsonl by the server
14
15
  * process — no agent involvement required.
@@ -31,11 +32,18 @@ import { z } from 'zod';
31
32
  import type { EnforcementEngine } from '../services/enforcement-engine.js';
32
33
  import type { PolicyState, ResolvedRole } from '../types.js';
33
34
 
34
- // ─── Enforcement Directive ──────────────────────────────────────────────────
35
+ // ─── Governance Introduction ────────────────────────────────────────────────
35
36
  // This prefix is prepended to every tool description. It reaches the agent
36
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.
37
45
 
38
- const ENFORCEMENT_DIRECTIVE = `IMPORTANT: You are connected to the Aegis MCP enforcement layer. ALL file read, write, and delete operations MUST use the aegis_* tools. Do NOT use native file tools (Read, Write, Edit, etc.). Aegis validates every action against your role's governance policy. Blocked actions are logged automatically.\n\n`;
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`;
39
47
 
40
48
  export function registerTools(
41
49
  server: McpServer,
@@ -50,7 +58,7 @@ export function registerTools(
50
58
  'aegis_check_permissions',
51
59
  {
52
60
  title: 'Check Permissions',
53
- description: `${ENFORCEMENT_DIRECTIVE}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.
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.
54
62
 
55
63
  Args:
56
64
  - path (string): Target file path relative to project root
@@ -100,7 +108,7 @@ Returns:
100
108
  'aegis_write_file',
101
109
  {
102
110
  title: 'Write File (Governed)',
103
- description: `${ENFORCEMENT_DIRECTIVE}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.
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.
104
112
 
105
113
  Args:
106
114
  - path (string): File path relative to project root
@@ -158,7 +166,7 @@ Returns:
158
166
  'aegis_read_file',
159
167
  {
160
168
  title: 'Read File (Governed)',
161
- description: `${ENFORCEMENT_DIRECTIVE}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.
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.
162
170
 
163
171
  Args:
164
172
  - path (string): File path relative to project root
@@ -204,7 +212,7 @@ Returns:
204
212
  'aegis_delete_file',
205
213
  {
206
214
  title: 'Delete File (Governed)',
207
- description: `${ENFORCEMENT_DIRECTIVE}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.
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.
208
216
 
209
217
  Args:
210
218
  - path (string): File path relative to project root
@@ -250,7 +258,7 @@ Returns:
250
258
  'aegis_execute',
251
259
  {
252
260
  title: 'Execute Command (Governed)',
253
- description: `${ENFORCEMENT_DIRECTIVE}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.
254
262
 
255
263
  Args:
256
264
  - command (string): Shell command to execute
@@ -309,7 +317,7 @@ Returns:
309
317
  'aegis_complete_task',
310
318
  {
311
319
  title: 'Complete Task',
312
- description: `${ENFORCEMENT_DIRECTIVE}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.
313
321
 
314
322
  Args:
315
323
  - task_id (string): Identifier for the task being completed
@@ -390,10 +398,10 @@ Returns:
390
398
  'aegis_policy_summary',
391
399
  {
392
400
  title: 'Policy Summary',
393
- description: `${ENFORCEMENT_DIRECTIVE}Get a minimal summary of your current role and permissions. Call this FIRST before doing any work. 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.
394
402
 
395
403
  Returns:
396
- { "enforcement_directive": "...", "role": "...", "writable_paths": [...], "forbidden_actions": [...], ... }`,
404
+ { "governance_notice": "...", "role": "...", "writable_paths": [...], "forbidden_actions": [...], ... }`,
397
405
  inputSchema: {},
398
406
  annotations: {
399
407
  readOnlyHint: true,
@@ -408,7 +416,7 @@ Returns:
408
416
  const protocol = state.governance.override_protocol;
409
417
 
410
418
  const summary = {
411
- enforcement_directive: 'You are governed by the Aegis MCP enforcement layer. ALL file operations (read, write, delete) MUST use aegis_* tools. Do NOT use native file tools. Violations are blocked and logged automatically. There are no exceptions to this requirement.',
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.',
412
420
  role: role.id,
413
421
  role_name: role.name,
414
422
  purpose: role.purpose,