@cybedefend/vibedefend 1.5.0 → 1.7.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/README.md +71 -2
- package/dist/api/gateway-request.js +49 -0
- package/dist/api/gateway-request.js.map +1 -0
- package/dist/api/projects.js +67 -0
- package/dist/api/projects.js.map +1 -1
- package/dist/api/repository-link.js +157 -0
- package/dist/api/repository-link.js.map +1 -0
- package/dist/auth/auth-store.js +107 -25
- package/dist/auth/auth-store.js.map +1 -1
- package/dist/auth/auth.js +21 -0
- package/dist/auth/auth.js.map +1 -1
- package/dist/clients/cursor.js +5 -1
- package/dist/clients/cursor.js.map +1 -1
- package/dist/clients/vscode.js +38 -29
- package/dist/clients/vscode.js.map +1 -1
- package/dist/commands/mcp/allow.js +219 -0
- package/dist/commands/mcp/allow.js.map +1 -0
- package/dist/commands/mcp/connect.js +337 -0
- package/dist/commands/mcp/connect.js.map +1 -0
- package/dist/commands/mcp/index.js +170 -0
- package/dist/commands/mcp/index.js.map +1 -0
- package/dist/commands/mcp/proxy.js +320 -0
- package/dist/commands/mcp/proxy.js.map +1 -0
- package/dist/commands/mcp/scan.js +349 -0
- package/dist/commands/mcp/scan.js.map +1 -0
- package/dist/commands/mcp/sync.js +215 -0
- package/dist/commands/mcp/sync.js.map +1 -0
- package/dist/config.js +6 -0
- package/dist/config.js.map +1 -1
- package/dist/diagnostics.js +78 -12
- package/dist/diagnostics.js.map +1 -1
- package/dist/doctor.js +19 -0
- package/dist/doctor.js.map +1 -1
- package/dist/guards-evaluator/analysis-types.js +27 -0
- package/dist/guards-evaluator/analysis-types.js.map +1 -0
- package/dist/guards-evaluator/command-analysis.js +572 -0
- package/dist/guards-evaluator/command-analysis.js.map +1 -0
- package/dist/guards-evaluator/command-view.js +586 -0
- package/dist/guards-evaluator/command-view.js.map +1 -0
- package/dist/guards-evaluator/env.js +11 -0
- package/dist/guards-evaluator/env.js.map +1 -0
- package/dist/guards-evaluator/evaluate.js +91 -41
- package/dist/guards-evaluator/evaluate.js.map +1 -1
- package/dist/guards-evaluator/index.js +2 -1
- package/dist/guards-evaluator/index.js.map +1 -1
- package/dist/guards-evaluator/inline-code.js +259 -0
- package/dist/guards-evaluator/inline-code.js.map +1 -0
- package/dist/guards-evaluator/normalize.js +716 -0
- package/dist/guards-evaluator/normalize.js.map +1 -0
- package/dist/guards-evaluator/preprocess.js +13 -5
- package/dist/guards-evaluator/preprocess.js.map +1 -1
- package/dist/guards-evaluator/redact.js +19 -0
- package/dist/guards-evaluator/redact.js.map +1 -1
- package/dist/guards-evaluator/regex.js +25 -3
- package/dist/guards-evaluator/regex.js.map +1 -1
- package/dist/guards-evaluator/safe-commands.js +155 -0
- package/dist/guards-evaluator/safe-commands.js.map +1 -0
- package/dist/guards-evaluator/triage.js +315 -0
- package/dist/guards-evaluator/triage.js.map +1 -0
- package/dist/hook-runner.js +24679 -5079
- package/dist/hooks/install.js +38 -0
- package/dist/hooks/install.js.map +1 -1
- package/dist/hooks/runtime/config.js +38 -0
- package/dist/hooks/runtime/config.js.map +1 -1
- package/dist/hooks/runtime/emit.js +94 -61
- package/dist/hooks/runtime/emit.js.map +1 -1
- package/dist/hooks/runtime/fetch-rules.js +22 -7
- package/dist/hooks/runtime/fetch-rules.js.map +1 -1
- package/dist/hooks/runtime/gateway-http-error.js +34 -0
- package/dist/hooks/runtime/gateway-http-error.js.map +1 -0
- package/dist/hooks/runtime/guard-rules-cache.js +139 -17
- package/dist/hooks/runtime/guard-rules-cache.js.map +1 -1
- package/dist/hooks/runtime/guard-violations-buffer.js +321 -48
- package/dist/hooks/runtime/guard-violations-buffer.js.map +1 -1
- package/dist/hooks/runtime/judge-cache.js +6 -0
- package/dist/hooks/runtime/judge-cache.js.map +1 -1
- package/dist/hooks/runtime/judge-triage.js +193 -0
- package/dist/hooks/runtime/judge-triage.js.map +1 -0
- package/dist/hooks/runtime/judge.js +7 -1
- package/dist/hooks/runtime/judge.js.map +1 -1
- package/dist/hooks/runtime/pre-compact.js +12 -6
- package/dist/hooks/runtime/pre-compact.js.map +1 -1
- package/dist/hooks/runtime/resolve.js +90 -8
- package/dist/hooks/runtime/resolve.js.map +1 -1
- package/dist/hooks/runtime/retry-policy.js +57 -0
- package/dist/hooks/runtime/retry-policy.js.map +1 -0
- package/dist/hooks/runtime/review-sessions.js +74 -0
- package/dist/hooks/runtime/review-sessions.js.map +1 -0
- package/dist/hooks/runtime/script-resolve.js +695 -0
- package/dist/hooks/runtime/script-resolve.js.map +1 -0
- package/dist/hooks/runtime/session-activation.js +5 -1
- package/dist/hooks/runtime/session-activation.js.map +1 -1
- package/dist/hooks/runtime/session-review.js +163 -45
- package/dist/hooks/runtime/session-review.js.map +1 -1
- package/dist/hooks/runtime/session-start.js +2 -1
- package/dist/hooks/runtime/session-start.js.map +1 -1
- package/dist/hooks/runtime/session-writes.js +232 -0
- package/dist/hooks/runtime/session-writes.js.map +1 -0
- package/dist/hooks/runtime/sniff.js +26 -7
- package/dist/hooks/runtime/sniff.js.map +1 -1
- package/dist/hooks/runtime/target-resolve.js +336 -0
- package/dist/hooks/runtime/target-resolve.js.map +1 -0
- package/dist/hooks/runtime/unmapped-tools.js +93 -0
- package/dist/hooks/runtime/unmapped-tools.js.map +1 -0
- package/dist/hooks/runtime/usage-block.js +4 -0
- package/dist/hooks/runtime/usage-block.js.map +1 -1
- package/dist/hooks/runtime/user-prompt-submit.js +2 -1
- package/dist/hooks/runtime/user-prompt-submit.js.map +1 -1
- package/dist/hooks/runtime/wire-text.js +41 -0
- package/dist/hooks/runtime/wire-text.js.map +1 -0
- package/dist/hooks/runtime/work-dir.js +84 -0
- package/dist/hooks/runtime/work-dir.js.map +1 -0
- package/dist/index.js +45 -12
- package/dist/index.js.map +1 -1
- package/dist/install.js +174 -11
- package/dist/install.js.map +1 -1
- package/dist/link.js +74 -48
- package/dist/link.js.map +1 -1
- package/dist/login.js +77 -11
- package/dist/login.js.map +1 -1
- package/dist/mcp/auth/agent-sign-ins.js +174 -0
- package/dist/mcp/auth/agent-sign-ins.js.map +1 -0
- package/dist/mcp/auth/callback.js +200 -0
- package/dist/mcp/auth/callback.js.map +1 -0
- package/dist/mcp/auth/connect.js +392 -0
- package/dist/mcp/auth/connect.js.map +1 -0
- package/dist/mcp/auth/discovery.js +399 -0
- package/dist/mcp/auth/discovery.js.map +1 -0
- package/dist/mcp/auth/oauth.js +326 -0
- package/dist/mcp/auth/oauth.js.map +1 -0
- package/dist/mcp/auth/probe.js +128 -0
- package/dist/mcp/auth/probe.js.map +1 -0
- package/dist/mcp/auth/secrets.js +446 -0
- package/dist/mcp/auth/secrets.js.map +1 -0
- package/dist/mcp/auth/store.js +260 -0
- package/dist/mcp/auth/store.js.map +1 -0
- package/dist/mcp/auth/tokenSource.js +55 -0
- package/dist/mcp/auth/tokenSource.js.map +1 -0
- package/dist/mcp/config/atomicWrite.js +98 -0
- package/dist/mcp/config/atomicWrite.js.map +1 -0
- package/dist/mcp/config/clients.js +171 -0
- package/dist/mcp/config/clients.js.map +1 -0
- package/dist/mcp/config/cybedefend-servers.js +48 -0
- package/dist/mcp/config/cybedefend-servers.js.map +1 -0
- package/dist/mcp/config/discover.js +114 -0
- package/dist/mcp/config/discover.js.map +1 -0
- package/dist/mcp/config/hook.js +123 -0
- package/dist/mcp/config/hook.js.map +1 -0
- package/dist/mcp/config/index.js +11 -0
- package/dist/mcp/config/index.js.map +1 -0
- package/dist/mcp/config/install.js +132 -0
- package/dist/mcp/config/install.js.map +1 -0
- package/dist/mcp/config/installed.js +37 -0
- package/dist/mcp/config/installed.js.map +1 -0
- package/dist/mcp/config/jsonEdit.js +119 -0
- package/dist/mcp/config/jsonEdit.js.map +1 -0
- package/dist/mcp/config/lock.js +102 -0
- package/dist/mcp/config/lock.js.map +1 -0
- package/dist/mcp/config/proxyBinary.js +211 -0
- package/dist/mcp/config/proxyBinary.js.map +1 -0
- package/dist/mcp/config/rewrite.js +388 -0
- package/dist/mcp/config/rewrite.js.map +1 -0
- package/dist/mcp/config/types.js +34 -0
- package/dist/mcp/config/types.js.map +1 -0
- package/dist/mcp/proxy/audit.js +83 -0
- package/dist/mcp/proxy/audit.js.map +1 -0
- package/dist/mcp/proxy/authInterceptor.js +119 -0
- package/dist/mcp/proxy/authInterceptor.js.map +1 -0
- package/dist/mcp/proxy/expand.js +93 -0
- package/dist/mcp/proxy/expand.js.map +1 -0
- package/dist/mcp/proxy/inject.js +412 -0
- package/dist/mcp/proxy/inject.js.map +1 -0
- package/dist/mcp/proxy/intercept.js +63 -0
- package/dist/mcp/proxy/intercept.js.map +1 -0
- package/dist/mcp/proxy/jsonrpc.js +153 -0
- package/dist/mcp/proxy/jsonrpc.js.map +1 -0
- package/dist/mcp/proxy/log.js +109 -0
- package/dist/mcp/proxy/log.js.map +1 -0
- package/dist/mcp/proxy/paths.js +57 -0
- package/dist/mcp/proxy/paths.js.map +1 -0
- package/dist/mcp/proxy/proxy.js +520 -0
- package/dist/mcp/proxy/proxy.js.map +1 -0
- package/dist/mcp/proxy/serverCheckTimer.js +75 -0
- package/dist/mcp/proxy/serverCheckTimer.js.map +1 -0
- package/dist/mcp/proxy/sessionLifecycle.js +29 -0
- package/dist/mcp/proxy/sessionLifecycle.js.map +1 -0
- package/dist/mcp/proxy/spec.js +203 -0
- package/dist/mcp/proxy/spec.js.map +1 -0
- package/dist/mcp/proxy/sse.js +77 -0
- package/dist/mcp/proxy/sse.js.map +1 -0
- package/dist/mcp/proxy/upstream.js +2 -0
- package/dist/mcp/proxy/upstream.js.map +1 -0
- package/dist/mcp/proxy/upstreamHttp.js +499 -0
- package/dist/mcp/proxy/upstreamHttp.js.map +1 -0
- package/dist/mcp/proxy/upstreamStdio.js +188 -0
- package/dist/mcp/proxy/upstreamStdio.js.map +1 -0
- package/dist/mcp/proxy/upstreams.js +143 -0
- package/dist/mcp/proxy/upstreams.js.map +1 -0
- package/dist/mcp/proxy/verifyInterceptor.js +718 -0
- package/dist/mcp/proxy/verifyInterceptor.js.map +1 -0
- package/dist/mcp/proxy/windowsCommand.js +99 -0
- package/dist/mcp/proxy/windowsCommand.js.map +1 -0
- package/dist/mcp/report/buffer.js +351 -0
- package/dist/mcp/report/buffer.js.map +1 -0
- package/dist/mcp/report/coalesce.js +165 -0
- package/dist/mcp/report/coalesce.js.map +1 -0
- package/dist/mcp/report/constants.js +51 -0
- package/dist/mcp/report/constants.js.map +1 -0
- package/dist/mcp/report/project.js +83 -0
- package/dist/mcp/report/project.js.map +1 -0
- package/dist/mcp/report/reporter.js +443 -0
- package/dist/mcp/report/reporter.js.map +1 -0
- package/dist/mcp/report/types.js +3 -0
- package/dist/mcp/report/types.js.map +1 -0
- package/dist/mcp/report/validate.js +179 -0
- package/dist/mcp/report/validate.js.map +1 -0
- package/dist/mcp/scan/args.js +228 -0
- package/dist/mcp/scan/args.js.map +1 -0
- package/dist/mcp/scan/results.js +253 -0
- package/dist/mcp/scan/results.js.map +1 -0
- package/dist/mcp/scan/types.js +40 -0
- package/dist/mcp/scan/types.js.map +1 -0
- package/dist/mcp/verify/api.js +514 -0
- package/dist/mcp/verify/api.js.map +1 -0
- package/dist/mcp/verify/backend.js +143 -0
- package/dist/mcp/verify/backend.js.map +1 -0
- package/dist/mcp/verify/cache.js +200 -0
- package/dist/mcp/verify/cache.js.map +1 -0
- package/dist/mcp/verify/contract-errors.js +198 -0
- package/dist/mcp/verify/contract-errors.js.map +1 -0
- package/dist/mcp/verify/digest.js +91 -0
- package/dist/mcp/verify/digest.js.map +1 -0
- package/dist/mcp/verify/factory.js +56 -0
- package/dist/mcp/verify/factory.js.map +1 -0
- package/dist/mcp/verify/identity.js +286 -0
- package/dist/mcp/verify/identity.js.map +1 -0
- package/dist/mcp/verify/policy-store.js +63 -0
- package/dist/mcp/verify/policy-store.js.map +1 -0
- package/dist/mcp/verify/policy.js +160 -0
- package/dist/mcp/verify/policy.js.map +1 -0
- package/dist/mcp/verify/pool.js +27 -0
- package/dist/mcp/verify/pool.js.map +1 -0
- package/dist/mcp/verify/token-refresh.js +44 -0
- package/dist/mcp/verify/token-refresh.js.map +1 -0
- package/dist/mcp/verify/token.js +67 -0
- package/dist/mcp/verify/token.js.map +1 -0
- package/dist/mcp/verify/verifier.js +1166 -0
- package/dist/mcp/verify/verifier.js.map +1 -0
- package/dist/org-gate.js +1 -1
- package/dist/org-gate.js.map +1 -1
- package/dist/org.js +146 -0
- package/dist/org.js.map +1 -0
- package/dist/project-create.js +129 -0
- package/dist/project-create.js.map +1 -0
- package/dist/prompts.js +21 -0
- package/dist/prompts.js.map +1 -1
- package/dist/re2.wasm +0 -0
- package/dist/status.js +61 -0
- package/dist/status.js.map +1 -1
- package/dist/uninstall.js +49 -4
- package/dist/uninstall.js.map +1 -1
- package/dist/utils.js +62 -6
- package/dist/utils.js.map +1 -1
- package/package.json +10 -3
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import { chain } from '../../mcp/proxy/intercept.js';
|
|
2
|
+
import { createTokenSource } from '../../mcp/auth/tokenSource.js';
|
|
3
|
+
import { connectCommandFor, createAuthInterceptor } from '../../mcp/proxy/authInterceptor.js';
|
|
4
|
+
import { createAudit } from '../../mcp/proxy/audit.js';
|
|
5
|
+
import { createVerifyInterceptor } from '../../mcp/proxy/verifyInterceptor.js';
|
|
6
|
+
import { startServerCheckTimer } from '../../mcp/proxy/serverCheckTimer.js';
|
|
7
|
+
import { createSessionLifecycle } from '../../mcp/proxy/sessionLifecycle.js';
|
|
8
|
+
import { makeReportBuffer } from '../../mcp/report/buffer.js';
|
|
9
|
+
import { resolveReportProjectId } from '../../mcp/report/project.js';
|
|
10
|
+
import { McpReporter } from '../../mcp/report/reporter.js';
|
|
11
|
+
import { postMcpReport } from '../../mcp/verify/api.js';
|
|
12
|
+
import { buildVerifier } from '../../mcp/verify/factory.js';
|
|
13
|
+
import { reportServerIdentity } from '../../mcp/verify/identity.js';
|
|
14
|
+
import { verifyTokenResolver } from '../../mcp/verify/token.js';
|
|
15
|
+
import { isProxyInstalled } from '../../mcp/config/installed.js';
|
|
16
|
+
import { withSyncLock } from '../../mcp/config/lock.js';
|
|
17
|
+
import { checkProxyBinary } from '../../mcp/config/proxyBinary.js';
|
|
18
|
+
import { applySyncPlan, planSync } from '../../mcp/config/rewrite.js';
|
|
19
|
+
import { loggerFromEnv, parseLogLevel } from '../../mcp/proxy/log.js';
|
|
20
|
+
import { mcpLogsDir, PROXY_ENV_PREFIX } from '../../mcp/proxy/paths.js';
|
|
21
|
+
import { Proxy } from '../../mcp/proxy/proxy.js';
|
|
22
|
+
import { createLogger } from '../../mcp/proxy/log.js';
|
|
23
|
+
import { describeUpstream, resolveUpstreamSpec, UpstreamSpecError, } from '../../mcp/proxy/spec.js';
|
|
24
|
+
import { expandedSpecOf, resolveNamedUpstream, specOf, UnknownUpstreamError, } from '../../mcp/proxy/upstreams.js';
|
|
25
|
+
/** Exit code for a usage error, distinct from an upstream that died. */
|
|
26
|
+
export const EXIT_USAGE = 2;
|
|
27
|
+
export async function runMcpProxyCommand(options, runtime) {
|
|
28
|
+
// TWO specs, and they are not interchangeable.
|
|
29
|
+
//
|
|
30
|
+
// `spec` is what the upstream is reached with: expanded, because the child
|
|
31
|
+
// needs the value the originating client would have given it.
|
|
32
|
+
//
|
|
33
|
+
// `identitySpec` is the entry as stored: NOT expanded, because
|
|
34
|
+
// `upstreamServerId` hashes `command` + `args` (or the url), and that hash
|
|
35
|
+
// keys the verdict cache and the user's own `allow`/`deny` overrides —
|
|
36
|
+
// which `vibedefend allow|deny|status` compute from the stored entry.
|
|
37
|
+
// Deriving it from the expanded spec makes a `deny` stop applying the
|
|
38
|
+
// moment a reference appears in `args`, silently. Measured, not feared:
|
|
39
|
+
// see the conformance test that pins it.
|
|
40
|
+
let spec;
|
|
41
|
+
let identitySpec;
|
|
42
|
+
// The client whose config this server was read from; the agent's own
|
|
43
|
+
// `clientInfo` wins when it names itself.
|
|
44
|
+
let fallbackClientName;
|
|
45
|
+
// Variable references the originating client would have resolved. Names
|
|
46
|
+
// only — these are logged, and one of them is an API key.
|
|
47
|
+
let expansion = { resolved: [], missing: [] };
|
|
48
|
+
try {
|
|
49
|
+
// `--name` is the shape `vibedefend install` writes into a client config,
|
|
50
|
+
// so it wins over anything else on the command line.
|
|
51
|
+
if (options.name) {
|
|
52
|
+
const { entry } = resolveNamedUpstream(options.name, runtime.env);
|
|
53
|
+
// Expanded HERE, at the moment of use — `upstreams.json` keeps the
|
|
54
|
+
// reference, never the value. See `expand.ts`.
|
|
55
|
+
const expanded = expandedSpecOf(entry, runtime.env);
|
|
56
|
+
spec = expanded.value;
|
|
57
|
+
identitySpec = specOf(entry);
|
|
58
|
+
fallbackClientName = entry.source?.client;
|
|
59
|
+
expansion = { resolved: expanded.resolved, missing: expanded.missing };
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
spec = resolveUpstreamSpec(options);
|
|
63
|
+
// Nothing was expanded, so the two are the same object.
|
|
64
|
+
identitySpec = spec;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (error instanceof UpstreamSpecError || error instanceof UnknownUpstreamError) {
|
|
69
|
+
runtime.stderr.write(`vibedefend mcp: ${error.message}\n`);
|
|
70
|
+
return EXIT_USAGE;
|
|
71
|
+
}
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
const level = options.logLevel
|
|
75
|
+
? parseLogLevel(options.logLevel)
|
|
76
|
+
: parseLogLevel(runtime.env[`${PROXY_ENV_PREFIX}LOG_LEVEL`]);
|
|
77
|
+
const logger = options.logLevel
|
|
78
|
+
? createLogger({
|
|
79
|
+
level,
|
|
80
|
+
dir: mcpLogsDir(runtime.env),
|
|
81
|
+
base: { pid: process.pid, upstream: describeUpstream(spec) },
|
|
82
|
+
mirrorToStderr: runtime.env[`${PROXY_ENV_PREFIX}LOG_STDERR`] === '1',
|
|
83
|
+
})
|
|
84
|
+
: loggerFromEnv({ pid: process.pid, upstream: describeUpstream(spec) }, runtime.env);
|
|
85
|
+
// Names only, never values — this line is the one that would have made the
|
|
86
|
+
// signoz 401 a ten-second diagnosis instead of a dogfooding session.
|
|
87
|
+
if (expansion.resolved.length > 0 || expansion.missing.length > 0) {
|
|
88
|
+
logger.info('expanded variable references from the client entry', {
|
|
89
|
+
resolved: expansion.resolved,
|
|
90
|
+
resolvedCount: expansion.resolved.length,
|
|
91
|
+
missing: expansion.missing,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
for (const name of expansion.missing) {
|
|
95
|
+
logger.warn('a variable referenced by this server is not set and has no default; ' +
|
|
96
|
+
'the literal text is passed through, exactly as the client would', { variable: name });
|
|
97
|
+
}
|
|
98
|
+
const built = buildInterceptor(spec, identitySpec, options.name, logger, runtime, fallbackClientName);
|
|
99
|
+
const backgroundSyncOff = runtime.env[`${PROXY_ENV_PREFIX}NO_SYNC`] === '1';
|
|
100
|
+
const proxy = new Proxy({
|
|
101
|
+
spec,
|
|
102
|
+
logger,
|
|
103
|
+
interceptor: built.interceptor,
|
|
104
|
+
stdin: runtime.stdin,
|
|
105
|
+
stdout: runtime.stdout,
|
|
106
|
+
stderr: runtime.stderr,
|
|
107
|
+
proxyVersion: runtime.version,
|
|
108
|
+
// Only an http upstream can carry a bearer. The source reads nothing until
|
|
109
|
+
// the server answers 401, so a server that wants no token never causes a
|
|
110
|
+
// credential-store lookup at all.
|
|
111
|
+
auth: spec.transport === 'http'
|
|
112
|
+
? createTokenSource(spec.url, {
|
|
113
|
+
onLookup: (outcome) => logger.info('credential lookup', { outcome }),
|
|
114
|
+
})
|
|
115
|
+
: undefined,
|
|
116
|
+
afterInitialize: backgroundSyncOff && !built.lifecycle
|
|
117
|
+
? undefined
|
|
118
|
+
: async (client) => {
|
|
119
|
+
built.lifecycle?.start(client);
|
|
120
|
+
if (!backgroundSyncOff)
|
|
121
|
+
await backgroundSync(options, runtime, logger);
|
|
122
|
+
},
|
|
123
|
+
onExit: built.lifecycle ? () => built.lifecycle?.stop() : undefined,
|
|
124
|
+
agentInitializeDeadlineMs: positiveMs(runtime.env[`${PROXY_ENV_PREFIX}INIT_DEADLINE_MS`]),
|
|
125
|
+
upstreamInitializeTimeoutMs: positiveMs(runtime.env[`${PROXY_ENV_PREFIX}UPSTREAM_INIT_TIMEOUT_MS`]),
|
|
126
|
+
});
|
|
127
|
+
const register = runtime.onSignal ?? ((handler) => {
|
|
128
|
+
process.on('SIGINT', () => handler('SIGINT'));
|
|
129
|
+
process.on('SIGTERM', () => handler('SIGTERM'));
|
|
130
|
+
});
|
|
131
|
+
register((signal) => {
|
|
132
|
+
logger.info('received a signal', { signal });
|
|
133
|
+
proxy.shutdown(0);
|
|
134
|
+
});
|
|
135
|
+
return proxy.run();
|
|
136
|
+
}
|
|
137
|
+
/** An override is honoured only when it is a positive number of milliseconds. */
|
|
138
|
+
function positiveMs(value) {
|
|
139
|
+
if (!value)
|
|
140
|
+
return undefined;
|
|
141
|
+
const parsed = Number(value);
|
|
142
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* May this proxy rewrite the clients' configs?
|
|
146
|
+
*
|
|
147
|
+
* Only when all three hold: it was spawned from a wrapped entry (`--name`,
|
|
148
|
+
* not an ad hoc `--upstream` typed by a human), the user explicitly installed
|
|
149
|
+
* the proxy (the `installed` marker), and the binary running is the one
|
|
150
|
+
* `vibedefend` resolves to on the PATH — so the entries it would write point
|
|
151
|
+
* at itself. A checkout's `node dist/index.js` fails the third, whatever the
|
|
152
|
+
* marker says: measured on 2026-09-08, it wrapped twelve real servers behind
|
|
153
|
+
* a global release that had no `mcp` command.
|
|
154
|
+
*/
|
|
155
|
+
function backgroundSyncPermission(options, runtime) {
|
|
156
|
+
if (!options.name)
|
|
157
|
+
return 'ad-hoc';
|
|
158
|
+
if (!isProxyInstalled(runtime.env))
|
|
159
|
+
return 'not-installed';
|
|
160
|
+
const check = checkProxyBinary({ env: runtime.env, argv1: runtime.argv1 ?? process.argv[1] });
|
|
161
|
+
if (!check.matches)
|
|
162
|
+
return check.reason ?? 'different-binary';
|
|
163
|
+
return 'granted';
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* The background `sync` the plan asks the proxy to run at startup.
|
|
167
|
+
*
|
|
168
|
+
* It exists so that a server added with `claude mcp add` mid-week ends up
|
|
169
|
+
* behind the proxy without anyone remembering a command. Three things make it
|
|
170
|
+
* safe to run from here:
|
|
171
|
+
*
|
|
172
|
+
* - the permission above, checked first and logged when refused;
|
|
173
|
+
* - the lock. One proxy runs per MCP server, so five of them start within
|
|
174
|
+
* the same second and would otherwise all rewrite `~/.claude.json` at
|
|
175
|
+
* once; whoever gets the lock does the work and the rest do nothing.
|
|
176
|
+
* - no backup. A timestamped copy per session, per server, would fill the
|
|
177
|
+
* user's home with files nobody asked for. The originals are in
|
|
178
|
+
* `upstreams.json`, which is what `uninstall` restores from anyway.
|
|
179
|
+
*
|
|
180
|
+
* Every failure is logged and swallowed: an MCP session must not end because
|
|
181
|
+
* a config file could not be rewritten.
|
|
182
|
+
*/
|
|
183
|
+
async function backgroundSync(options, runtime, logger) {
|
|
184
|
+
const env = runtime.env;
|
|
185
|
+
const permission = backgroundSyncPermission(options, runtime);
|
|
186
|
+
if (permission !== 'granted') {
|
|
187
|
+
// An ad hoc launch is routine; the other two mean an installed proxy that
|
|
188
|
+
// cannot do its job, which somebody reading the log should see.
|
|
189
|
+
logger[permission === 'ad-hoc' ? 'debug' : 'info']('background sync skipped', {
|
|
190
|
+
reason: permission,
|
|
191
|
+
});
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const ran = await withSyncLock(() => {
|
|
195
|
+
const plan = planSync({ env });
|
|
196
|
+
const result = applySyncPlan(plan, { env, backup: false });
|
|
197
|
+
return { plan, result };
|
|
198
|
+
}, { env });
|
|
199
|
+
if (!ran) {
|
|
200
|
+
logger.debug('background sync skipped: another process holds the lock');
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const wrapped = ran.plan.changes.filter((change) => change.kind === 'wrap').length;
|
|
204
|
+
const forgotten = ran.plan.changes.filter((change) => change.kind === 'forget').length;
|
|
205
|
+
if (wrapped === 0 && forgotten === 0 && ran.result.failed.length === 0) {
|
|
206
|
+
logger.debug('background sync: nothing to do');
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
logger.info('background sync', {
|
|
210
|
+
wrapped,
|
|
211
|
+
forgotten,
|
|
212
|
+
failed: ran.result.failed.length,
|
|
213
|
+
files: ran.result.written,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* The interceptors, in the order they see a message.
|
|
218
|
+
*
|
|
219
|
+
* Auth first: an http upstream that refuses every token gets `initialize`
|
|
220
|
+
* answered by the proxy and a tool list reduced to
|
|
221
|
+
* `vibedefend_connect_required`, and verification has nothing to say about a
|
|
222
|
+
* list the proxy wrote itself. It is wired whatever `VIBEDEFEND_MCP_NO_VERIFY`
|
|
223
|
+
* says, because it is not verification: it is section 0's rule that
|
|
224
|
+
* `initialize` is always answered.
|
|
225
|
+
*/
|
|
226
|
+
function buildInterceptor(spec, identitySpec, name, logger, runtime, fallbackClientName) {
|
|
227
|
+
const interceptors = [];
|
|
228
|
+
if (spec.transport === 'http') {
|
|
229
|
+
interceptors.push(createAuthInterceptor({
|
|
230
|
+
// Displayed, so the stored form: an expanded url would print the
|
|
231
|
+
// value of the reference into the agent's context.
|
|
232
|
+
serverName: name ?? describeUpstream(identitySpec),
|
|
233
|
+
connectCommand: connectCommandFor({ name, spec: identitySpec }),
|
|
234
|
+
proxyVersion: runtime.version,
|
|
235
|
+
logger,
|
|
236
|
+
}));
|
|
237
|
+
}
|
|
238
|
+
const verify = buildVerifyInterceptor(identitySpec, name, logger, runtime, fallbackClientName);
|
|
239
|
+
if (verify)
|
|
240
|
+
interceptors.push(verify.interceptor);
|
|
241
|
+
const lifecycle = verify?.lifecycle;
|
|
242
|
+
if (interceptors.length === 0)
|
|
243
|
+
return { lifecycle };
|
|
244
|
+
return {
|
|
245
|
+
interceptor: interceptors.length === 1 ? interceptors[0] : chain(interceptors),
|
|
246
|
+
lifecycle,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* The verification seam, wired to the local cache and to the CybeDefend
|
|
251
|
+
* backend — through `buildVerifier`, the same wiring `vibedefend scan` uses,
|
|
252
|
+
* so what one buys the other finds.
|
|
253
|
+
*
|
|
254
|
+
* `VIBEDEFEND_MCP_NO_VERIFY=1` takes it out entirely, which is what the
|
|
255
|
+
* Phase 1 conformance suite runs with: those tests assert that the proxy is
|
|
256
|
+
* indistinguishable from the server, and a `vibedefend_alert` appended to a
|
|
257
|
+
* tool list is, correctly, a difference.
|
|
258
|
+
*/
|
|
259
|
+
function buildVerifyInterceptor(spec, name, logger, runtime, fallbackClientName) {
|
|
260
|
+
if (runtime.env[`${PROXY_ENV_PREFIX}NO_VERIFY`] === '1') {
|
|
261
|
+
logger.info('verification disabled by the environment');
|
|
262
|
+
return undefined;
|
|
263
|
+
}
|
|
264
|
+
// No credential means no backend call, and the cache alone decides. That
|
|
265
|
+
// is a supported state, not a degraded one: a machine with a blacklisted
|
|
266
|
+
// server in its cache still refuses it. No network here: an organization
|
|
267
|
+
// that is not persisted yet is resolved at the first verification, after
|
|
268
|
+
// `initialize` has been answered (section 0).
|
|
269
|
+
const { verifier, serverId, serverName, backend } = buildVerifier(spec, name ?? describeUpstream(spec), logger, runtime.env);
|
|
270
|
+
logger.info('verification enabled', {
|
|
271
|
+
serverId,
|
|
272
|
+
backend: backend !== null,
|
|
273
|
+
organization: backend?.organizationId ? 'persisted' : backend ? 'resolved-at-first-call' : 'none',
|
|
274
|
+
});
|
|
275
|
+
const env = runtime.env;
|
|
276
|
+
// What a report says of this server: a host, a package or a label, and a
|
|
277
|
+
// key. A URL that does not canonicalise gives no identity and no report.
|
|
278
|
+
const identity = reportServerIdentity(spec, name);
|
|
279
|
+
const reporter = identity
|
|
280
|
+
? new McpReporter({
|
|
281
|
+
identity,
|
|
282
|
+
vibedefendVersion: runtime.version,
|
|
283
|
+
fallbackClientName,
|
|
284
|
+
snapshot: () => verifier.inventorySnapshot(),
|
|
285
|
+
backendContext: () => verifier.backendContext(),
|
|
286
|
+
projectId: (clientName) => resolveReportProjectId({ env, clientName }),
|
|
287
|
+
buffer: makeReportBuffer({ env }),
|
|
288
|
+
post: (ctx, body) => postMcpReport(ctx, body, { resolveTokenFn: verifyTokenResolver({ env }) }),
|
|
289
|
+
logger,
|
|
290
|
+
firstDelayMs: positiveMs(env[`${PROXY_ENV_PREFIX}REPORT_DELAY_MS`]),
|
|
291
|
+
minIntervalMs: positiveMs(env[`${PROXY_ENV_PREFIX}REPORT_MIN_INTERVAL_MS`]),
|
|
292
|
+
})
|
|
293
|
+
: undefined;
|
|
294
|
+
const verify = createVerifyInterceptor({
|
|
295
|
+
verifier,
|
|
296
|
+
logger,
|
|
297
|
+
spec,
|
|
298
|
+
serverId,
|
|
299
|
+
serverName,
|
|
300
|
+
// Sizes and rule names, never arguments and never results: the plan's
|
|
301
|
+
// rule is that nothing from a `tools/call` leaves the machine, and a file
|
|
302
|
+
// quoting them would be a second copy of everything the user has done.
|
|
303
|
+
audit: createAudit({ env }),
|
|
304
|
+
report: reporter,
|
|
305
|
+
});
|
|
306
|
+
return {
|
|
307
|
+
interceptor: verify,
|
|
308
|
+
lifecycle: createSessionLifecycle({
|
|
309
|
+
reporter,
|
|
310
|
+
refreshServerGate: () => verify.refreshServerGate(),
|
|
311
|
+
startTimer: (onChange) => startServerCheckTimer({
|
|
312
|
+
verifier,
|
|
313
|
+
logger,
|
|
314
|
+
intervalMs: positiveMs(env[`${PROXY_ENV_PREFIX}SERVER_CHECK_INTERVAL_MS`]),
|
|
315
|
+
onChange,
|
|
316
|
+
}),
|
|
317
|
+
}),
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
//# sourceMappingURL=proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.js","sourceRo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