aegis-mcp-server 0.1.4 → 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,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
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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
|
|
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"}
|
package/dist/tools/file-tools.js
CHANGED
|
@@ -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
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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
|
-
// ───
|
|
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
|
-
|
|
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: `${
|
|
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: `${
|
|
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: `${
|
|
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: `${
|
|
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: `${
|
|
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: `${
|
|
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: `${
|
|
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
|
-
{ "
|
|
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
|
-
|
|
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,MAAM,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,+EAA+E;AAC/E,2EAA2E;AAC3E,4EAA4E;AAE5E,MAAM,qBAAqB,GAAG,oTAAoT,CAAC;AAEnV,MAAM,UAAU,aAAa,CAC3B,MAAiB,EACjB,SAAkC,EAClC,QAA2B,EAC3B,OAA2B;IAG3B,6EAA6E;IAE7E,MAAM,CAAC,YAAY,CACjB,yBAAyB,EACzB;QACE,KAAK,EAAE,mBAAmB;QAC1B,WAAW,EAAE,GAAG,qBAAqB;;;;;;;+DAOoB;QACzD,WAAW,EAAE;YACX,IAAI,EAAE,C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AC,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
package/src/tools/file-tools.ts
CHANGED
|
@@ -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
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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
|
-
// ───
|
|
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
|
|
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: `${
|
|
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: `${
|
|
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: `${
|
|
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: `${
|
|
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: `${
|
|
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: `${
|
|
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: `${
|
|
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
|
-
{ "
|
|
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
|
-
|
|
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,
|