@getaegis/cli 0.9.3 → 0.9.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.
- package/README.md +148 -550
- package/dist/cli/commands/mcp.d.ts.map +1 -1
- package/dist/cli/commands/mcp.js +37 -10
- package/dist/cli/commands/mcp.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,28 +5,45 @@
|
|
|
5
5
|
[](https://ghcr.io/getaegis/aegis)
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
|
|
8
|
-
**
|
|
9
|
-
|
|
10
|
-
Aegis sits between your
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
8
|
+
**Stop putting API keys where AI agents can read them.**
|
|
9
|
+
|
|
10
|
+
Aegis is a local-first credential isolation proxy for AI agents. It sits between your agent and the APIs it calls — injecting secrets at the network boundary so the agent never sees, stores, or transmits real credentials.
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<img src="docs/assets/demo.gif" alt="Aegis demo" width="720" />
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
## How It Works
|
|
17
|
+
|
|
18
|
+
```mermaid
|
|
19
|
+
graph LR
|
|
20
|
+
Agent["🤖 AI Agent<br/><i>No credentials</i>"]
|
|
21
|
+
Gate["🛡️ Aegis Gate<br/><i>localhost:3100</i>"]
|
|
22
|
+
Check{"② Domain<br/>allowed?"}
|
|
23
|
+
API["🌐 Target API<br/><i>slack.com, github.com</i>"]
|
|
24
|
+
Ledger["📋 Ledger"]
|
|
25
|
+
|
|
26
|
+
Agent -->|"① HTTP request<br/>(no auth headers)"| Gate
|
|
27
|
+
Gate --> Check
|
|
28
|
+
Check -->|"Yes"| Inject
|
|
29
|
+
Inject["③ Inject credential"] -->|"Forward over HTTPS"| API
|
|
30
|
+
API -->|"④ Response"| Gate
|
|
31
|
+
Gate -->|"⑤ Return response<br/>(credential stripped)"| Agent
|
|
32
|
+
Check -->|"No"| Block["🚫 Blocked"]
|
|
33
|
+
Gate -.->|"Log every request"| Ledger
|
|
34
|
+
|
|
35
|
+
style Agent fill:#1a1f26,stroke:#C8973E,color:#e8ecef
|
|
36
|
+
style Gate fill:#1a1f26,stroke:#C8973E,color:#C8973E,stroke-width:2px
|
|
37
|
+
style Check fill:#1a1f26,stroke:#C8973E,color:#e8ecef
|
|
38
|
+
style Inject fill:#1a1f26,stroke:#C8973E,color:#e8ecef
|
|
39
|
+
style API fill:#1a1f26,stroke:#666,color:#e8ecef
|
|
40
|
+
style Block fill:#1a1f26,stroke:#e74c3c,color:#e74c3c
|
|
41
|
+
style Ledger fill:#1a1f26,stroke:#C8973E,color:#e8ecef
|
|
25
42
|
```
|
|
26
43
|
|
|
27
44
|
## Why?
|
|
28
45
|
|
|
29
|
-
AI agents (Claude, GPT, Cursor, custom bots) increasingly
|
|
46
|
+
AI agents (Claude, GPT, Cursor, custom bots) increasingly call real APIs — Slack, GitHub, Stripe, databases. The current pattern is dangerous:
|
|
30
47
|
|
|
31
48
|
1. **Agents see raw API keys** — one prompt injection exfiltrates them
|
|
32
49
|
2. **No domain guard** — a compromised agent can send your Slack token to `evil.com`
|
|
@@ -35,48 +52,15 @@ AI agents (Claude, GPT, Cursor, custom bots) increasingly need to call APIs —
|
|
|
35
52
|
|
|
36
53
|
Aegis solves all four. Your agent makes HTTP calls through a local proxy. Aegis handles authentication, enforces domain restrictions, and logs everything.
|
|
37
54
|
|
|
38
|
-
## Prerequisites
|
|
39
|
-
|
|
40
|
-
- **Node.js ≥ 20** — check with `node -v`
|
|
41
|
-
|
|
42
55
|
## Quick Start
|
|
43
56
|
|
|
44
57
|
```bash
|
|
45
|
-
# Install
|
|
58
|
+
# Install
|
|
46
59
|
npm install -g @getaegis/cli
|
|
47
60
|
|
|
48
|
-
# Initialize
|
|
61
|
+
# Initialize (stores master key in OS keychain by default)
|
|
49
62
|
aegis init
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
By default, `aegis init` stores the master key in your OS keychain (macOS Keychain, Windows Credential Manager, or Linux Secret Service). If no keychain is available, it falls back to a file at `.aegis/.master-key` (mode 0600).
|
|
53
|
-
|
|
54
|
-
Alternative storage modes:
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
# Store in .env file (for CI/headless environments)
|
|
58
|
-
aegis init --env-file
|
|
59
63
|
|
|
60
|
-
# Store in aegis.config.yaml (convenient for local dev, not recommended for production)
|
|
61
|
-
aegis init --write-secrets
|
|
62
|
-
|
|
63
|
-
# Check where your master key is stored
|
|
64
|
-
aegis key where
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
**Master key resolution order** (highest priority wins):
|
|
68
|
-
|
|
69
|
-
| Priority | Source | Set by |
|
|
70
|
-
|----------|--------|--------|
|
|
71
|
-
| 1 | `AEGIS_MASTER_KEY` environment variable | `export` in shell |
|
|
72
|
-
| 2 | `.env` file | `aegis init --env-file` |
|
|
73
|
-
| 3 | `aegis.config.yaml` (`vault.master_key`) | `aegis init --write-secrets` |
|
|
74
|
-
| 4 | OS keychain (macOS/Windows/Linux) | `aegis init` (default) |
|
|
75
|
-
| 5 | File fallback (`.aegis/.master-key`) | Auto when no keychain available |
|
|
76
|
-
|
|
77
|
-
Run `aegis key where` to see which source is active.
|
|
78
|
-
|
|
79
|
-
```bash
|
|
80
64
|
# Add a credential
|
|
81
65
|
aegis vault add \
|
|
82
66
|
--name slack-bot \
|
|
@@ -85,530 +69,166 @@ aegis vault add \
|
|
|
85
69
|
--domains api.slack.com
|
|
86
70
|
|
|
87
71
|
# Start the proxy
|
|
88
|
-
aegis gate
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
Your agent now calls `http://localhost:3100/slack/api/chat.postMessage` — Aegis injects the Bearer token and forwards to `https://api.slack.com`. The agent never sees the token. The request is logged.
|
|
72
|
+
aegis gate --no-agent-auth
|
|
92
73
|
|
|
93
|
-
|
|
94
|
-
#
|
|
74
|
+
# Test it — Aegis injects the token, forwards to Slack, logs the request
|
|
75
|
+
# X-Target-Host tells Gate which upstream server to forward to (optional if credential has one domain)
|
|
95
76
|
curl http://localhost:3100/slack/api/auth.test \
|
|
96
77
|
-H "X-Target-Host: api.slack.com"
|
|
97
78
|
```
|
|
98
79
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
| Feature | Description |
|
|
102
|
-
|---------|-------------|
|
|
103
|
-
| **Encrypted Vault** | AES-256-GCM encrypted credential storage with PBKDF2 key derivation |
|
|
104
|
-
| **HTTP Proxy (Gate)** | Transparent credential injection — agent hits `localhost:3100/{service}/path` |
|
|
105
|
-
| **Domain Guard** | Every outbound request checked against credential allowlists. No bypass. |
|
|
106
|
-
| **Audit Ledger** | Every request (allowed and blocked) logged to SQLite with full context |
|
|
107
|
-
| **Agent Identity** | Per-agent tokens, credential scoping, and rate limits |
|
|
108
|
-
| **Policy Engine** | Declarative YAML policies — method, path, rate-limit, time-of-day restrictions |
|
|
109
|
-
| **Body Inspector** | Outbound request bodies scanned for credential-like patterns |
|
|
110
|
-
| **MCP Server** | Native Model Context Protocol integration for Claude, Cursor, VS Code |
|
|
111
|
-
| **Web Dashboard** | Real-time monitoring UI with WebSocket live feed |
|
|
112
|
-
| **Prometheus Metrics** | `/_aegis/metrics` endpoint for Grafana dashboards |
|
|
113
|
-
| **Webhook Alerts** | HMAC-signed notifications for blocked requests, expiring credentials |
|
|
114
|
-
| **RBAC** | Admin, operator, viewer roles with 16 granular permissions |
|
|
115
|
-
| **Multi-Vault** | Separate vaults for dev/staging/prod with isolated encryption keys |
|
|
116
|
-
| **Shamir's Secret Sharing** | M-of-N key splitting for team master key management |
|
|
117
|
-
| **Cross-Platform Key Storage** | OS keychain by default (macOS Keychain, Windows Credential Manager, Linux Secret Service) with file fallback |
|
|
118
|
-
| **TLS Support** | Optional HTTPS on Gate with cert/key configuration |
|
|
119
|
-
| **Configuration File** | `aegis.config.yaml` with env var overrides and CLI flag overrides |
|
|
120
|
-
|
|
121
|
-
## MCP Integration
|
|
122
|
-
|
|
123
|
-
Aegis is a first-class [MCP](https://modelcontextprotocol.io) server. Any MCP-compatible AI agent (Claude Desktop, Cursor, VS Code Copilot) can use Aegis natively — no HTTP calls needed.
|
|
124
|
-
|
|
125
|
-
```bash
|
|
126
|
-
# Generate config for your AI host
|
|
127
|
-
aegis mcp config claude # Claude Desktop
|
|
128
|
-
aegis mcp config cursor # Cursor
|
|
129
|
-
aegis mcp config vscode # VS Code
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
Copy the printed JSON into your AI host's MCP config file. The MCP server exposes three tools:
|
|
133
|
-
|
|
134
|
-
| Tool | Description |
|
|
135
|
-
|------|-------------|
|
|
136
|
-
| `aegis_proxy_request` | Make an authenticated API call (provide service + path, Aegis injects credentials) |
|
|
137
|
-
| `aegis_list_services` | List available services (names only, never secrets) |
|
|
138
|
-
| `aegis_health` | Check Aegis status |
|
|
139
|
-
|
|
140
|
-
The MCP server replicates the full Gate security pipeline: domain guard, agent auth, body inspection, rate limiting, audit logging.
|
|
141
|
-
|
|
142
|
-
## Agent Identity & Scoping
|
|
143
|
-
|
|
144
|
-
Agent authentication is **on by default**. Every request through Gate must include a valid `X-Aegis-Agent` header. Requests without a token get a helpful 401 error with instructions to create an agent.
|
|
80
|
+
### Production Setup (with agent auth)
|
|
145
81
|
|
|
146
82
|
```bash
|
|
147
|
-
#
|
|
148
|
-
aegis agent add --name "
|
|
149
|
-
|
|
150
|
-
# Grant access to specific credentials only
|
|
151
|
-
aegis agent grant --agent "research-bot" --credential "slack-bot"
|
|
83
|
+
# Create an agent identity
|
|
84
|
+
aegis agent add --name "my-agent"
|
|
85
|
+
# Save the printed token — it's shown once only
|
|
152
86
|
|
|
153
|
-
#
|
|
154
|
-
aegis agent
|
|
87
|
+
# Grant it access to specific credentials
|
|
88
|
+
aegis agent grant --agent "my-agent" --credential "slack-bot"
|
|
155
89
|
|
|
156
90
|
# Start Gate (agent auth is on by default)
|
|
157
91
|
aegis gate
|
|
158
92
|
|
|
159
|
-
# Agent must include its token
|
|
93
|
+
# Agent must include its token
|
|
160
94
|
curl http://localhost:3100/slack/api/auth.test \
|
|
161
95
|
-H "X-Target-Host: api.slack.com" \
|
|
162
96
|
-H "X-Aegis-Agent: aegis_a1b2c3d4..."
|
|
163
|
-
|
|
164
|
-
# To disable agent auth (not recommended):
|
|
165
|
-
aegis gate --no-agent-auth
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
Tokens are SHA-256 hashed for storage — they cannot be recovered, only regenerated:
|
|
169
|
-
|
|
170
|
-
```bash
|
|
171
|
-
aegis agent regenerate --name "research-bot"
|
|
172
|
-
# Old token stops working immediately. New token printed once.
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
## Policy Engine
|
|
176
|
-
|
|
177
|
-
Declarative YAML policies control what each agent can do:
|
|
178
|
-
|
|
179
|
-
```yaml
|
|
180
|
-
# policies/research-bot.yaml
|
|
181
|
-
agent: research-bot
|
|
182
|
-
rules:
|
|
183
|
-
- service: slack
|
|
184
|
-
methods: [GET]
|
|
185
|
-
paths:
|
|
186
|
-
- /api/conversations.*
|
|
187
|
-
- /api/users.*
|
|
188
|
-
rate_limit: 100/hour
|
|
189
|
-
time_window:
|
|
190
|
-
start: "09:00"
|
|
191
|
-
end: "18:00"
|
|
192
|
-
timezone: "UTC"
|
|
193
|
-
- service: github
|
|
194
|
-
methods: [GET, POST]
|
|
195
|
-
paths:
|
|
196
|
-
- /repos/myorg/.*
|
|
197
|
-
rate_limit: 200/hour
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
```bash
|
|
201
|
-
# Validate policies without starting Gate
|
|
202
|
-
aegis policy validate --policies-dir ./policies
|
|
203
|
-
|
|
204
|
-
# Dry-run: see what would be allowed/blocked without enforcing
|
|
205
|
-
aegis gate --policies-dir ./policies --policy-mode dry-run
|
|
206
|
-
|
|
207
|
-
# Enforce policies
|
|
208
|
-
aegis gate --policies-dir ./policies --policy-mode enforce
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
## Credential Options
|
|
212
|
-
|
|
213
|
-
When adding a credential, you can configure TTL, scopes, rate limits, and body inspection:
|
|
214
|
-
|
|
215
|
-
```bash
|
|
216
|
-
aegis vault add \
|
|
217
|
-
--name github-bot \
|
|
218
|
-
--service github \
|
|
219
|
-
--secret "ghp_xxxxxxxxxxxxxxxxxxxx" \
|
|
220
|
-
--domains api.github.com \
|
|
221
|
-
--auth-type bearer \
|
|
222
|
-
--scopes read,write \
|
|
223
|
-
--ttl 90 \
|
|
224
|
-
--rate-limit 100/min \
|
|
225
|
-
--body-inspection block
|
|
226
97
|
```
|
|
227
98
|
|
|
228
|
-
|
|
229
|
-
|------|---------|-------------|
|
|
230
|
-
| `--auth-type` | `bearer` | How Aegis injects the credential (see Auth Types below) |
|
|
231
|
-
| `--scopes` | `*` | Comma-separated: `read` (GET/HEAD/OPTIONS), `write` (POST/PUT/PATCH/DELETE), `*` (all) |
|
|
232
|
-
| `--ttl <days>` | *(none)* | Credential expires after this many days |
|
|
233
|
-
| `--rate-limit` | *(none)* | Rate limit: `100/min`, `1000/hour`, `10/sec` |
|
|
234
|
-
| `--body-inspection` | `block` | Scan outbound bodies for credential patterns: `off`, `warn`, `block` |
|
|
235
|
-
| `--header-name` | — | Custom header name (for `--auth-type header`) |
|
|
236
|
-
| `--query-param` | `key` | Query parameter name (for `--auth-type query`) |
|
|
237
|
-
|
|
238
|
-
Update any field later:
|
|
239
|
-
|
|
240
|
-
```bash
|
|
241
|
-
aegis vault update --name github-bot --rate-limit 200/min --body-inspection warn
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
## Auth Types
|
|
245
|
-
|
|
246
|
-
Aegis supports four credential injection methods:
|
|
247
|
-
|
|
248
|
-
| Type | Flag | What Aegis Injects |
|
|
249
|
-
|------|------|--------------------|
|
|
250
|
-
| `bearer` | `--auth-type bearer` (default) | `Authorization: Bearer <secret>` |
|
|
251
|
-
| `header` | `--auth-type header --header-name X-API-Key` | `X-API-Key: <secret>` |
|
|
252
|
-
| `basic` | `--auth-type basic` | `Authorization: Basic <base64(secret)>` |
|
|
253
|
-
| `query` | `--auth-type query --query-param api_key` | Appends `?api_key=<secret>` to the URL |
|
|
254
|
-
|
|
255
|
-
## Configuration
|
|
256
|
-
|
|
257
|
-
Aegis uses a layered configuration model: **CLI flags** > **environment variables** > **config file** > **built-in defaults**.
|
|
258
|
-
|
|
259
|
-
```yaml
|
|
260
|
-
# aegis.config.yaml
|
|
261
|
-
gate:
|
|
262
|
-
port: 3100
|
|
263
|
-
tls:
|
|
264
|
-
cert: ./certs/aegis.crt
|
|
265
|
-
key: ./certs/aegis.key
|
|
266
|
-
require_agent_auth: true
|
|
267
|
-
policy_mode: enforce
|
|
268
|
-
policies_dir: ./policies
|
|
269
|
-
|
|
270
|
-
vault:
|
|
271
|
-
name: default
|
|
272
|
-
data_dir: ./.aegis
|
|
273
|
-
|
|
274
|
-
observability:
|
|
275
|
-
log_level: info
|
|
276
|
-
log_format: json
|
|
277
|
-
metrics: true
|
|
278
|
-
dashboard:
|
|
279
|
-
enabled: true
|
|
280
|
-
port: 3200
|
|
281
|
-
|
|
282
|
-
mcp:
|
|
283
|
-
transport: stdio
|
|
284
|
-
port: 3300
|
|
285
|
-
|
|
286
|
-
webhooks:
|
|
287
|
-
- url: https://your-webhook-endpoint.com/aegis
|
|
288
|
-
events: [blocked_request, credential_expiry]
|
|
289
|
-
secret: your-hmac-secret
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
```bash
|
|
293
|
-
# Validate your config file
|
|
294
|
-
aegis config validate
|
|
295
|
-
|
|
296
|
-
# Show resolved config (with all overrides applied)
|
|
297
|
-
aegis config show
|
|
298
|
-
```
|
|
299
|
-
|
|
300
|
-
### Environment Variables
|
|
301
|
-
|
|
302
|
-
All environment variables override config file settings. CLI flags override both.
|
|
303
|
-
|
|
304
|
-
| Variable | Default | Description |
|
|
305
|
-
|----------|---------|-------------|
|
|
306
|
-
| `AEGIS_MASTER_KEY` | *(none)* | Master encryption key (from `aegis init`) |
|
|
307
|
-
| `AEGIS_SALT` | *(none)* | Vault encryption salt (auto-generated, stored in `.aegis/vaults.json`) |
|
|
308
|
-
| `AEGIS_VAULT` | `default` | Active vault name |
|
|
309
|
-
| `AEGIS_PORT` | `3100` | Gate proxy listen port |
|
|
310
|
-
| `AEGIS_DATA_DIR` | `./.aegis` | Directory for vault databases and registry |
|
|
311
|
-
| `AEGIS_LOG_LEVEL` | `info` | Log verbosity: `debug`, `info`, `warn`, `error` |
|
|
312
|
-
| `AEGIS_LOG_FORMAT` | `json` | Log output format: `json` or `pretty` |
|
|
313
|
-
| `AEGIS_REQUIRE_AGENT_AUTH` | `true` | Require `X-Aegis-Agent` header on every request (`true`/`false`) |
|
|
314
|
-
| `AEGIS_POLICY_MODE` | `enforce` | Policy enforcement: `enforce`, `dry-run`, or `off` |
|
|
315
|
-
| `AEGIS_POLICIES_DIR` | *(none)* | Directory containing YAML policy files |
|
|
316
|
-
| `AEGIS_METRICS` | `true` | Enable Prometheus metrics endpoint (`true`/`false`) |
|
|
317
|
-
| `AEGIS_USER_TOKEN` | *(none)* | RBAC user token for CLI authentication |
|
|
318
|
-
|
|
319
|
-
## Webhooks
|
|
320
|
-
|
|
321
|
-
Get real-time notifications when security events occur:
|
|
322
|
-
|
|
323
|
-
```bash
|
|
324
|
-
# Add a webhook for blocked requests and expiring credentials
|
|
325
|
-
aegis webhook add \
|
|
326
|
-
--url https://your-endpoint.com/aegis \
|
|
327
|
-
--events blocked_request,credential_expiry \
|
|
328
|
-
--secret your-hmac-signing-secret
|
|
329
|
-
|
|
330
|
-
# Test delivery
|
|
331
|
-
aegis webhook test --id <webhook-id>
|
|
332
|
-
|
|
333
|
-
# Check for credentials expiring within 7 days
|
|
334
|
-
aegis webhook check-expiry
|
|
335
|
-
|
|
336
|
-
# Manage
|
|
337
|
-
aegis webhook list
|
|
338
|
-
aegis webhook remove --id <webhook-id>
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
Webhook payloads are signed with HMAC-SHA256. Verify the `X-Aegis-Signature` header to authenticate delivery. Five event types: `blocked_request`, `credential_expiry`, `rate_limit_exceeded`, `agent_auth_failure`, `body_inspection`.
|
|
99
|
+
## MCP Integration
|
|
342
100
|
|
|
343
|
-
|
|
101
|
+
Aegis is a first-class [MCP](https://modelcontextprotocol.io) server. Any MCP-compatible AI agent can use it natively — no HTTP calls needed.
|
|
344
102
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
103
|
+
**Before (plaintext key in config):**
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"mcpServers": {
|
|
107
|
+
"slack": {
|
|
108
|
+
"command": "node",
|
|
109
|
+
"args": ["slack-mcp-server"],
|
|
110
|
+
"env": { "SLACK_TOKEN": "xoxb-1234-real-token-here" }
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
350
114
|
```
|
|
351
115
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
```bash
|
|
363
|
-
# Create the first admin user (no auth required — bootstrap mode)
|
|
364
|
-
aegis user add --name admin --role admin
|
|
365
|
-
|
|
366
|
-
# ✓ User added to Aegis
|
|
367
|
-
# Name: admin
|
|
368
|
-
# Role: admin
|
|
369
|
-
# API Key (shown ONCE — save it now):
|
|
370
|
-
# aegis_user_xxxxxxxx-xxxx_xxxxxxxxxxxxxxxx
|
|
371
|
-
#
|
|
372
|
-
# Use AEGIS_USER_TOKEN=<key> to authenticate CLI commands.
|
|
116
|
+
**After (Aegis — no key visible):**
|
|
117
|
+
```json
|
|
118
|
+
{
|
|
119
|
+
"mcpServers": {
|
|
120
|
+
"aegis": {
|
|
121
|
+
"command": "npx",
|
|
122
|
+
"args": ["-y", "@getaegis/cli", "mcp", "serve"]
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
373
126
|
```
|
|
374
127
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
### Authenticating
|
|
378
|
-
|
|
379
|
-
Set `AEGIS_USER_TOKEN` in your environment:
|
|
128
|
+
Generate the config for your AI host:
|
|
380
129
|
|
|
381
130
|
```bash
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
aegis vault list
|
|
386
|
-
aegis agent list
|
|
387
|
-
aegis ledger show
|
|
131
|
+
aegis mcp config claude # Claude Desktop
|
|
132
|
+
aegis mcp config cursor # Cursor
|
|
133
|
+
aegis mcp config vscode # VS Code
|
|
388
134
|
```
|
|
389
135
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
| Permission | Admin | Operator | Viewer |
|
|
393
|
-
|------------|:-----:|:--------:|:------:|
|
|
394
|
-
| `vault:read` — list credentials | ✓ | ✓ | ✓ |
|
|
395
|
-
| `vault:write` — add/remove/rotate credentials | ✓ | | |
|
|
396
|
-
| `vault:manage` — create/destroy vaults | ✓ | | |
|
|
397
|
-
| `agent:read` — list agents | ✓ | ✓ | |
|
|
398
|
-
| `agent:write` — add/remove/grant agents | ✓ | ✓ | |
|
|
399
|
-
| `ledger:read` — view audit logs | ✓ | ✓ | ✓ |
|
|
400
|
-
| `ledger:export` — export audit logs | ✓ | ✓ | |
|
|
401
|
-
| `gate:start` — start the proxy | ✓ | ✓ | |
|
|
402
|
-
| `policy:read` — view policies | ✓ | ✓ | |
|
|
403
|
-
| `policy:write` — manage policies | ✓ | | |
|
|
404
|
-
| `webhook:read` — list webhooks | ✓ | ✓ | |
|
|
405
|
-
| `webhook:write` — add/remove webhooks | ✓ | | |
|
|
406
|
-
| `user:read` — list users | ✓ | | |
|
|
407
|
-
| `user:write` — add/remove users | ✓ | | |
|
|
408
|
-
| `dashboard:view` — access the dashboard | ✓ | ✓ | ✓ |
|
|
409
|
-
| `doctor:run` — run health checks | ✓ | ✓ | ✓ |
|
|
410
|
-
|
|
411
|
-
### Managing Users
|
|
412
|
-
|
|
413
|
-
```bash
|
|
414
|
-
# Add more users (requires admin role)
|
|
415
|
-
aegis user add --name alice --role operator
|
|
416
|
-
aegis user add --name bob --role viewer
|
|
417
|
-
|
|
418
|
-
# Change a user's role
|
|
419
|
-
aegis user role --name alice --role admin
|
|
420
|
-
|
|
421
|
-
# Regenerate a lost token (invalidates the old one immediately)
|
|
422
|
-
aegis user regenerate-token --name alice
|
|
423
|
-
|
|
424
|
-
# Remove a user
|
|
425
|
-
aegis user remove --name bob --confirm
|
|
136
|
+
The MCP server exposes three tools:
|
|
426
137
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
138
|
+
| Tool | Description |
|
|
139
|
+
|------|-------------|
|
|
140
|
+
| `aegis_proxy_request` | Make an authenticated API call (provide service + path, Aegis injects credentials) |
|
|
141
|
+
| `aegis_list_services` | List available services (names only, never secrets) |
|
|
142
|
+
| `aegis_health` | Check Aegis status |
|
|
430
143
|
|
|
431
|
-
|
|
144
|
+
The MCP server replicates the full Gate security pipeline: domain guard, agent auth, body inspection, rate limiting, audit logging.
|
|
432
145
|
|
|
433
|
-
|
|
146
|
+
### Setup Guides
|
|
434
147
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
148
|
+
- [Claude Desktop](docs/guides/claude-desktop.md)
|
|
149
|
+
- [Cursor](docs/guides/cursor.md)
|
|
150
|
+
- [VS Code](docs/guides/vscode.md)
|
|
151
|
+
- [Windsurf](docs/guides/windsurf.md)
|
|
152
|
+
- [Cline](docs/guides/cline.md)
|
|
438
153
|
|
|
439
|
-
|
|
440
|
-
AEGIS_VAULT=staging aegis vault add --name slack --service slack ...
|
|
154
|
+
## Features
|
|
441
155
|
|
|
442
|
-
|
|
443
|
-
|
|
156
|
+
| Feature | Description |
|
|
157
|
+
|---------|-------------|
|
|
158
|
+
| **Encrypted Vault** | AES-256-GCM encrypted credential storage with PBKDF2 key derivation |
|
|
159
|
+
| **HTTP Proxy (Gate)** | Transparent credential injection — agent hits `localhost:3100/{service}/path` |
|
|
160
|
+
| **Domain Guard** | Every outbound request checked against credential allowlists. No bypass |
|
|
161
|
+
| **Audit Ledger** | Every request (allowed and blocked) logged with full context |
|
|
162
|
+
| **Agent Identity** | Per-agent tokens, credential scoping, and rate limits |
|
|
163
|
+
| **Policy Engine** | Declarative YAML policies — method, path, rate-limit, time-of-day restrictions |
|
|
164
|
+
| **Body Inspector** | Outbound request bodies scanned for credential-like patterns |
|
|
165
|
+
| **MCP Server** | Native Model Context Protocol for Claude, Cursor, VS Code, Windsurf, Cline |
|
|
166
|
+
| **Web Dashboard** | Real-time monitoring UI with WebSocket live feed |
|
|
167
|
+
| **Prometheus Metrics** | `/_aegis/metrics` endpoint for Grafana dashboards |
|
|
168
|
+
| **Webhook Alerts** | HMAC-signed notifications for blocked requests, expiring credentials |
|
|
169
|
+
| **RBAC** | Admin, operator, viewer roles with 16 granular permissions |
|
|
170
|
+
| **Multi-Vault** | Separate vaults for dev/staging/prod with isolated encryption keys |
|
|
171
|
+
| **Shamir's Secret Sharing** | M-of-N key splitting for team master key management |
|
|
172
|
+
| **Cross-Platform Key Storage** | OS keychain by default (macOS, Windows, Linux) with file fallback |
|
|
173
|
+
| **TLS Support** | Optional HTTPS on Gate with cert/key configuration |
|
|
174
|
+
| **Configuration File** | `aegis.config.yaml` with env var overrides and CLI flag overrides |
|
|
444
175
|
|
|
445
|
-
|
|
446
|
-
aegis vault destroy --name staging
|
|
447
|
-
```
|
|
176
|
+
## Example Integrations
|
|
448
177
|
|
|
449
|
-
|
|
178
|
+
Step-by-step guides with config files and policies included:
|
|
450
179
|
|
|
451
|
-
|
|
180
|
+
- [**Slack Bot**](examples/slack-bot/) — Protect your Slack bot token with domain-restricted proxy access
|
|
181
|
+
- [**GitHub Integration**](examples/github-integration/) — Secure GitHub PAT with per-agent grants and read-only policies
|
|
182
|
+
- [**Stripe Backend**](examples/stripe-backend/) — Isolate Stripe API keys with body inspection and rate limiting
|
|
452
183
|
|
|
453
|
-
|
|
184
|
+
## Security
|
|
454
185
|
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
186
|
+
- Published [STRIDE threat model](docs/THREAT_MODEL.md) — 28 threats analysed, 0 critical/high unmitigated findings
|
|
187
|
+
- Full [security architecture](docs/SECURITY_ARCHITECTURE.md) documentation (trust boundaries, crypto pipeline, data flow)
|
|
188
|
+
- AES-256-GCM + ChaCha20-Poly1305 encryption at rest
|
|
189
|
+
- Domain guard enforced on every request — no bypass
|
|
190
|
+
- Agent tokens stored as SHA-256 hashes — cannot be recovered, only regenerated
|
|
191
|
+
- Request body inspection for credential pattern detection
|
|
192
|
+
- Open source (Apache 2.0) — read the code
|
|
458
193
|
|
|
459
|
-
|
|
460
|
-
aegis vault seal
|
|
194
|
+
## How Aegis Compares
|
|
461
195
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
196
|
+
| | `.env` files | Vault/Doppler | Infisical | **Aegis** |
|
|
197
|
+
|---|---|---|---|---|
|
|
198
|
+
| Agent sees raw key | Yes | Yes (after fetch) | Yes (after fetch) | **No — never** |
|
|
199
|
+
| Domain restrictions | No | No | No | **Yes** |
|
|
200
|
+
| MCP-native | No | No | Adding | **Yes** |
|
|
201
|
+
| Local-first | Yes | No | No | **Yes** |
|
|
202
|
+
| Setup | 10 sec | 30+ min | 15+ min | **~2 min** |
|
|
468
203
|
|
|
469
|
-
|
|
204
|
+
See [full comparison](docs/COMPARISON.md) for detailed breakdowns against each approach.
|
|
470
205
|
|
|
471
|
-
|
|
206
|
+
## Documentation
|
|
472
207
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
aegis ledger show --since 2026-03-01
|
|
483
|
-
|
|
484
|
-
# Request statistics
|
|
485
|
-
aegis ledger stats
|
|
486
|
-
aegis ledger stats --agent research-bot
|
|
487
|
-
aegis ledger stats --since 2026-03-01
|
|
488
|
-
|
|
489
|
-
# Export (CSV, JSON, or JSON Lines)
|
|
490
|
-
aegis ledger export -f csv
|
|
491
|
-
aegis ledger export -f json -o audit.json
|
|
492
|
-
aegis ledger export -f jsonl --service slack --since 2026-03-01
|
|
493
|
-
```
|
|
208
|
+
| Document | Description |
|
|
209
|
+
|----------|-------------|
|
|
210
|
+
| [Usage Guide](docs/USAGE.md) | Full reference: CLI commands, configuration, RBAC, policies, webhooks, troubleshooting |
|
|
211
|
+
| [Security Architecture](docs/SECURITY_ARCHITECTURE.md) | Trust boundaries, crypto pipeline, data flow diagrams |
|
|
212
|
+
| [Threat Model](docs/THREAT_MODEL.md) | STRIDE analysis — 28 threats, mitigations, residual risks |
|
|
213
|
+
| [Comparison](docs/COMPARISON.md) | Detailed comparison with .env, Vault, Doppler, Infisical |
|
|
214
|
+
| [FAQ](docs/FAQ.md) | Common questions and objections |
|
|
215
|
+
| [Roadmap](docs/ROADMAP.md) | Feature roadmap from v0.1 to v1.0 |
|
|
216
|
+
| [Contributing](CONTRIBUTING.md) | Code style, PR process, architecture overview |
|
|
494
217
|
|
|
495
|
-
##
|
|
218
|
+
## Install
|
|
496
219
|
|
|
497
220
|
```bash
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
Runs diagnostics on your Aegis installation:
|
|
502
|
-
- Config file validation
|
|
503
|
-
- Database accessibility and schema
|
|
504
|
-
- Master key correctness (test decrypt)
|
|
505
|
-
- Key storage backend (keychain type and status)
|
|
506
|
-
- Expired or expiring-soon credentials
|
|
507
|
-
|
|
508
|
-
Returns pass/warn/fail for each check.
|
|
509
|
-
|
|
510
|
-
## Security Model
|
|
511
|
-
|
|
512
|
-
- **Encryption at rest** — AES-256-GCM with PBKDF2 key derivation (210,000 iterations, SHA-512, random per-deployment salt)
|
|
513
|
-
- **Cross-platform key storage** — master key stored in OS keychain by default (macOS Keychain, Windows Credential Manager, Linux Secret Service). File fallback for CI/headless
|
|
514
|
-
- **Domain guard** — enforced on every outbound request. No bypass, no override. Wildcards supported (`*.slack.com`)
|
|
515
|
-
- **Credential scopes** — `read` (GET/HEAD/OPTIONS), `write` (POST/PUT/PATCH/DELETE), `*` (all). Enforced at the Gate before any request is forwarded
|
|
516
|
-
- **Header stripping** — agent-supplied `Authorization`, `X-API-Key`, `Proxy-Authorization` headers are removed before injection
|
|
517
|
-
- **Body inspection** — outbound request bodies scanned for credential-like patterns (configurable per credential: `off`, `warn`, `block`)
|
|
518
|
-
- **Hash-only token storage** — agent tokens stored as SHA-256 hashes. Lost tokens are regenerated, never recovered
|
|
519
|
-
- **Audit logging** — every request (allowed and blocked) recorded with full context. Export with `aegis ledger export -f csv`
|
|
520
|
-
- **TLS support** — optional HTTPS on Gate (`aegis gate --tls --cert <path> --key <path>`)
|
|
521
|
-
- **Graceful shutdown** — drains in-flight requests on SIGINT/SIGTERM
|
|
522
|
-
|
|
523
|
-
See [SECURITY_ARCHITECTURE.md](docs/SECURITY_ARCHITECTURE.md) for the full security design and trust boundaries, and [THREAT_MODEL.md](docs/THREAT_MODEL.md) for the STRIDE threat analysis.
|
|
221
|
+
# npm
|
|
222
|
+
npm install -g @getaegis/cli
|
|
524
223
|
|
|
525
|
-
|
|
224
|
+
# Homebrew
|
|
225
|
+
brew tap getaegis/aegis && brew install aegis
|
|
526
226
|
|
|
527
|
-
|
|
528
|
-
aegis
|
|
529
|
-
aegis gate [--port] [--tls] [--no-agent-auth] [--policies-dir] [--policy-mode]
|
|
530
|
-
Start the HTTP proxy
|
|
531
|
-
aegis dashboard [--port] [--gate-port] Start the web dashboard + Gate
|
|
532
|
-
|
|
533
|
-
aegis vault add [--name] [--service] [--secret] [--domains] [--auth-type]
|
|
534
|
-
[--header-name] [--scopes] [--ttl] [--rate-limit] [--body-inspection]
|
|
535
|
-
Add a credential
|
|
536
|
-
aegis vault list List credentials (secrets never shown)
|
|
537
|
-
aegis vault remove --name <name> Remove a credential
|
|
538
|
-
aegis vault rotate --name <name> --secret <new>
|
|
539
|
-
Rotate a credential's secret
|
|
540
|
-
aegis vault update --name <name> [--domains] [--auth-type] [--header-name]
|
|
541
|
-
[--scopes] [--rate-limit] [--body-inspection]
|
|
542
|
-
Update credential metadata
|
|
543
|
-
aegis vault create --name <name> Create a new named vault
|
|
544
|
-
aegis vault vaults List all vaults
|
|
545
|
-
aegis vault destroy --name <name> Delete a vault and its credentials
|
|
546
|
-
aegis vault split [--shares] [--threshold]
|
|
547
|
-
Split master key (Shamir)
|
|
548
|
-
aegis vault seal Seal the vault
|
|
549
|
-
aegis vault unseal --key-share <share>... Unseal (provide threshold shares)
|
|
550
|
-
|
|
551
|
-
aegis agent add --name <name> Register agent, print token (one-time)
|
|
552
|
-
aegis agent list List agents (no tokens shown)
|
|
553
|
-
aegis agent remove --name <name> Remove agent + cascade-delete grants
|
|
554
|
-
aegis agent regenerate --name <name> Regenerate token (old one invalidated)
|
|
555
|
-
aegis agent grant --agent <a> --credential <c>
|
|
556
|
-
Grant credential access
|
|
557
|
-
aegis agent revoke --agent <a> --credential <c>
|
|
558
|
-
Revoke credential access
|
|
559
|
-
aegis agent set-rate-limit --agent <a> --limit <rate>
|
|
560
|
-
Set per-agent rate limit
|
|
561
|
-
|
|
562
|
-
aegis policy validate [--policies-dir] Validate policy files
|
|
563
|
-
aegis policy test --agent <a> --service <s> --method <m> --path <p>
|
|
564
|
-
Test a request against policies
|
|
565
|
-
aegis policy list [--policies-dir] List loaded policies
|
|
566
|
-
|
|
567
|
-
aegis ledger show [--service] [--agent] [--blocked] [--system] [--since] [--limit]
|
|
568
|
-
View audit logs
|
|
569
|
-
aegis ledger stats [--agent] [--since] Request statistics
|
|
570
|
-
aegis ledger export -f <csv|json|jsonl> [-o file] [--service] [--since]
|
|
571
|
-
Export audit log
|
|
572
|
-
|
|
573
|
-
aegis webhook add --url <url> --events <types>
|
|
574
|
-
Add a webhook endpoint
|
|
575
|
-
aegis webhook list List webhooks
|
|
576
|
-
aegis webhook remove --id <id> Remove a webhook
|
|
577
|
-
aegis webhook test --id <id> Send a test payload
|
|
578
|
-
aegis webhook check-expiry Check for expiring credentials
|
|
579
|
-
|
|
580
|
-
aegis user add --name <name> --role <role>
|
|
581
|
-
Add RBAC user (admin/operator/viewer)
|
|
582
|
-
aegis user list List users
|
|
583
|
-
aegis user remove --name <name> Remove user
|
|
584
|
-
aegis user role --name <name> --role <role>
|
|
585
|
-
Change user role
|
|
586
|
-
aegis user regenerate-token --name <name> Regenerate user token
|
|
587
|
-
|
|
588
|
-
aegis mcp serve [--transport] [--port] Start the MCP server
|
|
589
|
-
aegis mcp config <claude|cursor|vscode> Generate MCP host config
|
|
590
|
-
|
|
591
|
-
aegis db backup [--output <path>] Backup the vault database
|
|
592
|
-
aegis db restore --input <path> [--force] Restore from a backup
|
|
593
|
-
|
|
594
|
-
aegis config validate Validate config file
|
|
595
|
-
aegis config show Show resolved configuration
|
|
596
|
-
aegis key where Show where the master key is stored
|
|
597
|
-
aegis doctor Health check diagnostics
|
|
227
|
+
# Docker
|
|
228
|
+
docker run ghcr.io/getaegis/aegis --help
|
|
598
229
|
```
|
|
599
230
|
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
| Error | Cause | Fix |
|
|
603
|
-
|-------|-------|-----|
|
|
604
|
-
| `AEGIS_MASTER_KEY is not set` | No master key in config, env, or keychain | Run `aegis key where` to check storage, or `export AEGIS_MASTER_KEY=<key>` |
|
|
605
|
-
| `Invalid master key` | Wrong key for this vault | Check `AEGIS_MASTER_KEY` matches the key from `aegis init` |
|
|
606
|
-
| `Port 3100 is already in use` | Another process on that port | Use `aegis gate --port 3200` or stop the other process |
|
|
607
|
-
| `Database file is corrupted` | SQLite file damaged | Back up `.aegis/` and re-run `aegis init` |
|
|
608
|
-
| `Domain guard: blocked` | Target domain not in credential allowlist | Update domains: `aegis vault update --name <n> --domains <d>` |
|
|
609
|
-
| `Body inspection: blocked` | Request body contains credential-like patterns | Remove sensitive patterns from the body, or set `--body-inspection warn` on the credential |
|
|
610
|
-
| `Authentication required` | RBAC is active (users exist) but no token set | `export AEGIS_USER_TOKEN=<key>` — get a key from your admin or `aegis user regenerate-token` |
|
|
611
|
-
| `Permission denied` | Your RBAC role lacks the required permission | Ask an admin to upgrade your role with `aegis user role` |
|
|
231
|
+
**Requires Node.js ≥ 20** — check with `node -v`
|
|
612
232
|
|
|
613
233
|
## Development
|
|
614
234
|
|
|
@@ -617,33 +237,11 @@ git clone https://github.com/getaegis/aegis.git
|
|
|
617
237
|
cd aegis
|
|
618
238
|
yarn install
|
|
619
239
|
yarn build
|
|
620
|
-
yarn test
|
|
621
|
-
yarn lint # Biome linter
|
|
622
|
-
yarn verify # Biome check + TypeScript typecheck
|
|
240
|
+
yarn test
|
|
623
241
|
```
|
|
624
242
|
|
|
625
243
|
See [CONTRIBUTING.md](CONTRIBUTING.md) for code style, PR process, and architecture overview.
|
|
626
244
|
|
|
627
|
-
### Tech Stack
|
|
628
|
-
|
|
629
|
-
| Layer | Technology |
|
|
630
|
-
|-------|------------|
|
|
631
|
-
| Language | TypeScript (ES2022, native ESM) |
|
|
632
|
-
| Runtime | Node.js ≥ 20 |
|
|
633
|
-
| Database | SQLite via better-sqlite3-multiple-ciphers (WAL mode, ChaCha20-Poly1305 encryption at rest) |
|
|
634
|
-
| Encryption | AES-256-GCM (field-level), ChaCha20-Poly1305 (full-database), PBKDF2 |
|
|
635
|
-
| Logging | pino (structured JSON, field-level redaction) |
|
|
636
|
-
| Metrics | prom-client (Prometheus) |
|
|
637
|
-
| CLI | Commander.js |
|
|
638
|
-
| MCP | @modelcontextprotocol/sdk |
|
|
639
|
-
| Dashboard | Vite + React 19 + Tailwind CSS v4 |
|
|
640
|
-
| Testing | Vitest |
|
|
641
|
-
| Linting | Biome |
|
|
642
|
-
|
|
643
|
-
## Roadmap
|
|
644
|
-
|
|
645
|
-
See [ROADMAP.md](docs/ROADMAP.md) for the full plan from v0.1 to v1.0.
|
|
646
|
-
|
|
647
245
|
## License
|
|
648
246
|
|
|
649
247
|
[Apache 2.0](LICENSE)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/mcp.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/mcp.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAkBzC,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA6Q/C"}
|
package/dist/cli/commands/mcp.js
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
* MCP commands: serve, config.
|
|
3
3
|
*/
|
|
4
4
|
import * as fs from 'node:fs';
|
|
5
|
+
import * as os from 'node:os';
|
|
5
6
|
import * as path from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
6
8
|
import { AgentRegistry } from '../../agent/index.js';
|
|
7
|
-
import { getConfig } from '../../config.js';
|
|
9
|
+
import { findConfigFile, getConfig } from '../../config.js';
|
|
8
10
|
import { getDb, getVaultSalt, migrate } from '../../db.js';
|
|
9
11
|
import { Ledger } from '../../ledger/index.js';
|
|
10
12
|
import { AegisMcpServer } from '../../mcp/index.js';
|
|
@@ -99,23 +101,45 @@ export function register(program) {
|
|
|
99
101
|
.action((host, opts) => {
|
|
100
102
|
const transport = opts.transport;
|
|
101
103
|
const port = opts.port;
|
|
102
|
-
// Resolve the aegis CLI path
|
|
103
|
-
//
|
|
104
|
-
//
|
|
105
|
-
|
|
104
|
+
// Resolve the aegis CLI path relative to this module's own location
|
|
105
|
+
// (not CWD). This module lives at src/cli/commands/mcp.ts and compiles
|
|
106
|
+
// to dist/cli/commands/mcp.js — package root is three levels up.
|
|
107
|
+
const currentFile = fileURLToPath(import.meta.url);
|
|
108
|
+
const packageRoot = path.resolve(path.dirname(currentFile), '..', '..', '..');
|
|
106
109
|
let aegisCmd;
|
|
107
110
|
let aegisBaseArgs;
|
|
108
|
-
const distCli = path.
|
|
111
|
+
const distCli = path.join(packageRoot, 'dist', 'cli.js');
|
|
112
|
+
const srcCli = path.join(packageRoot, 'src', 'cli.ts');
|
|
109
113
|
if (fs.existsSync(distCli)) {
|
|
110
114
|
// Use node + absolute path to the built CLI (always stable)
|
|
111
|
-
aegisCmd = process.execPath;
|
|
115
|
+
aegisCmd = process.execPath;
|
|
112
116
|
aegisBaseArgs = [distCli];
|
|
113
117
|
}
|
|
114
|
-
else {
|
|
118
|
+
else if (fs.existsSync(srcCli)) {
|
|
115
119
|
// Development fallback: use tsx
|
|
116
|
-
const cliPath = path.resolve('src/cli.ts');
|
|
117
120
|
aegisCmd = 'npx';
|
|
118
|
-
aegisBaseArgs = ['tsx',
|
|
121
|
+
aegisBaseArgs = ['tsx', srcCli];
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
// Last resort: reuse however we were invoked
|
|
125
|
+
aegisCmd = process.execPath;
|
|
126
|
+
aegisBaseArgs = [path.resolve(process.argv[1])];
|
|
127
|
+
}
|
|
128
|
+
// Build environment block for stdio configs.
|
|
129
|
+
// MCP hosts (Claude Desktop, Cursor) don't inherit the user's shell
|
|
130
|
+
// environment, so we must pass variables the Aegis process needs.
|
|
131
|
+
const stdioEnv = {
|
|
132
|
+
HOME: os.homedir(),
|
|
133
|
+
PATH: process.env.PATH ?? '/usr/local/bin:/usr/bin:/bin',
|
|
134
|
+
};
|
|
135
|
+
// Capture data directory so the MCP server finds the right vault
|
|
136
|
+
// even when spawned from an unpredictable CWD.
|
|
137
|
+
const cfgFile = findConfigFile();
|
|
138
|
+
const baseDir = cfgFile ? path.dirname(path.resolve(cfgFile)) : process.cwd();
|
|
139
|
+
stdioEnv.AEGIS_DATA_DIR = path.resolve(baseDir, '.aegis');
|
|
140
|
+
// Forward master key if set in the current environment
|
|
141
|
+
if (process.env.AEGIS_MASTER_KEY) {
|
|
142
|
+
stdioEnv.AEGIS_MASTER_KEY = process.env.AEGIS_MASTER_KEY;
|
|
119
143
|
}
|
|
120
144
|
const buildArgs = () => {
|
|
121
145
|
const args = [...aegisBaseArgs, 'mcp', 'serve', '--transport', transport];
|
|
@@ -148,6 +172,7 @@ export function register(program) {
|
|
|
148
172
|
aegis: {
|
|
149
173
|
command: aegisCmd,
|
|
150
174
|
args,
|
|
175
|
+
env: stdioEnv,
|
|
151
176
|
},
|
|
152
177
|
},
|
|
153
178
|
};
|
|
@@ -176,6 +201,7 @@ export function register(program) {
|
|
|
176
201
|
aegis: {
|
|
177
202
|
command: aegisCmd,
|
|
178
203
|
args,
|
|
204
|
+
env: stdioEnv,
|
|
179
205
|
},
|
|
180
206
|
},
|
|
181
207
|
};
|
|
@@ -206,6 +232,7 @@ export function register(program) {
|
|
|
206
232
|
type: 'stdio',
|
|
207
233
|
command: aegisCmd,
|
|
208
234
|
args,
|
|
235
|
+
env: stdioEnv,
|
|
209
236
|
},
|
|
210
237
|
},
|
|
211
238
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../../src/cli/commands/mcp.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../../src/cli/commands/mcp.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAA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