@envseal/mcp-server 0.1.2 → 0.1.4

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/bin.js CHANGED
@@ -4,7 +4,7 @@ import { Broker } from '@envseal/core';
4
4
  import { selectPrompter } from '@envseal/prompters';
5
5
  import { createServer } from './index.js';
6
6
  import { parseArgv, resolveProjectRoot, USAGE, VERSION } from './cli-args.js';
7
- import { createProbeApproval, createUseConfirm } from './confirm.js';
7
+ import { createProbeApproval, createRevokeConfirm, createUseConfirm } from './confirm.js';
8
8
  import { createRefusingPrompter, createStubPrompter, isStubOutcome, } from './test-prompter.js';
9
9
  // NOTE: MCP protocol owns stdout. All diagnostics MUST go to stderr.
10
10
  // Any output to stdout corrupts the JSON-RPC stream.
@@ -57,6 +57,7 @@ async function main() {
57
57
  // cannot ask anyone, and exec.ts turns that absence into "the user
58
58
  // denied the confirmation" for a user who was never asked.
59
59
  onConfirm: createUseConfirm(surface),
60
+ onRevokeConfirm: createRevokeConfirm(surface),
60
61
  // PLAN.md §6.4: consent before a credential goes to a host the registry
61
62
  // does not allowlist. Supplied by no binding before this.
62
63
  onApprovalNeeded: createProbeApproval(surface),
@@ -2,8 +2,8 @@
2
2
  * Argument handling for the `envseal-mcp` binary, kept out of bin.ts so it can
3
3
  * be tested without importing a module whose side effect is starting a server.
4
4
  */
5
- export declare const VERSION = "0.1.2";
6
- export declare const USAGE = "envseal-mcp 0.1.2\n\nServes the SEP/1 tools to an MCP host over stdio JSON-RPC.\n\nUsage: envseal-mcp [--project <dir>]\n\nOptions:\n --project <dir> Project root to broker secrets for. Default: search\n upward from the current directory for env.schema.jsonc,\n .git or package.json. If none is found, this server\n refuses to start rather than create .envseal/ in a\n directory that is not a project.\n --help, -h Show this help and exit.\n --version, -v Print the version and exit.\n\nTransport: stdio only. --http and --port were removed; they were parsed and\nthen ignored, and no HTTP or SSE transport was ever implemented. For an HTTP\nsurface use @envseal/http-server, which speaks REST + OpenAPI on loopback --\nthat is a different protocol, not MCP over HTTP.\n";
5
+ export declare const VERSION = "0.1.4";
6
+ export declare const USAGE = "envseal-mcp 0.1.4\n\nServes the SEP/1 tools to an MCP host over stdio JSON-RPC.\n\nUsage: envseal-mcp [--project <dir>]\n\nOptions:\n --project <dir> Project root to broker secrets for. Default: search\n upward from the current directory for env.schema.jsonc,\n .git or package.json. If none is found, this server\n refuses to start rather than create .envseal/ in a\n directory that is not a project.\n --help, -h Show this help and exit.\n --version, -v Print the version and exit.\n\nTransport: stdio only. --http and --port were removed; they were parsed and\nthen ignored, and no HTTP or SSE transport was ever implemented. For an HTTP\nsurface use @envseal/http-server, which speaks REST + OpenAPI on loopback --\nthat is a different protocol, not MCP over HTTP.\n";
7
7
  export type ParsedArgv = {
8
8
  kind: 'help';
9
9
  } | {
package/dist/cli-args.js CHANGED
@@ -5,7 +5,7 @@ import { findProjectRoot } from '@envseal/core';
5
5
  * Argument handling for the `envseal-mcp` binary, kept out of bin.ts so it can
6
6
  * be tested without importing a module whose side effect is starting a server.
7
7
  */
8
- export const VERSION = '0.1.2';
8
+ export const VERSION = '0.1.4';
9
9
  export const USAGE = `envseal-mcp ${VERSION}
10
10
 
11
11
  Serves the SEP/1 tools to an MCP host over stdio JSON-RPC.
package/dist/confirm.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { BrokerOptions } from '@envseal/core';
1
+ import { escapeForDisplay as coreEscapeForDisplay, displayArg as coreDisplayArg, type BrokerOptions, type TargetInfo } from '@envseal/core';
2
2
  import type { ManifestEntry, VerifyResult } from '@envseal/protocol';
3
3
  import type { Prompter } from '@envseal/prompters';
4
4
  /**
@@ -18,16 +18,16 @@ import type { Prompter } from '@envseal/prompters';
18
18
  * between a prompt-injected model and arbitrary code holding live
19
19
  * credentials. In CI these operations are simply unavailable, and say so.
20
20
  *
21
- * DUPLICATION: this file is a hand-maintained twin of
22
- * packages/sdk/src/confirm.ts. Its natural home is a `confirm()` method
23
- * on the `Prompter` interface every surface already knows how to draw a
24
- * dialog but @envseal/mcp-server does not depend on @envseal/sdk, and
25
- * @envseal/prompters was outside the scope of the change that added this. Both
26
- * packages test the behaviour independently, so drift shows up as a red test
27
- * rather than as a binding that quietly stops asking.
21
+ * DUPLICATION: this file remains a hand-maintained twin of
22
+ * packages/sdk/src/confirm.ts for the ask/outcome mapping, but the dialog
23
+ * BODY (escaping, truncation caps, fingerprints, warnings) is shared via
24
+ * useConfirmationBody from @envseal/core so the CLI, SDK and MCP surfaces
25
+ * can never drift on what the user is shown.
28
26
  */
29
27
  /** Value-entry key name carrying the `env_use` confirmation. */
30
28
  export declare const CONFIRM_KEY_USE = "APPROVE";
29
+ /** Value-entry key name carrying the `env_revoke` confirmation. */
30
+ export declare const CONFIRM_KEY_REVOKE = "APPROVE_REVOKE";
31
31
  /** Value-entry key name carrying the `env_verify` probe-consent question. */
32
32
  export declare const CONFIRM_KEY_PROBE = "APPROVE_PROBE";
33
33
  export interface ConfirmSurface {
@@ -40,11 +40,15 @@ export interface ConfirmSurface {
40
40
  prompter: () => Promise<Prompter>;
41
41
  timeoutMs?: number;
42
42
  }
43
+ export declare const escapeForDisplay: typeof coreEscapeForDisplay;
44
+ export declare const displayArg: typeof coreDisplayArg;
43
45
  export declare function useConfirmationBody(info: {
44
46
  command: string[];
45
47
  keys: string[];
46
48
  networkEgress: boolean;
49
+ target?: TargetInfo;
47
50
  }, projectRoot: string): string;
51
+ export declare function revokeConfirmationBody(keys: string[], projectRoot: string): string;
48
52
  export declare function probeConfirmationBody(entry: ManifestEntry): string | null;
49
53
  /**
50
54
  * `onConfirm` for the Broker: gates `env_use`.
@@ -55,6 +59,13 @@ export declare function probeConfirmationBody(entry: ManifestEntry): string | nu
55
59
  * or for a silence — the defect this project already fixed once in the CLI.
56
60
  */
57
61
  export declare function createUseConfirm(surface: ConfirmSurface): NonNullable<BrokerOptions['onConfirm']>;
62
+ /**
63
+ * `onRevokeConfirm` for the Broker: gates `env_revoke`.
64
+ *
65
+ * Same ask/outcome mapping as createUseConfirm. Throws rather than returning
66
+ * false when no human could be asked or when the ask expired unanswered.
67
+ */
68
+ export declare function createRevokeConfirm(surface: ConfirmSurface): NonNullable<BrokerOptions['onRevokeConfirm']>;
58
69
  /**
59
70
  * `onApprovalNeeded` for the Broker: PLAN.md §6.4 probe consent for
60
71
  * `env_verify` against a host that is not registry-allowlisted.
package/dist/confirm.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { randomBytes } from 'node:crypto';
2
+ import { useConfirmationBody as sharedUseConfirmationBody, revokeConfirmationBody as sharedRevokeConfirmationBody, escapeForDisplay as coreEscapeForDisplay, displayArg as coreDisplayArg, } from '@envseal/core';
2
3
  import { SepError, zero } from '@envseal/protocol';
3
4
  import { makeDisplayNonce } from '@envseal/prompters';
4
5
  /**
@@ -18,21 +19,19 @@ import { makeDisplayNonce } from '@envseal/prompters';
18
19
  * between a prompt-injected model and arbitrary code holding live
19
20
  * credentials. In CI these operations are simply unavailable, and say so.
20
21
  *
21
- * DUPLICATION: this file is a hand-maintained twin of
22
- * packages/sdk/src/confirm.ts. Its natural home is a `confirm()` method
23
- * on the `Prompter` interface every surface already knows how to draw a
24
- * dialog but @envseal/mcp-server does not depend on @envseal/sdk, and
25
- * @envseal/prompters was outside the scope of the change that added this. Both
26
- * packages test the behaviour independently, so drift shows up as a red test
27
- * rather than as a binding that quietly stops asking.
22
+ * DUPLICATION: this file remains a hand-maintained twin of
23
+ * packages/sdk/src/confirm.ts for the ask/outcome mapping, but the dialog
24
+ * BODY (escaping, truncation caps, fingerprints, warnings) is shared via
25
+ * useConfirmationBody from @envseal/core so the CLI, SDK and MCP surfaces
26
+ * can never drift on what the user is shown.
28
27
  */
29
28
  /** Value-entry key name carrying the `env_use` confirmation. */
30
29
  export const CONFIRM_KEY_USE = 'APPROVE';
30
+ /** Value-entry key name carrying the `env_revoke` confirmation. */
31
+ export const CONFIRM_KEY_REVOKE = 'APPROVE_REVOKE';
31
32
  /** Value-entry key name carrying the `env_verify` probe-consent question. */
32
33
  export const CONFIRM_KEY_PROBE = 'APPROVE_PROBE';
33
34
  const DEFAULT_TIMEOUT_MS = 120_000;
34
- /** Per-argument display cap; longer arguments are shown truncated, and said to be. */
35
- const MAX_ARG_CHARS = 300;
36
35
  /** Whole-dialog cap. Past this we refuse rather than ask about something unreadable. */
37
36
  const MAX_BODY_CHARS = 16 * 1024;
38
37
  const INSTRUCTION = 'Type yes to approve, or submit an empty box to deny.';
@@ -41,57 +40,16 @@ const INSTRUCTION = 'Type yes to approve, or submit an empty box to deny.';
41
40
  * `env_use` in a loop and stack up dialogs until one gets clicked through.
42
41
  */
43
42
  let confirmationOpen = false;
44
- /**
45
- * Model-supplied argv, key names and probe metadata land in a dialog the user
46
- * is about to trust. A raw newline lets a crafted argument forge extra lines —
47
- * "keys: none", "this command is safe" — inside the very block that exists to
48
- * tell the truth about the command. Render control characters visibly instead.
49
- */
50
- function escapeForDisplay(value) {
51
- let out = '';
52
- for (const ch of value) {
53
- const code = ch.codePointAt(0) ?? 0;
54
- if (code < 0x20 || (code >= 0x7f && code <= 0x9f)) {
55
- out += `<0x${code.toString(16).padStart(2, '0')}>`;
56
- }
57
- else {
58
- out += ch;
59
- }
60
- }
61
- return out;
62
- }
63
- function displayArg(arg) {
64
- const escaped = escapeForDisplay(arg);
65
- if (escaped.length <= MAX_ARG_CHARS) {
66
- return escaped;
67
- }
68
- const hidden = escaped.length - MAX_ARG_CHARS;
69
- return `${escaped.slice(0, MAX_ARG_CHARS)}[... ${hidden} more characters, not shown]`;
70
- }
43
+ // Re-exported so existing importers of the twins keep working; the
44
+ // implementations live in @envseal/core/display.ts and are shared across
45
+ // every binding (CLI, SDK and MCP alike).
46
+ export const escapeForDisplay = coreEscapeForDisplay;
47
+ export const displayArg = coreDisplayArg;
71
48
  export function useConfirmationBody(info, projectRoot) {
72
- const lines = [
73
- 'EnvSeal is about to run a program with these secrets in its environment.',
74
- '',
75
- ` project: ${escapeForDisplay(projectRoot)}`,
76
- ` keys: ${info.keys.length > 0 ? info.keys.map(escapeForDisplay).join(', ') : '(none)'}`,
77
- '',
78
- ' command, one argument per line, exactly as it will be run (no shell):',
79
- ];
80
- info.command.forEach((arg, index) => {
81
- lines.push(` [${index}] ${displayArg(arg)}`);
82
- });
83
- lines.push('');
84
- if (info.networkEgress) {
85
- lines.push(' WARNING: this command can reach the network, so it could send these', ' values somewhere. Only continue if you trust it.');
86
- }
87
- else {
88
- // Honest about what the check is worth: NETWORK_TOOLS plus a URL scan is a
89
- // heuristic, and claiming more would be the kind of overstatement this
90
- // project has already had to walk back once.
91
- lines.push(' No network tool or URL was recognised in this command. That is a', ' heuristic, not a guarantee: any program can open a socket.');
92
- }
93
- lines.push('', `${INSTRUCTION} Nothing runs unless you approve.`);
94
- return lines.join('\n');
49
+ return sharedUseConfirmationBody(info, projectRoot);
50
+ }
51
+ export function revokeConfirmationBody(keys, projectRoot) {
52
+ return sharedRevokeConfirmationBody(keys, projectRoot);
95
53
  }
96
54
  export function probeConfirmationBody(entry) {
97
55
  const probe = entry.verify;
@@ -207,6 +165,50 @@ export function createUseConfirm(surface) {
207
165
  }
208
166
  };
209
167
  }
168
+ /**
169
+ * `onRevokeConfirm` for the Broker: gates `env_revoke`.
170
+ *
171
+ * Same ask/outcome mapping as createUseConfirm. Throws rather than returning
172
+ * false when no human could be asked or when the ask expired unanswered.
173
+ */
174
+ export function createRevokeConfirm(surface) {
175
+ return async (keys) => {
176
+ const outcome = await ask(surface, CONFIRM_KEY_REVOKE, 'Approve removing stored credentials? Nothing has been removed yet.', revokeConfirmationBody(keys, surface.projectRoot));
177
+ switch (outcome) {
178
+ case 'approved':
179
+ return true;
180
+ case 'denied':
181
+ return false;
182
+ case 'timed-out':
183
+ throw new SepError({
184
+ code: 'SEP_TICKET_EXPIRED',
185
+ userMessage: 'The env_revoke confirmation closed after its timeout with nobody answering it. Nothing was ' +
186
+ 'removed. This is not a denial: ask the user to approve it, then call env_revoke again.',
187
+ });
188
+ case 'no-surface':
189
+ throw new SepError({
190
+ code: 'SEP_NO_INTERACTIVE_SURFACE',
191
+ userMessage: 'env_revoke needs the user to confirm before stored credentials are removed, ' +
192
+ 'but there is no interactive surface here to ask on (this is what CI looks like to envseal). ' +
193
+ 'Nothing was removed. ' +
194
+ 'There is no flag or environment variable that skips this prompt in this binding: the request ' +
195
+ 'came from a model, and the confirmation is the only control on it. ' +
196
+ 'Run `envseal revoke` yourself in a session that has a browser or a terminal.',
197
+ });
198
+ case 'busy':
199
+ throw new SepError({
200
+ code: 'SEP_RATE_LIMITED',
201
+ userMessage: 'Another envseal confirmation is already open. Answer that one first, then call env_revoke again.',
202
+ });
203
+ case 'too-large':
204
+ throw new SepError({
205
+ code: 'SEP_FORMAT_INVALID',
206
+ userMessage: 'This revoke request is too large to display in a confirmation dialog, and envseal will not ask ' +
207
+ 'anyone to approve something it cannot show them. Revoke fewer keys at once.',
208
+ });
209
+ }
210
+ };
211
+ }
210
212
  /**
211
213
  * `onApprovalNeeded` for the Broker: PLAN.md §6.4 probe consent for
212
214
  * `env_verify` against a host that is not registry-allowlisted.
@@ -219,7 +221,7 @@ export function createUseConfirm(surface) {
219
221
  */
220
222
  export function createProbeApproval(surface) {
221
223
  return async (entry) => {
222
- const outcome = await ask(surface, CONFIRM_KEY_PROBE, `Approve sending ${entry.key} to a host that is not on envseal's allowlist? Nothing has been sent yet.`, probeConfirmationBody(entry));
224
+ const outcome = await ask(surface, CONFIRM_KEY_PROBE, `Approve sending ${escapeForDisplay(entry.key)} to a host that is not on envseal's allowlist? Nothing has been sent yet.`, probeConfirmationBody(entry));
223
225
  return outcome === 'approved';
224
226
  };
225
227
  }
