@firfi/huly-mcp 0.43.0 → 0.44.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.
Files changed (3) hide show
  1. package/README.md +27 -58
  2. package/dist/index.cjs +1308 -325
  3. package/package.json +3 -2
package/dist/index.cjs CHANGED
@@ -82690,7 +82690,7 @@ var require_connection2 = __commonJS({
82690
82690
  });
82691
82691
  module2.exports = __toCommonJS2(connection_exports);
82692
82692
  var import_analytics = require_lib3();
82693
- var import_client88 = __toESM2(require_lib7());
82693
+ var import_client89 = __toESM2(require_lib7());
82694
82694
  var import_core105 = __toESM2(require_lib5());
82695
82695
  var import_platform4 = __toESM2(require_lib());
82696
82696
  var import_rpc = require_lib19();
@@ -82801,7 +82801,7 @@ var require_connection2 = __commonJS({
82801
82801
  }
82802
82802
  if (!this.closed) {
82803
82803
  void this.sendRequest({
82804
- method: import_client88.pingConst,
82804
+ method: import_client89.pingConst,
82805
82805
  params: [],
82806
82806
  once: true,
82807
82807
  handleResult: /* @__PURE__ */ __name(async (result) => {
@@ -82834,7 +82834,7 @@ var require_connection2 = __commonJS({
82834
82834
  }
82835
82835
  }
82836
82836
  isConnected() {
82837
- return this.websocket != null && this.websocket.readyState === import_client88.ClientSocketReadyState.OPEN && this.helloReceived;
82837
+ return this.websocket != null && this.websocket.readyState === import_client89.ClientSocketReadyState.OPEN && this.helloReceived;
82838
82838
  }
82839
82839
  delay = 0;
82840
82840
  onConnectHandlers = [];
@@ -82974,8 +82974,8 @@ var require_connection2 = __commonJS({
82974
82974
  }
82975
82975
  return;
82976
82976
  }
82977
- if (resp.result === import_client88.pingConst) {
82978
- void this.sendRequest({ method: import_client88.pingConst, params: [] }).catch((err) => {
82977
+ if (resp.result === import_client89.pingConst) {
82978
+ void this.sendRequest({ method: import_client89.pingConst, params: [] }).catch((err) => {
82979
82979
  this.ctx.error("failed to send ping", { err });
82980
82980
  });
82981
82981
  return;
@@ -83067,15 +83067,15 @@ var require_connection2 = __commonJS({
83067
83067
  }
83068
83068
  }
83069
83069
  checkArrayBufferPing(data) {
83070
- if (data.byteLength === import_client88.pingConst.length || data.byteLength === import_client88.pongConst.length) {
83070
+ if (data.byteLength === import_client89.pingConst.length || data.byteLength === import_client89.pongConst.length) {
83071
83071
  const text = new TextDecoder().decode(data);
83072
- if (text === import_client88.pingConst) {
83073
- void this.sendRequest({ method: import_client88.pingConst, params: [] }).catch((err) => {
83072
+ if (text === import_client89.pingConst) {
83073
+ void this.sendRequest({ method: import_client89.pingConst, params: [] }).catch((err) => {
83074
83074
  this.ctx.error("failed to send ping", { err });
83075
83075
  });
83076
83076
  return true;
83077
83077
  }
83078
- if (text === import_client88.pongConst) {
83078
+ if (text === import_client89.pongConst) {
83079
83079
  this.pingResponse = Date.now();
83080
83080
  return true;
83081
83081
  }
@@ -83085,7 +83085,7 @@ var require_connection2 = __commonJS({
83085
83085
  openConnection(ctx, socketId) {
83086
83086
  this.binaryMode = false;
83087
83087
  this.helloReceived = false;
83088
- const clientSocketFactory = this.opt?.socketFactory ?? (0, import_platform4.getMetadata)(import_client88.default.metadata.ClientSocketFactory) ?? ((url4) => {
83088
+ const clientSocketFactory = this.opt?.socketFactory ?? (0, import_platform4.getMetadata)(import_client89.default.metadata.ClientSocketFactory) ?? ((url4) => {
83089
83089
  const s = new WebSocket(url4);
83090
83090
  return s;
83091
83091
  });
@@ -83120,12 +83120,12 @@ var require_connection2 = __commonJS({
83120
83120
  if (this.websocket !== wsocket) {
83121
83121
  return;
83122
83122
  }
83123
- if (event.data === import_client88.pongConst) {
83123
+ if (event.data === import_client89.pongConst) {
83124
83124
  this.pingResponse = Date.now();
83125
83125
  return;
83126
83126
  }
83127
- if (event.data === import_client88.pingConst) {
83128
- void this.sendRequest({ method: import_client88.pingConst, params: [] }).catch((err) => {
83127
+ if (event.data === import_client89.pingConst) {
83128
+ void this.sendRequest({ method: import_client89.pingConst, params: [] }).catch((err) => {
83129
83129
  this.ctx.error("failed to send ping", { err });
83130
83130
  });
83131
83131
  return;
@@ -83190,8 +83190,8 @@ var require_connection2 = __commonJS({
83190
83190
  if (this.websocket !== wsocket) {
83191
83191
  return;
83192
83192
  }
83193
- const useBinary = this.opt?.useBinaryProtocol ?? (0, import_platform4.getMetadata)(import_client88.default.metadata.UseBinaryProtocol) ?? true;
83194
- this.compressionMode = this.opt?.useProtocolCompression ?? (0, import_platform4.getMetadata)(import_client88.default.metadata.UseProtocolCompression) ?? false;
83193
+ const useBinary = this.opt?.useBinaryProtocol ?? (0, import_platform4.getMetadata)(import_client89.default.metadata.UseBinaryProtocol) ?? true;
83194
+ this.compressionMode = this.opt?.useProtocolCompression ?? (0, import_platform4.getMetadata)(import_client89.default.metadata.UseProtocolCompression) ?? false;
83195
83195
  const helloRequest = {
83196
83196
  method: "hello",
83197
83197
  params: [],
@@ -83237,13 +83237,13 @@ var require_connection2 = __commonJS({
83237
83237
  if (w instanceof Promise) {
83238
83238
  await w;
83239
83239
  }
83240
- if (data.method !== import_client88.pingConst) {
83240
+ if (data.method !== import_client89.pingConst) {
83241
83241
  this.requests.set(id, promise4);
83242
83242
  }
83243
83243
  promise4.sendData = () => {
83244
- if (this.websocket?.readyState === import_client88.ClientSocketReadyState.OPEN) {
83244
+ if (this.websocket?.readyState === import_client89.ClientSocketReadyState.OPEN) {
83245
83245
  promise4.startTime = Date.now();
83246
- if (data.method !== import_client88.pingConst) {
83246
+ if (data.method !== import_client89.pingConst) {
83247
83247
  const dta = this.rpcHandler.serialize(
83248
83248
  {
83249
83249
  method: data.method,
@@ -83256,7 +83256,7 @@ var require_connection2 = __commonJS({
83256
83256
  );
83257
83257
  this.websocket?.send(dta);
83258
83258
  } else {
83259
- this.websocket?.send(import_client88.pingConst);
83259
+ this.websocket?.send(import_client89.pingConst);
83260
83260
  }
83261
83261
  }
83262
83262
  };
@@ -83270,7 +83270,7 @@ var require_connection2 = __commonJS({
83270
83270
  };
83271
83271
  }
83272
83272
  promise4.sendData();
83273
- if (data.method !== import_client88.pingConst) {
83273
+ if (data.method !== import_client89.pingConst) {
83274
83274
  return await promise4.promise;
83275
83275
  }
83276
83276
  },
@@ -83436,7 +83436,7 @@ var require_lib20 = __commonJS({
83436
83436
  default: () => index_default
83437
83437
  });
83438
83438
  module2.exports = __toCommonJS2(index_exports2);
83439
- var import_client88 = __toESM2(require_lib7());
83439
+ var import_client89 = __toESM2(require_lib7());
83440
83440
  var import_core105 = __toESM2(require_lib5());
83441
83441
  var import_platform4 = __toESM2(require_lib());
83442
83442
  var import_connection = require_connection2();
@@ -83480,8 +83480,8 @@ var require_lib20 = __commonJS({
83480
83480
  return {
83481
83481
  function: {
83482
83482
  GetClient: /* @__PURE__ */ __name(async (token, endpoint, opt) => {
83483
- const filterModel = (0, import_platform4.getMetadata)(import_client88.default.metadata.FilterModel) ?? "none";
83484
- const extraFilter = (0, import_platform4.getMetadata)(import_client88.default.metadata.ExtraFilter) ?? [];
83483
+ const filterModel = (0, import_platform4.getMetadata)(import_client89.default.metadata.FilterModel) ?? "none";
83484
+ const extraFilter = (0, import_platform4.getMetadata)(import_client89.default.metadata.ExtraFilter) ?? [];
83485
83485
  const handler = /* @__PURE__ */ __name(async (handler2) => {
83486
83486
  const url4 = (0, import_core105.concatLink)(endpoint, `/${token}`);
83487
83487
  const upgradeHandler = /* @__PURE__ */ __name((...txes) => {
@@ -83509,7 +83509,7 @@ var require_lib20 = __commonJS({
83509
83509
  throw new Error("Workspace or account not found in token");
83510
83510
  }
83511
83511
  const newOpt = { ...opt };
83512
- const connectTimeout = opt?.connectionTimeout ?? (0, import_platform4.getMetadata)(import_client88.default.metadata.ConnectionTimeout);
83512
+ const connectTimeout = opt?.connectionTimeout ?? (0, import_platform4.getMetadata)(import_client89.default.metadata.ConnectionTimeout);
83513
83513
  let connectPromise;
83514
83514
  if ((connectTimeout ?? 0) > 0) {
83515
83515
  connectPromise = new Promise((resolve2, reject) => {
@@ -83561,7 +83561,7 @@ var require_lib20 = __commonJS({
83561
83561
  function returnUITxes(txes, extraFilter) {
83562
83562
  const configs = /* @__PURE__ */ new Map();
83563
83563
  (0, import_core105.fillConfiguration)(txes, configs);
83564
- const allowedPlugins = [...(0, import_platform4.getPlugins)(), ...(0, import_platform4.getMetadata)(import_client88.default.metadata.ExtraPlugins) ?? []];
83564
+ const allowedPlugins = [...(0, import_platform4.getPlugins)(), ...(0, import_platform4.getMetadata)(import_client89.default.metadata.ExtraPlugins) ?? []];
83565
83565
  const excludedPlugins = Array.from(configs.values()).filter(
83566
83566
  (it) => !it.enabled || !allowedPlugins.includes(it.pluginId) || extraFilter.includes(it.pluginId)
83567
83567
  );
@@ -83609,7 +83609,7 @@ var require_lib20 = __commonJS({
83609
83609
  }
83610
83610
  __name(returnClientTxes, "returnClientTxes");
83611
83611
  function createModelPersistence(workspace2) {
83612
- const overrideStore = (0, import_platform4.getMetadata)(import_client88.default.metadata.OverridePersistenceStore);
83612
+ const overrideStore = (0, import_platform4.getMetadata)(import_client89.default.metadata.OverridePersistenceStore);
83613
83613
  if (overrideStore !== void 0) {
83614
83614
  return overrideStore;
83615
83615
  }
@@ -83706,7 +83706,7 @@ var require_client6 = __commonJS({
83706
83706
  });
83707
83707
  module2.exports = __toCommonJS2(client_exports);
83708
83708
  var import_account_client2 = require_lib6();
83709
- var import_client88 = __toESM2(require_lib7());
83709
+ var import_client89 = __toESM2(require_lib7());
83710
83710
  var import_core105 = require_lib5();
83711
83711
  var import_platform4 = require_lib();
83712
83712
  var import_config10 = require_config();
@@ -83732,9 +83732,9 @@ var require_client6 = __commonJS({
83732
83732
  }
83733
83733
  __name(connect, "connect");
83734
83734
  async function createClient(url4, endpoint, token, workspaceUuid, account, config3, options) {
83735
- (0, import_platform4.addLocation)(import_client88.clientId, () => Promise.resolve().then(() => __toESM(require_lib20())));
83735
+ (0, import_platform4.addLocation)(import_client89.clientId, () => Promise.resolve().then(() => __toESM(require_lib20())));
83736
83736
  const { socketFactory, connectionTimeout } = options;
83737
- const clientFactory = await (0, import_platform4.getResource)(import_client88.default.function.GetClient);
83737
+ const clientFactory = await (0, import_platform4.getResource)(import_client89.default.function.GetClient);
83738
83738
  const connection = await clientFactory(token, endpoint, {
83739
83739
  socketFactory,
83740
83740
  connectionTimeout
@@ -84855,11 +84855,11 @@ var require_storage2 = __commonJS({
84855
84855
  var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
84856
84856
  var storage_exports = {};
84857
84857
  __export2(storage_exports, {
84858
- connectStorage: () => import_client88.connectStorage,
84859
- createStorageClient: () => import_client88.createStorageClient
84858
+ connectStorage: () => import_client89.connectStorage,
84859
+ createStorageClient: () => import_client89.createStorageClient
84860
84860
  });
84861
84861
  module2.exports = __toCommonJS2(storage_exports);
84862
- var import_client88 = require_client7();
84862
+ var import_client89 = require_client7();
84863
84863
  __reExport2(storage_exports, require_error3(), module2.exports);
84864
84864
  __reExport2(storage_exports, require_types8(), module2.exports);
84865
84865
  }
@@ -116881,10 +116881,10 @@ var require_code3 = __commonJS({
116881
116881
  return schemaMap ? Object.keys(schemaMap).filter((p) => p !== "__proto__") : [];
116882
116882
  }
116883
116883
  exports2.allSchemaProperties = allSchemaProperties;
116884
- function schemaProperties(it, schemaMap) {
116884
+ function schemaProperties2(it, schemaMap) {
116885
116885
  return allSchemaProperties(schemaMap).filter((p) => !(0, util_1.alwaysValidSchema)(it, schemaMap[p]));
116886
116886
  }
116887
- exports2.schemaProperties = schemaProperties;
116887
+ exports2.schemaProperties = schemaProperties2;
116888
116888
  function callValidateCode({ schemaCode, data, it: { gen: gen6, topSchemaRef, schemaPath, errorPath }, it }, func2, context6, passSchema) {
116889
116889
  const dataAndSchema = passSchema ? (0, codegen_1._)`${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data;
116890
116890
  const valCxt = [
@@ -158122,6 +158122,16 @@ var InvalidStatusError = class extends Schema_exports.TaggedError()(
158122
158122
  return `Invalid status '${this.status}' for project '${this.project}'`;
158123
158123
  }
158124
158124
  };
158125
+ var IssueReferenceError = class extends Schema_exports.TaggedError()(
158126
+ "IssueReferenceError",
158127
+ {
158128
+ reason: Schema_exports.String
158129
+ }
158130
+ ) {
158131
+ get message() {
158132
+ return `Invalid issue references: ${this.reason}`;
158133
+ }
158134
+ };
158125
158135
  var CommentNotFoundError = class extends Schema_exports.TaggedError()(
158126
158136
  "CommentNotFoundError",
158127
158137
  {
@@ -158263,6 +158273,7 @@ var HulyDomainError = Schema_exports.Union(
158263
158273
  ViewletNotFoundError,
158264
158274
  ViewletIdentifierAmbiguousError,
158265
158275
  IssueNotFoundError,
158276
+ IssueReferenceError,
158266
158277
  ProjectNotFoundError,
158267
158278
  InvalidStatusError,
158268
158279
  ContactChannelConflictError,
@@ -169336,6 +169347,7 @@ var createErrorResponse = (text, errorCode, errorTag, warnings = []) => {
169336
169347
  };
169337
169348
  var INVALID_PARAMS_TAGS = /* @__PURE__ */ new Set([
169338
169349
  "IssueNotFoundError",
169350
+ "IssueReferenceError",
169339
169351
  "ApprovalRequestNotFoundError",
169340
169352
  "ApprovalRequestTargetNotFoundError",
169341
169353
  "ApprovalRequestInvalidApprovalThresholdError",
@@ -171243,6 +171255,38 @@ var ToolsetsContextSchema = Schema_exports.Struct({
171243
171255
  totalRegisteredToolCount: Count,
171244
171256
  builtinTools: Schema_exports.Array(Schema_exports.Literal("get_version", "get_huly_context"))
171245
171257
  });
171258
+ var ToolScopeContextSchema = Schema_exports.Struct({
171259
+ active: Schema_exports.Boolean,
171260
+ requestedToolsets: Schema_exports.Array(NonEmptyTrimmedString2),
171261
+ enabledToolsets: Schema_exports.Array(NonEmptyTrimmedString2),
171262
+ ignoredToolsets: Schema_exports.Array(NonEmptyTrimmedString2),
171263
+ requestedTools: Schema_exports.Array(NonEmptyTrimmedString2),
171264
+ enabledTools: Schema_exports.Array(NonEmptyTrimmedString2),
171265
+ ignoredTools: Schema_exports.Array(NonEmptyTrimmedString2),
171266
+ availableCategories: Schema_exports.Array(NonEmptyTrimmedString2),
171267
+ visibleRegisteredToolCount: Count,
171268
+ totalRegisteredToolCount: Count,
171269
+ builtinTools: Schema_exports.Array(Schema_exports.Literal("get_version", "get_huly_context"))
171270
+ });
171271
+ var ToolExposureContextSchema = Schema_exports.Struct({
171272
+ configuredMode: Schema_exports.Literal("auto", "native", "proxy"),
171273
+ resolvedMode: Schema_exports.Literal("native", "proxy"),
171274
+ clientKind: Schema_exports.Literal(
171275
+ "claude-code",
171276
+ "claude-ai",
171277
+ "cursor",
171278
+ "windsurf",
171279
+ "github-copilot",
171280
+ "codex",
171281
+ "opencode",
171282
+ "unknown"
171283
+ ),
171284
+ proxyOutputStrict: Schema_exports.Boolean,
171285
+ visibleToolCount: Count,
171286
+ nativeVisibleToolCount: Count,
171287
+ proxyCandidateToolCount: Count,
171288
+ proxyToolNames: Schema_exports.Array(NonEmptyTrimmedString2)
171289
+ });
171246
171290
  var GetHulyContextResultSchema = Schema_exports.Struct({
171247
171291
  package: Schema_exports.Struct({
171248
171292
  name: Schema_exports.Literal("@firfi/huly-mcp"),
@@ -171258,7 +171302,9 @@ var GetHulyContextResultSchema = Schema_exports.Struct({
171258
171302
  huly: HulyRuntimeContextSchema,
171259
171303
  auth: AuthContextSchema,
171260
171304
  configSources: ConfigSourcesSchema,
171261
- toolsets: ToolsetsContextSchema
171305
+ toolsets: ToolsetsContextSchema,
171306
+ toolScope: ToolScopeContextSchema,
171307
+ toolExposure: ToolExposureContextSchema
171262
171308
  });
171263
171309
  var getHulyContextResultJsonSchema = JSONSchema_exports.make(GetHulyContextResultSchema);
171264
171310
 
@@ -172816,7 +172862,7 @@ var CreateIssueParamsSchema = Schema_exports.Struct({
172816
172862
  description: "Issue title"
172817
172863
  }),
172818
172864
  description: Schema_exports.optional(Schema_exports.String.annotations({
172819
- description: "Issue description (markdown supported)"
172865
+ description: "Issue description in markdown. Markdown links to current-workspace Huly browse URLs with _class, _id, and label become native Huly references. External URLs and other-workspace browse URLs stay normal links."
172820
172866
  })),
172821
172867
  priority: Schema_exports.optional(IssuePrioritySchema.annotations({
172822
172868
  description: "Issue priority (urgent, high, medium, low, no-priority)"
@@ -172865,7 +172911,9 @@ var UpdateIssueParamsSchema = Schema_exports.Struct({
172865
172911
  title: Schema_exports.optional(NonEmptyString2.annotations({
172866
172912
  description: "New issue title"
172867
172913
  })),
172868
- description: Schema_exports.optional(clearableText("New issue description (markdown supported).")),
172914
+ description: Schema_exports.optional(clearableText(
172915
+ "New issue description in markdown. Markdown links to current-workspace Huly browse URLs with _class, _id, and label become native Huly references. External URLs and other-workspace browse URLs stay normal links."
172916
+ )),
172869
172917
  priority: Schema_exports.optional(IssuePrioritySchema.annotations({
172870
172918
  description: "New issue priority"
172871
172919
  })),
@@ -181591,25 +181639,8 @@ var parseUpdateDriveFileCommentParams = Schema_exports.decodeUnknown(UpdateDrive
181591
181639
  var parseDeleteDriveFileCommentParams = Schema_exports.decodeUnknown(DeleteDriveFileCommentParamsSchema);
181592
181640
  var parseListDriveFileActivityParams = Schema_exports.decodeUnknown(ListDriveFileActivityParamsSchema);
181593
181641
 
181594
- // src/huly/diagnostics.ts
181595
- var Diagnostics = class extends Context_exports.Tag("@hulymcp/Diagnostics")() {
181596
- };
181597
- var warningLogText = (warning) => `Agent-visible tool warning [${warning.code}]: ${warning.message}`;
181598
- var makeDiagnosticsScope = Effect_exports.gen(function* () {
181599
- const warningsRef = yield* Ref_exports.make([]);
181600
- return {
181601
- service: {
181602
- warnAgent: (warning) => Ref_exports.update(warningsRef, (warnings) => [...warnings, warning]).pipe(
181603
- Effect_exports.zipRight(Effect_exports.logWarning(warningLogText(warning)))
181604
- ),
181605
- trail: (message) => Effect_exports.logInfo(`Diagnostic trail: ${message}`)
181606
- },
181607
- drainWarnings: Ref_exports.get(warningsRef)
181608
- };
181609
- });
181610
-
181611
181642
  // src/version.ts
181612
- var VERSION = true ? "0.43.0" : "0.0.0-dev";
181643
+ var VERSION = true ? "0.44.1" : "0.0.0-dev";
181613
181644
 
181614
181645
  // src/mcp/json-schema-refs.ts
181615
181646
  var isJsonObject = (value3) => typeof value3 === "object" && value3 !== null && !Array.isArray(value3);
@@ -181630,6 +181661,25 @@ var collectJsonSchemaDefinitions = (value3) => {
181630
181661
  return mergeDefinitionRecords([...nestedDefinitions, ownDefinitions]);
181631
181662
  };
181632
181663
  var omitJsonSchemaDocumentMetadata = (schema) => Object.fromEntries(Object.entries(schema).filter(([key]) => key !== "$defs" && key !== "$schema"));
181664
+ var EFFECT_PSEUDO_ID_PREFIX = "/schemas/";
181665
+ var isCollidingSchemaId = (key, value3) => key === "$id" && typeof value3 === "string" && value3.startsWith(EFFECT_PSEUDO_ID_PREFIX);
181666
+ var stripCollidingSchemaIds = (value3) => {
181667
+ if (Array.isArray(value3)) return value3.map(stripCollidingSchemaIds);
181668
+ if (!isJsonObject(value3)) return value3;
181669
+ return Object.fromEntries(
181670
+ Object.entries(value3).filter(([key, nested6]) => !isCollidingSchemaId(key, nested6)).map(([key, nested6]) => [key, stripCollidingSchemaIds(nested6)])
181671
+ );
181672
+ };
181673
+ var stripCollidingSchemaIdsRecord = (record4) => {
181674
+ const stripped = stripCollidingSchemaIds(record4);
181675
+ return isJsonObject(stripped) ? stripped : record4;
181676
+ };
181677
+ var stripCollidingSchemaIdsProperties = (properties) => Object.fromEntries(
181678
+ Object.entries(properties).map(([key, value3]) => {
181679
+ const stripped = stripCollidingSchemaIds(value3);
181680
+ return [key, isJsonObject(stripped) ? stripped : value3];
181681
+ })
181682
+ );
181633
181683
 
181634
181684
  // src/mcp/tool-output-schema.ts
181635
181685
  var toolWarningCodeEnum = [...ToolWarningCodeSchema.literals];
@@ -181669,6 +181719,70 @@ var wrapResultOutputSchema = (resultSchema) => {
181669
181719
  var createToolOutputSchema = (resultSchema) => wrapResultOutputSchema(JSONSchema_exports.make(resultSchema));
181670
181720
  var hulyContextToolOutputSchema = wrapResultOutputSchema(getHulyContextResultJsonSchema);
181671
181721
 
181722
+ // src/mcp/tool-scope.ts
181723
+ var normalizeCsv = (raw) => {
181724
+ const normalized = raw.split(",").map((part) => part.trim().toLowerCase()).filter((part) => part !== "");
181725
+ return [...new Set(normalized)];
181726
+ };
181727
+ var orderedCategories = (definitions) => [...new Set(definitions.map((definition) => definition.category))];
181728
+ var knownValueMap = (values4) => new Map(values4.map((value3) => [value3, value3]));
181729
+ var resolveRequested = (requested, known, unknownMessage, writeError2) => requested.reduce((acc, name) => {
181730
+ const knownValue = known.get(name);
181731
+ if (knownValue !== void 0) {
181732
+ return {
181733
+ ...acc,
181734
+ enabled: [...acc.enabled, knownValue]
181735
+ };
181736
+ }
181737
+ writeError2(unknownMessage(name));
181738
+ return {
181739
+ ...acc,
181740
+ ignored: [...acc.ignored, name]
181741
+ };
181742
+ }, {
181743
+ enabled: [],
181744
+ ignored: []
181745
+ });
181746
+ var resolveToolScope = (rawEnv, definitions, writeError2) => {
181747
+ const requestedToolsets = normalizeCsv(rawEnv.toolsets);
181748
+ const requestedTools = normalizeCsv(rawEnv.tools);
181749
+ const availableCategories = orderedCategories(definitions);
181750
+ const knownCategories = knownValueMap(availableCategories);
181751
+ const knownToolNames = knownValueMap(definitions.map((definition) => definition.name));
181752
+ const toolsets = resolveRequested(
181753
+ requestedToolsets,
181754
+ knownCategories,
181755
+ (category) => `Warning: unknown toolset category "${category}", ignoring. Valid categories: ${availableCategories.join(", ")}`,
181756
+ writeError2
181757
+ );
181758
+ const tools = resolveRequested(
181759
+ requestedTools,
181760
+ knownToolNames,
181761
+ (tool) => `Warning: unknown tool name "${tool}", ignoring.`,
181762
+ writeError2
181763
+ );
181764
+ const filteringActive = requestedToolsets.length > 0 || requestedTools.length > 0;
181765
+ const enabledCategories = new Set(toolsets.enabled);
181766
+ const enabledToolNames = new Set(tools.enabled);
181767
+ const visibleRegisteredToolCount = filteringActive ? definitions.filter(
181768
+ (definition) => enabledCategories.has(definition.category) || enabledToolNames.has(definition.name)
181769
+ ).length : definitions.length;
181770
+ return {
181771
+ filteringActive,
181772
+ requestedToolsets,
181773
+ enabledToolsets: toolsets.enabled,
181774
+ ignoredToolsets: toolsets.ignored,
181775
+ requestedTools,
181776
+ enabledTools: tools.enabled,
181777
+ ignoredTools: tools.ignored,
181778
+ enabledCategories,
181779
+ enabledToolNames,
181780
+ availableCategories,
181781
+ visibleRegisteredToolCount,
181782
+ totalRegisteredToolCount: definitions.length
181783
+ };
181784
+ };
181785
+
181672
181786
  // src/huly/operations/activity-messages.ts
181673
181787
  var import_core11 = __toESM(require_lib5(), 1);
181674
181788
 
@@ -182886,17 +183000,30 @@ var listDirectMessages = (params) => Effect_exports.gen(function* () {
182886
183000
  var import_core19 = __toESM(require_lib5(), 1);
182887
183001
  var import_rank = __toESM(require_lib37(), 1);
182888
183002
 
182889
- // src/huly/operations/document-native-references.ts
183003
+ // src/huly/operations/native-reference-markup.ts
182890
183004
  var malformedReferenceList = (entries2) => entries2.map((entry) => `'${entry}'`).join(", ");
183005
+ var renderMarkdownWithNativeReferencesForWrite = (content, urls, fieldName) => {
183006
+ const rendered = markdownToMarkupStringWithHulyLinks(content, urls);
183007
+ if (rendered.malformedReferences.length > 0) {
183008
+ return {
183009
+ _tag: "malformed",
183010
+ reason: `malformed Huly native reference links in ${fieldName}: ${malformedReferenceList(rendered.malformedReferences)}`
183011
+ };
183012
+ }
183013
+ return {
183014
+ _tag: "success",
183015
+ rendered: { markup: rendered.markup, format: "markup" }
183016
+ };
183017
+ };
183018
+
183019
+ // src/huly/operations/document-native-references.ts
182891
183020
  var renderDocumentContentForWrite = (content) => Effect_exports.gen(function* () {
182892
183021
  const client = yield* HulyClient;
182893
- const rendered = markdownToMarkupStringWithHulyLinks(content, client.markupUrlConfig);
182894
- if (rendered.malformedReferences.length > 0) {
182895
- return yield* new DocumentReferenceError({
182896
- reason: `malformed Huly native reference links in content: ${malformedReferenceList(rendered.malformedReferences)}`
182897
- });
183022
+ const rendered = renderMarkdownWithNativeReferencesForWrite(content, client.markupUrlConfig, "content");
183023
+ if (rendered._tag === "malformed") {
183024
+ return yield* new DocumentReferenceError({ reason: rendered.reason });
182898
183025
  }
182899
- return { markup: rendered.markup, format: "markup" };
183026
+ return rendered.rendered;
182900
183027
  });
182901
183028
 
182902
183029
  // src/huly/operations/documents-shared.ts
@@ -183410,6 +183537,25 @@ var deleteDocument = (params) => Effect_exports.gen(function* () {
183410
183537
 
183411
183538
  // src/huly/operations/issues-shared.ts
183412
183539
  var import_tracker = __toESM(require_lib41(), 1);
183540
+
183541
+ // src/huly/diagnostics.ts
183542
+ var Diagnostics = class extends Context_exports.Tag("@hulymcp/Diagnostics")() {
183543
+ };
183544
+ var warningLogText = (warning) => `Agent-visible tool warning [${warning.code}]: ${warning.message}`;
183545
+ var makeDiagnosticsScope = Effect_exports.gen(function* () {
183546
+ const warningsRef = yield* Ref_exports.make([]);
183547
+ return {
183548
+ service: {
183549
+ warnAgent: (warning) => Ref_exports.update(warningsRef, (warnings) => [...warnings, warning]).pipe(
183550
+ Effect_exports.zipRight(Effect_exports.logWarning(warningLogText(warning)))
183551
+ ),
183552
+ trail: (message) => Effect_exports.logInfo(`Diagnostic trail: ${message}`)
183553
+ },
183554
+ drainWarnings: Ref_exports.get(warningsRef)
183555
+ };
183556
+ });
183557
+
183558
+ // src/huly/operations/issues-shared.ts
183413
183559
  var zeroAsUnset = (value3) => value3 > 0 ? PositiveNumber.make(value3) : void 0;
183414
183560
  var findProject = (projectIdentifier) => Effect_exports.gen(function* () {
183415
183561
  const client = yield* HulyClient;
@@ -183795,6 +183941,36 @@ var listMentions = (params) => Effect_exports.gen(function* () {
183795
183941
  });
183796
183942
 
183797
183943
  // src/mcp/tools/registry.ts
183944
+ var ToolName = Schema_exports.NonEmptyTrimmedString.pipe(Schema_exports.brand("ToolName")).annotations({
183945
+ identifier: "ToolName",
183946
+ title: "ToolName",
183947
+ description: "Exact MCP tool name registered by this server."
183948
+ });
183949
+ var ToolDescription = Schema_exports.NonEmptyTrimmedString.pipe(Schema_exports.brand("ToolDescription")).annotations({
183950
+ identifier: "ToolDescription",
183951
+ title: "ToolDescription",
183952
+ description: "Human-readable MCP tool description."
183953
+ });
183954
+ var ToolCategory = Schema_exports.NonEmptyTrimmedString.pipe(Schema_exports.brand("ToolCategory")).annotations({
183955
+ identifier: "ToolCategory",
183956
+ title: "ToolCategory",
183957
+ description: "MCP tool category used for toolset filtering and proxy discovery."
183958
+ });
183959
+ var makeToolName = (value3) => ToolName.make(value3);
183960
+ var makeToolDescription = (value3) => ToolDescription.make(value3);
183961
+ var makeToolCategory = (value3) => ToolCategory.make(value3);
183962
+ var parseToolName = (input) => {
183963
+ const decoded = Schema_exports.decodeUnknownEither(ToolName)(input);
183964
+ return Either_exports.isRight(decoded) ? decoded.right : void 0;
183965
+ };
183966
+ var createToolDefinition = (spec) => ({
183967
+ name: makeToolName(spec.name),
183968
+ description: makeToolDescription(spec.description),
183969
+ inputSchema: spec.inputSchema,
183970
+ outputSchema: spec.outputSchema,
183971
+ category: makeToolCategory(spec.category),
183972
+ ...spec.annotations === void 0 ? {} : { annotations: spec.annotations }
183973
+ });
183798
183974
  var deriveTitle = (name) => name.split("_").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
183799
183975
  var READ_PREFIXES = ["list_", "get_", "describe_", "search_", "fulltext_", "download_", "preview_"];
183800
183976
  var CREATE_PREFIXES = ["create_", "add_", "upload_", "send_", "log_"];
@@ -183864,7 +184040,7 @@ var isEmptyStructUnionSchema = (schema) => {
183864
184040
  var requiresArgumentsObject = (tool) => isToolInputSchema(tool.inputSchema) && (hasRequiredFields(tool.inputSchema) || unionVariants(tool.inputSchema).some(hasRequiredFields));
183865
184041
  var isNoArgumentTool = (tool) => isToolInputSchema(tool.inputSchema) && !requiresArgumentsObject(tool) && (!hasDeclaredProperties(tool.inputSchema) && tool.inputSchema.additionalProperties === false || isEmptyStructUnionSchema(tool.inputSchema));
183866
184042
  var encodeOutput = (schema, result) => Schema_exports.encodeUnknownSync(schema)(result);
183867
- var stripResultSchema = (spec) => ({
184043
+ var stripResultSchema = (spec) => createToolDefinition({
183868
184044
  name: spec.name,
183869
184045
  description: spec.description,
183870
184046
  inputSchema: spec.inputSchema,
@@ -196563,6 +196739,16 @@ var getIssue = (params) => Effect_exports.gen(function* () {
196563
196739
  );
196564
196740
  });
196565
196741
 
196742
+ // src/huly/operations/issue-native-references.ts
196743
+ var renderIssueDescriptionForWrite = (description) => Effect_exports.gen(function* () {
196744
+ const client = yield* HulyClient;
196745
+ const rendered = renderMarkdownWithNativeReferencesForWrite(description, client.markupUrlConfig, "description");
196746
+ if (rendered._tag === "malformed") {
196747
+ return yield* new IssueReferenceError({ reason: rendered.reason });
196748
+ }
196749
+ return rendered.rendered;
196750
+ });
196751
+
196566
196752
  // src/huly/operations/issues-write-shared.ts
196567
196753
  var resolveAssignee = (client, assigneeIdentifier) => Effect_exports.gen(function* () {
196568
196754
  const person = yield* findPersonByEmailOrName(client, assigneeIdentifier);
@@ -196654,24 +196840,32 @@ var updateIssue = (params) => Effect_exports.gen(function* () {
196654
196840
  params.project
196655
196841
  );
196656
196842
  const descriptionUpdatedInPlace = params.description !== void 0 && textContentOrClear(params.description) !== void 0 && Boolean(issue2.description);
196843
+ const descriptionUpdateEntry = (operations) => coveredUpdateEntry("description", operations);
196657
196844
  const updateEntries = {
196658
196845
  title: Effect_exports.succeed(coveredUpdateEntry("title", params.title === void 0 ? {} : { title: params.title })),
196659
196846
  description: Effect_exports.gen(function* () {
196660
- if (params.description === void 0) return coveredUpdateEntry("description", {});
196847
+ if (params.description === void 0) return descriptionUpdateEntry({});
196661
196848
  const description = textContentOrClear(params.description);
196662
- if (description === void 0) return coveredUpdateEntry("description", { description: null });
196849
+ if (description === void 0) return descriptionUpdateEntry({ description: null });
196850
+ const renderedDescription = yield* renderIssueDescriptionForWrite(description);
196663
196851
  if (issue2.description) {
196664
- yield* client.updateMarkup(tracker.class.Issue, issue2._id, "description", description, "markdown");
196665
- return coveredUpdateEntry("description", {});
196852
+ yield* client.updateMarkup(
196853
+ tracker.class.Issue,
196854
+ issue2._id,
196855
+ "description",
196856
+ renderedDescription.markup,
196857
+ renderedDescription.format
196858
+ );
196859
+ return descriptionUpdateEntry({});
196666
196860
  }
196667
196861
  const descriptionMarkupRef = yield* client.uploadMarkup(
196668
196862
  tracker.class.Issue,
196669
196863
  issue2._id,
196670
196864
  "description",
196671
- description,
196672
- "markdown"
196865
+ renderedDescription.markup,
196866
+ renderedDescription.format
196673
196867
  );
196674
- return coveredUpdateEntry("description", { description: descriptionMarkupRef });
196868
+ return descriptionUpdateEntry({ description: descriptionMarkupRef });
196675
196869
  }),
196676
196870
  priority: Effect_exports.succeed(
196677
196871
  coveredUpdateEntry(
@@ -196752,6 +196946,7 @@ var createIssue = (params) => Effect_exports.gen(function* () {
196752
196946
  const taskTypeStatusRef = taskTypeWorkflow === void 0 ? void 0 : yield* chooseStatusForTaskType(taskTypeWorkflow, params.status, void 0, params.project);
196753
196947
  const statusRef = taskTypeStatusRef !== void 0 ? taskTypeStatusRef : params.status !== void 0 ? yield* resolveStatusByName(statuses, params.status, params.project) : defaultStatusId !== void 0 ? defaultStatusId : yield* Effect_exports.fail(new InvalidStatusError({ status: "(default)", project: params.project }));
196754
196948
  const assigneeRef = params.assignee !== void 0 ? (yield* resolveAssignee(client, params.assignee))._id : null;
196949
+ const renderedDescription = params.description !== void 0 && params.description.trim() !== "" ? yield* renderIssueDescriptionForWrite(params.description) : void 0;
196755
196950
  const parentIssueParam = params.parentIssue;
196756
196951
  const { attachedTo, attachedToClass, collection, parents } = parentIssueParam !== void 0 ? yield* Effect_exports.gen(function* () {
196757
196952
  const parentIssue = yield* findIssueInProject(client, project3, parentIssueParam);
@@ -196790,13 +196985,13 @@ var createIssue = (params) => Effect_exports.gen(function* () {
196790
196985
  { sort: { rank: import_core60.SortingOrder.Descending } }
196791
196986
  );
196792
196987
  const rank = (0, import_rank5.makeRank)(lastIssue?.rank, void 0);
196793
- const descriptionMarkupRef = params.description !== void 0 && params.description.trim() !== "" ? yield* client.uploadMarkup(
196988
+ const descriptionMarkupRef = renderedDescription === void 0 ? null : yield* client.uploadMarkup(
196794
196989
  tracker.class.Issue,
196795
196990
  issueId,
196796
196991
  "description",
196797
- params.description,
196798
- "markdown"
196799
- ) : null;
196992
+ renderedDescription.markup,
196993
+ renderedDescription.format
196994
+ );
196800
196995
  const priority = stringToPriority(params.priority ?? DEFAULT_ISSUE_PRIORITY);
196801
196996
  const identifier2 = `${project3.identifier}-${sequence}`;
196802
196997
  const issueData = {
@@ -197482,7 +197677,7 @@ var issueTools = [
197482
197677
  defineTool(
197483
197678
  {
197484
197679
  name: "create_issue",
197485
- description: "Create a new issue in a Huly project. Optionally set taskType by ID or display name; it is resolved within the target project's project type, and status is validated against that task type's workflow. Use list_task_types or get_project_type to discover valid task types and statuses. Optionally create as a sub-issue by specifying parentIssue. Description supports markdown formatting. Returns the created issue identifier.",
197680
+ description: "Create a new issue in a Huly project. Optionally set taskType by ID or display name; it is resolved within the target project's project type, and status is validated against that task type's workflow. Use list_task_types or get_project_type to discover valid task types and statuses. Optionally create as a sub-issue by specifying parentIssue. Description supports markdown formatting; markdown links to current-workspace Huly browse URLs with _class, _id, and label become native references, while external URLs stay normal links. Returns the created issue identifier.",
197486
197681
  category: CATEGORY21,
197487
197682
  inputSchema: createIssueParamsJsonSchema,
197488
197683
  resultSchema: CreateIssueResultSchema
@@ -197493,7 +197688,7 @@ var issueTools = [
197493
197688
  defineTool(
197494
197689
  {
197495
197690
  name: "update_issue",
197496
- description: "Update fields on an existing Huly issue. Optionally set taskType by ID or display name; it is resolved within the target project's project type, and the status is preserved only when valid for the new task type. Use list_task_types or get_project_type to discover valid task types and statuses. Only provided fields are modified. Description updates support markdown.",
197691
+ description: "Update fields on an existing Huly issue. Optionally set taskType by ID or display name; it is resolved within the target project's project type, and the status is preserved only when valid for the new task type. Use list_task_types or get_project_type to discover valid task types and statuses. Only provided fields are modified. Description updates support markdown; markdown links to current-workspace Huly browse URLs with _class, _id, and label become native references, while external URLs stay normal links.",
197497
197692
  category: CATEGORY21,
197498
197693
  inputSchema: updateIssueParamsJsonSchema,
197499
197694
  resultSchema: UpdateIssueResultSchema
@@ -207218,14 +207413,20 @@ var buildRegistry = (tools) => {
207218
207413
  }
207219
207414
  };
207220
207415
  };
207221
- var createFilteredRegistry = (categories) => buildRegistry(allTools.filter((t) => categories.has(t.category)));
207222
207416
  var toolRegistry = buildRegistry(allTools);
207417
+ var createScopedRegistry = (scope5) => {
207418
+ if (!scope5.filteringActive) return toolRegistry;
207419
+ return buildRegistry(
207420
+ allTools.filter((t) => scope5.categories.has(t.category) || scope5.toolNames.has(t.name))
207421
+ );
207422
+ };
207223
207423
  var TOOL_DEFINITIONS = Object.fromEntries(toolRegistry.tools);
207224
207424
 
207225
207425
  // src/mcp/huly-context-tool.ts
207226
207426
  var NPM_PACKAGE_NAME = "@firfi/huly-mcp";
207227
- var VERSION_TOOL_NAME = "get_version";
207228
- var GET_HULY_CONTEXT_TOOL_NAME = "get_huly_context";
207427
+ var BUILTIN_TOOL_NAME_LITERALS = ["get_version", "get_huly_context"];
207428
+ var VERSION_TOOL_NAME = makeToolName(BUILTIN_TOOL_NAME_LITERALS[0]);
207429
+ var GET_HULY_CONTEXT_TOOL_NAME = makeToolName(BUILTIN_TOOL_NAME_LITERALS[1]);
207229
207430
  var emptyInputSchema = { type: "object", properties: {}, additionalProperties: false };
207230
207431
  var VersionToolResultSchema = Schema_exports.Struct({
207231
207432
  current: NonEmptyString2,
@@ -207233,7 +207434,9 @@ var VersionToolResultSchema = Schema_exports.Struct({
207233
207434
  });
207234
207435
  var versionToolDefinition = {
207235
207436
  name: VERSION_TOOL_NAME,
207236
- description: "Returns the current version of this Huly MCP server and the latest version available on npm.",
207437
+ description: makeToolDescription(
207438
+ "Returns the current version of this Huly MCP server and the latest version available on npm."
207439
+ ),
207237
207440
  inputSchema: emptyInputSchema,
207238
207441
  outputSchema: createToolOutputSchema(VersionToolResultSchema),
207239
207442
  annotations: {
@@ -207246,7 +207449,9 @@ var versionToolDefinition = {
207246
207449
  };
207247
207450
  var getHulyContextToolDefinition = {
207248
207451
  name: GET_HULY_CONTEXT_TOOL_NAME,
207249
- description: "Returns sanitized runtime and configuration context for this Huly MCP session, including package version, transport, auth mode, Huly URL origin/host, workspace, timeout, and toolset filtering. Does not connect to Huly. Secret values such as tokens, passwords, and credential headers are never returned.",
207452
+ description: makeToolDescription(
207453
+ "Returns sanitized runtime and configuration context for this Huly MCP session, including package version, transport, auth mode, Huly URL origin/host, workspace, timeout, native tool scope filtering, and resolved native/proxy tool exposure. Does not connect to Huly. Secret values such as tokens, passwords, and credential headers are never returned."
207454
+ ),
207250
207455
  inputSchema: emptyInputSchema,
207251
207456
  outputSchema: hulyContextToolOutputSchema,
207252
207457
  annotations: {
@@ -207257,104 +207462,73 @@ var getHulyContextToolDefinition = {
207257
207462
  openWorldHint: false
207258
207463
  }
207259
207464
  };
207260
- var parseToolsets = (raw, writeError2) => {
207261
- if (raw === void 0 || raw.trim() === "") {
207262
- return {
207263
- enabledCategories: void 0,
207264
- requestedCategories: [],
207265
- ignoredCategories: []
207266
- };
207267
- }
207268
- const requested = raw.split(",").map((s) => s.trim().toLowerCase()).filter(Boolean);
207269
- const parsed = requested.reduce((acc, category) => {
207270
- if (CATEGORY_NAMES.has(category)) {
207271
- return {
207272
- ...acc,
207273
- enabledCategories: [...acc.enabledCategories, category]
207274
- };
207275
- }
207276
- writeError2(
207277
- `Warning: unknown toolset category "${category}", ignoring. Valid categories: ${[...CATEGORY_NAMES].join(", ")}`
207278
- );
207279
- return {
207280
- ...acc,
207281
- ignoredCategories: [...acc.ignoredCategories, category]
207282
- };
207283
- }, {
207284
- enabledCategories: [],
207285
- ignoredCategories: []
207286
- });
207287
- const enabled2 = new Set(parsed.enabledCategories);
207288
- return {
207289
- enabledCategories: enabled2.size > 0 ? enabled2 : void 0,
207290
- requestedCategories: requested,
207291
- ignoredCategories: parsed.ignoredCategories
207292
- };
207293
- };
207294
- var builtinToolNames = [VERSION_TOOL_NAME, GET_HULY_CONTEXT_TOOL_NAME];
207465
+ var builtinToolNames = BUILTIN_TOOL_NAME_LITERALS;
207295
207466
  var nonEmptyOrDefault = (value3, fallback) => {
207296
207467
  const trimmed2 = value3?.trim();
207297
207468
  return trimmed2 === void 0 || trimmed2 === "" ? fallback : trimmed2;
207298
207469
  };
207299
- var buildHulyContext = (config3, registry2, toolsetSummary, runtimeConfig) => ({
207300
- package: {
207301
- name: NPM_PACKAGE_NAME,
207302
- version: nonEmptyOrDefault(VERSION, "0.0.0-dev")
207303
- },
207304
- transport: {
207305
- type: config3.transport,
207306
- ...config3.transport === "http" ? {
207307
- http: {
207308
- host: nonEmptyOrDefault(config3.httpHost, "127.0.0.1"),
207309
- port: config3.httpPort ?? DEFAULT_HTTP_PORT
207310
- }
207311
- } : {}
207312
- },
207313
- huly: runtimeConfig.huly,
207314
- auth: runtimeConfig.auth,
207315
- configSources: runtimeConfig.configSources,
207316
- toolsets: {
207317
- filteringActive: toolsetSummary.enabledCategories !== void 0,
207318
- requestedCategories: toolsetSummary.requestedCategories,
207319
- enabledCategories: toolsetSummary.enabledCategories === void 0 ? [] : [...toolsetSummary.enabledCategories],
207320
- ignoredCategories: toolsetSummary.ignoredCategories,
207321
- availableCategories: [...CATEGORY_NAMES],
207322
- visibleRegisteredToolCount: Count.make(registry2.definitions.length),
207323
- totalRegisteredToolCount: Count.make(toolRegistry.definitions.length),
207324
- builtinTools: builtinToolNames
207325
- }
207326
- });
207327
-
207328
- // src/mcp/input-schema-compat.ts
207329
- var ROOT_COMPOSITION_KEYS = /* @__PURE__ */ new Set(["anyOf", "oneOf", "allOf"]);
207330
- var isRecord3 = (value3) => typeof value3 === "object" && value3 !== null && !Array.isArray(value3);
207331
- var mergeObjectFields = (sources) => {
207332
- const merged = sources.reduce(
207333
- (acc, source) => isRecord3(source) ? { ...source, ...acc } : acc,
207334
- {}
207335
- );
207336
- return Object.keys(merged).length > 0 ? merged : void 0;
207337
- };
207338
- var rootCompositionBranches = (schema) => [...ROOT_COMPOSITION_KEYS].flatMap((key) => {
207339
- const branches = Reflect.get(schema, key);
207340
- return Array.isArray(branches) ? branches.filter(isRecord3) : [];
207341
- });
207342
- var schemaAndCompositionDescendants = (schema) => [
207343
- schema,
207344
- ...rootCompositionBranches(schema).flatMap(schemaAndCompositionDescendants)
207345
- ];
207346
- var mergedSchemaField = (schema, field) => mergeObjectFields(schemaAndCompositionDescendants(schema).map((branch) => Reflect.get(branch, field)));
207347
- var toClientCompatibleInputSchema = (schema) => {
207348
- const rootFields = Object.fromEntries(
207349
- Object.entries(schema).filter(([key]) => key !== "type" && !ROOT_COMPOSITION_KEYS.has(key))
207350
- );
207351
- const properties = mergedSchemaField(schema, "properties");
207352
- const defs = collectJsonSchemaDefinitions(schema);
207470
+ var defaultToolExposureContext = (registry2) => ({
207471
+ configuredMode: "auto",
207472
+ resolvedMode: "native",
207473
+ clientKind: "unknown",
207474
+ proxyOutputStrict: false,
207475
+ visibleToolCount: builtinToolNames.length + registry2.definitions.length,
207476
+ nativeVisibleToolCount: registry2.definitions.length,
207477
+ proxyCandidateToolCount: toolRegistry.definitions.length,
207478
+ proxyToolNames: []
207479
+ });
207480
+ var buildHulyContext = (config3, registry2, toolScope, runtimeConfig, exposureContext = defaultToolExposureContext(registry2)) => {
207481
+ const toolExposure = {
207482
+ configuredMode: exposureContext.configuredMode,
207483
+ resolvedMode: exposureContext.resolvedMode,
207484
+ clientKind: exposureContext.clientKind,
207485
+ proxyOutputStrict: exposureContext.proxyOutputStrict,
207486
+ visibleToolCount: Count.make(exposureContext.visibleToolCount),
207487
+ nativeVisibleToolCount: Count.make(exposureContext.nativeVisibleToolCount),
207488
+ proxyCandidateToolCount: Count.make(exposureContext.proxyCandidateToolCount),
207489
+ proxyToolNames: exposureContext.proxyToolNames
207490
+ };
207353
207491
  return {
207354
- ...rootFields,
207355
- type: "object",
207356
- ...properties === void 0 ? {} : { properties },
207357
- ...defs === void 0 ? {} : { $defs: defs }
207492
+ package: {
207493
+ name: NPM_PACKAGE_NAME,
207494
+ version: nonEmptyOrDefault(VERSION, "0.0.0-dev")
207495
+ },
207496
+ transport: {
207497
+ type: config3.transport,
207498
+ ...config3.transport === "http" ? {
207499
+ http: {
207500
+ host: nonEmptyOrDefault(config3.httpHost, "127.0.0.1"),
207501
+ port: config3.httpPort ?? DEFAULT_HTTP_PORT
207502
+ }
207503
+ } : {}
207504
+ },
207505
+ huly: runtimeConfig.huly,
207506
+ auth: runtimeConfig.auth,
207507
+ configSources: runtimeConfig.configSources,
207508
+ toolsets: {
207509
+ filteringActive: toolScope.filteringActive,
207510
+ requestedCategories: toolScope.requestedToolsets,
207511
+ enabledCategories: toolScope.enabledToolsets,
207512
+ ignoredCategories: toolScope.ignoredToolsets,
207513
+ availableCategories: toolScope.availableCategories,
207514
+ visibleRegisteredToolCount: Count.make(registry2.definitions.length),
207515
+ totalRegisteredToolCount: Count.make(toolScope.totalRegisteredToolCount),
207516
+ builtinTools: builtinToolNames
207517
+ },
207518
+ toolScope: {
207519
+ active: toolScope.filteringActive,
207520
+ requestedToolsets: toolScope.requestedToolsets,
207521
+ enabledToolsets: toolScope.enabledToolsets,
207522
+ ignoredToolsets: toolScope.ignoredToolsets,
207523
+ requestedTools: toolScope.requestedTools,
207524
+ enabledTools: toolScope.enabledTools,
207525
+ ignoredTools: toolScope.ignoredTools,
207526
+ availableCategories: toolScope.availableCategories,
207527
+ visibleRegisteredToolCount: Count.make(registry2.definitions.length),
207528
+ totalRegisteredToolCount: Count.make(toolScope.totalRegisteredToolCount),
207529
+ builtinTools: builtinToolNames
207530
+ },
207531
+ toolExposure
207358
207532
  };
207359
207533
  };
207360
207534
 
@@ -207617,12 +207791,7 @@ var readHulyResource = (uri) => Effect_exports.try({
207617
207791
  Effect_exports.flatMap(readParsedHulyResource)
207618
207792
  );
207619
207793
 
207620
- // src/mcp/protocol-handlers.ts
207621
- var DRAIN_POLL_MS = 50;
207622
- var DRAIN_TIMEOUT_MS2 = 3e4;
207623
- var NPM_FETCH_TIMEOUT_MS = 5e3;
207624
- var NPM_PACKAGE_NAME2 = "@firfi/huly-mcp";
207625
- var computeOutputBytes = (response) => response.content.reduce((sum2, c) => sum2 + c.text.length, 0);
207794
+ // src/mcp/protocol-resource-handlers.ts
207626
207795
  var withResourceWarnings = (result, warnings) => warnings.length === 0 ? result : {
207627
207796
  ...result,
207628
207797
  _meta: {
@@ -207630,6 +207799,777 @@ var withResourceWarnings = (result, warnings) => warnings.length === 0 ? result
207630
207799
  warnings
207631
207800
  }
207632
207801
  };
207802
+ var createResourceClientResolutionError = (uri, _error) => new McpError(
207803
+ ErrorCode.InternalError,
207804
+ `Failed to initialize Huly clients while reading resource "${uri}". Verify Huly URL, workspace, and authentication configuration.`
207805
+ );
207806
+ var createResourceListClientResolutionError = (_error) => new McpError(
207807
+ ErrorCode.InternalError,
207808
+ "Failed to initialize Huly clients while listing resources. Verify Huly URL, workspace, and authentication configuration."
207809
+ );
207810
+ var isConfigValidationFailure = (error2) => {
207811
+ if (error2 instanceof ConfigValidationError) return true;
207812
+ if (!Runtime_exports.isFiberFailure(error2)) return false;
207813
+ return Chunk_exports.toArray(Cause_exports.failures(error2[Runtime_exports.FiberFailureCauseId])).some(
207814
+ (failure) => failure instanceof ConfigValidationError
207815
+ );
207816
+ };
207817
+ var resolveResourceClientsOrThrow = async (resolveClients, mapError7) => {
207818
+ try {
207819
+ return await resolveClients();
207820
+ } catch (e) {
207821
+ throw mapError7(e);
207822
+ }
207823
+ };
207824
+ var throwResourceReadError = (uri, cause3) => {
207825
+ const failures3 = Chunk_exports.toArray(Cause_exports.failures(cause3));
207826
+ const failure = failures3[0];
207827
+ if (failure instanceof McpError) throw failure;
207828
+ throw new McpError(ErrorCode.InternalError, `Failed to read Huly resource "${uri}"`);
207829
+ };
207830
+ var throwResourceListError = (cause3) => {
207831
+ const failures3 = Chunk_exports.toArray(Cause_exports.failures(cause3));
207832
+ const failure = failures3[0];
207833
+ if (failure instanceof McpError) throw failure;
207834
+ throw new McpError(ErrorCode.InternalError, "Failed to list Huly resources");
207835
+ };
207836
+ var createResourceProtocolHandlers = (input) => {
207837
+ const listResourcesHandler = async () => {
207838
+ input.enter();
207839
+ try {
207840
+ let clients;
207841
+ try {
207842
+ clients = await input.resolveClients();
207843
+ } catch (e) {
207844
+ if (isConfigValidationFailure(e)) return { resources: [] };
207845
+ throw createResourceListClientResolutionError(e);
207846
+ }
207847
+ const resourceList = await Effect_exports.runPromiseExit(
207848
+ listResources().pipe(
207849
+ Effect_exports.provideService(HulyClient, clients.hulyClient)
207850
+ )
207851
+ );
207852
+ if (Exit_exports.isSuccess(resourceList)) return resourceList.value;
207853
+ return throwResourceListError(resourceList.cause);
207854
+ } finally {
207855
+ input.leave();
207856
+ }
207857
+ };
207858
+ const readResource = async (request3) => {
207859
+ input.enter();
207860
+ try {
207861
+ const { uri } = request3.params;
207862
+ const clients = await resolveResourceClientsOrThrow(
207863
+ input.resolveClients,
207864
+ (error2) => createResourceClientResolutionError(uri, error2)
207865
+ );
207866
+ const diagnosticsScope = await Effect_exports.runPromise(makeDiagnosticsScope);
207867
+ const resourceRead = await Effect_exports.runPromiseExit(
207868
+ readHulyResource(uri).pipe(
207869
+ Effect_exports.provideService(HulyClient, clients.hulyClient),
207870
+ Effect_exports.provideService(Diagnostics, diagnosticsScope.service)
207871
+ )
207872
+ );
207873
+ const warnings = await Effect_exports.runPromise(diagnosticsScope.drainWarnings);
207874
+ if (Exit_exports.isSuccess(resourceRead)) return withResourceWarnings(resourceRead.value, warnings);
207875
+ return throwResourceReadError(uri, resourceRead.cause);
207876
+ } finally {
207877
+ input.leave();
207878
+ }
207879
+ };
207880
+ return {
207881
+ listResources: listResourcesHandler,
207882
+ readResource
207883
+ };
207884
+ };
207885
+
207886
+ // src/mcp/input-schema-compat.ts
207887
+ var ROOT_COMPOSITION_KEYS = /* @__PURE__ */ new Set(["anyOf", "oneOf", "allOf"]);
207888
+ var isRecord3 = (value3) => typeof value3 === "object" && value3 !== null && !Array.isArray(value3);
207889
+ var mergeObjectFields = (sources) => {
207890
+ const merged = sources.reduce(
207891
+ (acc, source) => isRecord3(source) ? { ...source, ...acc } : acc,
207892
+ {}
207893
+ );
207894
+ return Object.keys(merged).length > 0 ? merged : void 0;
207895
+ };
207896
+ var rootCompositionBranches = (schema) => [...ROOT_COMPOSITION_KEYS].flatMap((key) => {
207897
+ const branches = Reflect.get(schema, key);
207898
+ return Array.isArray(branches) ? branches.filter(isRecord3) : [];
207899
+ });
207900
+ var schemaAndCompositionDescendants = (schema) => [
207901
+ schema,
207902
+ ...rootCompositionBranches(schema).flatMap(schemaAndCompositionDescendants)
207903
+ ];
207904
+ var mergedSchemaField = (schema, field) => mergeObjectFields(schemaAndCompositionDescendants(schema).map((branch) => Reflect.get(branch, field)));
207905
+ var toClientCompatibleInputSchema = (schema) => {
207906
+ const rootFields = Object.fromEntries(
207907
+ Object.entries(schema).filter(([key]) => key !== "type" && !ROOT_COMPOSITION_KEYS.has(key))
207908
+ );
207909
+ const properties = mergedSchemaField(schema, "properties");
207910
+ const defs = collectJsonSchemaDefinitions(schema);
207911
+ return {
207912
+ ...rootFields,
207913
+ type: "object",
207914
+ ...properties === void 0 ? {} : { properties },
207915
+ ...defs === void 0 ? {} : { $defs: defs }
207916
+ };
207917
+ };
207918
+
207919
+ // src/mcp/proxy-tool-catalog.ts
207920
+ var SEARCH_DEFAULT_LIMIT = 10;
207921
+ var SEARCH_MAX_LIMIT = 50;
207922
+ var ToolSearchQuery = Schema_exports.NonEmptyTrimmedString.pipe(Schema_exports.brand("ToolSearchQuery"));
207923
+ var ToolParameterName = Schema_exports.NonEmptyTrimmedString.pipe(Schema_exports.brand("ToolParameterName"));
207924
+ var SearchToolLimit = Schema_exports.Number.pipe(
207925
+ Schema_exports.int(),
207926
+ Schema_exports.positive(),
207927
+ Schema_exports.lessThanOrEqualTo(SEARCH_MAX_LIMIT),
207928
+ Schema_exports.brand("SearchToolLimit")
207929
+ );
207930
+ var makeSearchToolLimit = (value3) => SearchToolLimit.make(value3);
207931
+ var SEARCH_DEFAULT_LIMIT_VALUE = makeSearchToolLimit(SEARCH_DEFAULT_LIMIT);
207932
+ var isRecord4 = (value3) => typeof value3 === "object" && value3 !== null && !Array.isArray(value3);
207933
+ var stringArray = (value3) => Array.isArray(value3) && value3.every((item) => typeof item === "string") ? value3 : [];
207934
+ var parseToolParameterName = (value3) => {
207935
+ const decoded = Schema_exports.decodeUnknownEither(ToolParameterName)(value3);
207936
+ return Either_exports.isRight(decoded) ? decoded.right : void 0;
207937
+ };
207938
+ var schemaProperties = (schema) => {
207939
+ const properties = isRecord4(schema) ? schema.properties : void 0;
207940
+ return isRecord4(properties) ? Object.keys(properties).map(parseToolParameterName).filter((name) => name !== void 0) : [];
207941
+ };
207942
+ var schemaRequired = (schema) => isRecord4(schema) ? stringArray(schema.required) : [];
207943
+ var toolParamSummary = (tool) => {
207944
+ const required4 = new Set(schemaRequired(tool.inputSchema));
207945
+ const properties = schemaProperties(tool.inputSchema);
207946
+ return {
207947
+ requiredParams: properties.filter((name) => required4.has(name)),
207948
+ optionalParams: properties.filter((name) => !required4.has(name))
207949
+ };
207950
+ };
207951
+ var categoryDescriptionEntry = (category, description) => [
207952
+ makeToolCategory(category),
207953
+ makeToolDescription(description)
207954
+ ];
207955
+ var CATEGORY_DESCRIPTIONS = new Map([
207956
+ categoryDescriptionEntry(
207957
+ "projects",
207958
+ "Project discovery, project metadata, project target preferences, and project-level settings."
207959
+ ),
207960
+ categoryDescriptionEntry(
207961
+ "issues",
207962
+ "Issue tracking: create, read, update, move, delete, relate, label, and organize Huly issues."
207963
+ ),
207964
+ categoryDescriptionEntry("labels", "Issue and workspace labels for classification and filtering."),
207965
+ categoryDescriptionEntry("tags", "Generic tags that can be created, updated, attached, detached, and listed."),
207966
+ categoryDescriptionEntry("tag-categories", "Tag category administration and tag grouping metadata."),
207967
+ categoryDescriptionEntry(
207968
+ "templates",
207969
+ "Issue and message templates, including template fields, categories, children, and rendering."
207970
+ ),
207971
+ categoryDescriptionEntry("comments", "Comments and discussion content attached to Huly objects."),
207972
+ categoryDescriptionEntry(
207973
+ "collaborators",
207974
+ "Collaborator discovery and participation metadata for documents and other shared objects."
207975
+ ),
207976
+ categoryDescriptionEntry("milestones", "Issue milestone lifecycle and milestone assignment."),
207977
+ categoryDescriptionEntry(
207978
+ "documents",
207979
+ "Teamspaces and documents: create, read, edit, snapshot, inline comment, and delete document content."
207980
+ ),
207981
+ categoryDescriptionEntry(
207982
+ "drive",
207983
+ "Drive spaces, folders, files, versions, comments, and drive membership administration."
207984
+ ),
207985
+ categoryDescriptionEntry(
207986
+ "associations",
207987
+ "Generic associations and relations between Huly documents, issues, cards, and raw objects."
207988
+ ),
207989
+ categoryDescriptionEntry(
207990
+ "inventory",
207991
+ "Inventory products, categories, variants, product media, comments, and attachments."
207992
+ ),
207993
+ categoryDescriptionEntry(
207994
+ "spaces",
207995
+ "Generic Huly spaces, space types, space permissions, members, owners, roles, and preferences."
207996
+ ),
207997
+ categoryDescriptionEntry(
207998
+ "sdk-discovery",
207999
+ "SDK and model discovery helpers for Huly platform classes, attributes, mixins, and enums."
208000
+ ),
208001
+ categoryDescriptionEntry("storage", "Storage diagnostics and storage-backed object helpers."),
208002
+ categoryDescriptionEntry(
208003
+ "attachments",
208004
+ "Issue, document, and generic attachment upload, download, pinning, updating, and deletion."
208005
+ ),
208006
+ categoryDescriptionEntry(
208007
+ "contacts",
208008
+ "People, employees, organizations, contact channels, channel providers, and contact ownership."
208009
+ ),
208010
+ categoryDescriptionEntry(
208011
+ "channels",
208012
+ "Messaging: channels, direct messages, group messages, thread replies, reactions, and saved messages."
208013
+ ),
208014
+ categoryDescriptionEntry(
208015
+ "boards",
208016
+ "Board administration, board labels, board cards, board views, menus, and archive workflows."
208017
+ ),
208018
+ categoryDescriptionEntry("views", "Saved and filtered views across boards and other view-capable Huly modules."),
208019
+ categoryDescriptionEntry("cards", "Generic cards, card spaces, card relations, master tags, and card metadata."),
208020
+ categoryDescriptionEntry("leads", "CRM funnels and leads discovery."),
208021
+ categoryDescriptionEntry(
208022
+ "recruiting",
208023
+ "Recruiting vacancies, applicants, reviews, opinions, candidate skills, and recruiting media."
208024
+ ),
208025
+ categoryDescriptionEntry("custom-fields", "Custom field definitions and custom field values on Huly documents."),
208026
+ categoryDescriptionEntry(
208027
+ "calendar",
208028
+ "Calendar events, recurring events, schedules, meeting rooms, and availability."
208029
+ ),
208030
+ categoryDescriptionEntry(
208031
+ "time tracking",
208032
+ "Time tracking, work logs, time reports, detailed time summaries, and estimates."
208033
+ ),
208034
+ categoryDescriptionEntry("planner", "Planner todos, schedules, work slots, priorities, and completion workflows."),
208035
+ categoryDescriptionEntry(
208036
+ "preferences",
208037
+ "User and project preferences, notification preferences, and preference diagnostics."
208038
+ ),
208039
+ categoryDescriptionEntry(
208040
+ "approvals",
208041
+ "Approval request lifecycle, approval comments, approve/reject/cancel actions, and approval status."
208042
+ ),
208043
+ categoryDescriptionEntry("search", "Workspace-wide full-text and structured search across Huly content."),
208044
+ categoryDescriptionEntry("activity", "Activity timelines and activity messages for Huly objects."),
208045
+ categoryDescriptionEntry(
208046
+ "notifications",
208047
+ "Inbox notifications, notification counts, read state, and notification actions."
208048
+ ),
208049
+ categoryDescriptionEntry("user-statuses", "User status and online/presence status discovery."),
208050
+ categoryDescriptionEntry("virtual-office", "Virtual office rooms, members, presence, and office room state."),
208051
+ categoryDescriptionEntry(
208052
+ "processes",
208053
+ "Huly process definitions, executions, process cards, and process state transitions."
208054
+ ),
208055
+ categoryDescriptionEntry(
208056
+ "workspace",
208057
+ "Workspace metadata, members, settings, access links, invites, and administrative context."
208058
+ ),
208059
+ categoryDescriptionEntry(
208060
+ "task-management",
208061
+ "Task management project types, task types, issue statuses, workflow references, and process setup."
208062
+ ),
208063
+ categoryDescriptionEntry(
208064
+ "test-management",
208065
+ "Test management projects, suites, cases, plans, runs, results, and plan execution."
208066
+ )
208067
+ ]);
208068
+ var categoryDescription = (category) => CATEGORY_DESCRIPTIONS.get(category) ?? ToolDescription.make(`Huly ${category} tools.`);
208069
+ var listCategories = (registry2) => {
208070
+ const counts = /* @__PURE__ */ new Map();
208071
+ for (const tool of registry2.definitions) {
208072
+ counts.set(tool.category, (counts.get(tool.category) ?? 0) + 1);
208073
+ }
208074
+ return createSuccessResponse({
208075
+ categories: [...counts.entries()].map(([name, toolCount]) => ({
208076
+ name,
208077
+ description: categoryDescription(name),
208078
+ toolCount: Count.make(toolCount)
208079
+ }))
208080
+ });
208081
+ };
208082
+ var queryTokens = (query) => query.toLowerCase().split(/[^a-z0-9]+/u).filter((token) => token !== "");
208083
+ var tokenHitCount = (tokens, text) => {
208084
+ const lower = text.toLowerCase();
208085
+ return tokens.filter((token) => lower.includes(token)).length;
208086
+ };
208087
+ var toolScore = (tool, tokens, normalizedQuery) => {
208088
+ const params = toolParamSummary(tool);
208089
+ const paramText = [...params.requiredParams, ...params.optionalParams].join(" ");
208090
+ const categoryText = `${tool.category} ${categoryDescription(tool.category)}`;
208091
+ const exactScore = tool.name.toLowerCase() === normalizedQuery ? 1e4 : 0;
208092
+ return exactScore + tokenHitCount(tokens, tool.name) * 1e3 + tokenHitCount(tokens, categoryText) * 100 + tokenHitCount(tokens, tool.description) * 10 + tokenHitCount(tokens, paramText);
208093
+ };
208094
+ var searchToolDefinitions = (registry2, query, limit = SEARCH_DEFAULT_LIMIT_VALUE) => {
208095
+ const normalizedQuery = query.trim().toLowerCase();
208096
+ const tokens = queryTokens(normalizedQuery);
208097
+ if (tokens.length === 0) return [];
208098
+ return registry2.definitions.map((tool, index) => ({ index, score: toolScore(tool, tokens, normalizedQuery), tool })).filter((match16) => match16.score > 0).sort((a, b) => b.score - a.score || a.index - b.index).slice(0, limit).map((match16) => match16.tool);
208099
+ };
208100
+
208101
+ // src/mcp/proxy-tools.ts
208102
+ var LIST_TOOL_CATEGORIES_TOOL_NAME = ToolName.make("list_tool_categories");
208103
+ var SEARCH_TOOLS_TOOL_NAME = ToolName.make("search_tools");
208104
+ var GET_TOOL_SCHEMA_TOOL_NAME = ToolName.make("get_tool_schema");
208105
+ var INVOKE_TOOL_TOOL_NAME = ToolName.make("invoke_tool");
208106
+ var PROXY_TOOL_CATEGORY = makeToolCategory("proxy");
208107
+ var PROXY_TOOL_NAMES = [
208108
+ LIST_TOOL_CATEGORIES_TOOL_NAME,
208109
+ SEARCH_TOOLS_TOOL_NAME,
208110
+ GET_TOOL_SCHEMA_TOOL_NAME,
208111
+ INVOKE_TOOL_TOOL_NAME
208112
+ ];
208113
+ var EmptyProxyParamsSchema = Schema_exports.Record({ key: Schema_exports.String, value: Schema_exports.Never });
208114
+ var SearchToolsParamsSchema = Schema_exports.Struct({
208115
+ query: ToolSearchQuery,
208116
+ limit: Schema_exports.optionalWith(SearchToolLimit, { exact: true })
208117
+ });
208118
+ var ToolNameParamsSchema = Schema_exports.Struct({
208119
+ toolName: ToolName
208120
+ });
208121
+ var InvokeToolParamsSchema = Schema_exports.Struct({
208122
+ toolName: ToolName,
208123
+ arguments: Schema_exports.optionalWith(Schema_exports.Unknown, { exact: true })
208124
+ });
208125
+ var ProxyToolCategorySchema = Schema_exports.Struct({
208126
+ name: ToolCategory,
208127
+ description: ToolDescription,
208128
+ toolCount: Count
208129
+ });
208130
+ var ListToolCategoriesResultSchema = Schema_exports.Struct({
208131
+ categories: Schema_exports.Array(ProxyToolCategorySchema)
208132
+ });
208133
+ var ToolSearchMatchSchema = Schema_exports.Struct({
208134
+ name: ToolName,
208135
+ category: ToolCategory,
208136
+ description: ToolDescription,
208137
+ requiredParams: Schema_exports.Array(ToolParameterName),
208138
+ optionalParams: Schema_exports.Array(ToolParameterName)
208139
+ });
208140
+ var SearchToolsResultSchema = Schema_exports.Struct({
208141
+ matches: Schema_exports.Array(ToolSearchMatchSchema)
208142
+ });
208143
+ var ToolAnnotationsSchema2 = Schema_exports.Struct({
208144
+ title: Schema_exports.optionalWith(Schema_exports.NonEmptyTrimmedString, { exact: true }),
208145
+ readOnlyHint: Schema_exports.optionalWith(Schema_exports.Boolean, { exact: true }),
208146
+ destructiveHint: Schema_exports.optionalWith(Schema_exports.Boolean, { exact: true }),
208147
+ idempotentHint: Schema_exports.optionalWith(Schema_exports.Boolean, { exact: true }),
208148
+ openWorldHint: Schema_exports.optionalWith(Schema_exports.Boolean, { exact: true })
208149
+ });
208150
+ var GetToolSchemaResultSchema = Schema_exports.Struct({
208151
+ name: ToolName,
208152
+ category: ToolCategory,
208153
+ description: ToolDescription,
208154
+ inputSchema: Schema_exports.Unknown,
208155
+ outputSchema: Schema_exports.Unknown,
208156
+ annotations: ToolAnnotationsSchema2
208157
+ });
208158
+ var InvokeToolResultSchema = Schema_exports.Struct({
208159
+ toolName: ToolName,
208160
+ result: Schema_exports.Unknown,
208161
+ warnings: Schema_exports.optionalWith(Schema_exports.Array(Schema_exports.Unknown), { exact: true })
208162
+ });
208163
+ var emptyInputSchema2 = {
208164
+ type: "object",
208165
+ properties: {},
208166
+ additionalProperties: false
208167
+ };
208168
+ var searchToolsInputSchema = {
208169
+ type: "object",
208170
+ properties: {
208171
+ query: {
208172
+ type: "string",
208173
+ minLength: 1,
208174
+ description: "Search text matched against Huly tool names, categories, descriptions, and parameter names."
208175
+ },
208176
+ limit: {
208177
+ type: "integer",
208178
+ minimum: 1,
208179
+ maximum: SEARCH_MAX_LIMIT,
208180
+ description: "Maximum number of matches to return. Defaults to 10 and cannot exceed 50."
208181
+ }
208182
+ },
208183
+ required: ["query"],
208184
+ additionalProperties: false
208185
+ };
208186
+ var toolNameInputSchema = {
208187
+ type: "object",
208188
+ properties: {
208189
+ toolName: {
208190
+ type: "string",
208191
+ minLength: 1,
208192
+ description: "Exact Huly tool name from search_tools or list_tool_categories results."
208193
+ }
208194
+ },
208195
+ required: ["toolName"],
208196
+ additionalProperties: false
208197
+ };
208198
+ var invokeToolInputSchema = {
208199
+ type: "object",
208200
+ properties: {
208201
+ toolName: {
208202
+ type: "string",
208203
+ minLength: 1,
208204
+ description: "Exact Huly tool name to invoke through the proxy."
208205
+ },
208206
+ arguments: {
208207
+ description: "Arguments object for the target Huly tool. Use {} when the target tool accepts no parameters."
208208
+ }
208209
+ },
208210
+ required: ["toolName"],
208211
+ additionalProperties: false
208212
+ };
208213
+ var readOnlyProxyAnnotations = (title) => ({
208214
+ title,
208215
+ readOnlyHint: true,
208216
+ destructiveHint: false,
208217
+ idempotentHint: true,
208218
+ openWorldHint: false
208219
+ });
208220
+ var proxyToolDefinitions = [
208221
+ createToolDefinition({
208222
+ name: LIST_TOOL_CATEGORIES_TOOL_NAME,
208223
+ description: "Lists Huly tool categories available through this proxy. Use this first when you need a broad map of capabilities before searching for a specific Huly tool.",
208224
+ inputSchema: emptyInputSchema2,
208225
+ outputSchema: createToolOutputSchema(ListToolCategoriesResultSchema),
208226
+ category: PROXY_TOOL_CATEGORY,
208227
+ annotations: readOnlyProxyAnnotations("List Tool Categories")
208228
+ }),
208229
+ createToolDefinition({
208230
+ name: SEARCH_TOOLS_TOOL_NAME,
208231
+ description: "Searches the current proxy-visible Huly tool catalog by tool name, category, description, and parameter names. Returns exact tool names plus required and optional parameter names for single-call follow-up with get_tool_schema or invoke_tool.",
208232
+ inputSchema: searchToolsInputSchema,
208233
+ outputSchema: createToolOutputSchema(SearchToolsResultSchema),
208234
+ category: PROXY_TOOL_CATEGORY,
208235
+ annotations: readOnlyProxyAnnotations("Search Tools")
208236
+ }),
208237
+ createToolDefinition({
208238
+ name: GET_TOOL_SCHEMA_TOOL_NAME,
208239
+ description: "Returns the exact input and output schema for one proxy-visible Huly tool. Use this before invoke_tool when you are not certain about required argument names or result shape.",
208240
+ inputSchema: toolNameInputSchema,
208241
+ outputSchema: createToolOutputSchema(GetToolSchemaResultSchema),
208242
+ category: PROXY_TOOL_CATEGORY,
208243
+ annotations: readOnlyProxyAnnotations("Get Tool Schema")
208244
+ }),
208245
+ createToolDefinition({
208246
+ name: INVOKE_TOOL_TOOL_NAME,
208247
+ description: "Invokes one proxy-visible Huly tool by exact name with its arguments. This tool can call read or write Huly operations; check get_tool_schema and the target tool annotations when safety matters.",
208248
+ inputSchema: invokeToolInputSchema,
208249
+ outputSchema: createToolOutputSchema(InvokeToolResultSchema),
208250
+ category: PROXY_TOOL_CATEGORY,
208251
+ annotations: {
208252
+ title: "Invoke Tool",
208253
+ readOnlyHint: false,
208254
+ destructiveHint: true,
208255
+ idempotentHint: false,
208256
+ openWorldHint: false
208257
+ }
208258
+ })
208259
+ ];
208260
+ var isProxyToolName = (name) => PROXY_TOOL_NAMES.some((toolName) => toolName === name);
208261
+ var decodeOrError = (schema, input, toolName) => {
208262
+ const decoded = Schema_exports.decodeUnknownEither(schema)(input ?? {});
208263
+ if (Either_exports.isRight(decoded)) return decoded.right;
208264
+ return mapParseErrorToMcp(decoded.left, toolName);
208265
+ };
208266
+ var isRecord5 = (value3) => typeof value3 === "object" && value3 !== null && !Array.isArray(value3);
208267
+ var isMcpToolResponse = (value3) => isRecord5(value3) && Array.isArray(value3.content);
208268
+ var searchTools2 = (registry2, args2) => {
208269
+ const params = decodeOrError(SearchToolsParamsSchema, args2, SEARCH_TOOLS_TOOL_NAME);
208270
+ if (isMcpToolResponse(params)) return params;
208271
+ const limit = params.limit ?? SEARCH_DEFAULT_LIMIT_VALUE;
208272
+ const matches = searchToolDefinitions(registry2, params.query, limit).map((tool) => {
208273
+ const paramSummary = toolParamSummary(tool);
208274
+ return {
208275
+ name: tool.name,
208276
+ category: tool.category,
208277
+ description: tool.description,
208278
+ requiredParams: paramSummary.requiredParams,
208279
+ optionalParams: paramSummary.optionalParams
208280
+ };
208281
+ });
208282
+ return createSuccessResponse({ matches });
208283
+ };
208284
+ var getToolSchema = (registry2, args2) => {
208285
+ const params = decodeOrError(ToolNameParamsSchema, args2, GET_TOOL_SCHEMA_TOOL_NAME);
208286
+ if (isMcpToolResponse(params)) return params;
208287
+ const tool = registry2.tools.get(params.toolName);
208288
+ if (tool === void 0) return createUnknownToolError(params.toolName);
208289
+ return createSuccessResponse({
208290
+ name: tool.name,
208291
+ category: tool.category,
208292
+ description: tool.description,
208293
+ inputSchema: tool.inputSchema,
208294
+ outputSchema: tool.outputSchema,
208295
+ annotations: resolveAnnotations(tool)
208296
+ });
208297
+ };
208298
+ var invokeTool = async (registry2, args2, clients) => {
208299
+ const params = decodeOrError(InvokeToolParamsSchema, args2, INVOKE_TOOL_TOOL_NAME);
208300
+ if (isMcpToolResponse(params)) return params;
208301
+ if (!registry2.tools.has(params.toolName)) return createUnknownToolError(params.toolName);
208302
+ const response = await registry2.handleToolCall(
208303
+ params.toolName,
208304
+ params.arguments,
208305
+ clients.hulyClient,
208306
+ clients.storageClient,
208307
+ clients.workspaceClient
208308
+ );
208309
+ if (response === null) return createUnknownToolError(params.toolName);
208310
+ if (response.isError === true) return response;
208311
+ const warnings = response.structuredContent?.warnings ?? [];
208312
+ return createSuccessResponse(
208313
+ {
208314
+ toolName: params.toolName,
208315
+ result: response.structuredContent?.result ?? response.content,
208316
+ ...warnings.length === 0 ? {} : { warnings }
208317
+ },
208318
+ warnings
208319
+ );
208320
+ };
208321
+ var handleProxyToolCall = async (input) => {
208322
+ switch (input.toolName) {
208323
+ case LIST_TOOL_CATEGORIES_TOOL_NAME: {
208324
+ const params = decodeOrError(EmptyProxyParamsSchema, input.args, LIST_TOOL_CATEGORIES_TOOL_NAME);
208325
+ if (isMcpToolResponse(params)) return params;
208326
+ return listCategories(input.proxyCandidateRegistry);
208327
+ }
208328
+ case SEARCH_TOOLS_TOOL_NAME:
208329
+ return searchTools2(input.proxyCandidateRegistry, input.args);
208330
+ case GET_TOOL_SCHEMA_TOOL_NAME:
208331
+ return getToolSchema(input.proxyCandidateRegistry, input.args);
208332
+ case INVOKE_TOOL_TOOL_NAME:
208333
+ if (input.clients === void 0) {
208334
+ return createInvalidParamsError("invoke_tool requires initialized Huly clients.", "ProxyClientsMissing");
208335
+ }
208336
+ return invokeTool(input.proxyCandidateRegistry, input.args, input.clients);
208337
+ default:
208338
+ return createUnknownToolError(input.toolName);
208339
+ }
208340
+ };
208341
+
208342
+ // src/mcp/tool-mode.ts
208343
+ var ToolExposureModeSchema = Schema_exports.Literal("native", "proxy");
208344
+ var ToolModeConfigSchema = Schema_exports.Literal("auto", "native", "proxy");
208345
+ var ProxyOutputStrictEnvSchema = Schema_exports.Literal("true", "false");
208346
+ var decodeToolExposureMode = Schema_exports.decodeUnknownSync(ToolExposureModeSchema);
208347
+ var NATIVE_TOOL_EXPOSURE_MODE = decodeToolExposureMode("native");
208348
+ var PROXY_TOOL_EXPOSURE_MODE = decodeToolExposureMode("proxy");
208349
+ var ToolExposureConfigSchema = Schema_exports.Struct({
208350
+ configuredMode: ToolModeConfigSchema,
208351
+ proxyOutputStrict: Schema_exports.Boolean
208352
+ });
208353
+ var ToolExposureEnvSchema = Schema_exports.Struct({
208354
+ hulyToolMode: Schema_exports.optionalWith(Schema_exports.String, { exact: true }),
208355
+ proxyOutputStrict: Schema_exports.optionalWith(Schema_exports.String, { exact: true })
208356
+ });
208357
+ var DEFAULT_TOOL_EXPOSURE_CONFIG = ToolExposureConfigSchema.make({
208358
+ configuredMode: "auto",
208359
+ proxyOutputStrict: false
208360
+ });
208361
+ var isUnknownRecord = (input) => typeof input === "object" && input !== null && !Array.isArray(input);
208362
+ var envShapeFailure = (input) => {
208363
+ if (isUnknownRecord(input)) {
208364
+ if ("hulyToolMode" in input && input.hulyToolMode !== void 0 && typeof input.hulyToolMode !== "string") {
208365
+ return {
208366
+ _tag: "Failure",
208367
+ field: "HULY_TOOL_MODE",
208368
+ message: "Configuration error: HULY_TOOL_MODE must be a string when set."
208369
+ };
208370
+ }
208371
+ if ("proxyOutputStrict" in input && input.proxyOutputStrict !== void 0 && typeof input.proxyOutputStrict !== "string") {
208372
+ return {
208373
+ _tag: "Failure",
208374
+ field: "PROXY_OUTPUT_STRICT",
208375
+ message: "Configuration error: PROXY_OUTPUT_STRICT must be a string when set."
208376
+ };
208377
+ }
208378
+ }
208379
+ return {
208380
+ _tag: "Failure",
208381
+ field: "HULY_TOOL_MODE",
208382
+ message: "Configuration error: HULY_TOOL_MODE and PROXY_OUTPUT_STRICT must be string environment values."
208383
+ };
208384
+ };
208385
+ var ClientKindSchema = Schema_exports.Literal(
208386
+ "claude-code",
208387
+ "claude-ai",
208388
+ "cursor",
208389
+ "windsurf",
208390
+ "github-copilot",
208391
+ "codex",
208392
+ "opencode",
208393
+ "unknown"
208394
+ );
208395
+ var DEFAULT_MODE_BY_CLIENT_KIND = {
208396
+ "claude-code": NATIVE_TOOL_EXPOSURE_MODE,
208397
+ "claude-ai": PROXY_TOOL_EXPOSURE_MODE,
208398
+ cursor: PROXY_TOOL_EXPOSURE_MODE,
208399
+ windsurf: PROXY_TOOL_EXPOSURE_MODE,
208400
+ "github-copilot": PROXY_TOOL_EXPOSURE_MODE,
208401
+ codex: PROXY_TOOL_EXPOSURE_MODE,
208402
+ opencode: PROXY_TOOL_EXPOSURE_MODE,
208403
+ unknown: PROXY_TOOL_EXPOSURE_MODE
208404
+ };
208405
+ var McpClientName = Schema_exports.Trim.pipe(Schema_exports.nonEmptyString(), Schema_exports.brand("McpClientName")).annotations({
208406
+ identifier: "McpClientName",
208407
+ title: "McpClientName",
208408
+ description: "Trimmed MCP client name from initialize or request metadata."
208409
+ });
208410
+ var McpClientInfoLikeSchema = Schema_exports.Struct({
208411
+ name: Schema_exports.optionalWith(McpClientName, { exact: true })
208412
+ });
208413
+ var trimmedLower = (value3) => value3.trim().toLowerCase();
208414
+ var parseConfiguredMode = (raw) => {
208415
+ if (raw === void 0) {
208416
+ return { _tag: "Success", value: DEFAULT_TOOL_EXPOSURE_CONFIG.configuredMode };
208417
+ }
208418
+ const normalized = trimmedLower(raw);
208419
+ const decoded = Schema_exports.decodeUnknownEither(ToolModeConfigSchema)(normalized);
208420
+ if (Either_exports.isRight(decoded)) return { _tag: "Success", value: decoded.right };
208421
+ return {
208422
+ _tag: "Failure",
208423
+ field: "HULY_TOOL_MODE",
208424
+ message: `Configuration error: HULY_TOOL_MODE must be one of auto, native, or proxy; received "${raw}".`
208425
+ };
208426
+ };
208427
+ var parseProxyOutputStrict = (raw) => {
208428
+ if (raw === void 0) return { _tag: "Success", value: false };
208429
+ const normalized = trimmedLower(raw);
208430
+ const decoded = Schema_exports.decodeUnknownEither(ProxyOutputStrictEnvSchema)(normalized);
208431
+ if (Either_exports.isRight(decoded)) return { _tag: "Success", value: decoded.right === "true" };
208432
+ return {
208433
+ _tag: "Failure",
208434
+ field: "PROXY_OUTPUT_STRICT",
208435
+ message: `Configuration error: PROXY_OUTPUT_STRICT must be true or false; received "${raw}".`
208436
+ };
208437
+ };
208438
+ var parseToolExposureConfig = (input) => {
208439
+ const decodedEnv = Schema_exports.decodeUnknownEither(ToolExposureEnvSchema)(input);
208440
+ if (Either_exports.isLeft(decodedEnv)) return envShapeFailure(input);
208441
+ const env = decodedEnv.right;
208442
+ const configuredMode = parseConfiguredMode(env.hulyToolMode);
208443
+ if (configuredMode._tag === "Failure") return configuredMode;
208444
+ const proxyOutputStrict = parseProxyOutputStrict(env.proxyOutputStrict);
208445
+ if (proxyOutputStrict._tag === "Failure") return proxyOutputStrict;
208446
+ return {
208447
+ _tag: "Success",
208448
+ value: ToolExposureConfigSchema.make({
208449
+ configuredMode: configuredMode.value,
208450
+ proxyOutputStrict: proxyOutputStrict.value
208451
+ })
208452
+ };
208453
+ };
208454
+ var parseMcpClientInfo = (input) => {
208455
+ const decoded = Schema_exports.decodeUnknownEither(McpClientInfoLikeSchema)(input);
208456
+ return Either_exports.isRight(decoded) ? decoded.right : void 0;
208457
+ };
208458
+ var rawClientName = (clientInfo) => {
208459
+ const name = clientInfo?.name?.toLowerCase();
208460
+ if (name === void 0 || name === "") return "";
208461
+ return name;
208462
+ };
208463
+ var withoutRemoteSuffix = (name) => name.replace(/\s*\([^)]*\)\s*$/, "").trim();
208464
+ var makeClientKind = Schema_exports.decodeUnknownSync(ClientKindSchema);
208465
+ var classifyMcpClient = (clientInfo) => {
208466
+ const rawName = rawClientName(clientInfo);
208467
+ if (rawName === "claude-code") return makeClientKind("claude-code");
208468
+ const name = withoutRemoteSuffix(rawName);
208469
+ if (name === "claude-code") return makeClientKind("unknown");
208470
+ if (name === "claude-ai") return makeClientKind("claude-ai");
208471
+ if (name === "cursor-vscode" || name.startsWith("cursor")) return makeClientKind("cursor");
208472
+ if (name.startsWith("windsurf") || name.startsWith("cascade")) return makeClientKind("windsurf");
208473
+ if (name.startsWith("github-copilot") || name.startsWith("copilot") || name.startsWith("visual studio code") || name.startsWith("visual-studio-code")) {
208474
+ return makeClientKind("github-copilot");
208475
+ }
208476
+ if (name.startsWith("codex") || name.startsWith("openai-codex")) return makeClientKind("codex");
208477
+ if (name.startsWith("opencode")) return makeClientKind("opencode");
208478
+ return makeClientKind("unknown");
208479
+ };
208480
+ var resolveToolExposureMode = (input) => {
208481
+ if (input.configuredMode !== "auto") return input.configuredMode;
208482
+ return DEFAULT_MODE_BY_CLIENT_KIND[classifyMcpClient(input.clientInfo)];
208483
+ };
208484
+
208485
+ // src/mcp/protocol-tool-exposure.ts
208486
+ var BUILTIN_TOOL_COUNT = 2;
208487
+ var DEFAULT_HANDLER_EXPOSURE_CONFIG = {
208488
+ configuredMode: "native",
208489
+ proxyOutputStrict: false
208490
+ };
208491
+ var emptyToolRegistry = {
208492
+ tools: /* @__PURE__ */ new Map(),
208493
+ definitions: [],
208494
+ handleToolCall: async () => null
208495
+ };
208496
+ var isObjectPropertyEntry = (entry) => {
208497
+ const value3 = entry[1];
208498
+ return typeof value3 === "object" && value3 !== null;
208499
+ };
208500
+ var objectProperties = (properties) => {
208501
+ if (properties === void 0) return void 0;
208502
+ return Object.entries(properties).filter(isObjectPropertyEntry).reduce(
208503
+ (acc, [key, value3]) => ({ ...acc, [key]: value3 }),
208504
+ {}
208505
+ );
208506
+ };
208507
+ var toProtocolObjectSchema = (schema) => {
208508
+ const { properties, required: required4, ...rest } = schema;
208509
+ const convertedProperties = objectProperties(properties);
208510
+ return {
208511
+ ...stripCollidingSchemaIdsRecord(rest),
208512
+ type: "object",
208513
+ ...convertedProperties === void 0 ? {} : { properties: stripCollidingSchemaIdsProperties(convertedProperties) },
208514
+ ...required4 === void 0 ? {} : { required: [...required4] }
208515
+ };
208516
+ };
208517
+ var normalizeRegistries = (registry2) => "fullRegistry" in registry2 ? registry2 : { fullRegistry: registry2, scopedNativeRegistry: registry2 };
208518
+ var defaultExposureOptions = () => ({
208519
+ exposureConfig: DEFAULT_HANDLER_EXPOSURE_CONFIG,
208520
+ toolScopeFilteringActive: false,
208521
+ currentClientInfo: () => void 0
208522
+ });
208523
+ var resolveProxyCandidateRegistry = (registries, options) => {
208524
+ if (!options.exposureConfig.proxyOutputStrict) return registries.fullRegistry;
208525
+ return options.toolScopeFilteringActive ? registries.scopedNativeRegistry : registries.fullRegistry;
208526
+ };
208527
+ var resolveProtocolExposure = (registries, options) => {
208528
+ const clientInfo = options.currentClientInfo();
208529
+ const clientKind = classifyMcpClient(clientInfo);
208530
+ const resolvedMode = resolveToolExposureMode({
208531
+ configuredMode: options.exposureConfig.configuredMode,
208532
+ ...clientInfo === void 0 ? {} : { clientInfo }
208533
+ });
208534
+ const proxyCandidateRegistry = resolveProxyCandidateRegistry(registries, options);
208535
+ const visibleNativeRegistry = resolvedMode === "native" ? registries.scopedNativeRegistry : options.toolScopeFilteringActive && !options.exposureConfig.proxyOutputStrict ? registries.scopedNativeRegistry : emptyToolRegistry;
208536
+ const visibleToolCount = BUILTIN_TOOL_COUNT + visibleNativeRegistry.definitions.length + (resolvedMode === "proxy" ? proxyToolDefinitions.length : 0);
208537
+ return {
208538
+ context: {
208539
+ configuredMode: options.exposureConfig.configuredMode,
208540
+ resolvedMode,
208541
+ clientKind,
208542
+ proxyOutputStrict: options.exposureConfig.proxyOutputStrict,
208543
+ visibleToolCount,
208544
+ nativeVisibleToolCount: visibleNativeRegistry.definitions.length,
208545
+ proxyCandidateToolCount: proxyCandidateRegistry.definitions.length,
208546
+ proxyToolNames: resolvedMode === "proxy" ? PROXY_TOOL_NAMES : []
208547
+ },
208548
+ visibleNativeRegistry,
208549
+ proxyCandidateRegistry
208550
+ };
208551
+ };
208552
+ var toListedTool = (tool) => ({
208553
+ name: tool.name,
208554
+ description: tool.description,
208555
+ inputSchema: toProtocolObjectSchema(tool.inputSchema),
208556
+ ...tool.outputSchema === void 0 ? {} : { outputSchema: toProtocolObjectSchema(tool.outputSchema) },
208557
+ ...tool.annotations === void 0 ? {} : { annotations: tool.annotations }
208558
+ });
208559
+ var toListedHulyTool = (tool) => toListedTool({
208560
+ name: tool.name,
208561
+ description: tool.description,
208562
+ inputSchema: toClientCompatibleInputSchema(tool.inputSchema),
208563
+ outputSchema: tool.outputSchema,
208564
+ annotations: resolveAnnotations(tool)
208565
+ });
208566
+
208567
+ // src/mcp/protocol-handlers.ts
208568
+ var DRAIN_POLL_MS = 50;
208569
+ var DRAIN_TIMEOUT_MS2 = 3e4;
208570
+ var NPM_FETCH_TIMEOUT_MS = 5e3;
208571
+ var NPM_PACKAGE_NAME2 = "@firfi/huly-mcp";
208572
+ var computeOutputBytes = (response) => response.content.reduce((sum2, c) => sum2 + c.text.length, 0);
207633
208573
  var deriveEditMode = (name, args2) => {
207634
208574
  if (name !== "edit_document" || args2 === void 0) return void 0;
207635
208575
  if (typeof args2 !== "object" || args2 === null || Array.isArray(args2)) return void 0;
@@ -207671,63 +208611,15 @@ var fetchLatestNpmVersion = async (fetchImpl = fetch) => {
207671
208611
  return "unknown";
207672
208612
  }
207673
208613
  };
207674
- var isObjectPropertyEntry = (entry) => {
207675
- const value3 = entry[1];
207676
- return typeof value3 === "object" && value3 !== null;
207677
- };
207678
- var objectProperties = (properties) => {
207679
- if (properties === void 0) return void 0;
207680
- return Object.entries(properties).filter(isObjectPropertyEntry).reduce(
207681
- (acc, [key, value3]) => ({ ...acc, [key]: value3 }),
207682
- {}
207683
- );
207684
- };
207685
- var toProtocolObjectSchema = (schema) => {
207686
- const { properties, required: required4, ...rest } = schema;
207687
- const convertedProperties = objectProperties(properties);
207688
- return {
207689
- ...rest,
207690
- type: "object",
207691
- ...convertedProperties === void 0 ? {} : { properties: convertedProperties },
207692
- ...required4 === void 0 ? {} : { required: [...required4] }
208614
+ var isRecord6 = (value3) => typeof value3 === "object" && value3 !== null && !Array.isArray(value3);
208615
+ var createMcpProtocolHandlers = (resolveClients, telemetry, registry2, getHulyContext, clock3 = liveNowClock, fetchLatestVersion = fetchLatestNpmVersion, exposureOptions = {}) => {
208616
+ const registries = normalizeRegistries(registry2);
208617
+ const defaults = defaultExposureOptions();
208618
+ const protocolExposureOptions = {
208619
+ exposureConfig: exposureOptions.exposureConfig ?? defaults.exposureConfig,
208620
+ currentClientInfo: exposureOptions.currentClientInfo ?? defaults.currentClientInfo,
208621
+ toolScopeFilteringActive: exposureOptions.toolScopeFilteringActive ?? defaults.toolScopeFilteringActive
207693
208622
  };
207694
- };
207695
- var createResourceClientResolutionError = (uri, _error) => new McpError(
207696
- ErrorCode.InternalError,
207697
- `Failed to initialize Huly clients while reading resource "${uri}". Verify Huly URL, workspace, and authentication configuration.`
207698
- );
207699
- var createResourceListClientResolutionError = (_error) => new McpError(
207700
- ErrorCode.InternalError,
207701
- "Failed to initialize Huly clients while listing resources. Verify Huly URL, workspace, and authentication configuration."
207702
- );
207703
- var isConfigValidationFailure = (error2) => {
207704
- if (error2 instanceof ConfigValidationError) return true;
207705
- if (!Runtime_exports.isFiberFailure(error2)) return false;
207706
- return Chunk_exports.toArray(Cause_exports.failures(error2[Runtime_exports.FiberFailureCauseId])).some(
207707
- (failure) => failure instanceof ConfigValidationError
207708
- );
207709
- };
207710
- var shouldReturnEmptyResourceListOnClientResolutionFailure = (error2, _getHulyContext) => isConfigValidationFailure(error2);
207711
- var resolveResourceClientsOrThrow = async (resolveClients, mapError7) => {
207712
- try {
207713
- return await resolveClients();
207714
- } catch (e) {
207715
- throw mapError7(e);
207716
- }
207717
- };
207718
- var throwResourceReadError = (uri, cause3) => {
207719
- const failures3 = Chunk_exports.toArray(Cause_exports.failures(cause3));
207720
- const failure = failures3[0];
207721
- if (failure instanceof McpError) throw failure;
207722
- throw new McpError(ErrorCode.InternalError, `Failed to read Huly resource "${uri}"`);
207723
- };
207724
- var throwResourceListError = (cause3) => {
207725
- const failures3 = Chunk_exports.toArray(Cause_exports.failures(cause3));
207726
- const failure = failures3[0];
207727
- if (failure instanceof McpError) throw failure;
207728
- throw new McpError(ErrorCode.InternalError, "Failed to list Huly resources");
207729
- };
207730
- var createMcpProtocolHandlers = (resolveClients, telemetry, registry2, getHulyContext, clock3 = liveNowClock, fetchLatestVersion = fetchLatestNpmVersion) => {
207731
208623
  let inflight = 0;
207732
208624
  const drainInflight = createDrainInflight(() => inflight, clock3);
207733
208625
  const enter = () => {
@@ -207737,29 +208629,24 @@ var createMcpProtocolHandlers = (resolveClients, telemetry, registry2, getHulyCo
207737
208629
  inflight--;
207738
208630
  };
207739
208631
  const listTools = async () => {
207740
- telemetry.firstListTools();
208632
+ const exposure = resolveProtocolExposure(registries, protocolExposureOptions);
208633
+ telemetry.firstListTools({
208634
+ clientKind: exposure.context.clientKind,
208635
+ resolvedMode: exposure.context.resolvedMode
208636
+ });
207741
208637
  return {
207742
208638
  tools: [
207743
- versionToolDefinition,
207744
- getHulyContextToolDefinition,
207745
- ...registry2.definitions.map((tool) => ({
207746
- name: tool.name,
207747
- description: tool.description,
207748
- inputSchema: toClientCompatibleInputSchema(tool.inputSchema),
207749
- outputSchema: tool.outputSchema,
207750
- annotations: resolveAnnotations(tool)
207751
- }))
207752
- ].map((tool) => ({
207753
- ...tool,
207754
- inputSchema: toProtocolObjectSchema(tool.inputSchema),
207755
- outputSchema: toProtocolObjectSchema(tool.outputSchema)
207756
- }))
208639
+ ...[versionToolDefinition, getHulyContextToolDefinition].map(toListedTool),
208640
+ ...exposure.context.resolvedMode === "proxy" ? proxyToolDefinitions.map(toListedHulyTool) : [],
208641
+ ...exposure.visibleNativeRegistry.definitions.map(toListedHulyTool)
208642
+ ]
207757
208643
  };
207758
208644
  };
207759
208645
  const callTool = async (request3) => {
207760
208646
  enter();
207761
208647
  try {
207762
208648
  const { arguments: args2, name } = request3.params;
208649
+ const exposure = resolveProtocolExposure(registries, protocolExposureOptions);
207763
208650
  const start3 = clock3.currentTimeMillis();
207764
208651
  const inputBytes = JSON.stringify(args2 ?? {}).length;
207765
208652
  const returnError = (errorResponse, editMode2) => {
@@ -207767,6 +208654,8 @@ var createMcpProtocolHandlers = (resolveClients, telemetry, registry2, getHulyCo
207767
208654
  telemetry.toolCalled({
207768
208655
  toolName: name,
207769
208656
  status: "error",
208657
+ clientKind: exposure.context.clientKind,
208658
+ resolvedMode: exposure.context.resolvedMode,
207770
208659
  errorTag: errorResponse._meta?.errorTag,
207771
208660
  durationMs: durationMs2,
207772
208661
  inputBytes,
@@ -207776,7 +208665,7 @@ var createMcpProtocolHandlers = (resolveClients, telemetry, registry2, getHulyCo
207776
208665
  return toMcpResponse(errorResponse);
207777
208666
  };
207778
208667
  if (name === VERSION_TOOL_NAME) {
207779
- if (!isEmptyArgumentsObject(args2)) return returnError(createUnexpectedArgumentsError(name));
208668
+ if (!isEmptyArgumentsObject(args2)) return returnError(createUnexpectedArgumentsError(VERSION_TOOL_NAME));
207780
208669
  const latest = await fetchLatestVersion();
207781
208670
  let versionResult;
207782
208671
  try {
@@ -207789,6 +208678,8 @@ var createMcpProtocolHandlers = (resolveClients, telemetry, registry2, getHulyCo
207789
208678
  telemetry.toolCalled({
207790
208679
  toolName: name,
207791
208680
  status: "success",
208681
+ clientKind: exposure.context.clientKind,
208682
+ resolvedMode: exposure.context.resolvedMode,
207792
208683
  durationMs: durationMs2,
207793
208684
  inputBytes,
207794
208685
  outputBytes: computeOutputBytes(versionResponse)
@@ -207796,10 +208687,12 @@ var createMcpProtocolHandlers = (resolveClients, telemetry, registry2, getHulyCo
207796
208687
  return toMcpResponse(versionResponse);
207797
208688
  }
207798
208689
  if (name === GET_HULY_CONTEXT_TOOL_NAME) {
207799
- if (!isEmptyArgumentsObject(args2)) return returnError(createUnexpectedArgumentsError(name));
208690
+ if (!isEmptyArgumentsObject(args2)) {
208691
+ return returnError(createUnexpectedArgumentsError(GET_HULY_CONTEXT_TOOL_NAME));
208692
+ }
207800
208693
  let context6;
207801
208694
  try {
207802
- context6 = validateHulyContextResult(getHulyContext());
208695
+ context6 = validateHulyContextResult(getHulyContext(exposure.context));
207803
208696
  } catch {
207804
208697
  return returnError(mapDomainErrorToMcp(new HulyError({ message: "Failed to build Huly context" })));
207805
208698
  }
@@ -207808,21 +208701,68 @@ var createMcpProtocolHandlers = (resolveClients, telemetry, registry2, getHulyCo
207808
208701
  telemetry.toolCalled({
207809
208702
  toolName: name,
207810
208703
  status: "success",
208704
+ clientKind: exposure.context.clientKind,
208705
+ resolvedMode: exposure.context.resolvedMode,
207811
208706
  durationMs: durationMs2,
207812
208707
  inputBytes,
207813
208708
  outputBytes: computeOutputBytes(contextResponse)
207814
208709
  });
207815
208710
  return toMcpResponse(contextResponse);
207816
208711
  }
207817
- const tool = registry2.tools.get(name);
208712
+ if (isProxyToolName(name)) {
208713
+ if (exposure.context.resolvedMode !== "proxy") return returnError(createUnknownToolError(name));
208714
+ const editMode2 = name === INVOKE_TOOL_TOOL_NAME && isRecord6(args2) && typeof args2.toolName === "string" ? deriveEditMode(args2.toolName, args2.arguments) : void 0;
208715
+ let clients2;
208716
+ if (name === INVOKE_TOOL_TOOL_NAME) {
208717
+ try {
208718
+ clients2 = await resolveClients();
208719
+ } catch (e) {
208720
+ const errorResponse = mapDomainErrorToMcp(
208721
+ new HulyError({
208722
+ message: `Failed to initialize Huly clients: ${e instanceof Error ? e.message : String(e)}`
208723
+ })
208724
+ );
208725
+ return returnError(errorResponse, editMode2);
208726
+ }
208727
+ }
208728
+ const response2 = await handleProxyToolCall({
208729
+ toolName: name,
208730
+ args: args2,
208731
+ proxyCandidateRegistry: exposure.proxyCandidateRegistry,
208732
+ ...clients2 === void 0 ? {} : {
208733
+ clients: {
208734
+ hulyClient: clients2.hulyClient,
208735
+ storageClient: clients2.storageClient,
208736
+ ...clients2.workspaceClient === void 0 ? {} : { workspaceClient: clients2.workspaceClient }
208737
+ }
208738
+ }
208739
+ });
208740
+ const durationMs2 = clock3.currentTimeMillis() - start3;
208741
+ telemetry.toolCalled({
208742
+ toolName: name,
208743
+ status: response2.isError === true ? "error" : "success",
208744
+ clientKind: exposure.context.clientKind,
208745
+ resolvedMode: exposure.context.resolvedMode,
208746
+ errorTag: response2._meta?.errorTag,
208747
+ durationMs: durationMs2,
208748
+ inputBytes,
208749
+ outputBytes: computeOutputBytes(response2),
208750
+ editMode: editMode2
208751
+ });
208752
+ return toMcpResponse(response2);
208753
+ }
208754
+ const hulyToolName = parseToolName(name);
208755
+ if (hulyToolName === void 0) return returnError(createUnknownToolError(name));
208756
+ const nativeCallRegistry = exposure.visibleNativeRegistry.tools.has(hulyToolName) ? exposure.visibleNativeRegistry : exposure.context.resolvedMode === "proxy" ? exposure.proxyCandidateRegistry : exposure.visibleNativeRegistry;
208757
+ const tool = nativeCallRegistry.tools.get(hulyToolName);
207818
208758
  if (tool === void 0) return returnError(createUnknownToolError(name));
207819
208759
  if (isNoArgumentTool(tool) && !isEmptyArgumentsObject(args2)) {
207820
- return returnError(createUnexpectedArgumentsError(name));
208760
+ return returnError(createUnexpectedArgumentsError(hulyToolName));
207821
208761
  }
207822
208762
  if (args2 === void 0 && requiresArgumentsObject(tool)) {
207823
- return returnError(createMissingArgumentsError(name));
208763
+ return returnError(createMissingArgumentsError(hulyToolName));
207824
208764
  }
207825
- const editMode = deriveEditMode(name, args2);
208765
+ const editMode = deriveEditMode(hulyToolName, args2);
207826
208766
  let clients;
207827
208767
  try {
207828
208768
  clients = await resolveClients();
@@ -207832,8 +208772,8 @@ var createMcpProtocolHandlers = (resolveClients, telemetry, registry2, getHulyCo
207832
208772
  );
207833
208773
  return returnError(errorResponse, editMode);
207834
208774
  }
207835
- const response = await registry2.handleToolCall(
207836
- name,
208775
+ const response = await nativeCallRegistry.handleToolCall(
208776
+ hulyToolName,
207837
208777
  args2,
207838
208778
  clients.hulyClient,
207839
208779
  clients.storageClient,
@@ -207842,8 +208782,10 @@ var createMcpProtocolHandlers = (resolveClients, telemetry, registry2, getHulyCo
207842
208782
  const durationMs = clock3.currentTimeMillis() - start3;
207843
208783
  if (response === null) return returnError(createUnknownToolError(name), editMode);
207844
208784
  telemetry.toolCalled({
207845
- toolName: name,
208785
+ toolName: hulyToolName,
207846
208786
  status: response.isError === true ? "error" : "success",
208787
+ clientKind: exposure.context.clientKind,
208788
+ resolvedMode: exposure.context.resolvedMode,
207847
208789
  errorTag: response._meta?.errorTag,
207848
208790
  durationMs,
207849
208791
  inputBytes,
@@ -207855,55 +208797,13 @@ var createMcpProtocolHandlers = (resolveClients, telemetry, registry2, getHulyCo
207855
208797
  leave();
207856
208798
  }
207857
208799
  };
207858
- const listResourcesHandler = async () => {
207859
- enter();
207860
- try {
207861
- let clients;
207862
- try {
207863
- clients = await resolveClients();
207864
- } catch (e) {
207865
- if (shouldReturnEmptyResourceListOnClientResolutionFailure(e, getHulyContext)) return { resources: [] };
207866
- throw createResourceListClientResolutionError(e);
207867
- }
207868
- const resourceList = await Effect_exports.runPromiseExit(
207869
- listResources().pipe(
207870
- Effect_exports.provideService(HulyClient, clients.hulyClient)
207871
- )
207872
- );
207873
- if (Exit_exports.isSuccess(resourceList)) return resourceList.value;
207874
- return throwResourceListError(resourceList.cause);
207875
- } finally {
207876
- leave();
207877
- }
207878
- };
207879
- const readResource = async (request3) => {
207880
- enter();
207881
- try {
207882
- const { uri } = request3.params;
207883
- const clients = await resolveResourceClientsOrThrow(
207884
- resolveClients,
207885
- (error2) => createResourceClientResolutionError(uri, error2)
207886
- );
207887
- const diagnosticsScope = await Effect_exports.runPromise(makeDiagnosticsScope);
207888
- const resourceRead = await Effect_exports.runPromiseExit(
207889
- readHulyResource(uri).pipe(
207890
- Effect_exports.provideService(HulyClient, clients.hulyClient),
207891
- Effect_exports.provideService(Diagnostics, diagnosticsScope.service)
207892
- )
207893
- );
207894
- const warnings = await Effect_exports.runPromise(diagnosticsScope.drainWarnings);
207895
- if (Exit_exports.isSuccess(resourceRead)) return withResourceWarnings(resourceRead.value, warnings);
207896
- return throwResourceReadError(uri, resourceRead.cause);
207897
- } finally {
207898
- leave();
207899
- }
207900
- };
208800
+ const resourceHandlers = createResourceProtocolHandlers({ resolveClients, enter, leave });
207901
208801
  return {
207902
208802
  listTools,
207903
208803
  callTool,
207904
- listResources: listResourcesHandler,
208804
+ listResources: resourceHandlers.listResources,
207905
208805
  listResourceTemplates,
207906
- readResource,
208806
+ readResource: resourceHandlers.readResource,
207907
208807
  serverDiscover: () => ({
207908
208808
  resultType: "complete",
207909
208809
  supportedVersions: ["2026-07-28"],
@@ -213547,9 +214447,25 @@ var createDefaultMcpSdkServer = () => new Server(
213547
214447
  );
213548
214448
 
213549
214449
  // src/mcp/create-mcp-server.ts
213550
- var createMcpServer = (resolveClients, telemetry, registry2, getHulyContext, createServer = createDefaultMcpSdkServer) => {
214450
+ var currentClientInfoFromServer = (server) => {
214451
+ const maybeServer = server;
214452
+ return parseMcpClientInfo(maybeServer.getClientVersion?.());
214453
+ };
214454
+ var createMcpServer = (resolveClients, telemetry, registry2, getHulyContext, createServer = createDefaultMcpSdkServer, exposureOptions = {}) => {
213551
214455
  const server = createServer();
213552
- const handlers = createMcpProtocolHandlers(resolveClients, telemetry, registry2, getHulyContext);
214456
+ const currentClientInfo = () => exposureOptions.currentClientInfo?.() ?? currentClientInfoFromServer(server);
214457
+ const handlers = createMcpProtocolHandlers(
214458
+ resolveClients,
214459
+ telemetry,
214460
+ registry2,
214461
+ getHulyContext,
214462
+ void 0,
214463
+ void 0,
214464
+ {
214465
+ ...exposureOptions,
214466
+ currentClientInfo
214467
+ }
214468
+ );
213553
214469
  server.setRequestHandler(ListToolsRequestSchema, handlers.listTools);
213554
214470
  server.setRequestHandler(CallToolRequestSchema, handlers.callTool);
213555
214471
  server.setRequestHandler(ListResourcesRequestSchema, handlers.listResources);
@@ -217407,11 +218323,19 @@ var createPostHogTelemetry = (debug, dependencies = defaultDependencies) => {
217407
218323
  }
217408
218324
  });
217409
218325
  },
217410
- firstListTools: () => {
218326
+ firstListTools: (props) => {
217411
218327
  if (listToolsSent) return;
217412
218328
  listToolsSent = true;
217413
- debugLog("[telemetry] first_list_tools");
217414
- capture2({ event: "first_list_tools" });
218329
+ debugLog(`[telemetry] first_list_tools: ${JSON.stringify(props ?? {})}`);
218330
+ capture2(
218331
+ props === void 0 ? { event: "first_list_tools" } : {
218332
+ event: "first_list_tools",
218333
+ properties: {
218334
+ client_kind: props.clientKind,
218335
+ resolved_mode: props.resolvedMode
218336
+ }
218337
+ }
218338
+ );
217415
218339
  },
217416
218340
  toolCalled: (props) => {
217417
218341
  debugLog(`[telemetry] tool_called: ${JSON.stringify(props)}`);
@@ -217421,6 +218345,8 @@ var createPostHogTelemetry = (debug, dependencies = defaultDependencies) => {
217421
218345
  tool_name: props.toolName,
217422
218346
  status: props.status,
217423
218347
  duration_ms: props.durationMs,
218348
+ ...props.clientKind !== void 0 && { client_kind: props.clientKind },
218349
+ ...props.resolvedMode !== void 0 && { resolved_mode: props.resolvedMode },
217424
218350
  ...props.errorTag !== void 0 && { error_tag: props.errorTag },
217425
218351
  ...props.inputBytes !== void 0 && { input_bytes: props.inputBytes },
217426
218352
  ...props.outputBytes !== void 0 && { output_bytes: props.outputBytes },
@@ -217479,6 +218405,23 @@ var McpServerError = class extends Schema_exports.TaggedError()(
217479
218405
  var defaultWriteError = (message) => {
217480
218406
  console.error(message);
217481
218407
  };
218408
+ var parseToolExposureConfigEffect = (env) => {
218409
+ const parsed = parseToolExposureConfig(env);
218410
+ if (parsed._tag === "Success") return Effect_exports.succeed(parsed.value);
218411
+ return Effect_exports.fail(new McpServerError({ message: parsed.message }));
218412
+ };
218413
+ var isRecord7 = (value3) => typeof value3 === "object" && value3 !== null && !Array.isArray(value3);
218414
+ var clientInfoFromMcp2026Request = (req) => {
218415
+ const body = req.body;
218416
+ if (!isRecord7(body) || !isRecord7(body.params) || !isRecord7(body.params._meta)) return void 0;
218417
+ const clientInfo = body.params._meta["io.modelcontextprotocol/clientInfo"];
218418
+ return parseMcpClientInfo(clientInfo);
218419
+ };
218420
+ var clientInfoFromLegacyHttpRequest = (req) => {
218421
+ const body = req.body;
218422
+ if (!isRecord7(body) || !isRecord7(body.params)) return void 0;
218423
+ return parseMcpClientInfo(body.params.clientInfo) ?? clientInfoFromMcp2026Request(req);
218424
+ };
217482
218425
  var McpServerService = class _McpServerService extends Context_exports.Tag("@hulymcp/McpServer")() {
217483
218426
  static layer(config3) {
217484
218427
  return Layer_exports.effect(
@@ -217487,16 +218430,51 @@ var McpServerService = class _McpServerService extends Context_exports.Tag("@hul
217487
218430
  const telemetry = yield* TelemetryService;
217488
218431
  const writeError2 = config3.writeError ?? defaultWriteError;
217489
218432
  const toolsetsRaw = yield* Effect_exports.orElseSucceed(Config_exports.string("TOOLSETS"), () => "");
217490
- const toolsetSummary = parseToolsets(toolsetsRaw || void 0, writeError2);
217491
- const enabledCategories = toolsetSummary.enabledCategories;
217492
- const toolsets = enabledCategories ? [...enabledCategories] : null;
217493
- const registry2 = enabledCategories ? createFilteredRegistry(enabledCategories) : toolRegistry;
218433
+ const toolsRaw = yield* Effect_exports.orElseSucceed(Config_exports.string("TOOLS"), () => "");
218434
+ const hulyToolModeRaw = yield* Effect_exports.orElseSucceed(
218435
+ Config_exports.string("HULY_TOOL_MODE"),
218436
+ () => void 0
218437
+ );
218438
+ const proxyOutputStrictRaw = yield* Effect_exports.orElseSucceed(
218439
+ Config_exports.string("PROXY_OUTPUT_STRICT"),
218440
+ () => void 0
218441
+ );
218442
+ const exposureConfig = yield* parseToolExposureConfigEffect({
218443
+ ...hulyToolModeRaw === void 0 ? {} : { hulyToolMode: hulyToolModeRaw },
218444
+ ...proxyOutputStrictRaw === void 0 ? {} : { proxyOutputStrict: proxyOutputStrictRaw }
218445
+ });
218446
+ const toolScope = resolveToolScope(
218447
+ {
218448
+ toolsets: toolsetsRaw,
218449
+ tools: toolsRaw
218450
+ },
218451
+ toolRegistry.definitions,
218452
+ writeError2
218453
+ );
218454
+ const toolsets = toolScope.filteringActive ? toolScope.enabledToolsets : null;
218455
+ const scopedNativeRegistry = createScopedRegistry({
218456
+ filteringActive: toolScope.filteringActive,
218457
+ categories: toolScope.enabledCategories,
218458
+ toolNames: toolScope.enabledToolNames
218459
+ });
218460
+ const registries = {
218461
+ fullRegistry: toolRegistry,
218462
+ scopedNativeRegistry
218463
+ };
217494
218464
  const getRuntimeConfigContext = config3.getRuntimeConfigContext ?? (() => sanitizeHulyRuntimeConfigFromEnv(process.env));
217495
- const getHulyContext = (runtimeConfig) => buildHulyContext(config3, registry2, toolsetSummary, runtimeConfig);
218465
+ const getHulyContext = (runtimeConfig, toolExposure) => buildHulyContext(config3, scopedNativeRegistry, toolScope, runtimeConfig, toolExposure);
218466
+ const sdkExposureOptions = {
218467
+ exposureConfig,
218468
+ toolScopeFilteringActive: toolScope.filteringActive
218469
+ };
218470
+ const requestExposureOptions = (currentClientInfo) => ({
218471
+ ...sdkExposureOptions,
218472
+ currentClientInfo
218473
+ });
217496
218474
  telemetry.sessionStart({
217497
218475
  transport: config3.transport,
217498
218476
  authMethod: config3.authMethod ?? "password",
217499
- toolCount: registry2.definitions.length,
218477
+ toolCount: scopedNativeRegistry.definitions.length,
217500
218478
  toolsets
217501
218479
  });
217502
218480
  const flushTelemetry = Effect_exports.ignore(
@@ -217516,9 +218494,10 @@ var McpServerService = class _McpServerService extends Context_exports.Tag("@hul
217516
218494
  const [stdioServer, drainInflight] = createMcpServer(
217517
218495
  config3.resolveClients,
217518
218496
  telemetry,
217519
- registry2,
217520
- () => getHulyContext(getRuntimeConfigContext()),
217521
- config3.createServer
218497
+ registries,
218498
+ (toolExposure) => getHulyContext(getRuntimeConfigContext(), toolExposure),
218499
+ config3.createServer,
218500
+ sdkExposureOptions
217522
218501
  );
217523
218502
  yield* Ref_exports.set(serverRef, stdioServer);
217524
218503
  const transport = config3.createStdioTransport?.() ?? new StdioServerTransport();
@@ -217575,9 +218554,10 @@ var McpServerService = class _McpServerService extends Context_exports.Tag("@hul
217575
218554
  return createMcpServer(
217576
218555
  requestResolveClients,
217577
218556
  telemetry,
217578
- registry2,
217579
- () => getHulyContext(requestRuntimeConfig),
217580
- config3.createServer
218557
+ registries,
218558
+ (toolExposure) => getHulyContext(requestRuntimeConfig, toolExposure),
218559
+ config3.createServer,
218560
+ requestExposureOptions(() => clientInfoFromLegacyHttpRequest(req))
217581
218561
  )[0];
217582
218562
  },
217583
218563
  config3.httpTransportDependencies,
@@ -217586,8 +218566,11 @@ var McpServerService = class _McpServerService extends Context_exports.Tag("@hul
217586
218566
  return createMcpProtocolHandlers(
217587
218567
  requestResolveClients,
217588
218568
  telemetry,
217589
- registry2,
217590
- () => getHulyContext(requestRuntimeConfig)
218569
+ registries,
218570
+ (toolExposure) => getHulyContext(requestRuntimeConfig, toolExposure),
218571
+ void 0,
218572
+ void 0,
218573
+ requestExposureOptions(() => clientInfoFromMcp2026Request(req))
217591
218574
  );
217592
218575
  }
217593
218576
  ).pipe(