@hediet/linkrpc-cli 0.0.3-next.20261031.1 → 0.0.3-next.20261102.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 CHANGED
@@ -936,7 +936,7 @@ idle minutes.
936
936
  ### Hub MCP aggregation
937
937
 
938
938
  `linkrpc hub mcp` is a lightweight stdio MCP server that discovers every MCP
939
- server published in the selected Hub and aggregates their tools: typed bridges
939
+ server published in the selected Hub and aggregates their tools: MCP services
940
940
  (`mcp.tools`) and forwarded servers (`mcp.forward`, or the legacy
941
941
  `vscode.mcp-forward`). No service IDs, filters, or principal overrides are
942
942
  required:
@@ -957,11 +957,14 @@ Endpoint/context/environment and identity selection follow the normal Hub CLI
957
957
  rules. An explicit endpoint can be supplied before `mcp`, for example
958
958
  `linkrpc hub --endpoint npipe://./pipe/my-hub mcp`. Signing and capability
959
959
  negotiation remain enabled by default; discovery does not bypass authorization.
960
- Typed tools are called through their generated methods, so capabilities and
960
+ Service tools are called through their generated methods, so capabilities and
961
961
  consent apply per tool; a forwarded server needs one capability for all its
962
962
  tools. Inaccessible directories and failed servers are reported on stderr;
963
963
  stdout contains only MCP protocol frames.
964
964
 
965
+ `--mcp-identity <serviceId>=<identity>` (repeatable) uses another account of a
966
+ published MCP server than its default and lists only that account's tools.
967
+
965
968
  `--scripts` additionally serves the LinkRPC script tools (`runLinkRpcScript`,
966
969
  `awaitLinkRpcTask`, `cancelLinkRpcTask`) of `@hediet/linkrpc-mcp` on the same
967
970
  connection, so one MCP entry gives both the hub's MCP tools and scripted access
@@ -977,18 +980,45 @@ This version aggregates tools, not resources, prompts, or sampling.
977
980
  ### Publishing MCP servers
978
981
 
979
982
  Producers stay separate. `mcp-publish` publishes one MCP server, given as a
980
- command after `--` or as a Streamable HTTP `--url` (with repeatable `--header`):
983
+ command after `--`, as a Streamable HTTP `--url` (with repeatable `--header`,
984
+ or `--header-env <header>=<ENV_VAR>` to read a secret from the environment),
985
+ as `--mcp-config <file>`, or (forward only) as `--stdio`:
981
986
 
982
987
  ```sh
983
- linkrpc hub mcp-publish --typed --forward --serviceId <authorized-service-id> -- npx -y @modelcontextprotocol/server-everything
988
+ linkrpc hub mcp-publish --service --forward --serviceId <authorized-service-id> -- npx -y @modelcontextprotocol/server-everything
984
989
  ```
985
990
 
986
- - `--typed` exposes every MCP tool as a method of a generated
987
- `mcp.tools.<name>` interface (`--name`, derived from the service ID by
988
- default). All callers share one MCP session; a caller can open an exclusive
989
- one with `mcp.server::openSession`.
991
+ - `--service` publishes the MCP server as a LinkRPC service: every MCP tool is
992
+ a method of a generated `mcp.tools.<name>` interface (`--name`, derived from
993
+ the service ID by default), and `mcp.tools::listTools`/`callTool` list and
994
+ call tools by name. All callers share one MCP session; a caller can open an
995
+ exclusive one with `mcp.server::openSession`. Repeatable
996
+ `--group <group>=<keyword,...>` moves tools whose name contains a keyword into
997
+ `mcp.tools.<name>.<group>`, so capabilities can cover a whole group, e.g.
998
+ `--group admin=delete,merge`.
990
999
  - `--forward` relays MCP verbatim over `mcp.forward`. Each connection gets its
991
1000
  own MCP session: a fresh child process, or a new HTTP session.