@@ -24,14 +24,22 @@ export function createStubPrompter(value) {
24
24
  return {
25
25
  id: 'ide',
26
26
  available: async () => true,
27
- prompt: async (req) => ({
28
- ticket: req.ticket,
29
- results: req.keys.map((k) => ({
30
- key: k.key,
31
- outcome: 'entered',
32
- value: secretFromUtf8(value),
33
- })),
34
- }),
27
+ prompt: async (req) => {
28
+ // Announce the stub on stderr, mirroring the CLI's probe-approval
29
+ // notice: any answer that did not come from a human must be visible in
30
+ // the transcript. A model that discovers the two-variable gate cannot
31
+ // use it as a silent approval oracle.
32
+ process.stderr.write(`ENVSEAL_TEST_MODE: prompter is a STUB — key(s) [${req.keys.map((k) => k.key).join(', ')}] ` +
33
+ `answered from ENVSEAL_TEST_PROMPTER_VALUE with no UI.\n`);
34
+ return {
35
+ ticket: req.ticket,
36
+ results: req.keys.map((k) => ({
37
+ key: k.key,
38
+ outcome: 'entered',
39
+ value: secretFromUtf8(value),
40
+ })),
41
+ };
42
+ },
35
43
  cancel: async () => {
36
44
  /* nothing to tear down */
37
45
  },
@@ -8,7 +8,7 @@ export declare const inputSchema: import("zod").ZodObject<{
8
8
  required: import("zod").ZodDefault<import("zod").ZodBoolean>;
9
9
  secret: import("zod").ZodDefault<import("zod").ZodBoolean>;
10
10
  format: import("zod").ZodOptional<import("zod").ZodObject<{
11
- pattern: import("zod").ZodOptional<import("zod").ZodString>;
11
+ pattern: import("zod").ZodOptional<import("zod").ZodEffects<import("zod").ZodString, string, string>>;
12
12
  minLength: import("zod").ZodOptional<import("zod").ZodNumber>;
13
13
  maxLength: import("zod").ZodOptional<import("zod").ZodNumber>;
14
14
  example: import("zod").ZodOptional<import("zod").ZodString>;
@@ -1,6 +1,6 @@
1
1
  import type { Broker } from '@envseal/core';
2
2
  export declare const name = "env_revoke";
3
- export declare const description = "Removes stored credentials. Records in the audit log and emits the provider rotation URL so you can help the user invalidate the old key.";
3
+ export declare const description = "Removes stored credentials after user confirmation. Records in the audit log and emits the provider rotation URL so you can help the user invalidate the old key.";
4
4
  export declare const inputSchema: import("zod").ZodObject<{
5
5
  keys: import("zod").ZodArray<import("zod").ZodString, "many">;
6
6
  }, "strict", import("zod").ZodTypeAny, {
@@ -1,7 +1,7 @@
1
1
  import { EnvRevokeInput, INPUT_SCHEMAS } from '@envseal/protocol';
2
2
  import { respond, respondError } from '../respond.js';
3
3
  export const name = 'env_revoke';
4
- export const description = 'Removes stored credentials. Records in the audit log and emits the provider rotation URL so you can help the user invalidate the old key.';
4
+ export const description = 'Removes stored credentials after user confirmation. Records in the audit log and emits the provider rotation URL so you can help the user invalidate the old key.';
5
5
  export const inputSchema = INPUT_SCHEMAS.env_revoke;
6
6
  export async function handler(args, broker) {
7
7
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@envseal/mcp-server",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.js",
@@ -25,10 +25,10 @@
25
25
  "dependencies": {
26
26
  "@modelcontextprotocol/sdk": "^1.13.0",
27
27
  "zod": "^3.24.1",
28
- "@envseal/protocol": "0.1.2",
29
- "@envseal/core": "0.1.2",
30
- "@envseal/registry": "0.1.2",
31
- "@envseal/prompters": "0.1.2"
28
+ "@envseal/protocol": "0.1.4",
29
+ "@envseal/core": "0.1.4",
30
+ "@envseal/registry": "0.1.4",
31
+ "@envseal/prompters": "0.1.4"
32
32
  },
33
33
  "devDependencies": {
34
34
  "tsx": "^4.19.2",