@envseal/mcp-server 0.1.0
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/LICENSE +201 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.js +84 -0
- package/dist/cli-args.d.ts +31 -0
- package/dist/cli-args.js +100 -0
- package/dist/confirm.d.ts +75 -0
- package/dist/confirm.js +247 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/dist/respond.d.ts +22 -0
- package/dist/respond.js +44 -0
- package/dist/server.d.ts +12 -0
- package/dist/server.js +43 -0
- package/dist/test-prompter.d.ts +40 -0
- package/dist/test-prompter.js +68 -0
- package/dist/tools/await.d.ts +15 -0
- package/dist/tools/await.js +20 -0
- package/dist/tools/declare.d.ts +253 -0
- package/dist/tools/declare.js +20 -0
- package/dist/tools/describe.d.ts +12 -0
- package/dist/tools/describe.js +22 -0
- package/dist/tools/request.d.ts +15 -0
- package/dist/tools/request.js +22 -0
- package/dist/tools/revoke.d.ts +12 -0
- package/dist/tools/revoke.js +16 -0
- package/dist/tools/use.d.ts +15 -0
- package/dist/tools/use.js +22 -0
- package/dist/tools/verify.d.ts +12 -0
- package/dist/tools/verify.js +24 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined in Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
24
|
+
permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or Object
|
|
36
|
+
form, made available under the License, as indicated by a copyright
|
|
37
|
+
notice that is included in or attached to the work (an example is
|
|
38
|
+
provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original Work and any Derivative Works thereof, that is
|
|
50
|
+
intentionally submitted to, or received by, Licensor for inclusion
|
|
51
|
+
in the Work by the copyright owner or by an individual or Legal
|
|
52
|
+
Entity authorized to submit on behalf of the copyright owner. For
|
|
53
|
+
the purposes of this definition, "submitted" means any form of
|
|
54
|
+
electronic, verbal, or written communication sent to the Licensor
|
|
55
|
+
or its representatives, including but not limited to communication
|
|
56
|
+
on electronic mailing lists, source code control systems, and issue
|
|
57
|
+
tracking systems that are managed by, or on behalf of, the Licensor
|
|
58
|
+
for the purpose of discussing and improving the Work, but excluding
|
|
59
|
+
communication that is conspicuously marked or otherwise designated
|
|
60
|
+
in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
63
|
+
which a Contribution has been received by Licensor and subsequently
|
|
64
|
+
incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file, then any
|
|
107
|
+
Derivative Works that You distribute must include a readable
|
|
108
|
+
copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE from the Work, provided that
|
|
120
|
+
such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions of this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contribution.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in appropriate
|
|
184
|
+
comment syntax for the file type. We also recommend that you
|
|
185
|
+
include a file or class name and date of last modification in
|
|
186
|
+
the header comment to make it easier to identify the original
|
|
187
|
+
author and when the file was changed.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 The envseal authors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/dist/bin.d.ts
ADDED
package/dist/bin.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
+
import { Broker } from '@envseal/core';
|
|
4
|
+
import { selectPrompter } from '@envseal/prompters';
|
|
5
|
+
import { createServer } from './index.js';
|
|
6
|
+
import { parseArgv, resolveProjectRoot, USAGE, VERSION } from './cli-args.js';
|
|
7
|
+
import { createProbeApproval, createUseConfirm } from './confirm.js';
|
|
8
|
+
import { createRefusingPrompter, createStubPrompter, isStubOutcome, } from './test-prompter.js';
|
|
9
|
+
// NOTE: MCP protocol owns stdout. All diagnostics MUST go to stderr.
|
|
10
|
+
// Any output to stdout corrupts the JSON-RPC stream.
|
|
11
|
+
//
|
|
12
|
+
// --help and --version are the two exceptions, and only because they exit
|
|
13
|
+
// before any transport is connected: at that point stdout is a terminal, not a
|
|
14
|
+
// JSON-RPC stream. Help nobody can see is the bug this replaced -- the old bin
|
|
15
|
+
// ignored --help entirely, wrote zero bytes to either stream, and left a
|
|
16
|
+
// .envseal/salt behind in whatever directory it happened to be launched from.
|
|
17
|
+
async function main() {
|
|
18
|
+
const parsed = parseArgv(process.argv.slice(2));
|
|
19
|
+
if (parsed.kind === 'help') {
|
|
20
|
+
process.stdout.write(USAGE);
|
|
21
|
+
process.exit(0);
|
|
22
|
+
}
|
|
23
|
+
if (parsed.kind === 'version') {
|
|
24
|
+
process.stdout.write(`envseal-mcp ${VERSION}\n`);
|
|
25
|
+
process.exit(0);
|
|
26
|
+
}
|
|
27
|
+
if (parsed.kind === 'usage-error') {
|
|
28
|
+
process.stderr.write(`[envseal-mcp] Error: ${parsed.message}\n\n${USAGE}`);
|
|
29
|
+
process.exit(2);
|
|
30
|
+
}
|
|
31
|
+
// Resolve BEFORE constructing anything: `new Broker` writes .envseal/salt.
|
|
32
|
+
const resolved = resolveProjectRoot(parsed.project, process.cwd());
|
|
33
|
+
if ('error' in resolved) {
|
|
34
|
+
process.stderr.write(`[envseal-mcp] Error: ${resolved.error}\n`);
|
|
35
|
+
process.exit(2);
|
|
36
|
+
}
|
|
37
|
+
const projectRoot = resolved.root;
|
|
38
|
+
try {
|
|
39
|
+
// Both gates must be set, and neither is ever set by the shipped CLI.
|
|
40
|
+
// See the comment in test-prompter.ts for why this is deliberately awkward.
|
|
41
|
+
const stubValue = process.env.ENVSEAL_TEST_PROMPTER_VALUE;
|
|
42
|
+
const testMode = process.env.ENVSEAL_TEST_MODE === '1';
|
|
43
|
+
// Same double gate and same precedence as the CLI's cli-utils.ts: a fixed
|
|
44
|
+
// value wins, else a refusal outcome, else the real surface.
|
|
45
|
+
const prompter = testMode && stubValue !== undefined && stubValue !== ''
|
|
46
|
+
? createStubPrompter(stubValue)
|
|
47
|
+
: testMode && isStubOutcome(process.env.ENVSEAL_TEST_PROMPTER_OUTCOME)
|
|
48
|
+
? createRefusingPrompter(process.env.ENVSEAL_TEST_PROMPTER_OUTCOME)
|
|
49
|
+
: await selectPrompter();
|
|
50
|
+
// One resolved surface for value entry AND for consent, so the user
|
|
51
|
+
// approves a command on the same surface they type values into.
|
|
52
|
+
const surface = { projectRoot, prompter: async () => prompter };
|
|
53
|
+
const broker = new Broker({
|
|
54
|
+
root: projectRoot,
|
|
55
|
+
prompter,
|
|
56
|
+
// env_use is advertised in tools/list. Without onConfirm the broker
|
|
57
|
+
// cannot ask anyone, and exec.ts turns that absence into "the user
|
|
58
|
+
// denied the confirmation" for a user who was never asked.
|
|
59
|
+
onConfirm: createUseConfirm(surface),
|
|
60
|
+
// PLAN.md §6.4: consent before a credential goes to a host the registry
|
|
61
|
+
// does not allowlist. Supplied by no binding before this.
|
|
62
|
+
onApprovalNeeded: createProbeApproval(surface),
|
|
63
|
+
});
|
|
64
|
+
const mcpServer = createServer(broker);
|
|
65
|
+
const transport = new StdioServerTransport();
|
|
66
|
+
await mcpServer.connect(transport);
|
|
67
|
+
// Keep the server running
|
|
68
|
+
await new Promise(() => {
|
|
69
|
+
// This promise never resolves, keeping the process alive
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
// Log to stderr only
|
|
74
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
75
|
+
console.error(`[envseal-mcp] Error: ${message}`);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
main().catch((error) => {
|
|
80
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
81
|
+
console.error(`[envseal-mcp] Fatal error: ${message}`);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
});
|
|
84
|
+
//# sourceMappingURL=bin.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Argument handling for the `envseal-mcp` binary, kept out of bin.ts so it can
|
|
3
|
+
* be tested without importing a module whose side effect is starting a server.
|
|
4
|
+
*/
|
|
5
|
+
export declare const VERSION = "0.1.0";
|
|
6
|
+
export declare const USAGE = "envseal-mcp 0.1.0\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
|
+
export type ParsedArgv = {
|
|
8
|
+
kind: 'help';
|
|
9
|
+
} | {
|
|
10
|
+
kind: 'version';
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'serve';
|
|
13
|
+
project: string | undefined;
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'usage-error';
|
|
16
|
+
message: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function parseArgv(args: string[]): ParsedArgv;
|
|
19
|
+
/**
|
|
20
|
+
* findProjectRoot() falls back to its starting directory when it finds no
|
|
21
|
+
* marker, and the Broker constructor eagerly writes .envseal/salt. Together
|
|
22
|
+
* that meant an MCP host launching this server with a cwd the user did not
|
|
23
|
+
* choose scattered .envseal/ directories around the filesystem and silently
|
|
24
|
+
* brokered for the wrong project. Detect the fallback and refuse.
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveProjectRoot(project: string | undefined, cwd: string): {
|
|
27
|
+
root: string;
|
|
28
|
+
} | {
|
|
29
|
+
error: string;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=cli-args.d.ts.map
|
package/dist/cli-args.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { existsSync, statSync } from 'node:fs';
|
|
2
|
+
import { join, resolve } from 'node:path';
|
|
3
|
+
import { findProjectRoot } from '@envseal/core';
|
|
4
|
+
/**
|
|
5
|
+
* Argument handling for the `envseal-mcp` binary, kept out of bin.ts so it can
|
|
6
|
+
* be tested without importing a module whose side effect is starting a server.
|
|
7
|
+
*/
|
|
8
|
+
export const VERSION = '0.1.0';
|
|
9
|
+
export const USAGE = `envseal-mcp ${VERSION}
|
|
10
|
+
|
|
11
|
+
Serves the SEP/1 tools to an MCP host over stdio JSON-RPC.
|
|
12
|
+
|
|
13
|
+
Usage: envseal-mcp [--project <dir>]
|
|
14
|
+
|
|
15
|
+
Options:
|
|
16
|
+
--project <dir> Project root to broker secrets for. Default: search
|
|
17
|
+
upward from the current directory for env.schema.jsonc,
|
|
18
|
+
.git or package.json. If none is found, this server
|
|
19
|
+
refuses to start rather than create .envseal/ in a
|
|
20
|
+
directory that is not a project.
|
|
21
|
+
--help, -h Show this help and exit.
|
|
22
|
+
--version, -v Print the version and exit.
|
|
23
|
+
|
|
24
|
+
Transport: stdio only. --http and --port were removed; they were parsed and
|
|
25
|
+
then ignored, and no HTTP or SSE transport was ever implemented. For an HTTP
|
|
26
|
+
surface use @envseal/http-server, which speaks REST + OpenAPI on loopback --
|
|
27
|
+
that is a different protocol, not MCP over HTTP.
|
|
28
|
+
`;
|
|
29
|
+
export function parseArgv(args) {
|
|
30
|
+
let project;
|
|
31
|
+
for (let i = 0; i < args.length; i++) {
|
|
32
|
+
const arg = args[i];
|
|
33
|
+
if (arg === undefined) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (arg === '--help' || arg === '-h') {
|
|
37
|
+
return { kind: 'help' };
|
|
38
|
+
}
|
|
39
|
+
if (arg === '--version' || arg === '-v') {
|
|
40
|
+
return { kind: 'version' };
|
|
41
|
+
}
|
|
42
|
+
if (arg === '--project' || arg.startsWith('--project=')) {
|
|
43
|
+
let value;
|
|
44
|
+
if (arg.startsWith('--project=')) {
|
|
45
|
+
value = arg.slice('--project='.length);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
value = args[i + 1];
|
|
49
|
+
i++;
|
|
50
|
+
}
|
|
51
|
+
if (value === undefined || value === '' || value.startsWith('-')) {
|
|
52
|
+
return { kind: 'usage-error', message: '--project needs a directory' };
|
|
53
|
+
}
|
|
54
|
+
project = value;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
// Unknown arguments used to be ignored silently, which is how --http and
|
|
58
|
+
// --port sat in the parser doing nothing while the README advertised
|
|
59
|
+
// "stdio + streamable HTTP".
|
|
60
|
+
if (arg === '--http' || arg === '--port' || arg.startsWith('--port=')) {
|
|
61
|
+
const flag = arg.startsWith('--port=') ? '--port' : arg;
|
|
62
|
+
return {
|
|
63
|
+
kind: 'usage-error',
|
|
64
|
+
message: `${flag} was removed: this server has only ever spoken stdio`,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return { kind: 'usage-error', message: `unknown argument: ${arg}` };
|
|
68
|
+
}
|
|
69
|
+
return { kind: 'serve', project };
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* findProjectRoot() falls back to its starting directory when it finds no
|
|
73
|
+
* marker, and the Broker constructor eagerly writes .envseal/salt. Together
|
|
74
|
+
* that meant an MCP host launching this server with a cwd the user did not
|
|
75
|
+
* choose scattered .envseal/ directories around the filesystem and silently
|
|
76
|
+
* brokered for the wrong project. Detect the fallback and refuse.
|
|
77
|
+
*/
|
|
78
|
+
export function resolveProjectRoot(project, cwd) {
|
|
79
|
+
if (project !== undefined) {
|
|
80
|
+
const root = resolve(project);
|
|
81
|
+
if (!existsSync(root) || !statSync(root).isDirectory()) {
|
|
82
|
+
return { error: `--project ${root} is not an existing directory` };
|
|
83
|
+
}
|
|
84
|
+
return { root };
|
|
85
|
+
}
|
|
86
|
+
const root = findProjectRoot(cwd);
|
|
87
|
+
const hasMarker = existsSync(join(root, 'env.schema.jsonc')) ||
|
|
88
|
+
existsSync(join(root, '.git')) ||
|
|
89
|
+
existsSync(join(root, 'package.json'));
|
|
90
|
+
if (!hasMarker) {
|
|
91
|
+
return {
|
|
92
|
+
error: `no project found from ${cwd}.\n` +
|
|
93
|
+
' Looked for env.schema.jsonc, .git or package.json there and in every parent.\n' +
|
|
94
|
+
' Refusing to create .envseal/ in a directory that is not a project.\n' +
|
|
95
|
+
' Pass --project <dir> to name the project explicitly.',
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return { root };
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=cli-args.js.map
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { BrokerOptions } from '@envseal/core';
|
|
2
|
+
import type { ManifestEntry, VerifyResult } from '@envseal/protocol';
|
|
3
|
+
import type { Prompter } from '@envseal/prompters';
|
|
4
|
+
/**
|
|
5
|
+
* The interactive consent surface for the two operations that move a live
|
|
6
|
+
* value: `env_use` (inject into a child process) and `env_verify` against a
|
|
7
|
+
* host the registry does not allowlist.
|
|
8
|
+
*
|
|
9
|
+
* Before this existed, three of the four bindings constructed the Broker with
|
|
10
|
+
* no `onConfirm`, and exec.ts turned that absence into
|
|
11
|
+
* SEP_CONFIRMATION_DENIED — "The user denied the confirmation" — when no user
|
|
12
|
+
* had been asked and no user had denied. `env_use` was advertised in
|
|
13
|
+
* tools/list and in the OpenAPI document and could never succeed.
|
|
14
|
+
*
|
|
15
|
+
* There is deliberately no environment-variable bypass here. `envseal run`
|
|
16
|
+
* honours ENVSEAL_ASSUME_YES because a human typed that command; in these
|
|
17
|
+
* bindings the argv comes from a *model*, and this prompt is the only thing
|
|
18
|
+
* between a prompt-injected model and arbitrary code holding live
|
|
19
|
+
* credentials. In CI these operations are simply unavailable, and say so.
|
|
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.
|
|
28
|
+
*/
|
|
29
|
+
/** Value-entry key name carrying the `env_use` confirmation. */
|
|
30
|
+
export declare const CONFIRM_KEY_USE = "APPROVE";
|
|
31
|
+
/** Value-entry key name carrying the `env_verify` probe-consent question. */
|
|
32
|
+
export declare const CONFIRM_KEY_PROBE = "APPROVE_PROBE";
|
|
33
|
+
export interface ConfirmSurface {
|
|
34
|
+
/** Shown so the user can tell which project is asking. */
|
|
35
|
+
projectRoot: string;
|
|
36
|
+
/**
|
|
37
|
+
* Resolves the surface to ask on. A thunk rather than a Prompter because
|
|
38
|
+
* `selectPrompter()` is async and `createBroker` is not.
|
|
39
|
+
*/
|
|
40
|
+
prompter: () => Promise<Prompter>;
|
|
41
|
+
timeoutMs?: number;
|
|
42
|
+
}
|
|
43
|
+
export declare function useConfirmationBody(info: {
|
|
44
|
+
command: string[];
|
|
45
|
+
keys: string[];
|
|
46
|
+
networkEgress: boolean;
|
|
47
|
+
}, projectRoot: string): string;
|
|
48
|
+
export declare function probeConfirmationBody(entry: ManifestEntry): string | null;
|
|
49
|
+
/**
|
|
50
|
+
* `onConfirm` for the Broker: gates `env_use`.
|
|
51
|
+
*
|
|
52
|
+
* Throws rather than returning false when no human could be asked or when the
|
|
53
|
+
* ask expired with nobody answering it, because exec.ts maps a `false` to
|
|
54
|
+
* SEP_CONFIRMATION_DENIED and that would blame the user for a missing surface
|
|
55
|
+
* or for a silence — the defect this project already fixed once in the CLI.
|
|
56
|
+
*/
|
|
57
|
+
export declare function createUseConfirm(surface: ConfirmSurface): NonNullable<BrokerOptions['onConfirm']>;
|
|
58
|
+
/**
|
|
59
|
+
* `onApprovalNeeded` for the Broker: PLAN.md §6.4 probe consent for
|
|
60
|
+
* `env_verify` against a host that is not registry-allowlisted.
|
|
61
|
+
*
|
|
62
|
+
* Never throws. verifyKey() calls this per key inside a loop that builds
|
|
63
|
+
* per-key results; throwing would abort the whole `env_verify` call, so a
|
|
64
|
+
* missing surface would take down the verification of keys whose probes are
|
|
65
|
+
* allowlisted and fine. Every non-approval returns false, which keeps the
|
|
66
|
+
* existing fail-closed `probe_not_approved` outcome for that one key.
|
|
67
|
+
*/
|
|
68
|
+
export declare function createProbeApproval(surface: ConfirmSurface): NonNullable<BrokerOptions['onApprovalNeeded']>;
|
|
69
|
+
/**
|
|
70
|
+
* `probe_not_approved` on its own tells the caller nothing it can act on.
|
|
71
|
+
* verify.ts (core) names the host; this adds what to do about it, in the one
|
|
72
|
+
* place a binding can add it without reaching into core.
|
|
73
|
+
*/
|
|
74
|
+
export declare function annotateVerifyResults(results: VerifyResult[]): VerifyResult[];
|
|
75
|
+
//# sourceMappingURL=confirm.d.ts.map
|