@happyvertical/smrt-app-cli 0.60.18 → 0.61.1
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 +35 -0
- package/dist/bin/smrt-app.js +1 -1
- package/dist/bin/smrt-mcp-bridge.js +1 -1
- package/dist/bridge-DT70h9LR.js +2 -0
- package/dist/bridge.d.ts +2 -0
- package/dist/bridge.d.ts.map +1 -1
- package/dist/commands/mcp.d.ts +21 -4
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/{config-B9dESami.js → config-DynygNnu.js} +60 -9
- package/dist/config.d.ts +10 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/desktop-plugins.d.ts +16 -0
- package/dist/desktop-plugins.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/{src-DjROuXuC.js → src-C8vwCeRO.js} +221 -27
- package/package.json +3 -3
- package/dist/bridge-Bl1p3Oun.js +0 -2
package/README.md
CHANGED
|
@@ -120,6 +120,30 @@ The stdio bridge carries it in MCP `_meta` under
|
|
|
120
120
|
`io.happyvertical/smrt`. It deliberately does not synthesize MCP
|
|
121
121
|
`structuredContent`.
|
|
122
122
|
|
|
123
|
+
## Remote MCP client commands
|
|
124
|
+
|
|
125
|
+
`<app> mcp tools` lists and `<app> mcp call <tool> '<json>'` invokes tools on a
|
|
126
|
+
deployed app's modern MCP endpoint (Streamable HTTP at exactly `/api/mcp`, or
|
|
127
|
+
`mcpPath`), printing the JSON result. Flags:
|
|
128
|
+
|
|
129
|
+
- `--url <server>` targets a server other than the configured one.
|
|
130
|
+
- `--token-env <NAME>` reads the bearer token from that environment variable.
|
|
131
|
+
The token is never printed: it is scrubbed from stdout and stderr, and
|
|
132
|
+
errors name only the variable. An explicit token requires an HTTPS (or
|
|
133
|
+
loopback) `--url`. Without it the stored login token is used.
|
|
134
|
+
- `--mcp-path <path>` overrides the same-server MCP route.
|
|
135
|
+
- `--legacy-rest` opts in to the deprecated `<mcpPath>/tools` and
|
|
136
|
+
`<mcpPath>/call` REST routes and their result envelope.
|
|
137
|
+
- `--confirm` (`mcp call` only) sets `confirm: true` in the call arguments for
|
|
138
|
+
outbound or destructive tools. It is never added unless passed, and the
|
|
139
|
+
arguments must be a JSON object. A `"confirm": true` already present in
|
|
140
|
+
the JSON passes through unchanged.
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
WORK_OWNER_TOKEN=... acme mcp call send_invoice '{"id":"inv_1"}' \
|
|
144
|
+
--url https://work.example.com --token-env WORK_OWNER_TOKEN --confirm
|
|
145
|
+
```
|
|
146
|
+
|
|
123
147
|
## Add an app-specific command
|
|
124
148
|
|
|
125
149
|
```ts
|
|
@@ -292,3 +316,14 @@ Each generated catalog contains one entry. For a shared catalog, merge the
|
|
|
292
316
|
entry into the catalog maintained by the packager. Live installation and
|
|
293
317
|
execution in Claude Desktop and ChatGPT desktop require the production
|
|
294
318
|
launcher and separate host verification.
|
|
319
|
+
|
|
320
|
+
### Generated local-client setup
|
|
321
|
+
|
|
322
|
+
`generateLocalMcpSetup({name,command,args})` renders Claude Code's shell-quoted
|
|
323
|
+
`claude mcp add`, Claude Desktop/`.mcp.json` JSON and Codex TOML for an existing
|
|
324
|
+
owner-authorized stdio launcher. Pass public executable/launcher paths only,
|
|
325
|
+
never a bearer. `CliConfigContext.configPath` lets the app write its private
|
|
326
|
+
connection directly through `saveCliConfig` without mutating process environment.
|
|
327
|
+
Modern stdio bridges advertise `tools.listChanged` and poll the stateless upstream
|
|
328
|
+
catalog every two seconds (including pages). Changed descriptors, revocation and
|
|
329
|
+
recovery invalidate discovery; close clears the timer. No shared catalog cache.
|
package/dist/bin/smrt-app.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { h as runMcpStdioBridge, u as resolveMcpPath } from "../config-
|
|
2
|
+
import { h as runMcpStdioBridge, u as resolveMcpPath } from "../config-DynygNnu.js";
|
|
3
3
|
//#region src/bridge-args.ts
|
|
4
4
|
/**
|
|
5
5
|
* Argument parsing for the generic `smrt-mcp-bridge` binary. Every value
|
package/dist/bridge.d.ts
CHANGED
|
@@ -51,6 +51,8 @@ export interface McpStdioBridgeOptions extends CliConfigContext {
|
|
|
51
51
|
* Override fetch implementation (used by tests so we never hit the network).
|
|
52
52
|
*/
|
|
53
53
|
fetch?: typeof fetch;
|
|
54
|
+
/** Re-list a stateless upstream and notify stdio clients. Default 2 seconds. */
|
|
55
|
+
catalogPollMs?: number;
|
|
54
56
|
}
|
|
55
57
|
/**
|
|
56
58
|
* Wire up the stdio server. Use `runMcpStdioBridge` for a one-call entry
|
package/dist/bridge.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAOH,OAAO,EAEL,KAAK,cAAc,EAGnB,aAAa,EAEb,MAAM,EACP,MAAM,8BAA8B,CAAC;AAKtC,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EAIrB,KAAK,iBAAiB,EAIvB,MAAM,aAAa,CAAC;AAErB,oEAAoE;AACpE,OAAO,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AAYtF;;;;;GAKG;AACH,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC7D,uDAAuD;IACvD,UAAU,EAAE;QACV,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2EAA2E;IAC3E,SAAS,CAAC,EAAE,KAAK,GAAG,aAAa,CAAC;IAClC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;O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C7B,aAAa,CAOf;AAiCD;;;GAGG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAIf"}
|
package/dist/commands/mcp.d.ts
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `<name> mcp tools` / `<name> mcp call <tool> '<json>'` — thin HTTP
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* `<name> mcp tools` / `<name> mcp call <tool> '<json>'` — thin HTTP client
|
|
3
|
+
* for a deployed app's modern MCP endpoint (`<mcpPath>`, Streamable HTTP) or,
|
|
4
|
+
* with `--legacy-rest`, its `<mcpPath>/tools` and `<mcpPath>/call`. The stdio
|
|
5
|
+
* bridge lives in `bin/smrt-mcp-bridge` and `bridge.ts`; these are the
|
|
6
|
+
* equivalent one-shot HTTP commands for ad-hoc inspection and owner tooling.
|
|
7
|
+
*
|
|
8
|
+
* Flags (either subcommand):
|
|
9
|
+
* - `--url <server>` target server (default: configured server URL)
|
|
10
|
+
* - `--token-env <NAME>` read the bearer token from this env var; the token
|
|
11
|
+
* is never printed and is scrubbed from all output
|
|
12
|
+
* - `--mcp-path <path>` same-server MCP route (default `/api/mcp`)
|
|
13
|
+
* - `--legacy-rest` use the deprecated `<mcpPath>/tools` and
|
|
14
|
+
* `<mcpPath>/call` REST routes instead of the modern
|
|
15
|
+
* MCP endpoint at exactly `<mcpPath>`
|
|
16
|
+
* `mcp call` only:
|
|
17
|
+
* - `--confirm` inject `confirm: true` into the call arguments for
|
|
18
|
+
* outbound/destructive tools; never added implicitly
|
|
6
19
|
*
|
|
7
20
|
* @packageDocumentation
|
|
8
21
|
*/
|
|
@@ -12,6 +25,10 @@ export interface McpCommandOptions {
|
|
|
12
25
|
stdout?: NodeJS.WriteStream;
|
|
13
26
|
stderr?: NodeJS.WriteStream;
|
|
14
27
|
fetch?: typeof fetch;
|
|
28
|
+
/** Environment used to resolve `--token-env` (tests). Defaults to `process.env`. */
|
|
29
|
+
env?: NodeJS.ProcessEnv;
|
|
30
|
+
/** Default MCP route when `--mcp-path` is absent (default `/api/mcp`). */
|
|
31
|
+
mcpPath?: string;
|
|
15
32
|
}
|
|
16
33
|
export declare function runMcpCommand(options: McpCommandOptions, args: string[]): Promise<boolean>;
|
|
17
34
|
//# sourceMappingURL=mcp.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/commands/mcp.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/commands/mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAMH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAWrD,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,gBAAgB,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC;IAC5B,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,oFAAoF;IACpF,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAkDD,wBAAsB,aAAa,CACjC,OAAO,EAAE,iBAAiB,EAC1B,IAAI,EAAE,MAAM,EAAE,GACb,OAAO,CAAC,OAAO,CAAC,CAuHlB"}
|
|
@@ -78,7 +78,7 @@ function createModernBridge(options) {
|
|
|
78
78
|
const path = resolveMcpPath(options.mcpPath);
|
|
79
79
|
const server = new Server(options.serverInfo, {
|
|
80
80
|
capabilities: {
|
|
81
|
-
tools: {},
|
|
81
|
+
tools: { listChanged: true },
|
|
82
82
|
resources: {}
|
|
83
83
|
},
|
|
84
84
|
cacheHints: { "tools/list": {
|
|
@@ -112,11 +112,58 @@ function createModernBridge(options) {
|
|
|
112
112
|
await client.close().catch(() => void 0);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
115
|
+
let catalog;
|
|
116
|
+
let timer;
|
|
117
|
+
let closed = false;
|
|
118
|
+
const pollMs = options.catalogPollMs ?? 2e3;
|
|
119
|
+
if (!Number.isSafeInteger(pollMs) || pollMs < 10) throw new TypeError("Invalid catalog polling interval");
|
|
120
|
+
const fingerprint = (result) => JSON.stringify([...result.tools].sort((a, b) => compareToolNames(a.name, b.name)));
|
|
121
|
+
function schedule() {
|
|
122
|
+
if (closed || timer) return;
|
|
123
|
+
timer = setTimeout(async () => {
|
|
124
|
+
timer = void 0;
|
|
125
|
+
try {
|
|
126
|
+
const next = fingerprint(await forward(async (client) => {
|
|
127
|
+
const tools = [];
|
|
128
|
+
const cursors = /* @__PURE__ */ new Set();
|
|
129
|
+
let cursor;
|
|
130
|
+
do {
|
|
131
|
+
const page = await client.listTools(cursor ? { cursor } : void 0);
|
|
132
|
+
tools.push(...page.tools);
|
|
133
|
+
cursor = page.nextCursor;
|
|
134
|
+
if (cursor && (cursors.has(cursor) || cursors.size >= 100)) throw new Error("Invalid catalog pagination");
|
|
135
|
+
if (cursor) cursors.add(cursor);
|
|
136
|
+
} while (cursor);
|
|
137
|
+
return { tools };
|
|
138
|
+
}));
|
|
139
|
+
const changed = catalog !== void 0 && next !== catalog;
|
|
140
|
+
catalog = next;
|
|
141
|
+
if (changed) await server.sendToolListChanged();
|
|
142
|
+
} catch {
|
|
143
|
+
if (catalog !== void 0 && catalog !== null) {
|
|
144
|
+
catalog = null;
|
|
145
|
+
await server.sendToolListChanged().catch(() => void 0);
|
|
146
|
+
}
|
|
147
|
+
} finally {
|
|
148
|
+
schedule();
|
|
149
|
+
}
|
|
150
|
+
}, pollMs);
|
|
151
|
+
timer.unref();
|
|
152
|
+
}
|
|
153
|
+
server.onclose = () => {
|
|
154
|
+
closed = true;
|
|
155
|
+
if (timer) clearTimeout(timer);
|
|
156
|
+
};
|
|
157
|
+
server.setRequestHandler("tools/list", (request) => forward(async (client) => {
|
|
158
|
+
const result = await client.listTools(request.params);
|
|
159
|
+
if (!request.params?.cursor && !result.nextCursor) catalog = fingerprint(result);
|
|
160
|
+
schedule();
|
|
161
|
+
return {
|
|
162
|
+
...result,
|
|
163
|
+
ttlMs: 0,
|
|
164
|
+
cacheScope: "private"
|
|
165
|
+
};
|
|
166
|
+
}));
|
|
120
167
|
server.setRequestHandler("tools/call", (request) => forward((client) => client.callTool(request.params)));
|
|
121
168
|
server.setRequestHandler("resources/list", (request) => forward(async (client) => ({
|
|
122
169
|
...await client.listResources(request.params),
|
|
@@ -253,6 +300,7 @@ function normalizeServerUrl(context, value) {
|
|
|
253
300
|
return normalized;
|
|
254
301
|
}
|
|
255
302
|
function configFilePath(context) {
|
|
303
|
+
if (context.configPath) return context.configPath;
|
|
256
304
|
const override = process.env[`${context.envPrefix}_CLI_CONFIG`];
|
|
257
305
|
if (override) return override;
|
|
258
306
|
const slug = context.appSlug ?? context.envPrefix.toLowerCase();
|
|
@@ -369,7 +417,8 @@ async function requestJson(context, path, init = {}, options = {}) {
|
|
|
369
417
|
async function requestJsonResult(context, path, init = {}, options = {}) {
|
|
370
418
|
const config = options.loadedConfig ?? await loadCliConfig(context);
|
|
371
419
|
const serverUrl = normalizeServerUrl(context, options.serverUrl ?? await getServerUrl(context, config));
|
|
372
|
-
|
|
420
|
+
if (options.token) assertSecureServerUrl(serverUrl);
|
|
421
|
+
const token = options.token || await getStoredToken(context, config, serverUrl);
|
|
373
422
|
const headers = new Headers(init.headers);
|
|
374
423
|
if (options.requireAuth && options.auth !== false && !token) return failure(401, {
|
|
375
424
|
code: "not_authenticated",
|
|
@@ -383,12 +432,14 @@ async function requestJsonResult(context, path, init = {}, options = {}) {
|
|
|
383
432
|
try {
|
|
384
433
|
response = await fetchImpl(`${serverUrl}${path}`, {
|
|
385
434
|
...init,
|
|
386
|
-
headers
|
|
435
|
+
headers,
|
|
436
|
+
redirect: "error",
|
|
437
|
+
signal: init.signal ?? AbortSignal.timeout(options.timeoutMs ?? 3e4)
|
|
387
438
|
});
|
|
388
439
|
} catch (error) {
|
|
389
440
|
return failure(0, {
|
|
390
441
|
code: "network_error",
|
|
391
|
-
message: redactMessage(error instanceof Error ? error.message : String(error)),
|
|
442
|
+
message: error instanceof Error && error.name === "TimeoutError" ? "Request timed out." : redactMessage(error instanceof Error ? error.message : String(error)),
|
|
392
443
|
retryable: true
|
|
393
444
|
});
|
|
394
445
|
}
|
package/dist/config.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ export interface CliConfig {
|
|
|
29
29
|
* - `${PREFIX}_CLI_CONFIG` (overrides config file path)
|
|
30
30
|
*/
|
|
31
31
|
export interface CliConfigContext {
|
|
32
|
+
/** Explicit private config path for an application-generated connection. */
|
|
33
|
+
configPath?: string;
|
|
32
34
|
/**
|
|
33
35
|
* Uppercase prefix for env vars and the app's namespaced config dir.
|
|
34
36
|
* Example: `WILLGRIFFIN` → reads `WILLGRIFFIN_SERVER_URL`, defaults the
|
|
@@ -86,6 +88,12 @@ export interface RequestJsonOptions {
|
|
|
86
88
|
requireAuth?: boolean;
|
|
87
89
|
/** Override the server URL for this request. */
|
|
88
90
|
serverUrl?: string;
|
|
91
|
+
/**
|
|
92
|
+
* Explicit bearer token for this request (for example read from an env var
|
|
93
|
+
* the operator named). Takes precedence over the stored login token and is
|
|
94
|
+
* never persisted.
|
|
95
|
+
*/
|
|
96
|
+
token?: string;
|
|
89
97
|
/** Override the fetch implementation (tests). */
|
|
90
98
|
fetch?: typeof fetch;
|
|
91
99
|
/**
|
|
@@ -98,6 +106,8 @@ export interface RequestJsonOptions {
|
|
|
98
106
|
* (#1311 review A4.)
|
|
99
107
|
*/
|
|
100
108
|
maxResponseBytes?: number;
|
|
109
|
+
/** Abort the request after this many ms (default 30000). */
|
|
110
|
+
timeoutMs?: number;
|
|
101
111
|
/**
|
|
102
112
|
* Pre-loaded config to avoid re-reading from disk. Set by callers that
|
|
103
113
|
* already have it (e.g. `buildAppContext`); leave undefined for the
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAaH,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EAEpB,MAAM,wCAAwC,CAAC;AAGhD,yDAAyD;AACzD,MAAM,WAAW,SAAS;IACxB,2DAA2D;IAC3D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iFAAiF;IACjF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8DAA8D;IAC9D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;OAEG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC;AAID;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAYhE;AAED,gFAAgF;AAChF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAoBzD;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAaH,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EAEpB,MAAM,wCAAwC,CAAC;AAGhD,yDA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CAAC,CAAC,GAAG,kBAAkB,CAAC;AAE9E,0EAA0E;AAC1E,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAC;gBAE5B,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB;CAM3D;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,CAAC,GAAG,OAAO,EAC3C,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,WAAgB,EACtB,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,CAAC,CAAC,CAMZ;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,GAAG,OAAO,EACjD,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,WAAgB,EACtB,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CA4G/B;AAED,gFAAgF;AAChF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAW5D;AAqKD,OAAO,EACL,oBAAoB,EACpB,KAAK,qBAAqB,EAC1B,iBAAiB,GAClB,MAAM,aAAa,CAAC"}
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/** Secret-free setup for an owner-authorized local stdio launcher. */
|
|
2
|
+
export declare function generateLocalMcpSetup(input: {
|
|
3
|
+
name: string;
|
|
4
|
+
command: string;
|
|
5
|
+
args: string[];
|
|
6
|
+
}): {
|
|
7
|
+
claudeCode: string;
|
|
8
|
+
claudeDesktop: string;
|
|
9
|
+
mcpJson: string;
|
|
10
|
+
codex: string;
|
|
11
|
+
chatgpt: string;
|
|
12
|
+
entry: {
|
|
13
|
+
command: string;
|
|
14
|
+
args: string[];
|
|
15
|
+
};
|
|
16
|
+
};
|
|
1
17
|
export interface DesktopPluginLauncher {
|
|
2
18
|
/** Platform of the packaged executable. */
|
|
3
19
|
readonly platform: 'darwin' | 'win32' | 'linux';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"desktop-plugins.d.ts","sourceRoot":"","sources":["../src/desktop-plugins.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,qBAAqB;IACpC,2CAA2C;IAC3C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;IAChD,8EAA8E;IAC9E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAmDD;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,eAAe,EAAE,OAAO,EACxB,QAAQ,EAAE,qBAAqB,GAC9B,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA2GlC"}
|
|
1
|
+
{"version":3,"file":"desktop-plugins.d.ts","sourceRoot":"","sources":["../src/desktop-plugins.ts"],"names":[],"mappings":"AAOA,sEAAsE;AACtE,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;;;;;;;;;;EAsBA;AAED,MAAM,WAAW,qBAAqB;IACpC,2CAA2C;IAC3C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;IAChD,8EAA8E;IAC9E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAmDD;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,eAAe,EAAE,OAAO,EACxB,QAAQ,EAAE,qBAAqB,GAC9B,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA2GlC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import { type CliConfig, type RequestJsonOptions } from './config.js';
|
|
19
19
|
export { AppCliRequestError, type AppCliResultMetadata, assertSecureServerUrl, type CliConfig, type CliConfigContext, clearStoredToken, getServerUrl, getStoredToken, loadCliConfig, type RequestJsonOptions, type RequestJsonResult, redactTransportValue, requestJson, requestJsonResult, saveAuth, saveCliConfig, } from './config.js';
|
|
20
20
|
import { type ResourceListResponse } from './discovery.js';
|
|
21
|
-
export { type DesktopPluginLauncher, generateDesktopPluginArtifacts, } from './desktop-plugins.js';
|
|
21
|
+
export { type DesktopPluginLauncher, generateDesktopPluginArtifacts, generateLocalMcpSetup, } from './desktop-plugins.js';
|
|
22
22
|
export { type CliResource, type CommandDefinition, type CommandKind, type CommandScope, fetchResourceList, findCommand, findResourceBySlug, type ResourceListResponse, } from './discovery.js';
|
|
23
23
|
export { buildUrl, invokeCommand } from './invoke.js';
|
|
24
24
|
export { createMcpClientIdMetadataDocument, type McpClientIdMetadataDocument, type McpClientRegistration, type McpClientRegistrationOptions, type McpRegisteredClient, type OAuthApplicationType, type OAuthAuthorizationServerMetadata, registerMcpClient, resolveMcpClientRegistration, } from './mcp-oauth.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACL,KAAK,SAAS,EAKd,KAAK,kBAAkB,EAExB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,kBAAkB,EAClB,KAAK,oBAAoB,EACzB,qBAAqB,EACrB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,aAAa,EACb,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,oBAAoB,EACpB,WAAW,EACX,iBAAiB,EACjB,QAAQ,EACR,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,OAAO,EAIL,KAAK,oBAAoB,EAC1B,MAAM,gBAAgB,CAAC;AAEx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IACnE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wEAAwE;IACxE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qEAAqE;IACrE,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;;;;;;;;;;;OAiBG;IACH,aAAa,CAAC,EAAE,aAAa,EAAE,CAAC;CACjC;AAED,MAAM,WAAW,MAAM;IACrB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC;;;;;;OAMG;IACH,cAAc,CAAC,UAAU,CAAC,EAAE;QAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,mFAAmF;QACnF,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnB;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CA8BjE"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as getStoredToken, c as requestJson, d as saveAuth, f as saveCliConfig, h as runMcpStdioBridge, i as getServerUrl, l as requestJsonResult, n as assertSecureServerUrl, o as loadCliConfig, p as createMcpStdioBridge, r as clearStoredToken, s as redactTransportValue, t as AppCliRequestError } from "./config-
|
|
2
|
-
import { a as buildFlagParser, c as createMcpClientIdMetadataDocument, d as buildUrl, f as invokeCommand, g as
|
|
3
|
-
export { AppCliRequestError, SMRT_MCP_RESULT_METADATA_KEY, assertSecureServerUrl, buildFlagParser, buildUrl, classifySchema, clearStoredToken, createAppCli, createMcpClientIdMetadataDocument, createMcpStdioBridge, fetchResourceList, findCommand, findResourceBySlug, generateDesktopPluginArtifacts, getServerUrl, getStoredToken, invokeCommand, loadCliConfig, parseAppCliExecutableConfig, redactTransportValue, registerMcpClient, renderResponse, requestJson, requestJsonResult, resolveMcpClientRegistration, runAppCliExecutable, runMcpStdioBridge, saveAuth, saveCliConfig };
|
|
1
|
+
import { a as getStoredToken, c as requestJson, d as saveAuth, f as saveCliConfig, h as runMcpStdioBridge, i as getServerUrl, l as requestJsonResult, n as assertSecureServerUrl, o as loadCliConfig, p as createMcpStdioBridge, r as clearStoredToken, s as redactTransportValue, t as AppCliRequestError } from "./config-DynygNnu.js";
|
|
2
|
+
import { _ as findResourceBySlug, a as buildFlagParser, c as createMcpClientIdMetadataDocument, d as buildUrl, f as invokeCommand, g as findCommand, h as fetchResourceList, i as runAppCliExecutable, l as registerMcpClient, m as generateLocalMcpSetup, n as createAppCli, o as classifySchema, p as generateDesktopPluginArtifacts, r as parseAppCliExecutableConfig, s as renderResponse, t as SMRT_MCP_RESULT_METADATA_KEY, u as resolveMcpClientRegistration } from "./src-C8vwCeRO.js";
|
|
3
|
+
export { AppCliRequestError, SMRT_MCP_RESULT_METADATA_KEY, assertSecureServerUrl, buildFlagParser, buildUrl, classifySchema, clearStoredToken, createAppCli, createMcpClientIdMetadataDocument, createMcpStdioBridge, fetchResourceList, findCommand, findResourceBySlug, generateDesktopPluginArtifacts, generateLocalMcpSetup, getServerUrl, getStoredToken, invokeCommand, loadCliConfig, parseAppCliExecutableConfig, redactTransportValue, registerMcpClient, renderResponse, requestJson, requestJsonResult, resolveMcpClientRegistration, runAppCliExecutable, runMcpStdioBridge, saveAuth, saveCliConfig };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { a as getStoredToken, c as requestJson, d as saveAuth, i as getServerUrl, l as requestJsonResult, n as assertSecureServerUrl, o as loadCliConfig, r as clearStoredToken, u as resolveMcpPath } from "./config-
|
|
1
|
+
import { a as getStoredToken, c as requestJson, d as saveAuth, i as getServerUrl, l as requestJsonResult, n as assertSecureServerUrl, o as loadCliConfig, r as clearStoredToken, s as redactTransportValue, u as resolveMcpPath } from "./config-DynygNnu.js";
|
|
2
2
|
import { SMRT_MCP_RESULT_METADATA_KEY as SMRT_MCP_RESULT_METADATA_KEY$1, validateDiscoveryConformanceArtifact } from "@happyvertical/smrt-users/app-contract";
|
|
3
|
+
import { Client, StreamableHTTPClientTransport } from "@modelcontextprotocol/client";
|
|
3
4
|
import { spawn, spawnSync } from "node:child_process";
|
|
4
5
|
//#region src/discovery.ts
|
|
5
6
|
/**
|
|
@@ -63,6 +64,23 @@ var PLUGIN_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
|
63
64
|
var SEMVER = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?$/;
|
|
64
65
|
var PORTABLE_SEGMENT = /^[a-zA-Z0-9_-]+(?:\.[a-zA-Z0-9_-]+)*$/;
|
|
65
66
|
var WINDOWS_DEVICE = /^(?:con|prn|aux|nul|com[0-9]|lpt[0-9])(?:\.|$)/i;
|
|
67
|
+
/** Secret-free setup for an owner-authorized local stdio launcher. */
|
|
68
|
+
function generateLocalMcpSetup(input) {
|
|
69
|
+
if (!PLUGIN_NAME.test(input.name) || !input.command || [input.command, ...input.args].some((value) => /[\r\n\0]/u.test(value))) throw new Error("Invalid local MCP launcher configuration");
|
|
70
|
+
const entry = {
|
|
71
|
+
command: input.command,
|
|
72
|
+
args: input.args
|
|
73
|
+
};
|
|
74
|
+
const quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
75
|
+
return {
|
|
76
|
+
claudeCode: `claude mcp add --transport stdio --scope local ${quote(input.name)} -- ${[input.command, ...input.args].map(quote).join(" ")}`,
|
|
77
|
+
claudeDesktop: JSON.stringify({ mcpServers: { [input.name]: entry } }, null, 2),
|
|
78
|
+
mcpJson: JSON.stringify({ mcpServers: { [input.name]: entry } }, null, 2),
|
|
79
|
+
codex: `[mcp_servers.${input.name}]\ncommand = ${JSON.stringify(input.command)}\nargs = ${JSON.stringify(input.args)}\n`,
|
|
80
|
+
chatgpt: "ChatGPT remote connectors cannot reach this local loopback app. ChatGPT desktop local execution is not verified for this app; the MCP Apps and OpenAI view adapters alone do not connect it. Use Codex, Claude Code or Claude Desktop here.",
|
|
81
|
+
entry
|
|
82
|
+
};
|
|
83
|
+
}
|
|
66
84
|
function object(value, field) {
|
|
67
85
|
if (value === null || typeof value !== "object" || Array.isArray(value)) throw new Error(`Desktop plugin ${field} must be an object`);
|
|
68
86
|
return value;
|
|
@@ -894,38 +912,213 @@ function openVerificationUrl(url) {
|
|
|
894
912
|
}
|
|
895
913
|
//#endregion
|
|
896
914
|
//#region src/commands/mcp.ts
|
|
915
|
+
/**
|
|
916
|
+
* `<name> mcp tools` / `<name> mcp call <tool> '<json>'` — thin HTTP client
|
|
917
|
+
* for a deployed app's modern MCP endpoint (`<mcpPath>`, Streamable HTTP) or,
|
|
918
|
+
* with `--legacy-rest`, its `<mcpPath>/tools` and `<mcpPath>/call`. The stdio
|
|
919
|
+
* bridge lives in `bin/smrt-mcp-bridge` and `bridge.ts`; these are the
|
|
920
|
+
* equivalent one-shot HTTP commands for ad-hoc inspection and owner tooling.
|
|
921
|
+
*
|
|
922
|
+
* Flags (either subcommand):
|
|
923
|
+
* - `--url <server>` target server (default: configured server URL)
|
|
924
|
+
* - `--token-env <NAME>` read the bearer token from this env var; the token
|
|
925
|
+
* is never printed and is scrubbed from all output
|
|
926
|
+
* - `--mcp-path <path>` same-server MCP route (default `/api/mcp`)
|
|
927
|
+
* - `--legacy-rest` use the deprecated `<mcpPath>/tools` and
|
|
928
|
+
* `<mcpPath>/call` REST routes instead of the modern
|
|
929
|
+
* MCP endpoint at exactly `<mcpPath>`
|
|
930
|
+
* `mcp call` only:
|
|
931
|
+
* - `--confirm` inject `confirm: true` into the call arguments for
|
|
932
|
+
* outbound/destructive tools; never added implicitly
|
|
933
|
+
*
|
|
934
|
+
* @packageDocumentation
|
|
935
|
+
*/
|
|
936
|
+
var USAGE = "Usage: mcp tools [flags] | mcp call <tool> [<json>] [--confirm] [flags]\nFlags: --url <server> --token-env <ENV_NAME> --mcp-path <path> --legacy-rest";
|
|
937
|
+
function parseMcpArgs(args) {
|
|
938
|
+
const parsed = {
|
|
939
|
+
positionals: [],
|
|
940
|
+
confirm: false,
|
|
941
|
+
legacyRest: false
|
|
942
|
+
};
|
|
943
|
+
const valueFlags = /* @__PURE__ */ new Set([
|
|
944
|
+
"--url",
|
|
945
|
+
"--token-env",
|
|
946
|
+
"--mcp-path"
|
|
947
|
+
]);
|
|
948
|
+
for (let i = 0; i < args.length; i++) {
|
|
949
|
+
const raw = args[i];
|
|
950
|
+
if (raw === "--confirm") {
|
|
951
|
+
parsed.confirm = true;
|
|
952
|
+
continue;
|
|
953
|
+
}
|
|
954
|
+
if (raw === "--legacy-rest") {
|
|
955
|
+
parsed.legacyRest = true;
|
|
956
|
+
continue;
|
|
957
|
+
}
|
|
958
|
+
if (raw.startsWith("--")) {
|
|
959
|
+
const eq = raw.indexOf("=");
|
|
960
|
+
const flag = eq === -1 ? raw : raw.slice(0, eq);
|
|
961
|
+
if (!valueFlags.has(flag)) throw new Error(`Unknown flag ${flag}.\n${USAGE}`);
|
|
962
|
+
const value = eq === -1 ? args[++i] : raw.slice(eq + 1);
|
|
963
|
+
if (!value || value.startsWith("--")) throw new Error(`Flag ${flag} requires a value.`);
|
|
964
|
+
if (flag === "--url") parsed.url = value;
|
|
965
|
+
else if (flag === "--token-env") parsed.tokenEnv = value;
|
|
966
|
+
else parsed.mcpPath = value;
|
|
967
|
+
continue;
|
|
968
|
+
}
|
|
969
|
+
parsed.positionals.push(raw);
|
|
970
|
+
}
|
|
971
|
+
return parsed;
|
|
972
|
+
}
|
|
897
973
|
async function runMcpCommand(options, args) {
|
|
898
974
|
const stdout = options.stdout ?? process.stdout;
|
|
899
975
|
const stderr = options.stderr ?? process.stderr;
|
|
900
|
-
const
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
976
|
+
const parsed = parseMcpArgs(args);
|
|
977
|
+
const [sub, ...rest] = parsed.positionals;
|
|
978
|
+
if (sub !== "tools" && sub !== "call") throw new Error(USAGE);
|
|
979
|
+
if (rest.length > (sub === "call" ? 2 : 0)) throw new Error(`Unexpected extra arguments.\n${USAGE}`);
|
|
980
|
+
if (parsed.confirm && sub !== "call") throw new Error("--confirm is only valid with `mcp call`.");
|
|
981
|
+
let token;
|
|
982
|
+
if (parsed.tokenEnv !== void 0) {
|
|
983
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/u.test(parsed.tokenEnv)) throw new Error("--token-env must be an environment variable name.");
|
|
984
|
+
token = (options.env ?? process.env)[parsed.tokenEnv];
|
|
985
|
+
if (!token) throw new Error(`Environment variable ${parsed.tokenEnv} is not set or is empty.`);
|
|
906
986
|
}
|
|
987
|
+
const base = resolveMcpPath(parsed.mcpPath ?? options.mcpPath).replace(/\/+$/u, "");
|
|
988
|
+
let callArguments;
|
|
989
|
+
let name;
|
|
907
990
|
if (sub === "call") {
|
|
908
|
-
|
|
909
|
-
const payload = args[2] ?? "{}";
|
|
991
|
+
name = rest[0];
|
|
910
992
|
if (!name) throw new Error("Usage: mcp call <tool> [<json>]");
|
|
911
|
-
let parsed;
|
|
912
993
|
try {
|
|
913
|
-
|
|
994
|
+
callArguments = JSON.parse(rest[1] ?? "{}");
|
|
914
995
|
} catch (error) {
|
|
915
996
|
throw new Error(`Could not parse mcp call payload: ${error.message}`);
|
|
916
997
|
}
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
998
|
+
if (parsed.confirm) {
|
|
999
|
+
if (callArguments === null || typeof callArguments !== "object" || Array.isArray(callArguments)) throw new Error("--confirm requires the call arguments to be a JSON object.");
|
|
1000
|
+
callArguments = {
|
|
1001
|
+
...callArguments,
|
|
1002
|
+
confirm: true
|
|
1003
|
+
};
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
const scrub = (text) => token ? text.split(token).join("[REDACTED]").split(JSON.stringify(token).slice(1, -1)).join("[REDACTED]") : text;
|
|
1007
|
+
if (!parsed.legacyRest) try {
|
|
1008
|
+
const result = await runModern(options, base, parsed.url, token, () => sub === "tools" ? { kind: "tools" } : {
|
|
1009
|
+
kind: "call",
|
|
1010
|
+
name,
|
|
1011
|
+
args: callArguments
|
|
1012
|
+
});
|
|
1013
|
+
stdout.write(scrub(`${JSON.stringify(redactTransportValue(result.value), null, 2)}\n`));
|
|
1014
|
+
if (result.isError) {
|
|
1015
|
+
stderr.write("MCP tool call returned an error result.\n");
|
|
1016
|
+
return false;
|
|
1017
|
+
}
|
|
1018
|
+
return true;
|
|
1019
|
+
} catch (error) {
|
|
1020
|
+
if (!(error instanceof McpTransportFailure)) throw error;
|
|
1021
|
+
stderr.write(scrub(`${safeMessage(error)}\n`));
|
|
1022
|
+
return false;
|
|
1023
|
+
}
|
|
1024
|
+
const requestOptions = {
|
|
1025
|
+
fetch: options.fetch,
|
|
1026
|
+
...parsed.url ? { serverUrl: parsed.url } : {},
|
|
1027
|
+
...token ? { token } : {}
|
|
1028
|
+
};
|
|
1029
|
+
let result;
|
|
1030
|
+
if (sub === "tools") result = await requestJsonResult(options.context, `${base}/tools`, { method: "GET" }, requestOptions);
|
|
1031
|
+
else result = await requestJsonResult(options.context, `${base}/call`, {
|
|
1032
|
+
body: JSON.stringify({
|
|
1033
|
+
arguments: callArguments,
|
|
1034
|
+
name
|
|
1035
|
+
}),
|
|
1036
|
+
method: "POST"
|
|
1037
|
+
}, requestOptions);
|
|
1038
|
+
stdout.write(scrub(`${JSON.stringify(result, null, 2)}\n`));
|
|
1039
|
+
if (!result.ok) stderr.write(scrub(`${result.error.message ?? result.error.code}\n`));
|
|
1040
|
+
return result.ok;
|
|
1041
|
+
}
|
|
1042
|
+
var MODERN_TIMEOUT_MS = 3e4;
|
|
1043
|
+
var MODERN_MAX_RESPONSE_BYTES = 10 * 1024 * 1024;
|
|
1044
|
+
/** Refuse oversized responses by header or by a streaming byte counter. */
|
|
1045
|
+
function capResponse(response, max) {
|
|
1046
|
+
const declared = Number(response.headers.get("content-length"));
|
|
1047
|
+
if (Number.isFinite(declared) && declared > max) throw new Error("Response too large.");
|
|
1048
|
+
if (!response.body) return response;
|
|
1049
|
+
let seen = 0;
|
|
1050
|
+
const counted = response.body.pipeThrough(new TransformStream({ transform(chunk, controller) {
|
|
1051
|
+
seen += chunk.byteLength;
|
|
1052
|
+
if (seen > max) controller.error(/* @__PURE__ */ new Error("Response too large."));
|
|
1053
|
+
else controller.enqueue(chunk);
|
|
1054
|
+
} }));
|
|
1055
|
+
return new Response(counted, {
|
|
1056
|
+
status: response.status,
|
|
1057
|
+
statusText: response.statusText,
|
|
1058
|
+
headers: response.headers
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
1061
|
+
var McpTransportFailure = class extends Error {};
|
|
1062
|
+
function safeMessage(error) {
|
|
1063
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1064
|
+
return String(redactTransportValue(message));
|
|
1065
|
+
}
|
|
1066
|
+
/** One-shot modern MCP client against the exact `<serverUrl><mcpPath>` target. */
|
|
1067
|
+
async function runModern(options, path, serverUrlOverride, token, operation) {
|
|
1068
|
+
const config = await loadCliConfig(options.context);
|
|
1069
|
+
const serverUrl = (serverUrlOverride ?? await getServerUrl(options.context, config)).replace(/\/+$/u, "");
|
|
1070
|
+
if (options.context.requireSecureServerUrl || token) assertSecureServerUrl(serverUrl);
|
|
1071
|
+
const bearer = token ?? await getStoredToken(options.context, config, serverUrl);
|
|
1072
|
+
const target = new URL(`${serverUrl}${path}`);
|
|
1073
|
+
const client = new Client({
|
|
1074
|
+
name: `${options.context.envPrefix.toLowerCase()}-mcp-cli`,
|
|
1075
|
+
version: "1"
|
|
1076
|
+
}, { versionNegotiation: { mode: { pin: "2026-07-28" } } });
|
|
1077
|
+
const transport = new StreamableHTTPClientTransport(target, { fetch: async (input, init) => {
|
|
1078
|
+
if (new URL(input instanceof Request ? input.url : String(input)).href !== target.href) throw new Error("MCP target changed.");
|
|
1079
|
+
const headers = new Headers(init?.headers);
|
|
1080
|
+
headers.delete("authorization");
|
|
1081
|
+
if (bearer) headers.set("authorization", `Bearer ${bearer}`);
|
|
1082
|
+
const signal = AbortSignal.any([init?.signal, AbortSignal.timeout(MODERN_TIMEOUT_MS)].filter((value) => value != null));
|
|
1083
|
+
return capResponse(await (options.fetch ?? fetch)(input, {
|
|
1084
|
+
...init,
|
|
1085
|
+
headers,
|
|
1086
|
+
redirect: "error",
|
|
1087
|
+
signal
|
|
1088
|
+
}), MODERN_MAX_RESPONSE_BYTES);
|
|
1089
|
+
} });
|
|
1090
|
+
try {
|
|
1091
|
+
await client.connect(transport);
|
|
1092
|
+
const op = operation();
|
|
1093
|
+
if (op.kind === "tools") {
|
|
1094
|
+
const tools = [];
|
|
1095
|
+
const cursors = /* @__PURE__ */ new Set();
|
|
1096
|
+
let cursor;
|
|
1097
|
+
do {
|
|
1098
|
+
const page = await client.listTools(cursor ? { cursor } : void 0);
|
|
1099
|
+
tools.push(...page.tools);
|
|
1100
|
+
cursor = page.nextCursor;
|
|
1101
|
+
if (cursor && (cursors.has(cursor) || cursors.size >= 100)) throw new Error("Invalid tool catalog pagination.");
|
|
1102
|
+
if (cursor) cursors.add(cursor);
|
|
1103
|
+
} while (cursor);
|
|
1104
|
+
return {
|
|
1105
|
+
value: { tools },
|
|
1106
|
+
isError: false
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1109
|
+
const called = await client.callTool({
|
|
1110
|
+
name: op.name,
|
|
1111
|
+
arguments: op.args
|
|
1112
|
+
});
|
|
1113
|
+
return {
|
|
1114
|
+
value: called,
|
|
1115
|
+
isError: called.isError === true
|
|
1116
|
+
};
|
|
1117
|
+
} catch (error) {
|
|
1118
|
+
throw new McpTransportFailure(`MCP request failed: ${safeMessage(error)}`);
|
|
1119
|
+
} finally {
|
|
1120
|
+
await client.close().catch(() => void 0);
|
|
927
1121
|
}
|
|
928
|
-
throw new Error("Usage: mcp tools | mcp call <tool> [<json>]");
|
|
929
1122
|
}
|
|
930
1123
|
//#endregion
|
|
931
1124
|
//#region src/commands/resources.ts
|
|
@@ -1107,7 +1300,7 @@ function createAppCli(options) {
|
|
|
1107
1300
|
return {
|
|
1108
1301
|
run: (argv) => runCli(context, options, extraByName, argv),
|
|
1109
1302
|
startMcpBridge: async (serverInfo) => {
|
|
1110
|
-
const { runMcpStdioBridge } = await import("./bridge-
|
|
1303
|
+
const { runMcpStdioBridge } = await import("./bridge-DT70h9LR.js");
|
|
1111
1304
|
const mcpPath = serverInfo?.mcpPath ?? options.mcpPath;
|
|
1112
1305
|
await runMcpStdioBridge({
|
|
1113
1306
|
...context,
|
|
@@ -1165,7 +1358,8 @@ async function dispatchCli(context, options, extras, argv, stdout, stderr) {
|
|
|
1165
1358
|
if (!await runMcpCommand({
|
|
1166
1359
|
context,
|
|
1167
1360
|
stdout,
|
|
1168
|
-
stderr
|
|
1361
|
+
stderr,
|
|
1362
|
+
mcpPath: options.mcpPath
|
|
1169
1363
|
}, rest)) process.exitCode = 1;
|
|
1170
1364
|
return;
|
|
1171
1365
|
}
|
|
@@ -1250,8 +1444,8 @@ function printUsage(options, extras, out) {
|
|
|
1250
1444
|
out.write(` ${name} auth logout\n`);
|
|
1251
1445
|
out.write(` ${name} resources [--json] [--debug]\n`);
|
|
1252
1446
|
out.write(` ${name} <resource> <command> [id] [--flags...] [json-payload]\n`);
|
|
1253
|
-
out.write(` ${name} mcp tools\n`);
|
|
1254
|
-
out.write(` ${name} mcp call <tool> [<json>]\n`);
|
|
1447
|
+
out.write(` ${name} mcp tools [--url <server>] [--token-env <ENV>] [--mcp-path <path>]\n`);
|
|
1448
|
+
out.write(` ${name} mcp call <tool> [<json>] [--confirm] [--url <server>] [--token-env <ENV>]\n`);
|
|
1255
1449
|
for (const cmd of extras.values()) out.write(` ${name} ${cmd.name} — ${cmd.description}\n`);
|
|
1256
1450
|
}
|
|
1257
1451
|
/** Naive levenshtein-style similarity. */
|
|
@@ -1266,4 +1460,4 @@ function similar(a, b) {
|
|
|
1266
1460
|
return true;
|
|
1267
1461
|
}
|
|
1268
1462
|
//#endregion
|
|
1269
|
-
export { buildFlagParser as a, createMcpClientIdMetadataDocument as c, buildUrl as d, invokeCommand as f,
|
|
1463
|
+
export { findResourceBySlug as _, buildFlagParser as a, createMcpClientIdMetadataDocument as c, buildUrl as d, invokeCommand as f, findCommand as g, fetchResourceList as h, runAppCliExecutable as i, registerMcpClient as l, generateLocalMcpSetup as m, createAppCli as n, classifySchema as o, generateDesktopPluginArtifacts as p, parseAppCliExecutableConfig as r, renderResponse as s, SMRT_MCP_RESULT_METADATA_KEY$1 as t, resolveMcpClientRegistration as u };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happyvertical/smrt-app-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.61.1",
|
|
4
4
|
"description": "Reusable CLI factory for SMRT apps — branded `<name> <resource> <command>` CLI + stdio MCP bridge with decorator-driven resource discovery",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
"AGENTS.md"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@happyvertical/smrt-users": "0.
|
|
24
|
+
"@happyvertical/smrt-users": "0.61.1",
|
|
25
25
|
"@modelcontextprotocol/client": "2.3.1",
|
|
26
26
|
"@modelcontextprotocol/server": "2.3.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@happyvertical/smrt-core": "0.
|
|
29
|
+
"@happyvertical/smrt-core": "0.61.1",
|
|
30
30
|
"@types/node": "24.13.6",
|
|
31
31
|
"typescript": "6.0.3",
|
|
32
32
|
"vite": "8.1.6",
|
package/dist/bridge-Bl1p3Oun.js
DELETED