1001
+ - `--mcp-config <file>` reads the server from JSON: `transport`, optional
1002
+ `identities` (accounts), `description`, `id`, and `expose` (flags override
1003
+ `expose`). Each identity adds env vars (stdio) or headers (HTTP); values can be
1004
+ `{ "fromEnv": "NAME" }`. Calls select an account with `mcpIdentity`:
1005
+
1006
+ ```json
1007
+ {
1008
+ "transport": { "kind": "streamable-http", "url": "https://api.githubcopilot.com/mcp/" },
1009
+ "identities": [
1010
+ { "id": "work", "headers": { "Authorization": { "fromEnv": "GITHUB_WORK_AUTHORIZATION" } } },
1011
+ { "id": "personal", "default": true, "headers": { "Authorization": { "fromEnv": "GITHUB_AUTHORIZATION" } } }
1012
+ ],
1013
+ "expose": { "service": {} }
1014
+ }
1015
+ ```
1016
+
1017
+ A capability pins an account with the parameter matcher
1018
+ `mcpIdentity: { "exact": "work" }`.
1019
+ - `--stdio` forwards an MCP server that is already running and attached to this
1020
+ process's stdin/stdout, one connection at a time. Later connections reach the
1021
+ same server; the command exits when stdin ends.
992
1022
 
993
1023
  `mcp-forward` is shorthand for `mcp-publish --forward`:
994
1024
 
@@ -996,6 +1026,10 @@ linkrpc hub mcp-publish --typed --forward --serviceId <authorized-service-id> --
996
1026
  linkrpc hub mcp-forward --serviceId <authorized-service-id> -- component-explorer mcp -p <config> --use-daemon --no-daemon-autostart
