@hediet/linkrpc-cli 0.0.3-next.20261031.1 → 0.0.3-next.20261101.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,7 +957,7 @@ 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.
@@ -977,18 +977,26 @@ This version aggregates tools, not resources, prompts, or sampling.
977
977
  ### Publishing MCP servers
978
978
 
979
979
  Producers stay separate. `mcp-publish` publishes one MCP server, given as a
980
- command after `--` or as a Streamable HTTP `--url` (with repeatable `--header`):
980
+ command after `--`, as a Streamable HTTP `--url` (with repeatable `--header`),
981
+ or (forward only) as `--stdio`:
981
982
 
982
983
  ```sh
983
- linkrpc hub mcp-publish --typed --forward --serviceId <authorized-service-id> -- npx -y @modelcontextprotocol/server-everything
984
+ linkrpc hub mcp-publish --service --forward --serviceId <authorized-service-id> -- npx -y @modelcontextprotocol/server-everything
984
985
  ```
985
986
 
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`.
987
+ - `--service` publishes the MCP server as a LinkRPC service: every MCP tool is
988
+ a method of a generated `mcp.tools.<name>` interface (`--name`, derived from
989
+ the service ID by default), and `mcp.tools::listTools`/`callTool` list and
990
+ call tools by name. All callers share one MCP session; a caller can open an
991
+ exclusive one with `mcp.server::openSession`. Repeatable
992
+ `--group <group>=<keyword,...>` moves tools whose name contains a keyword into
993
+ `mcp.tools.<name>.<group>`, so capabilities can cover a whole group, e.g.
994
+ `--group admin=delete,merge`.
990
995
  - `--forward` relays MCP verbatim over `mcp.forward`. Each connection gets its
991
996
  own MCP session: a fresh child process, or a new HTTP session.
997
+ - `--stdio` forwards an MCP server that is already running and attached to this
998
+ process's stdin/stdout, one connection at a time. Later connections reach the
999
+ same server; the command exits when stdin ends.
992
1000
 
993
1001
  `mcp-forward` is shorthand for `mcp-publish --forward`:
994
1002
 
@@ -996,6 +1004,10 @@ linkrpc hub mcp-publish --typed --forward --serviceId <authorized-service-id> --
996
1004
  linkrpc hub mcp-forward --serviceId <authorized-service-id> -- component-explorer mcp -p <config> --use-daemon --no-daemon-autostart
997
1005
  ```
998
1006
 
1007
+ To forward a server that must not be restarted per connection, start it
1008
+ yourself and connect its stdio, e.g. with a named pipe pair or a supervisor:
1009
+ `linkrpc hub mcp-forward --stdio --serviceId <id>`.
1010
+
999
1011
  Manage that producer and `component-explorer serve -p <same-config>` with your
1000
1012
  workspace daemon. The aggregator opens lightweight MCP connections; it does not
1001
1013
  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-haCYSPzH.js";
2
+ import { HubMcpAggregator, McpToolHost, hostMcpServer, 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-DSdS3hm7.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-DSdS3hm7.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,39 @@ 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
+ transport,
3407
3426
  expose: opts.expose
3408
3427
  }),
3409
3428
  log,
@@ -3411,8 +3430,8 @@ async function mcpPublishCommand(opts) {
3411
3430
  });
3412
3431
  try {
3413
3432
  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}`);
3433
+ const modes = [opts.expose.service && "as a service", opts.expose.forward && "forwarded"].filter(Boolean).join(" and ");
3434
+ log(`mcp-publish: claimed '${serviceId}' — publishing ${_describe(transport)} ${modes}`);
3416
3435
  await (opts.stop ?? _untilSignalled$1());
3417
3436
  log("mcp-publish: stopping");
3418
3437
  } finally {
@@ -3450,7 +3469,7 @@ const clientInfo = {
3450
3469
  version: "1.0.0"
3451
3470
  };
3452
3471
  /**
3453
- * Serve the tools of every MCP server published on the hub (typed bridges and
3472
+ * Serve the tools of every MCP server published on the hub (MCP services and
3454
3473
  * forwarded servers) as one stdio MCP server, optionally with the script tools.
3455
3474
  */
3456
3475
  async function mcpCommand(channel, options = {}) {
@@ -9210,7 +9229,7 @@ Batch options:
9210
9229
  local.close();
9211
9230
  }
9212
9231
  });
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) => {
9232
+ 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)").action(async (cmdOpts) => {
9214
9233
  await withChannel(endpoint, getPrincipalSpec(), async (channel, session) => {
9215
9234
  await mcpCommand(channel, {
9216
9235
  requestDirectoryAccess: session === void 0 ? void 0 : (serviceId) => requestDirectoryAccess(session, serviceId, { watch: true }),
@@ -9404,14 +9423,22 @@ Batch options:
9404
9423
  broker.close();
9405
9424
  }
9406
9425
  });
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);
9426
+ 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).option("--stdio", "forward the running MCP server attached to this process's stdin/stdout, one connection at a time");
9408
9427
  const runMcpPublish = async (commandName, mcpCommand, cmdOpts, expose, name) => {
9409
9428
  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`);