997
1027
  ```
998
1028
 
1029
+ To forward a server that must not be restarted per connection, start it
1030
+ yourself and connect its stdio, e.g. with a named pipe pair or a supervisor:
1031
+ `linkrpc hub mcp-forward --stdio --serviceId <id>`.
1032
+
999
1033
  Manage that producer and `component-explorer serve -p <same-config>` with your
1000
1034
  workspace daemon. The aggregator opens lightweight MCP connections; it does not
1001
1035
  start workspace builds or explorer daemons. Each forwarded connection spawns
@@ -1,5 +1,5 @@
1
- import { $ as requestTopologyAccess, B as proxyCommand, Ct as MethodRefWithOptHash, F as disconnectBroker, G as parseDuration, H as withStaticHubReflection, I as getBrokerStatus, L as readBrokerNotifications, M as readEndpointDiscovery, N as ContextStore, P as formatContextReference, Q as requestReflectionAccess, R as stopConnectionBroker, St as parseParamOverride, U as parseConnectionLimit, V as tunnelCommand, W as parseConnectionLimitMilliseconds, _t as describeSchema, a as resolveInvocationEndpoint, c as resolveLocalEndpoint, ct as readCliIdentity, dt as connect, et as setupSigning, ft as connectViaRootOverlay, gt as describeObjectParams, ht as resolvedEndpointToConfig, i as resolveInvocationContext, it as walkHub, lt as formatPrincipalSource, m as managedEndpointsInterface, mt as resolveTargetEndpoint, n as loadStaticHubSchema, nt as fetchSchema$1, o as resolveSigning, ot as cliIdentityTarget, pt as connectViaTransport, q as resolveCliInvocation, r as resolveStaticHubSchemaSource, rt as findMethodInSchema, s as validationDefault, st as deleteCliIdentity, t as completeForLine, tt as fetchDefaults, ut as parsePrincipalSpec, vt as explainValidation, xt as mergeParams, y as HubHome, yt as validateValueAgainstSchema, z as ConnectionBroker } from "./runComplete-C__MHMiO.js";
2
- import { HubMcpAggregator, McpToolHost, hostMcpServer, mcpServerConfigSchema } from "@hediet/linkrpc-mcp/hub";
1
+ import { $ as requestTopologyAccess, B as proxyCommand, Ct as MethodRefWithOptHash, F as disconnectBroker, G as parseDuration, H as withStaticHubReflection, I as getBrokerStatus, L as readBrokerNotifications, M as readEndpointDiscovery, N as ContextStore, P as formatContextReference, Q as requestReflectionAccess, R as stopConnectionBroker, St as parseParamOverride, U as parseConnectionLimit, V as tunnelCommand, W as parseConnectionLimitMilliseconds, _t as describeSchema, a as resolveInvocationEndpoint, c as resolveLocalEndpoint, ct as readCliIdentity, dt as connect, et as setupSigning, ft as connectViaRootOverlay, gt as describeObjectParams, ht as resolvedEndpointToConfig, i as resolveInvocationContext, it as walkHub, lt as formatPrincipalSource, m as managedEndpointsInterface, mt as resolveTargetEndpoint, n as loadStaticHubSchema, nt as fetchSchema$1, o as resolveSigning, ot as cliIdentityTarget, pt as connectViaTransport, q as resolveCliInvocation, r as resolveStaticHubSchemaSource, rt as findMethodInSchema, s as validationDefault, st as deleteCliIdentity, t as completeForLine, tt as fetchDefaults, ut as parsePrincipalSpec, vt as explainValidation, xt as mergeParams, y as HubHome, yt as validateValueAgainstSchema, z as ConnectionBroker } from "./runComplete-7So63j8K.js";
2
+ import { HubMcpAggregator, McpToolHost, hostMcpServer, mcpExposeConfigSchema, mcpServerConfigSchema, serveMcpForwardInstance, streamInstanceTransport } from "@hediet/linkrpc-mcp/hub";
3
3
  import { ErrorCode, INTERFACE_TEMPLATES_EXTENSION, LinkRpcConnection, RpcError, computeInterfaceHash, connectTransports, createSchemaToZod, directoryInterface, exportStaticHubSchema, generateTsContract, generateTsInterface, interfaceTemplateArgumentsEquivalent, interfaceTemplateMemberName, interfaceTemplatesEqual, isAssignable, jcsCanonicalize, matchParams, schemaToZod, validateInterfaceTemplates } from "@hediet/linkrpc";
4
4
  import { WebSocketTransport, connectNdjson, connectToHub, formatEndpointUri, isHubEndpoint, openWebSocket, parseEndpointUri, runInitializeHandshake, traceMessageTransport as traceMessageTransport$1 } from "@hediet/linkrpc/node";
5
5
  import { SocketServer } from "@hediet/linkrpc-hub/hub/server/node";
@@ -412,7 +412,7 @@ function contextNamespace(reference) {
412
412
  async function useLocalManagement(start, action) {
413
413
  const home = HubHome.resolve();
414
414
  if (start) {
415
- const { startDaemon, nodeDaemonLaunch } = await import("./src-CAZT8apO.js");
415
+ const { startDaemon, nodeDaemonLaunch } = await import("./src-JoLhzxlD.js");
416
416
  if (await startDaemon({
417
417
  home,
418
418
  launch: nodeDaemonLaunch(home)
@@ -432,7 +432,7 @@ async function useLocalManagement(start, action) {
432
432
  }
433
433
  }
434
434
  async function restartLocalDaemon() {
435
- const { startDaemon, stopDaemon, nodeDaemonLaunch } = await import("./src-CAZT8apO.js");
435
+ const { startDaemon, stopDaemon, nodeDaemonLaunch } = await import("./src-JoLhzxlD.js");
436
436
  const home = HubHome.resolve();
437
437
  process.stderr.write("Restarting the local Hub daemon: clients will disconnect and managed workloads will stop. OS autostart settings are unchanged.\n");
438
438
  await stopDaemon(home);
@@ -3390,20 +3390,41 @@ const CLAIM_METHOD = `${hubGrantedServiceIdInterface.info.id}::register`;
3390
3390
  /** Read-only connection facts — `hubGrantedServiceId::get`. */
3391
3391
  const INFO_METHOD = `${hubGrantedServiceIdInterface.info.id}::get`;
3392
3392
  /**
3393
- * Publish one MCP server on the hub until stopped: typed (one LinkRPC method
3394
- * per tool, one shared MCP session), forwarded (verbatim MCP over
3395
- * `mcp.forward`, one upstream session per connection), or both.
3393
+ * Publish one MCP server on the hub until stopped: as a service (one LinkRPC
3394
+ * method per tool plus generic `mcp.tools`, one shared MCP session), forwarded
3395
+ * (verbatim MCP over `mcp.forward`), or both.
3396
3396
  */
3397
3397
  async function mcpPublishCommand(opts) {
3398
3398
  const log = opts.log ?? ((line) => process.stderr.write(line + "\n"));
3399
3399
  const serviceId = opts.serviceId ?? await _resolveGrantedServiceId(opts.local);
3400
3400
  const connection = new LinkRpcConnection(opts.local.rpcChannel);
3401
+ if (opts.transport.kind === "own-stdio") {
3402
+ if (opts.expose.service !== void 0 || opts.expose.forward === void 0) throw new Error("mcp-publish: an MCP server on this process's stdio can only be forwarded.");
3403
+ const instance = serveMcpForwardInstance({
3404
+ connection,
3405
+ serviceId,
3406
+ transport: streamInstanceTransport(process.stdin, process.stdout),
3407
+ log
3408
+ });
3409
+ try {
3410
+ await opts.local.channel.sendRequest(CLAIM_METHOD, { serviceId });
3411
+ log(`mcp-publish: claimed '${serviceId}' — forwarding the MCP server on stdio to one connection at a time`);
3412
+ await Promise.race([instance.closed, opts.stop ?? _untilSignalled$1()]);
3413
+ log("mcp-publish: stopping");
3414
+ } finally {
3415
+ instance.dispose();
3416
+ }
3417
+ return;
3418
+ }
3419
+ const transport = opts.transport;
3401
3420
  const hosted = await hostMcpServer({
3402
3421
  connection,
3403
3422
  serviceId,
3404
3423
  server: mcpServerConfigSchema.parse({
3405
3424
  id: opts.name ?? interfaceNameFor(serviceId),
3406
- transport: opts.transport,
3425
+ ...opts.description !== void 0 ? { description: opts.description } : {},
3426
+ transport,
3427
+ ...opts.identities !== void 0 ? { identities: opts.identities } : {},
3407
3428
  expose: opts.expose
3408
3429
  }),
3409
3430
  log,
@@ -3411,14 +3432,30 @@ async function mcpPublishCommand(opts) {
3411
3432
  });
3412
3433
  try {
3413
3434
  await opts.local.channel.sendRequest(CLAIM_METHOD, { serviceId });
3414
- const modes = [opts.expose.typed && "typed", opts.expose.forward && "forwarded"].filter(Boolean).join(" and ");
3415
- log(`mcp-publish: claimed '${serviceId}' — publishing ${_describe(opts.transport)} ${modes}`);
3435
+ const modes = [opts.expose.service && "as a service", opts.expose.forward && "forwarded"].filter(Boolean).join(" and ");
3436
+ log(`mcp-publish: claimed '${serviceId}' — publishing ${_describe(transport)} ${modes}`);
3416
3437
  await (opts.stop ?? _untilSignalled$1());
3417
3438
  log("mcp-publish: stopping");
3418
3439
  } finally {
3419
3440
  await hosted.dispose();
3420
3441
  }
3421
3442
  }
3443
+ /** `mcp-publish --mcp-config` file: a server config whose `id` and `expose` may come from flags. */
3444
+ const mcpPublishConfigSchema = mcpServerConfigSchema.extend({
3445
+ id: mcpServerConfigSchema.shape.id.optional(),
3446
+ expose: mcpExposeConfigSchema.optional()
3447
+ });
3448
+ async function readMcpPublishConfig(path) {
3449
+ let json;
3450
+ try {
3451
+ json = JSON.parse(await readFile(path, "utf8"));
3452
+ } catch (error) {
3453
+ throw new Error(`mcp-publish: cannot read ${path}: ${error instanceof Error ? error.message : String(error)}`);
3454
+ }
3455
+ const parsed = mcpPublishConfigSchema.safeParse(json);
3456
+ if (!parsed.success) throw new Error(`mcp-publish: invalid ${path}: ${parsed.error.message}`);
3457
+ return parsed.data;
3458
+ }
3422
3459
  /** A valid `mcp.tools.<name>` suffix for `serviceId`, e.g. `my/MCP_server` → `my.mcp-server`. */
3423
3460
  function interfaceNameFor(serviceId) {
3424
3461
  const name = serviceId.toLowerCase().replace(/[^a-z0-9.-]+/g, ".").replace(/^[^a-z0-9]+|[^a-z0-9]+$/g, "");
@@ -3450,7 +3487,7 @@ const clientInfo = {
3450
3487
  version: "1.0.0"
3451
3488
  };
3452
3489
  /**
3453
- * Serve the tools of every MCP server published on the hub (typed bridges and
3490
+ * Serve the tools of every MCP server published on the hub (MCP services and
3454
3491
  * forwarded servers) as one stdio MCP server, optionally with the script tools.
3455
3492
  */
3456
3493
  async function mcpCommand(channel, options = {}) {
@@ -3460,7 +3497,8 @@ async function mcpCommand(channel, options = {}) {
3460
3497
  const aggregatorOptions = {
3461
3498
  requestDirectoryAccess: options.requestDirectoryAccess,
3462
3499
  log,
3463
- clientInfo
3500
+ clientInfo,
3501
+ ...options.mcpIdentities !== void 0 ? { mcpIdentityFor: (serviceId) => options.mcpIdentities?.[serviceId] } : {}
3464
3502
  };
3465
3503
  const transport = new StdioServerTransport(options.input ?? process.stdin, options.output ?? process.stdout);
3466
3504
  const input = options.input ?? process.stdin;
@@ -9210,9 +9248,10 @@ Batch options:
9210
9248
  local.close();
9211
9249
  }
9212
9250
  });
9213
- program.command("mcp").description("Expose the tools of all MCP servers published on the Hub (typed bridges and forwarded servers) as one stdio MCP server.").option("--scripts", "also serve the LinkRPC script tools (runLinkRpcScript, awaitLinkRpcTask, cancelLinkRpcTask)").action(async (cmdOpts) => {
9251
+ program.command("mcp").description("Expose the tools of all MCP servers published on the Hub (MCP services and forwarded servers) as one stdio MCP server.").option("--scripts", "also serve the LinkRPC script tools (runLinkRpcScript, awaitLinkRpcTask, cancelLinkRpcTask)").option("--mcp-identity <serviceId=identity>", "use this MCP identity (account) of a published MCP server instead of its default (repeatable)", collectKeyValue).action(async (cmdOpts) => {
9214
9252
  await withChannel(endpoint, getPrincipalSpec(), async (channel, session) => {
9215
9253
  await mcpCommand(channel, {
9254
+ ...cmdOpts.mcpIdentity !== void 0 ? { mcpIdentities: cmdOpts.mcpIdentity } : {},
9216
9255
  requestDirectoryAccess: session === void 0 ? void 0 : (serviceId) => requestDirectoryAccess(session, serviceId, { watch: true }),
9217
9256
  ...cmdOpts.scripts ? {
9218
9257
  scripts: true,
@@ -9404,17 +9443,40 @@ Batch options:
9404
9443
  broker.close();
9405
9444
  }
9406
9445
  });
9407
- const mcpUpstreamOptions = (command) => command.option("--serviceId <serviceId>", "serviceId prefix to claim (default: the connection's granted serviceId namespace)").option("--url <url>", "publish a Streamable HTTP MCP server instead of a command after `--`").option("--header <key=value>", "HTTP header sent to the --url server (repeatable)", collectKeyValue).option("--env <key=value>", "env var for the spawned MCP server child (repeatable)", collectKeyValue);
9446
+ const mcpUpstreamOptions = (command) => command.option("--serviceId <serviceId>", "serviceId prefix to claim (default: the connection's granted serviceId namespace)").option("--url <url>", "publish a Streamable HTTP MCP server instead of a command after `--`").option("--header <key=value>", "HTTP header sent to the --url server (repeatable)", collectKeyValue).option("--header-env <key=ENV_VAR>", "HTTP header read from an environment variable when a session opens, e.g. `Authorization=SLACK_AUTHORIZATION` (repeatable)", collectKeyValue).option("--mcp-config <file>", "JSON file with the MCP server: `transport`, optional `identities` (accounts), `description`, and `expose`").option("--env <key=value>", "env var for the spawned MCP server child (repeatable)", collectKeyValue).option("--stdio", "forward the running MCP server attached to this process's stdin/stdout, one connection at a time");
9408
9447
  const runMcpPublish = async (commandName, mcpCommand, cmdOpts, expose, name) => {
9409
9448
  const localEp = needEndpoint(endpoint);
9410
- if ((mcpCommand !== void 0 && mcpCommand.length > 0) === (cmdOpts.url !== void 0)) {
9411
- process.stderr.write(`linkrpc: ${commandName} requires either an MCP server command after \`--\` or --url, e.g. \`${commandName} -- npx -y @modelcontextprotocol/server-everything\`.\n`);
9449
+ if ([
9450
+ mcpCommand !== void 0 && mcpCommand.length > 0,
9451
+ cmdOpts.url !== void 0,
9452
+ cmdOpts.stdio === true,
9453
+ cmdOpts.mcpConfig !== void 0
9454
+ ].filter(Boolean).length !== 1) {
9455
+ process.stderr.write(`linkrpc: ${commandName} requires exactly one of an MCP server command after \`--\`, --url, --stdio, or --mcp-config, e.g. \`${commandName} -- npx -y @modelcontextprotocol/server-everything\`.\n`);
9456
+ process.exit(2);
9457
+ }
9458
+ if (cmdOpts.stdio && expose?.service !== void 0) {
9459
+ process.stderr.write(`linkrpc: ${commandName} --stdio supports only --forward.\n`);
9412
9460
  process.exit(2);
9413
9461
  }