9429
+ if ([
9430
+ mcpCommand !== void 0 && mcpCommand.length > 0,
9431
+ cmdOpts.url !== void 0,
9432
+ cmdOpts.stdio === true
9433
+ ].filter(Boolean).length !== 1) {
9434
+ process.stderr.write(`linkrpc: ${commandName} requires exactly one of an MCP server command after \`--\`, --url, or --stdio, e.g. \`${commandName} -- npx -y @modelcontextprotocol/server-everything\`.\n`);
9435
+ process.exit(2);
9436
+ }
9437
+ if (cmdOpts.stdio && expose.service !== void 0) {
9438
+ process.stderr.write(`linkrpc: ${commandName} --stdio supports only --forward.\n`);
9412
9439
  process.exit(2);
9413
9440
  }
9414
- const transport = cmdOpts.url !== void 0 ? {
9441
+ const transport = cmdOpts.stdio ? { kind: "own-stdio" } : cmdOpts.url !== void 0 ? {
9415
9442
  kind: "streamable-http",
9416
9443
  url: cmdOpts.url,
9417
9444
  ...cmdOpts.header ? { headers: cmdOpts.header } : {}
@@ -9438,16 +9465,24 @@ Batch options:
9438
9465
  local.close();
9439
9466
  }
9440
9467
  };
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) => {
9468
+ 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
9469
  await runMcpPublish("mcp-forward", mcpCommand, cmdOpts, { forward: { sharing: "exclusive" } }, void 0);
9443
9470
  });
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");
9471
+ 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) => {
9472
+ if (!cmdOpts.service && !cmdOpts.forward) {
9473
+ process.stderr.write("linkrpc: mcp-publish requires --service, --forward, or both.\n");
9447
9474
  process.exit(2);
9448
9475
  }
9476
+ if (cmdOpts.group && !cmdOpts.service) {
9477
+ process.stderr.write("linkrpc: mcp-publish --group requires --service.\n");
9478
+ process.exit(2);
9479
+ }
9480
+ const groups = Object.entries(cmdOpts.group ?? {}).map(([groupName, keywords]) => ({
9481
+ name: groupName,
9482
+ keywords: keywords.split(",").filter(Boolean)
9483
+ }));
9449
9484
  await runMcpPublish("mcp-publish", mcpCommand, cmdOpts, {
9450
- ...cmdOpts.typed ? { typed: {} } : {},
9485
+ ...cmdOpts.service ? { service: groups.length > 0 ? { groups } : {} } : {},
9451
9486
  ...cmdOpts.forward ? { forward: { sharing: "exclusive" } } : {}
9452
9487
  }, cmdOpts.name);
9453
9488
  });
@@ -9484,7 +9519,7 @@ Batch options:
9484
9519
  process.once("SIGINT", onSignal);
9485
9520
  process.once("SIGTERM", onSignal);
9486
9521
  try {
9487
- const { runApprovalUi } = await import("./runApprovalUi-CHLl-QDw.js");
9522
+ const { runApprovalUi } = await import("./runApprovalUi-BHomYhFQ.js");
9488
9523
  await runApprovalUi({
9489
9524
  client,
9490
9525
  signal: stop.signal
@@ -9499,7 +9534,7 @@ Batch options:
9499
9534
  registerViewCommands(program, (action) => withChannel(endpoint, getPrincipalSpec(), action));
9500
9535
  program.command("ui").description("Launch the terminal UI (form-based browser of services + methods).").action(async () => {
9501
9536
  const acquired = await acquireConnection(endpoint);
9502
- const { runUi } = await import("./runUi-CtNlZncr.js");
9537
+ const { runUi } = await import("./runUi-cl0J7cZB.js");
9503
9538
  try {
9504
9539
  await runUi({
9505
9540
  endpoint: acquired.ep,
@@ -10079,4 +10114,4 @@ function definedEnv(env) {
10079
10114
  //#endregion
10080
10115
  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
10116
 
10082
- //# sourceMappingURL=cli-DQr3bq_u.js.map
10117
+ //# sourceMappingURL=cli-CUctSk0X.js.map