9414
- const transport = cmdOpts.url !== void 0 ? {
9462
+ if (cmdOpts.headerEnv !== void 0 && cmdOpts.url === void 0) {
9463
+ process.stderr.write(`linkrpc: ${commandName} --header-env requires --url.\n`);
9464
+ process.exit(2);
9465
+ }
9466
+ const file = cmdOpts.mcpConfig === void 0 ? void 0 : await readMcpPublishConfig(cmdOpts.mcpConfig);
9467
+ const resolvedExpose = expose ?? file?.expose;
9468
+ if (resolvedExpose === void 0) {
9469
+ process.stderr.write(`linkrpc: ${commandName} requires --service, --forward, or \`expose\` in --mcp-config.\n`);
9470
+ process.exit(2);
9471
+ }
9472
+ const headers = {
9473
+ ...cmdOpts.header,
9474
+ ...Object.fromEntries(Object.entries(cmdOpts.headerEnv ?? {}).map(([key, variable]) => [key, { fromEnv: variable }]))
9475
+ };
9476
+ const transport = file !== void 0 ? file.transport : cmdOpts.stdio ? { kind: "own-stdio" } : cmdOpts.url !== void 0 ? {
9415
9477
  kind: "streamable-http",
9416
9478
  url: cmdOpts.url,
9417
- ...cmdOpts.header ? { headers: cmdOpts.header } : {}
9479
+ ...Object.keys(headers).length > 0 ? { headers } : {}
9418
9480
  } : {
9419
9481
  kind: "stdio",
9420
9482
  command: mcpCommand[0],
@@ -9427,29 +9489,40 @@ Batch options:
9427
9489
  const local = await connect(localEp, wireLog("hub"));
9428
9490
  try {
9429
9491
  reportIdentity(await setupSigning(local.channel, local.signing, getPrincipalSpec(), { negotiateHubCaps: isHubEndpoint(localEp) }));
9492
+ const id = name ?? file?.id;
9430
9493
  await mcpPublishCommand({
9431
9494
  ...cmdOpts.serviceId !== void 0 ? { serviceId: cmdOpts.serviceId } : {},
9432
- ...name !== void 0 ? { name } : {},
9495
+ ...id !== void 0 ? { name: id } : {},
9496
+ ...file?.identities !== void 0 ? { identities: file.identities } : {},
9497
+ ...file?.description !== void 0 ? { description: file.description } : {},
9433
9498
  local,
9434
9499
  transport,
9435
- expose
9500
+ expose: resolvedExpose
9436
9501
  });
9437
9502
  } finally {
9438
9503
  local.close();
9439
9504
  }
9440
9505
  };
9441
- mcpUpstreamOptions(program.command("mcp-forward [mcpCommand...]").description("Expose an MCP server through the hub (--endpoint*) as a transparent forwarder. By default it claims this connection's granted serviceId namespace; pass --serviceId to claim a specific prefix. The MCP server command follows `--`, e.g. `linkrpc mcp-forward -- npx -y @modelcontextprotocol/server-everything` or `linkrpc mcp-forward --serviceId my-mcp -- npx -y @modelcontextprotocol/server-everything`; use --url for a Streamable HTTP server. Each consumer that opens `<serviceId>::mcp.forward::connect` (or the legacy `vscode.mcp-forward`) gets its own MCP session (a fresh child, or a new HTTP session) relayed verbatim. Runs until Ctrl-C.")).action(async (mcpCommand, cmdOpts) => {
9506
+ mcpUpstreamOptions(program.command("mcp-forward [mcpCommand...]").description("Shorthand for `mcp-publish --forward`: relay an MCP server verbatim through the hub (--endpoint*) over `mcp.forward`. The MCP server is a command after `--` (a fresh process per connection), --url (a new HTTP session per connection), or --stdio (the running server attached to this process's stdin/stdout, one connection at a time). By default it claims this connection's granted serviceId namespace. Runs until Ctrl-C.")).action(async (mcpCommand, cmdOpts) => {
9442
9507
  await runMcpPublish("mcp-forward", mcpCommand, cmdOpts, { forward: { sharing: "exclusive" } }, void 0);
9443
9508
  });
9444
- mcpUpstreamOptions(program.command("mcp-publish [mcpCommand...]").description("Publish an MCP server through the hub (--endpoint*). --typed exposes each MCP tool as a method of a generated `mcp.tools.<name>` interface (one shared MCP session; capabilities per tool); --forward relays verbatim MCP over `mcp.forward` (one MCP session per connection; one capability per server). Pass one or both. The MCP server command follows `--`, or use --url for a Streamable HTTP server. Runs until Ctrl-C.")).option("--typed", "expose the tools as typed LinkRPC methods").option("--forward", "expose verbatim MCP forwarding").option("--name <name>", "generated interface name, `mcp.tools.<name>` (default: derived from the serviceId)").action(async (mcpCommand, cmdOpts) => {
9445
- if (!cmdOpts.typed && !cmdOpts.forward) {
9446
- process.stderr.write("linkrpc: mcp-publish requires --typed, --forward, or both.\n");
9509
+ mcpUpstreamOptions(program.command("mcp-publish [mcpCommand...]").description("Publish an MCP server through the hub (--endpoint*). --service publishes it as a LinkRPC service: one method per tool on generated `mcp.tools.<name>` interfaces (split with --group), generic `mcp.tools::listTools`/`callTool`, and `mcp.server`; callers share one MCP session. --forward relays verbatim MCP over `mcp.forward`. Pass one or both. The MCP server is a command after `--`, --url, or (forward only) --stdio. Runs until Ctrl-C.")).option("--service", "publish the MCP server as a LinkRPC service").option("--forward", "relay MCP verbatim over mcp.forward").option("--name <name>", "generated interface name, `mcp.tools.<name>` (default: derived from the serviceId)").option("--group <name=keywords>", "move tools whose name contains one of the comma-separated keywords into `mcp.tools.<name>.<group>` (repeatable; first match wins)", collectKeyValue).action(async (mcpCommand, cmdOpts) => {
9510
+ if (!cmdOpts.service && !cmdOpts.forward && cmdOpts.mcpConfig === void 0) {
9511
+ process.stderr.write("linkrpc: mcp-publish requires --service, --forward, or both.\n");
9447
9512
  process.exit(2);
9448
9513
  }
9449
- await runMcpPublish("mcp-publish", mcpCommand, cmdOpts, {
9450
- ...cmdOpts.typed ? { typed: {} } : {},
9514
+ if (cmdOpts.group && !cmdOpts.service) {
9515
+ process.stderr.write("linkrpc: mcp-publish --group requires --service.\n");
9516
+ process.exit(2);
9517
+ }
9518
+ const groups = Object.entries(cmdOpts.group ?? {}).map(([groupName, keywords]) => ({
9519
+ name: groupName,
9520
+ keywords: keywords.split(",").filter(Boolean)
9521
+ }));
9522
+ await runMcpPublish("mcp-publish", mcpCommand, cmdOpts, cmdOpts.service || cmdOpts.forward ? {
9523
+ ...cmdOpts.service ? { service: groups.length > 0 ? { groups } : {} } : {},
9451
9524
  ...cmdOpts.forward ? { forward: { sharing: "exclusive" } } : {}
9452
- }, cmdOpts.name);
9525
+ } : void 0, cmdOpts.name);
9453
9526
  });
9454
9527
  program.command("identity").description("Inspect the persistent principal used by connected CLI commands.").command("show").description("Print the resolved persistent CLI identity.").option("--json", "stable machine-readable JSON output").action(async (opts) => {
9455
9528
  await withResolvedSigning(endpoint, getPrincipalSpec(), async (_conn, session) => {
@@ -9484,7 +9557,7 @@ Batch options:
9484
9557
  process.once("SIGINT", onSignal);
9485
9558
  process.once("SIGTERM", onSignal);
9486
9559
  try {
9487
- const { runApprovalUi } = await import("./runApprovalUi-CHLl-QDw.js");
9560
+ const { runApprovalUi } = await import("./runApprovalUi-GJf_57fQ.js");
9488
9561
  await runApprovalUi({
9489
9562
  client,
9490
9563
  signal: stop.signal
@@ -9499,7 +9572,7 @@ Batch options:
9499
9572
  registerViewCommands(program, (action) => withChannel(endpoint, getPrincipalSpec(), action));
9500
9573
  program.command("ui").description("Launch the terminal UI (form-based browser of services + methods).").action(async () => {
9501
9574
  const acquired = await acquireConnection(endpoint);
9502
- const { runUi } = await import("./runUi-CtNlZncr.js");
9575
+ const { runUi } = await import("./runUi-Di-OpGlw.js");
9503
9576
  try {
9504
9577
  await runUi({
9505
9578
  endpoint: acquired.ep,
@@ -10079,4 +10152,4 @@ function definedEnv(env) {
10079
10152
  //#endregion
10080
10153
  export { formatCondition as _, formatCommandLegend as a, targetId as b, safeTerminalText as c, ObservablePromise as d, observableValue as f, resolveViewTarget as g, Disposable as h, dispatchHostKey as i, approvalDetailLines as l, derived as m, views as n, hostCommands as o, autorun as p, ViewFrame as r, matchesKey as s, runCli as t, ObservableLazyPromise as u, interfaceTarget as v, matchesTarget as y };
10081
10154
 
10082
- //# sourceMappingURL=cli-DQr3bq_u.js.map
10155
+ //# sourceMappingURL=cli-CvHY2xLj.js.map