@workglow/tasks 0.0.120 → 0.0.122

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 (97) hide show
  1. package/dist/browser.js +1041 -255
  2. package/dist/browser.js.map +18 -13
  3. package/dist/bun.js +1061 -258
  4. package/dist/bun.js.map +18 -13
  5. package/dist/common.d.ts +3 -1
  6. package/dist/common.d.ts.map +1 -1
  7. package/dist/node.js +1061 -258
  8. package/dist/node.js.map +18 -13
  9. package/dist/task/ArrayTask.d.ts +1 -10
  10. package/dist/task/ArrayTask.d.ts.map +1 -1
  11. package/dist/task/DateFormatTask.d.ts.map +1 -1
  12. package/dist/task/DebugLogTask.d.ts +3 -1
  13. package/dist/task/DebugLogTask.d.ts.map +1 -1
  14. package/dist/task/DelayTask.d.ts +3 -1
  15. package/dist/task/DelayTask.d.ts.map +1 -1
  16. package/dist/task/FetchUrlTask.d.ts +23 -1
  17. package/dist/task/FetchUrlTask.d.ts.map +1 -1
  18. package/dist/task/FileLoaderTask.d.ts +10 -7
  19. package/dist/task/FileLoaderTask.d.ts.map +1 -1
  20. package/dist/task/FileLoaderTask.server.d.ts +10 -7
  21. package/dist/task/FileLoaderTask.server.d.ts.map +1 -1
  22. package/dist/task/InputTask.d.ts +0 -1
  23. package/dist/task/InputTask.d.ts.map +1 -1
  24. package/dist/task/JavaScriptTask.d.ts +13 -10
  25. package/dist/task/JavaScriptTask.d.ts.map +1 -1
  26. package/dist/task/JsonPathTask.d.ts.map +1 -1
  27. package/dist/task/JsonTask.d.ts +3 -1
  28. package/dist/task/JsonTask.d.ts.map +1 -1
  29. package/dist/task/LambdaTask.d.ts +2 -2
  30. package/dist/task/LambdaTask.d.ts.map +1 -1
  31. package/dist/task/MergeTask.d.ts +3 -1
  32. package/dist/task/MergeTask.d.ts.map +1 -1
  33. package/dist/task/OutputTask.d.ts +0 -1
  34. package/dist/task/OutputTask.d.ts.map +1 -1
  35. package/dist/task/RegexTask.d.ts.map +1 -1
  36. package/dist/task/SplitTask.d.ts +3 -1
  37. package/dist/task/SplitTask.d.ts.map +1 -1
  38. package/dist/task/TemplateTask.d.ts.map +1 -1
  39. package/dist/task/adaptive.d.ts.map +1 -1
  40. package/dist/task/mcp/McpListTask.d.ts +245 -560
  41. package/dist/task/mcp/McpListTask.d.ts.map +1 -1
  42. package/dist/task/mcp/McpPromptGetTask.d.ts +84 -494
  43. package/dist/task/mcp/McpPromptGetTask.d.ts.map +1 -1
  44. package/dist/task/mcp/McpResourceReadTask.d.ts +20 -495
  45. package/dist/task/mcp/McpResourceReadTask.d.ts.map +1 -1
  46. package/dist/task/mcp/McpSearchTask.d.ts +111 -0
  47. package/dist/task/mcp/McpSearchTask.d.ts.map +1 -0
  48. package/dist/task/mcp/McpToolCallTask.d.ts +5 -498
  49. package/dist/task/mcp/McpToolCallTask.d.ts.map +1 -1
  50. package/dist/task/scalar/ScalarAbsTask.d.ts.map +1 -1
  51. package/dist/task/scalar/ScalarAddTask.d.ts.map +1 -1
  52. package/dist/task/scalar/ScalarCeilTask.d.ts.map +1 -1
  53. package/dist/task/scalar/ScalarDivideTask.d.ts.map +1 -1
  54. package/dist/task/scalar/ScalarFloorTask.d.ts.map +1 -1
  55. package/dist/task/scalar/ScalarMaxTask.d.ts.map +1 -1
  56. package/dist/task/scalar/ScalarMinTask.d.ts.map +1 -1
  57. package/dist/task/scalar/ScalarMultiplyTask.d.ts.map +1 -1
  58. package/dist/task/scalar/ScalarRoundTask.d.ts.map +1 -1
  59. package/dist/task/scalar/ScalarSubtractTask.d.ts.map +1 -1
  60. package/dist/task/scalar/ScalarSumTask.d.ts.map +1 -1
  61. package/dist/task/scalar/ScalarTruncTask.d.ts.map +1 -1
  62. package/dist/task/scalar/sumPrecise.d.ts.map +1 -1
  63. package/dist/task/string/StringConcatTask.d.ts.map +1 -1
  64. package/dist/task/string/StringIncludesTask.d.ts.map +1 -1
  65. package/dist/task/string/StringJoinTask.d.ts.map +1 -1
  66. package/dist/task/string/StringLengthTask.d.ts.map +1 -1
  67. package/dist/task/string/StringLowerCaseTask.d.ts.map +1 -1
  68. package/dist/task/string/StringReplaceTask.d.ts.map +1 -1
  69. package/dist/task/string/StringSliceTask.d.ts.map +1 -1
  70. package/dist/task/string/StringTemplateTask.d.ts.map +1 -1
  71. package/dist/task/string/StringTrimTask.d.ts.map +1 -1
  72. package/dist/task/string/StringUpperCaseTask.d.ts.map +1 -1
  73. package/dist/task/vector/VectorDistanceTask.d.ts.map +1 -1
  74. package/dist/task/vector/VectorDivideTask.d.ts.map +1 -1
  75. package/dist/task/vector/VectorDotProductTask.d.ts.map +1 -1
  76. package/dist/task/vector/VectorMultiplyTask.d.ts.map +1 -1
  77. package/dist/task/vector/VectorNormalizeTask.d.ts.map +1 -1
  78. package/dist/task/vector/VectorScaleTask.d.ts.map +1 -1
  79. package/dist/task/vector/VectorSubtractTask.d.ts.map +1 -1
  80. package/dist/task/vector/VectorSumTask.d.ts.map +1 -1
  81. package/dist/types.d.ts +4 -0
  82. package/dist/types.d.ts.map +1 -1
  83. package/dist/util/McpAuthProvider.d.ts +70 -0
  84. package/dist/util/McpAuthProvider.d.ts.map +1 -0
  85. package/dist/util/McpAuthTypes.d.ts +218 -0
  86. package/dist/util/McpAuthTypes.d.ts.map +1 -0
  87. package/dist/util/McpClientUtil.browser.d.ts +110 -0
  88. package/dist/util/McpClientUtil.browser.d.ts.map +1 -0
  89. package/dist/util/McpClientUtil.node.d.ts +134 -0
  90. package/dist/util/McpClientUtil.node.d.ts.map +1 -0
  91. package/dist/util/McpTaskDeps.d.ts +29 -0
  92. package/dist/util/McpTaskDeps.d.ts.map +1 -0
  93. package/dist/util/acorn.d.ts +3 -12
  94. package/dist/util/acorn.d.ts.map +1 -1
  95. package/dist/util/interpreter.d.ts +11 -486
  96. package/dist/util/interpreter.d.ts.map +1 -1
  97. package/package.json +21 -16
package/dist/browser.js CHANGED
@@ -6,9 +6,6 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
6
6
  throw Error('Dynamic require of "' + x + '" is not supported');
7
7
  });
8
8
 
9
- // src/browser.ts
10
- import { TaskRegistry as TaskRegistry2 } from "@workglow/task-graph";
11
-
12
9
  // src/task/adaptive.ts
13
10
  import { CreateAdaptiveWorkflow, Workflow as Workflow10 } from "@workglow/task-graph";
14
11
 
@@ -547,14 +544,16 @@ import {
547
544
  PROPERTY_ARRAY,
548
545
  TaskGraph
549
546
  } from "@workglow/task-graph";
550
- var TypeReplicateArray = (type, annotations = {}) => ({
551
- oneOf: [type, { type: "array", items: type }],
552
- title: type.title,
553
- description: type.description,
554
- ...type.format ? { format: type.format } : {},
555
- ...annotations,
556
- "x-replicate": true
557
- });
547
+ function TypeReplicateArray(type, annotations = {}) {
548
+ return {
549
+ oneOf: [type, { type: "array", items: type }],
550
+ title: type.title,
551
+ description: type.description,
552
+ ...type.format ? { format: type.format } : {},
553
+ ...annotations,
554
+ "x-replicate": true
555
+ };
556
+ }
558
557
 
559
558
  class ArrayTask extends GraphAsTask {
560
559
  static type = "ArrayTask";
@@ -1157,9 +1156,6 @@ class InputTask extends Task12 {
1157
1156
  outputSchema() {
1158
1157
  return this.config?.outputSchema ?? this.constructor.outputSchema();
1159
1158
  }
1160
- async execute(input) {
1161
- return input;
1162
- }
1163
1159
  async executeReactive(input) {
1164
1160
  return input;
1165
1161
  }
@@ -5983,9 +5979,6 @@ class OutputTask extends Task16 {
5983
5979
  outputSchema() {
5984
5980
  return this.config?.outputSchema ?? this.constructor.outputSchema();
5985
5981
  }
5986
- async execute(input2) {
5987
- return input2;
5988
- }
5989
5982
  async executeReactive(input2) {
5990
5983
  return input2;
5991
5984
  }
@@ -6377,26 +6370,22 @@ class TemplateTask extends Task21 {
6377
6370
  Workflow24.prototype.template = CreateWorkflow23(TemplateTask);
6378
6371
  // src/task/mcp/McpListTask.ts
6379
6372
  import { CreateWorkflow as CreateWorkflow24, Task as Task22, Workflow as Workflow25 } from "@workglow/task-graph";
6380
- import {
6381
- mcpClientFactory,
6382
- mcpServerConfigSchema
6383
- } from "@workglow/util";
6373
+
6374
+ // src/util/McpTaskDeps.ts
6375
+ import { createServiceToken, globalServiceRegistry } from "@workglow/util";
6376
+ var MCP_TASK_DEPS = createServiceToken("@workglow/tasks/mcp");
6377
+ function registerMcpTaskDeps(deps) {
6378
+ globalServiceRegistry.registerInstance(MCP_TASK_DEPS, deps);
6379
+ }
6380
+ function getMcpTaskDeps() {
6381
+ if (!globalServiceRegistry.has(MCP_TASK_DEPS)) {
6382
+ throw new Error("MCP task dependencies not registered. Import @workglow/tasks from a platform entry (browser, node, or bun) before using MCP tasks.");
6383
+ }
6384
+ return globalServiceRegistry.get(MCP_TASK_DEPS);
6385
+ }
6386
+
6387
+ // src/task/mcp/McpListTask.ts
6384
6388
  var mcpListTypes = ["tools", "resources", "prompts"];
6385
- var inputSchema22 = {
6386
- type: "object",
6387
- properties: {
6388
- ...mcpServerConfigSchema.properties,
6389
- list_type: {
6390
- type: "string",
6391
- enum: mcpListTypes,
6392
- title: "List Type",
6393
- description: "The type of items to list from the MCP server"
6394
- }
6395
- },
6396
- required: ["transport", "list_type"],
6397
- allOf: mcpServerConfigSchema.allOf,
6398
- additionalProperties: false
6399
- };
6400
6389
  var iconSchema = {
6401
6390
  type: "object",
6402
6391
  properties: {
@@ -6560,7 +6549,22 @@ class McpListTask extends Task22 {
6560
6549
  static cacheable = false;
6561
6550
  static hasDynamicSchemas = true;
6562
6551
  static inputSchema() {
6563
- return inputSchema22;
6552
+ const { mcpServerConfigSchema } = getMcpTaskDeps();
6553
+ return {
6554
+ type: "object",
6555
+ properties: {
6556
+ ...mcpServerConfigSchema.properties,
6557
+ list_type: {
6558
+ type: "string",
6559
+ enum: mcpListTypes,
6560
+ title: "List Type",
6561
+ description: "The type of items to list from the MCP server"
6562
+ }
6563
+ },
6564
+ required: ["transport", "list_type"],
6565
+ allOf: mcpServerConfigSchema.allOf,
6566
+ additionalProperties: false
6567
+ };
6564
6568
  }
6565
6569
  static outputSchema() {
6566
6570
  return outputSchemaAll;
@@ -6594,9 +6598,11 @@ class McpListTask extends Task22 {
6594
6598
  }
6595
6599
  }
6596
6600
  async execute(input2, context) {
6601
+ const { mcpClientFactory } = getMcpTaskDeps();
6597
6602
  const { client } = await mcpClientFactory.create(input2, context.signal);
6603
+ const listType = input2.list_type;
6598
6604
  try {
6599
- switch (input2.list_type) {
6605
+ switch (listType) {
6600
6606
  case "tools": {
6601
6607
  const result = await client.listTools();
6602
6608
  return { tools: result.tools };
@@ -6610,7 +6616,7 @@ class McpListTask extends Task22 {
6610
6616
  return { prompts: result.prompts };
6611
6617
  }
6612
6618
  default:
6613
- throw new Error(`Unsupported list type: ${input2.list_type}`);
6619
+ throw new Error(`Unsupported list type: ${String(listType)}`);
6614
6620
  }
6615
6621
  } finally {
6616
6622
  await client.close();
@@ -6628,29 +6634,6 @@ import {
6628
6634
  TaskConfigSchema as TaskConfigSchema5,
6629
6635
  Workflow as Workflow26
6630
6636
  } from "@workglow/task-graph";
6631
- import {
6632
- mcpClientFactory as mcpClientFactory2,
6633
- mcpServerConfigSchema as mcpServerConfigSchema2
6634
- } from "@workglow/util";
6635
- var configSchema2 = {
6636
- type: "object",
6637
- properties: {
6638
- ...TaskConfigSchema5["properties"],
6639
- ...mcpServerConfigSchema2.properties,
6640
- prompt_name: {
6641
- type: "string",
6642
- title: "Prompt Name",
6643
- description: "The name of the prompt to get",
6644
- format: "string:mcp-promptname"
6645
- }
6646
- },
6647
- required: ["transport", "prompt_name"],
6648
- if: { properties: { transport: { const: "stdio" } }, required: ["transport"] },
6649
- then: { required: ["command"] },
6650
- else: { required: ["server_url"] },
6651
- allOf: mcpServerConfigSchema2.allOf,
6652
- additionalProperties: false
6653
- };
6654
6637
  var annotationsSchema = {
6655
6638
  type: "object",
6656
6639
  properties: {
@@ -6799,7 +6782,26 @@ class McpPromptGetTask extends Task23 {
6799
6782
  return fallbackOutputSchema;
6800
6783
  }
6801
6784
  static configSchema() {
6802
- return configSchema2;
6785
+ const { mcpServerConfigSchema } = getMcpTaskDeps();
6786
+ return {
6787
+ type: "object",
6788
+ properties: {
6789
+ ...TaskConfigSchema5["properties"],
6790
+ ...mcpServerConfigSchema.properties,
6791
+ prompt_name: {
6792
+ type: "string",
6793
+ title: "Prompt Name",
6794
+ description: "The name of the prompt to get",
6795
+ format: "string:mcp-promptname"
6796
+ }
6797
+ },
6798
+ required: ["transport", "prompt_name"],
6799
+ if: { properties: { transport: { const: "stdio" } }, required: ["transport"] },
6800
+ then: { required: ["command"] },
6801
+ else: { required: ["server_url"] },
6802
+ allOf: mcpServerConfigSchema.allOf,
6803
+ additionalProperties: false
6804
+ };
6803
6805
  }
6804
6806
  inputSchema() {
6805
6807
  return this.config?.inputSchema ?? fallbackInputSchema;
@@ -6850,10 +6852,11 @@ class McpPromptGetTask extends Task23 {
6850
6852
  }
6851
6853
  async execute(input2, context) {
6852
6854
  await this.discoverSchemas(context.signal);
6853
- const { client } = await mcpClientFactory2.create(this.config, context.signal);
6855
+ const { mcpClientFactory } = getMcpTaskDeps();
6856
+ const { client } = await mcpClientFactory.create(this.config, context.signal);
6854
6857
  try {
6855
6858
  const result = await client.getPrompt({
6856
- name: this.config.prompt_name,
6859
+ name: String(this.config.prompt_name ?? ""),
6857
6860
  arguments: input2
6858
6861
  });
6859
6862
  return {
@@ -6876,29 +6879,6 @@ import {
6876
6879
  TaskConfigSchema as TaskConfigSchema6,
6877
6880
  Workflow as Workflow27
6878
6881
  } from "@workglow/task-graph";
6879
- import {
6880
- mcpClientFactory as mcpClientFactory3,
6881
- mcpServerConfigSchema as mcpServerConfigSchema3
6882
- } from "@workglow/util";
6883
- var configSchema3 = {
6884
- type: "object",
6885
- properties: {
6886
- ...TaskConfigSchema6["properties"],
6887
- ...mcpServerConfigSchema3.properties,
6888
- resource_uri: {
6889
- type: "string",
6890
- title: "Resource URI",
6891
- description: "The URI of the resource to read",
6892
- format: "string:uri:mcp-resourceuri"
6893
- }
6894
- },
6895
- required: ["transport", "resource_uri"],
6896
- if: { properties: { transport: { const: "stdio" } }, required: ["transport"] },
6897
- then: { required: ["command"] },
6898
- else: { required: ["server_url"] },
6899
- allOf: mcpServerConfigSchema3.allOf,
6900
- additionalProperties: false
6901
- };
6902
6882
  var contentItemSchema = {
6903
6883
  anyOf: [
6904
6884
  {
@@ -6925,7 +6905,7 @@ var contentItemSchema = {
6925
6905
  }
6926
6906
  ]
6927
6907
  };
6928
- var inputSchema23 = {
6908
+ var inputSchema22 = {
6929
6909
  type: "object",
6930
6910
  properties: {},
6931
6911
  additionalProperties: false
@@ -6952,18 +6932,40 @@ class McpResourceReadTask extends Task24 {
6952
6932
  static cacheable = false;
6953
6933
  static customizable = true;
6954
6934
  static inputSchema() {
6955
- return inputSchema23;
6935
+ return inputSchema22;
6956
6936
  }
6957
6937
  static outputSchema() {
6958
6938
  return outputSchema22;
6959
6939
  }
6960
6940
  static configSchema() {
6961
- return configSchema3;
6941
+ const { mcpServerConfigSchema } = getMcpTaskDeps();
6942
+ return {
6943
+ type: "object",
6944
+ properties: {
6945
+ ...TaskConfigSchema6["properties"],
6946
+ ...mcpServerConfigSchema.properties,
6947
+ resource_uri: {
6948
+ type: "string",
6949
+ title: "Resource URI",
6950
+ description: "The URI of the resource to read",
6951
+ format: "string:uri:mcp-resourceuri"
6952
+ }
6953
+ },
6954
+ required: ["transport", "resource_uri"],
6955
+ if: { properties: { transport: { const: "stdio" } }, required: ["transport"] },
6956
+ then: { required: ["command"] },
6957
+ else: { required: ["server_url"] },
6958
+ allOf: mcpServerConfigSchema.allOf,
6959
+ additionalProperties: false
6960
+ };
6962
6961
  }
6963
6962
  async execute(_input, context) {
6964
- const { client } = await mcpClientFactory3.create(this.config, context.signal);
6963
+ const { mcpClientFactory } = getMcpTaskDeps();
6964
+ const { client } = await mcpClientFactory.create(this.config, context.signal);
6965
6965
  try {
6966
- const result = await client.readResource({ uri: this.config.resource_uri });
6966
+ const result = await client.readResource({
6967
+ uri: String(this.config.resource_uri ?? "")
6968
+ });
6967
6969
  return { contents: result.contents };
6968
6970
  } finally {
6969
6971
  await client.close();
@@ -6974,36 +6976,174 @@ var mcpResourceRead = async (config) => {
6974
6976
  return new McpResourceReadTask({}, config).run({});
6975
6977
  };
6976
6978
  Workflow27.prototype.mcpResourceRead = CreateWorkflow26(McpResourceReadTask);
6977
- // src/task/mcp/McpToolCallTask.ts
6978
- import {
6979
- CreateWorkflow as CreateWorkflow27,
6980
- Task as Task25,
6981
- TaskConfigSchema as TaskConfigSchema7,
6982
- Workflow as Workflow28
6983
- } from "@workglow/task-graph";
6984
- import {
6985
- mcpClientFactory as mcpClientFactory4,
6986
- mcpServerConfigSchema as mcpServerConfigSchema4
6987
- } from "@workglow/util";
6988
- var configSchema4 = {
6979
+ // src/task/mcp/McpSearchTask.ts
6980
+ import { CreateWorkflow as CreateWorkflow27, Task as Task25, Workflow as Workflow28 } from "@workglow/task-graph";
6981
+ var MCP_REGISTRY_BASE = "https://registry.modelcontextprotocol.io/v0.1";
6982
+ var McpSearchInputSchema = {
6989
6983
  type: "object",
6990
6984
  properties: {
6991
- ...TaskConfigSchema7["properties"],
6992
- ...mcpServerConfigSchema4.properties,
6993
- tool_name: {
6985
+ query: {
6994
6986
  type: "string",
6995
- title: "Tool Name",
6996
- description: "The name of the tool to call",
6997
- format: "string:mcp-toolname"
6987
+ title: "Query",
6988
+ description: "Search query for the MCP registry"
6989
+ }
6990
+ },
6991
+ required: ["query"],
6992
+ additionalProperties: false
6993
+ };
6994
+ var McpSearchOutputSchema = {
6995
+ type: "object",
6996
+ properties: {
6997
+ results: {
6998
+ type: "array",
6999
+ items: {
7000
+ type: "object",
7001
+ properties: {
7002
+ id: { type: "string" },
7003
+ label: { type: "string" },
7004
+ description: { type: "string" },
7005
+ config: { type: "object", additionalProperties: true }
7006
+ },
7007
+ required: ["id", "label", "description", "config"],
7008
+ additionalProperties: false
7009
+ }
6998
7010
  }
6999
7011
  },
7000
- required: ["transport", "tool_name"],
7001
- if: { properties: { transport: { const: "stdio" } }, required: ["transport"] },
7002
- then: { required: ["command"] },
7003
- else: { required: ["server_url"] },
7004
- allOf: mcpServerConfigSchema4.allOf,
7012
+ required: ["results"],
7005
7013
  additionalProperties: false
7006
7014
  };
7015
+ function mapMcpRegistryResult(server) {
7016
+ const name = server.name.split("/").pop() ?? server.name;
7017
+ if (server.remotes && server.remotes.length > 0) {
7018
+ const remote = server.remotes[0];
7019
+ return {
7020
+ name,
7021
+ transport: remote.type,
7022
+ server_url: remote.url
7023
+ };
7024
+ }
7025
+ const pkg = server.packages?.[0];
7026
+ if (!pkg)
7027
+ return { name };
7028
+ let command;
7029
+ let args;
7030
+ switch (pkg.registryType) {
7031
+ case "npm":
7032
+ command = "npx";
7033
+ args = ["-y", pkg.identifier];
7034
+ break;
7035
+ case "pypi":
7036
+ command = "uvx";
7037
+ args = [pkg.identifier];
7038
+ break;
7039
+ case "oci":
7040
+ command = "docker";
7041
+ args = ["run", "-i", "--rm", pkg.identifier];
7042
+ break;
7043
+ default:
7044
+ command = pkg.identifier;
7045
+ args = [];
7046
+ }
7047
+ if (pkg.runtimeArguments) {
7048
+ for (const arg of pkg.runtimeArguments) {
7049
+ if (arg.name)
7050
+ args.push(arg.name);
7051
+ if (arg.value)
7052
+ args.push(arg.value);
7053
+ }
7054
+ }
7055
+ const result = {
7056
+ name,
7057
+ transport: "stdio",
7058
+ command,
7059
+ args
7060
+ };
7061
+ if (pkg.environmentVariables && pkg.environmentVariables.length > 0) {
7062
+ const env = {};
7063
+ for (const envVar of pkg.environmentVariables) {
7064
+ env[envVar.name] = "";
7065
+ }
7066
+ result.env = env;
7067
+ }
7068
+ return result;
7069
+ }
7070
+ function mapRegistryServersToResults(servers) {
7071
+ return (servers ?? []).map((entry) => {
7072
+ const s = entry.server;
7073
+ const pkg = s.packages?.[0];
7074
+ const remote = s.remotes?.[0];
7075
+ const badges = [pkg?.registryType, pkg?.transport?.type ?? remote?.type].filter(Boolean).join(" | ");
7076
+ return {
7077
+ id: `${s.name}:${s.version}`,
7078
+ label: `${s.title ?? s.name}${badges ? ` ${badges}` : ""}`,
7079
+ description: s.description,
7080
+ config: mapMcpRegistryResult(s)
7081
+ };
7082
+ });
7083
+ }
7084
+ async function searchMcpRegistryPage(query, options2) {
7085
+ const params = new URLSearchParams({
7086
+ search: query,
7087
+ limit: "100",
7088
+ version: "latest"
7089
+ });
7090
+ if (options2?.cursor) {
7091
+ params.set("cursor", options2.cursor);
7092
+ }
7093
+ const res = await fetch(`${MCP_REGISTRY_BASE}/servers?${params}`, {
7094
+ signal: options2?.signal
7095
+ });
7096
+ if (!res.ok) {
7097
+ let detail = `Registry returned ${res.status}`;
7098
+ try {
7099
+ const errBody = await res.json();
7100
+ if (typeof errBody.detail === "string") {
7101
+ detail = `${detail}: ${errBody.detail}`;
7102
+ } else if (Array.isArray(errBody.errors) && errBody.errors.length > 0) {
7103
+ detail = `${detail}: ${errBody.errors.map((e) => e.message).filter(Boolean).join("; ")}`;
7104
+ }
7105
+ } catch {}
7106
+ throw new Error(detail);
7107
+ }
7108
+ const data = await res.json();
7109
+ return {
7110
+ results: mapRegistryServersToResults(data.servers),
7111
+ nextCursor: data.metadata?.nextCursor
7112
+ };
7113
+ }
7114
+ async function searchMcpRegistry(query, signal) {
7115
+ const page = await searchMcpRegistryPage(query, { signal });
7116
+ return page.results;
7117
+ }
7118
+
7119
+ class McpSearchTask extends Task25 {
7120
+ static type = "McpSearchTask";
7121
+ static category = "MCP";
7122
+ static title = "MCP Search";
7123
+ static description = "Search the MCP server registry for servers matching a query";
7124
+ static cacheable = false;
7125
+ static inputSchema() {
7126
+ return McpSearchInputSchema;
7127
+ }
7128
+ static outputSchema() {
7129
+ return McpSearchOutputSchema;
7130
+ }
7131
+ async execute(input2, context) {
7132
+ const results = await searchMcpRegistry(input2.query, context.signal);
7133
+ return { results };
7134
+ }
7135
+ }
7136
+ var mcpSearch = (input2, config) => {
7137
+ return new McpSearchTask({}, config).run(input2);
7138
+ };
7139
+ Workflow28.prototype.mcpSearch = CreateWorkflow27(McpSearchTask);
7140
+ // src/task/mcp/McpToolCallTask.ts
7141
+ import {
7142
+ CreateWorkflow as CreateWorkflow28,
7143
+ Task as Task26,
7144
+ TaskConfigSchema as TaskConfigSchema7,
7145
+ Workflow as Workflow29
7146
+ } from "@workglow/task-graph";
7007
7147
  var annotationsSchema2 = {
7008
7148
  type: "object",
7009
7149
  properties: {
@@ -7129,7 +7269,7 @@ var fallbackInputSchema2 = {
7129
7269
  additionalProperties: true
7130
7270
  };
7131
7271
 
7132
- class McpToolCallTask extends Task25 {
7272
+ class McpToolCallTask extends Task26 {
7133
7273
  static type = "McpToolCallTask";
7134
7274
  static category = "MCP";
7135
7275
  static title = "MCP Call Tool";
@@ -7144,7 +7284,26 @@ class McpToolCallTask extends Task25 {
7144
7284
  return fallbackOutputSchema2;
7145
7285
  }
7146
7286
  static configSchema() {
7147
- return configSchema4;
7287
+ const { mcpServerConfigSchema } = getMcpTaskDeps();
7288
+ return {
7289
+ type: "object",
7290
+ properties: {
7291
+ ...TaskConfigSchema7["properties"],
7292
+ ...mcpServerConfigSchema.properties,
7293
+ tool_name: {
7294
+ type: "string",
7295
+ title: "Tool Name",
7296
+ description: "The name of the tool to call",
7297
+ format: "string:mcp-toolname"
7298
+ }
7299
+ },
7300
+ required: ["transport", "tool_name"],
7301
+ if: { properties: { transport: { const: "stdio" } }, required: ["transport"] },
7302
+ then: { required: ["command"] },
7303
+ else: { required: ["server_url"] },
7304
+ allOf: mcpServerConfigSchema.allOf,
7305
+ additionalProperties: false
7306
+ };
7148
7307
  }
7149
7308
  inputSchema() {
7150
7309
  return this.config?.inputSchema ?? fallbackInputSchema2;
@@ -7186,10 +7345,11 @@ class McpToolCallTask extends Task25 {
7186
7345
  }
7187
7346
  async execute(input2, context) {
7188
7347
  await this.discoverSchemas(context.signal);
7189
- const { client } = await mcpClientFactory4.create(this.config, context.signal);
7348
+ const { mcpClientFactory } = getMcpTaskDeps();
7349
+ const { client } = await mcpClientFactory.create(this.config, context.signal);
7190
7350
  try {
7191
7351
  const result = await client.callTool({
7192
- name: this.config.tool_name,
7352
+ name: String(this.config.tool_name ?? ""),
7193
7353
  arguments: input2
7194
7354
  });
7195
7355
  if (!("content" in result) || !Array.isArray(result.content)) {
@@ -7228,14 +7388,14 @@ class McpToolCallTask extends Task25 {
7228
7388
  var mcpToolCall = async (input2, config) => {
7229
7389
  return new McpToolCallTask({}, config).run(input2);
7230
7390
  };
7231
- Workflow28.prototype.mcpToolCall = CreateWorkflow27(McpToolCallTask);
7391
+ Workflow29.prototype.mcpToolCall = CreateWorkflow28(McpToolCallTask);
7232
7392
  // src/task/string/StringConcatTask.ts
7233
7393
  import {
7234
- CreateWorkflow as CreateWorkflow28,
7235
- Task as Task26,
7236
- Workflow as Workflow29
7394
+ CreateWorkflow as CreateWorkflow29,
7395
+ Task as Task27,
7396
+ Workflow as Workflow30
7237
7397
  } from "@workglow/task-graph";
7238
- var inputSchema24 = {
7398
+ var inputSchema23 = {
7239
7399
  type: "object",
7240
7400
  properties: {},
7241
7401
  additionalProperties: { type: "string" }
@@ -7253,13 +7413,13 @@ var outputSchema23 = {
7253
7413
  additionalProperties: false
7254
7414
  };
7255
7415
 
7256
- class StringConcatTask extends Task26 {
7416
+ class StringConcatTask extends Task27 {
7257
7417
  static type = "StringConcatTask";
7258
7418
  static category = "String";
7259
7419
  static title = "Concat";
7260
7420
  static description = "Concatenates all input strings";
7261
7421
  static inputSchema() {
7262
- return inputSchema24;
7422
+ return inputSchema23;
7263
7423
  }
7264
7424
  static outputSchema() {
7265
7425
  return outputSchema23;
@@ -7268,14 +7428,14 @@ class StringConcatTask extends Task26 {
7268
7428
  return { result: Object.values(input2).join("") };
7269
7429
  }
7270
7430
  }
7271
- Workflow29.prototype.stringConcat = CreateWorkflow28(StringConcatTask);
7431
+ Workflow30.prototype.stringConcat = CreateWorkflow29(StringConcatTask);
7272
7432
  // src/task/string/StringIncludesTask.ts
7273
7433
  import {
7274
- CreateWorkflow as CreateWorkflow29,
7275
- Task as Task27,
7276
- Workflow as Workflow30
7434
+ CreateWorkflow as CreateWorkflow30,
7435
+ Task as Task28,
7436
+ Workflow as Workflow31
7277
7437
  } from "@workglow/task-graph";
7278
- var inputSchema25 = {
7438
+ var inputSchema24 = {
7279
7439
  type: "object",
7280
7440
  properties: {
7281
7441
  value: {
@@ -7305,13 +7465,13 @@ var outputSchema24 = {
7305
7465
  additionalProperties: false
7306
7466
  };
7307
7467
 
7308
- class StringIncludesTask extends Task27 {
7468
+ class StringIncludesTask extends Task28 {
7309
7469
  static type = "StringIncludesTask";
7310
7470
  static category = "String";
7311
7471
  static title = "Includes";
7312
7472
  static description = "Checks if a string contains a substring";
7313
7473
  static inputSchema() {
7314
- return inputSchema25;
7474
+ return inputSchema24;
7315
7475
  }
7316
7476
  static outputSchema() {
7317
7477
  return outputSchema24;
@@ -7320,14 +7480,14 @@ class StringIncludesTask extends Task27 {
7320
7480
  return { result: input2.value.includes(input2.search) };
7321
7481
  }
7322
7482
  }
7323
- Workflow30.prototype.stringIncludes = CreateWorkflow29(StringIncludesTask);
7483
+ Workflow31.prototype.stringIncludes = CreateWorkflow30(StringIncludesTask);
7324
7484
  // src/task/string/StringJoinTask.ts
7325
7485
  import {
7326
- CreateWorkflow as CreateWorkflow30,
7327
- Task as Task28,
7328
- Workflow as Workflow31
7486
+ CreateWorkflow as CreateWorkflow31,
7487
+ Task as Task29,
7488
+ Workflow as Workflow32
7329
7489
  } from "@workglow/task-graph";
7330
- var inputSchema26 = {
7490
+ var inputSchema25 = {
7331
7491
  type: "object",
7332
7492
  properties: {
7333
7493
  values: {
@@ -7359,13 +7519,13 @@ var outputSchema25 = {
7359
7519
  additionalProperties: false
7360
7520
  };
7361
7521
 
7362
- class StringJoinTask extends Task28 {
7522
+ class StringJoinTask extends Task29 {
7363
7523
  static type = "StringJoinTask";
7364
7524
  static category = "String";
7365
7525
  static title = "Join";
7366
7526
  static description = "Joins an array of strings with a separator";
7367
7527
  static inputSchema() {
7368
- return inputSchema26;
7528
+ return inputSchema25;
7369
7529
  }
7370
7530
  static outputSchema() {
7371
7531
  return outputSchema25;
@@ -7375,14 +7535,14 @@ class StringJoinTask extends Task28 {
7375
7535
  return { result: input2.values.join(separator) };
7376
7536
  }
7377
7537
  }
7378
- Workflow31.prototype.stringJoin = CreateWorkflow30(StringJoinTask);
7538
+ Workflow32.prototype.stringJoin = CreateWorkflow31(StringJoinTask);
7379
7539
  // src/task/string/StringLengthTask.ts
7380
7540
  import {
7381
- CreateWorkflow as CreateWorkflow31,
7382
- Task as Task29,
7383
- Workflow as Workflow32
7541
+ CreateWorkflow as CreateWorkflow32,
7542
+ Task as Task30,
7543
+ Workflow as Workflow33
7384
7544
  } from "@workglow/task-graph";
7385
- var inputSchema27 = {
7545
+ var inputSchema26 = {
7386
7546
  type: "object",
7387
7547
  properties: {
7388
7548
  value: {
@@ -7407,13 +7567,13 @@ var outputSchema26 = {
7407
7567
  additionalProperties: false
7408
7568
  };
7409
7569
 
7410
- class StringLengthTask extends Task29 {
7570
+ class StringLengthTask extends Task30 {
7411
7571
  static type = "StringLengthTask";
7412
7572
  static category = "String";
7413
7573
  static title = "Length";
7414
7574
  static description = "Returns the length of a string";
7415
7575
  static inputSchema() {
7416
- return inputSchema27;
7576
+ return inputSchema26;
7417
7577
  }
7418
7578
  static outputSchema() {
7419
7579
  return outputSchema26;
@@ -7422,14 +7582,14 @@ class StringLengthTask extends Task29 {
7422
7582
  return { result: input2.value.length };
7423
7583
  }
7424
7584
  }
7425
- Workflow32.prototype.stringLength = CreateWorkflow31(StringLengthTask);
7585
+ Workflow33.prototype.stringLength = CreateWorkflow32(StringLengthTask);
7426
7586
  // src/task/string/StringLowerCaseTask.ts
7427
7587
  import {
7428
- CreateWorkflow as CreateWorkflow32,
7429
- Task as Task30,
7430
- Workflow as Workflow33
7588
+ CreateWorkflow as CreateWorkflow33,
7589
+ Task as Task31,
7590
+ Workflow as Workflow34
7431
7591
  } from "@workglow/task-graph";
7432
- var inputSchema28 = {
7592
+ var inputSchema27 = {
7433
7593
  type: "object",
7434
7594
  properties: {
7435
7595
  value: {
@@ -7454,13 +7614,13 @@ var outputSchema27 = {
7454
7614
  additionalProperties: false
7455
7615
  };
7456
7616
 
7457
- class StringLowerCaseTask extends Task30 {
7617
+ class StringLowerCaseTask extends Task31 {
7458
7618
  static type = "StringLowerCaseTask";
7459
7619
  static category = "String";
7460
7620
  static title = "Lower Case";
7461
7621
  static description = "Converts a string to lower case";
7462
7622
  static inputSchema() {
7463
- return inputSchema28;
7623
+ return inputSchema27;
7464
7624
  }
7465
7625
  static outputSchema() {
7466
7626
  return outputSchema27;
@@ -7469,14 +7629,14 @@ class StringLowerCaseTask extends Task30 {
7469
7629
  return { result: input2.value.toLowerCase() };
7470
7630
  }
7471
7631
  }
7472
- Workflow33.prototype.stringLowerCase = CreateWorkflow32(StringLowerCaseTask);
7632
+ Workflow34.prototype.stringLowerCase = CreateWorkflow33(StringLowerCaseTask);
7473
7633
  // src/task/string/StringReplaceTask.ts
7474
7634
  import {
7475
- CreateWorkflow as CreateWorkflow33,
7476
- Task as Task31,
7477
- Workflow as Workflow34
7635
+ CreateWorkflow as CreateWorkflow34,
7636
+ Task as Task32,
7637
+ Workflow as Workflow35
7478
7638
  } from "@workglow/task-graph";
7479
- var inputSchema29 = {
7639
+ var inputSchema28 = {
7480
7640
  type: "object",
7481
7641
  properties: {
7482
7642
  value: {
@@ -7511,13 +7671,13 @@ var outputSchema28 = {
7511
7671
  additionalProperties: false
7512
7672
  };
7513
7673
 
7514
- class StringReplaceTask extends Task31 {
7674
+ class StringReplaceTask extends Task32 {
7515
7675
  static type = "StringReplaceTask";
7516
7676
  static category = "String";
7517
7677
  static title = "Replace";
7518
7678
  static description = "Replaces all occurrences of a substring";
7519
7679
  static inputSchema() {
7520
- return inputSchema29;
7680
+ return inputSchema28;
7521
7681
  }
7522
7682
  static outputSchema() {
7523
7683
  return outputSchema28;
@@ -7526,14 +7686,14 @@ class StringReplaceTask extends Task31 {
7526
7686
  return { result: input2.value.replaceAll(input2.search, input2.replace) };
7527
7687
  }
7528
7688
  }
7529
- Workflow34.prototype.stringReplace = CreateWorkflow33(StringReplaceTask);
7689
+ Workflow35.prototype.stringReplace = CreateWorkflow34(StringReplaceTask);
7530
7690
  // src/task/string/StringSliceTask.ts
7531
7691
  import {
7532
- CreateWorkflow as CreateWorkflow34,
7533
- Task as Task32,
7534
- Workflow as Workflow35
7692
+ CreateWorkflow as CreateWorkflow35,
7693
+ Task as Task33,
7694
+ Workflow as Workflow36
7535
7695
  } from "@workglow/task-graph";
7536
- var inputSchema30 = {
7696
+ var inputSchema29 = {
7537
7697
  type: "object",
7538
7698
  properties: {
7539
7699
  value: {
@@ -7568,13 +7728,13 @@ var outputSchema29 = {
7568
7728
  additionalProperties: false
7569
7729
  };
7570
7730
 
7571
- class StringSliceTask extends Task32 {
7731
+ class StringSliceTask extends Task33 {
7572
7732
  static type = "StringSliceTask";
7573
7733
  static category = "String";
7574
7734
  static title = "Slice";
7575
7735
  static description = "Extracts a substring by start and optional end index";
7576
7736
  static inputSchema() {
7577
- return inputSchema30;
7737
+ return inputSchema29;
7578
7738
  }
7579
7739
  static outputSchema() {
7580
7740
  return outputSchema29;
@@ -7583,14 +7743,14 @@ class StringSliceTask extends Task32 {
7583
7743
  return { result: input2.value.slice(input2.start, input2.end) };
7584
7744
  }
7585
7745
  }
7586
- Workflow35.prototype.stringSlice = CreateWorkflow34(StringSliceTask);
7746
+ Workflow36.prototype.stringSlice = CreateWorkflow35(StringSliceTask);
7587
7747
  // src/task/string/StringTemplateTask.ts
7588
7748
  import {
7589
- CreateWorkflow as CreateWorkflow35,
7590
- Task as Task33,
7591
- Workflow as Workflow36
7749
+ CreateWorkflow as CreateWorkflow36,
7750
+ Task as Task34,
7751
+ Workflow as Workflow37
7592
7752
  } from "@workglow/task-graph";
7593
- var inputSchema31 = {
7753
+ var inputSchema30 = {
7594
7754
  type: "object",
7595
7755
  properties: {
7596
7756
  template: {
@@ -7621,13 +7781,13 @@ var outputSchema30 = {
7621
7781
  additionalProperties: false
7622
7782
  };
7623
7783
 
7624
- class StringTemplateTask extends Task33 {
7784
+ class StringTemplateTask extends Task34 {
7625
7785
  static type = "StringTemplateTask";
7626
7786
  static category = "String";
7627
7787
  static title = "Template";
7628
7788
  static description = "Replaces {{key}} placeholders in a template string with values";
7629
7789
  static inputSchema() {
7630
- return inputSchema31;
7790
+ return inputSchema30;
7631
7791
  }
7632
7792
  static outputSchema() {
7633
7793
  return outputSchema30;
@@ -7640,14 +7800,14 @@ class StringTemplateTask extends Task33 {
7640
7800
  return { result };
7641
7801
  }
7642
7802
  }
7643
- Workflow36.prototype.stringTemplate = CreateWorkflow35(StringTemplateTask);
7803
+ Workflow37.prototype.stringTemplate = CreateWorkflow36(StringTemplateTask);
7644
7804
  // src/task/string/StringTrimTask.ts
7645
7805
  import {
7646
- CreateWorkflow as CreateWorkflow36,
7647
- Task as Task34,
7648
- Workflow as Workflow37
7806
+ CreateWorkflow as CreateWorkflow37,
7807
+ Task as Task35,
7808
+ Workflow as Workflow38
7649
7809
  } from "@workglow/task-graph";
7650
- var inputSchema32 = {
7810
+ var inputSchema31 = {
7651
7811
  type: "object",
7652
7812
  properties: {
7653
7813
  value: {
@@ -7672,13 +7832,13 @@ var outputSchema31 = {
7672
7832
  additionalProperties: false
7673
7833
  };
7674
7834
 
7675
- class StringTrimTask extends Task34 {
7835
+ class StringTrimTask extends Task35 {
7676
7836
  static type = "StringTrimTask";
7677
7837
  static category = "String";
7678
7838
  static title = "Trim";
7679
7839
  static description = "Removes leading and trailing whitespace from a string";
7680
7840
  static inputSchema() {
7681
- return inputSchema32;
7841
+ return inputSchema31;
7682
7842
  }
7683
7843
  static outputSchema() {
7684
7844
  return outputSchema31;
@@ -7687,14 +7847,14 @@ class StringTrimTask extends Task34 {
7687
7847
  return { result: input2.value.trim() };
7688
7848
  }
7689
7849
  }
7690
- Workflow37.prototype.stringTrim = CreateWorkflow36(StringTrimTask);
7850
+ Workflow38.prototype.stringTrim = CreateWorkflow37(StringTrimTask);
7691
7851
  // src/task/string/StringUpperCaseTask.ts
7692
7852
  import {
7693
- CreateWorkflow as CreateWorkflow37,
7694
- Task as Task35,
7695
- Workflow as Workflow38
7853
+ CreateWorkflow as CreateWorkflow38,
7854
+ Task as Task36,
7855
+ Workflow as Workflow39
7696
7856
  } from "@workglow/task-graph";
7697
- var inputSchema33 = {
7857
+ var inputSchema32 = {
7698
7858
  type: "object",
7699
7859
  properties: {
7700
7860
  value: {
@@ -7719,13 +7879,13 @@ var outputSchema32 = {
7719
7879
  additionalProperties: false
7720
7880
  };
7721
7881
 
7722
- class StringUpperCaseTask extends Task35 {
7882
+ class StringUpperCaseTask extends Task36 {
7723
7883
  static type = "StringUpperCaseTask";
7724
7884
  static category = "String";
7725
7885
  static title = "Upper Case";
7726
7886
  static description = "Converts a string to upper case";
7727
7887
  static inputSchema() {
7728
- return inputSchema33;
7888
+ return inputSchema32;
7729
7889
  }
7730
7890
  static outputSchema() {
7731
7891
  return outputSchema32;
@@ -7734,10 +7894,10 @@ class StringUpperCaseTask extends Task35 {
7734
7894
  return { result: input2.value.toUpperCase() };
7735
7895
  }
7736
7896
  }
7737
- Workflow38.prototype.stringUpperCase = CreateWorkflow37(StringUpperCaseTask);
7897
+ Workflow39.prototype.stringUpperCase = CreateWorkflow38(StringUpperCaseTask);
7738
7898
  // src/task/scalar/ScalarAbsTask.ts
7739
- import { CreateWorkflow as CreateWorkflow38, Task as Task36, Workflow as Workflow39 } from "@workglow/task-graph";
7740
- var inputSchema34 = {
7899
+ import { CreateWorkflow as CreateWorkflow39, Task as Task37, Workflow as Workflow40 } from "@workglow/task-graph";
7900
+ var inputSchema33 = {
7741
7901
  type: "object",
7742
7902
  properties: {
7743
7903
  value: {
@@ -7762,13 +7922,13 @@ var outputSchema33 = {
7762
7922
  additionalProperties: false
7763
7923
  };
7764
7924
 
7765
- class ScalarAbsTask extends Task36 {
7925
+ class ScalarAbsTask extends Task37 {
7766
7926
  static type = "ScalarAbsTask";
7767
7927
  static category = "Math";
7768
7928
  static title = "Abs";
7769
7929
  static description = "Returns the absolute value of a number";
7770
7930
  static inputSchema() {
7771
- return inputSchema34;
7931
+ return inputSchema33;
7772
7932
  }
7773
7933
  static outputSchema() {
7774
7934
  return outputSchema33;
@@ -7777,10 +7937,10 @@ class ScalarAbsTask extends Task36 {
7777
7937
  return { result: Math.abs(input2.value) };
7778
7938
  }
7779
7939
  }
7780
- Workflow39.prototype.scalarAbs = CreateWorkflow38(ScalarAbsTask);
7940
+ Workflow40.prototype.scalarAbs = CreateWorkflow39(ScalarAbsTask);
7781
7941
  // src/task/scalar/ScalarCeilTask.ts
7782
- import { CreateWorkflow as CreateWorkflow39, Task as Task37, Workflow as Workflow40 } from "@workglow/task-graph";
7783
- var inputSchema35 = {
7942
+ import { CreateWorkflow as CreateWorkflow40, Task as Task38, Workflow as Workflow41 } from "@workglow/task-graph";
7943
+ var inputSchema34 = {
7784
7944
  type: "object",
7785
7945
  properties: {
7786
7946
  value: {
@@ -7805,13 +7965,13 @@ var outputSchema34 = {
7805
7965
  additionalProperties: false
7806
7966
  };
7807
7967
 
7808
- class ScalarCeilTask extends Task37 {
7968
+ class ScalarCeilTask extends Task38 {
7809
7969
  static type = "ScalarCeilTask";
7810
7970
  static category = "Math";
7811
7971
  static title = "Ceil";
7812
7972
  static description = "Returns the smallest integer greater than or equal to a number";
7813
7973
  static inputSchema() {
7814
- return inputSchema35;
7974
+ return inputSchema34;
7815
7975
  }
7816
7976
  static outputSchema() {
7817
7977
  return outputSchema34;
@@ -7820,10 +7980,10 @@ class ScalarCeilTask extends Task37 {
7820
7980
  return { result: Math.ceil(input2.value) };
7821
7981
  }
7822
7982
  }
7823
- Workflow40.prototype.scalarCeil = CreateWorkflow39(ScalarCeilTask);
7983
+ Workflow41.prototype.scalarCeil = CreateWorkflow40(ScalarCeilTask);
7824
7984
  // src/task/scalar/ScalarFloorTask.ts
7825
- import { CreateWorkflow as CreateWorkflow40, Task as Task38, Workflow as Workflow41 } from "@workglow/task-graph";
7826
- var inputSchema36 = {
7985
+ import { CreateWorkflow as CreateWorkflow41, Task as Task39, Workflow as Workflow42 } from "@workglow/task-graph";
7986
+ var inputSchema35 = {
7827
7987
  type: "object",
7828
7988
  properties: {
7829
7989
  value: {
@@ -7848,13 +8008,13 @@ var outputSchema35 = {
7848
8008
  additionalProperties: false
7849
8009
  };
7850
8010
 
7851
- class ScalarFloorTask extends Task38 {
8011
+ class ScalarFloorTask extends Task39 {
7852
8012
  static type = "ScalarFloorTask";
7853
8013
  static category = "Math";
7854
8014
  static title = "Floor";
7855
8015
  static description = "Returns the largest integer less than or equal to a number";
7856
8016
  static inputSchema() {
7857
- return inputSchema36;
8017
+ return inputSchema35;
7858
8018
  }
7859
8019
  static outputSchema() {
7860
8020
  return outputSchema35;
@@ -7863,10 +8023,10 @@ class ScalarFloorTask extends Task38 {
7863
8023
  return { result: Math.floor(input2.value) };
7864
8024
  }
7865
8025
  }
7866
- Workflow41.prototype.scalarFloor = CreateWorkflow40(ScalarFloorTask);
8026
+ Workflow42.prototype.scalarFloor = CreateWorkflow41(ScalarFloorTask);
7867
8027
  // src/task/scalar/ScalarMaxTask.ts
7868
- import { CreateWorkflow as CreateWorkflow41, Task as Task39, Workflow as Workflow42 } from "@workglow/task-graph";
7869
- var inputSchema37 = {
8028
+ import { CreateWorkflow as CreateWorkflow42, Task as Task40, Workflow as Workflow43 } from "@workglow/task-graph";
8029
+ var inputSchema36 = {
7870
8030
  type: "object",
7871
8031
  properties: {
7872
8032
  values: {
@@ -7892,13 +8052,13 @@ var outputSchema36 = {
7892
8052
  additionalProperties: false
7893
8053
  };
7894
8054
 
7895
- class ScalarMaxTask extends Task39 {
8055
+ class ScalarMaxTask extends Task40 {
7896
8056
  static type = "ScalarMaxTask";
7897
8057
  static category = "Math";
7898
8058
  static title = "Max";
7899
8059
  static description = "Returns the largest of the given numbers";
7900
8060
  static inputSchema() {
7901
- return inputSchema37;
8061
+ return inputSchema36;
7902
8062
  }
7903
8063
  static outputSchema() {
7904
8064
  return outputSchema36;
@@ -7907,10 +8067,10 @@ class ScalarMaxTask extends Task39 {
7907
8067
  return { result: Math.max(...input2.values) };
7908
8068
  }
7909
8069
  }
7910
- Workflow42.prototype.scalarMax = CreateWorkflow41(ScalarMaxTask);
8070
+ Workflow43.prototype.scalarMax = CreateWorkflow42(ScalarMaxTask);
7911
8071
  // src/task/scalar/ScalarMinTask.ts
7912
- import { CreateWorkflow as CreateWorkflow42, Task as Task40, Workflow as Workflow43 } from "@workglow/task-graph";
7913
- var inputSchema38 = {
8072
+ import { CreateWorkflow as CreateWorkflow43, Task as Task41, Workflow as Workflow44 } from "@workglow/task-graph";
8073
+ var inputSchema37 = {
7914
8074
  type: "object",
7915
8075
  properties: {
7916
8076
  values: {
@@ -7936,13 +8096,13 @@ var outputSchema37 = {
7936
8096
  additionalProperties: false
7937
8097
  };
7938
8098
 
7939
- class ScalarMinTask extends Task40 {
8099
+ class ScalarMinTask extends Task41 {
7940
8100
  static type = "ScalarMinTask";
7941
8101
  static category = "Math";
7942
8102
  static title = "Min";
7943
8103
  static description = "Returns the smallest of the given numbers";
7944
8104
  static inputSchema() {
7945
- return inputSchema38;
8105
+ return inputSchema37;
7946
8106
  }
7947
8107
  static outputSchema() {
7948
8108
  return outputSchema37;
@@ -7951,10 +8111,10 @@ class ScalarMinTask extends Task40 {
7951
8111
  return { result: Math.min(...input2.values) };
7952
8112
  }
7953
8113
  }
7954
- Workflow43.prototype.scalarMin = CreateWorkflow42(ScalarMinTask);
8114
+ Workflow44.prototype.scalarMin = CreateWorkflow43(ScalarMinTask);
7955
8115
  // src/task/scalar/ScalarRoundTask.ts
7956
- import { CreateWorkflow as CreateWorkflow43, Task as Task41, Workflow as Workflow44 } from "@workglow/task-graph";
7957
- var inputSchema39 = {
8116
+ import { CreateWorkflow as CreateWorkflow44, Task as Task42, Workflow as Workflow45 } from "@workglow/task-graph";
8117
+ var inputSchema38 = {
7958
8118
  type: "object",
7959
8119
  properties: {
7960
8120
  value: {
@@ -7979,13 +8139,13 @@ var outputSchema38 = {
7979
8139
  additionalProperties: false
7980
8140
  };
7981
8141
 
7982
- class ScalarRoundTask extends Task41 {
8142
+ class ScalarRoundTask extends Task42 {
7983
8143
  static type = "ScalarRoundTask";
7984
8144
  static category = "Math";
7985
8145
  static title = "Round";
7986
8146
  static description = "Returns the value of a number rounded to the nearest integer";
7987
8147
  static inputSchema() {
7988
- return inputSchema39;
8148
+ return inputSchema38;
7989
8149
  }
7990
8150
  static outputSchema() {
7991
8151
  return outputSchema38;
@@ -7994,10 +8154,10 @@ class ScalarRoundTask extends Task41 {
7994
8154
  return { result: Math.round(input2.value) };
7995
8155
  }
7996
8156
  }
7997
- Workflow44.prototype.scalarRound = CreateWorkflow43(ScalarRoundTask);
8157
+ Workflow45.prototype.scalarRound = CreateWorkflow44(ScalarRoundTask);
7998
8158
  // src/task/scalar/ScalarTruncTask.ts
7999
- import { CreateWorkflow as CreateWorkflow44, Task as Task42, Workflow as Workflow45 } from "@workglow/task-graph";
8000
- var inputSchema40 = {
8159
+ import { CreateWorkflow as CreateWorkflow45, Task as Task43, Workflow as Workflow46 } from "@workglow/task-graph";
8160
+ var inputSchema39 = {
8001
8161
  type: "object",
8002
8162
  properties: {
8003
8163
  value: {
@@ -8022,13 +8182,13 @@ var outputSchema39 = {
8022
8182
  additionalProperties: false
8023
8183
  };
8024
8184
 
8025
- class ScalarTruncTask extends Task42 {
8185
+ class ScalarTruncTask extends Task43 {
8026
8186
  static type = "ScalarTruncTask";
8027
8187
  static category = "Math";
8028
8188
  static title = "Truncate";
8029
8189
  static description = "Returns the integer part of a number by removing fractional digits";
8030
8190
  static inputSchema() {
8031
- return inputSchema40;
8191
+ return inputSchema39;
8032
8192
  }
8033
8193
  static outputSchema() {
8034
8194
  return outputSchema39;
@@ -8037,13 +8197,13 @@ class ScalarTruncTask extends Task42 {
8037
8197
  return { result: Math.trunc(input2.value) };
8038
8198
  }
8039
8199
  }
8040
- Workflow45.prototype.scalarTrunc = CreateWorkflow44(ScalarTruncTask);
8200
+ Workflow46.prototype.scalarTrunc = CreateWorkflow45(ScalarTruncTask);
8041
8201
  // src/task/vector/VectorDistanceTask.ts
8042
- import { CreateWorkflow as CreateWorkflow45, Task as Task43, Workflow as Workflow46 } from "@workglow/task-graph";
8202
+ import { CreateWorkflow as CreateWorkflow46, Task as Task44, Workflow as Workflow47 } from "@workglow/task-graph";
8043
8203
  import {
8044
8204
  TypedArraySchema as TypedArraySchema5
8045
8205
  } from "@workglow/util";
8046
- var inputSchema41 = {
8206
+ var inputSchema40 = {
8047
8207
  type: "object",
8048
8208
  properties: {
8049
8209
  vectors: {
@@ -8072,13 +8232,13 @@ var outputSchema40 = {
8072
8232
  additionalProperties: false
8073
8233
  };
8074
8234
 
8075
- class VectorDistanceTask extends Task43 {
8235
+ class VectorDistanceTask extends Task44 {
8076
8236
  static type = "VectorDistanceTask";
8077
8237
  static category = "Vector";
8078
8238
  static title = "Distance";
8079
8239
  static description = "Returns the Euclidean distance between the first two vectors";
8080
8240
  static inputSchema() {
8081
- return inputSchema41;
8241
+ return inputSchema40;
8082
8242
  }
8083
8243
  static outputSchema() {
8084
8244
  return outputSchema40;
@@ -8099,13 +8259,13 @@ class VectorDistanceTask extends Task43 {
8099
8259
  return { result: Math.sqrt(sumPrecise(diffs)) };
8100
8260
  }
8101
8261
  }
8102
- Workflow46.prototype.vectorDistance = CreateWorkflow45(VectorDistanceTask);
8262
+ Workflow47.prototype.vectorDistance = CreateWorkflow46(VectorDistanceTask);
8103
8263
  // src/task/vector/VectorDotProductTask.ts
8104
- import { CreateWorkflow as CreateWorkflow46, Task as Task44, Workflow as Workflow47 } from "@workglow/task-graph";
8264
+ import { CreateWorkflow as CreateWorkflow47, Task as Task45, Workflow as Workflow48 } from "@workglow/task-graph";
8105
8265
  import {
8106
8266
  TypedArraySchema as TypedArraySchema6
8107
8267
  } from "@workglow/util";
8108
- var inputSchema42 = {
8268
+ var inputSchema41 = {
8109
8269
  type: "object",
8110
8270
  properties: {
8111
8271
  vectors: {
@@ -8134,13 +8294,13 @@ var outputSchema41 = {
8134
8294
  additionalProperties: false
8135
8295
  };
8136
8296
 
8137
- class VectorDotProductTask extends Task44 {
8297
+ class VectorDotProductTask extends Task45 {
8138
8298
  static type = "VectorDotProductTask";
8139
8299
  static category = "Vector";
8140
8300
  static title = "Dot Product";
8141
8301
  static description = "Returns the dot (inner) product of the first two vectors";
8142
8302
  static inputSchema() {
8143
- return inputSchema42;
8303
+ return inputSchema41;
8144
8304
  }
8145
8305
  static outputSchema() {
8146
8306
  return outputSchema41;
@@ -8158,14 +8318,14 @@ class VectorDotProductTask extends Task44 {
8158
8318
  return { result: sumPrecise(products) };
8159
8319
  }
8160
8320
  }
8161
- Workflow47.prototype.vectorDotProduct = CreateWorkflow46(VectorDotProductTask);
8321
+ Workflow48.prototype.vectorDotProduct = CreateWorkflow47(VectorDotProductTask);
8162
8322
  // src/task/vector/VectorNormalizeTask.ts
8163
- import { CreateWorkflow as CreateWorkflow47, Task as Task45, Workflow as Workflow48 } from "@workglow/task-graph";
8323
+ import { CreateWorkflow as CreateWorkflow48, Task as Task46, Workflow as Workflow49 } from "@workglow/task-graph";
8164
8324
  import {
8165
8325
  TypedArraySchema as TypedArraySchema7,
8166
8326
  normalize
8167
8327
  } from "@workglow/util";
8168
- var inputSchema43 = {
8328
+ var inputSchema42 = {
8169
8329
  type: "object",
8170
8330
  properties: {
8171
8331
  vector: TypedArraySchema7({
@@ -8188,13 +8348,13 @@ var outputSchema42 = {
8188
8348
  additionalProperties: false
8189
8349
  };
8190
8350
 
8191
- class VectorNormalizeTask extends Task45 {
8351
+ class VectorNormalizeTask extends Task46 {
8192
8352
  static type = "VectorNormalizeTask";
8193
8353
  static category = "Vector";
8194
8354
  static title = "Normalize";
8195
8355
  static description = "Returns the L2-normalized (unit length) vector";
8196
8356
  static inputSchema() {
8197
- return inputSchema43;
8357
+ return inputSchema42;
8198
8358
  }
8199
8359
  static outputSchema() {
8200
8360
  return outputSchema42;
@@ -8203,14 +8363,14 @@ class VectorNormalizeTask extends Task45 {
8203
8363
  return { result: normalize(input2.vector) };
8204
8364
  }
8205
8365
  }
8206
- Workflow48.prototype.vectorNormalize = CreateWorkflow47(VectorNormalizeTask);
8366
+ Workflow49.prototype.vectorNormalize = CreateWorkflow48(VectorNormalizeTask);
8207
8367
  // src/task/vector/VectorScaleTask.ts
8208
- import { CreateWorkflow as CreateWorkflow48, Task as Task46, Workflow as Workflow49 } from "@workglow/task-graph";
8368
+ import { CreateWorkflow as CreateWorkflow49, Task as Task47, Workflow as Workflow50 } from "@workglow/task-graph";
8209
8369
  import {
8210
8370
  createTypedArrayFrom as createTypedArrayFrom5,
8211
8371
  TypedArraySchema as TypedArraySchema8
8212
8372
  } from "@workglow/util";
8213
- var inputSchema44 = {
8373
+ var inputSchema43 = {
8214
8374
  type: "object",
8215
8375
  properties: {
8216
8376
  vector: TypedArraySchema8({
@@ -8238,13 +8398,13 @@ var outputSchema43 = {
8238
8398
  additionalProperties: false
8239
8399
  };
8240
8400
 
8241
- class VectorScaleTask extends Task46 {
8401
+ class VectorScaleTask extends Task47 {
8242
8402
  static type = "VectorScaleTask";
8243
8403
  static category = "Vector";
8244
8404
  static title = "Scale";
8245
8405
  static description = "Multiplies each element of a vector by a scalar";
8246
8406
  static inputSchema() {
8247
- return inputSchema44;
8407
+ return inputSchema43;
8248
8408
  }
8249
8409
  static outputSchema() {
8250
8410
  return outputSchema43;
@@ -8255,7 +8415,7 @@ class VectorScaleTask extends Task46 {
8255
8415
  return { result: createTypedArrayFrom5([vector], values) };
8256
8416
  }
8257
8417
  }
8258
- Workflow49.prototype.vectorScale = CreateWorkflow48(VectorScaleTask);
8418
+ Workflow50.prototype.vectorScale = CreateWorkflow49(VectorScaleTask);
8259
8419
 
8260
8420
  // src/common.ts
8261
8421
  import { TaskRegistry } from "@workglow/task-graph";
@@ -8294,6 +8454,7 @@ var registerCommonTasks = () => {
8294
8454
  McpToolCallTask,
8295
8455
  McpResourceReadTask,
8296
8456
  McpPromptGetTask,
8457
+ McpSearchTask,
8297
8458
  McpListTask,
8298
8459
  StringConcatTask,
8299
8460
  StringIncludesTask,
@@ -8313,16 +8474,621 @@ var registerCommonTasks = () => {
8313
8474
  tasks.map(TaskRegistry.registerTask);
8314
8475
  return tasks;
8315
8476
  };
8477
+ // src/util/McpAuthTypes.ts
8478
+ var mcpAuthTypes = [
8479
+ "none",
8480
+ "bearer",
8481
+ "client_credentials",
8482
+ "private_key_jwt",
8483
+ "static_private_key_jwt",
8484
+ "authorization_code"
8485
+ ];
8486
+ var mcpAuthConfigSchema = {
8487
+ properties: {
8488
+ auth_type: {
8489
+ type: "string",
8490
+ enum: mcpAuthTypes,
8491
+ title: "Auth Type",
8492
+ description: "Authentication method for connecting to the MCP server",
8493
+ default: "none"
8494
+ },
8495
+ auth_token: {
8496
+ type: "string",
8497
+ format: "credential",
8498
+ title: "Bearer Token",
8499
+ description: "Static bearer token or API key (for bearer auth)"
8500
+ },
8501
+ auth_client_id: {
8502
+ type: "string",
8503
+ title: "Client ID",
8504
+ description: "OAuth client ID (for OAuth auth types)"
8505
+ },
8506
+ auth_client_secret: {
8507
+ type: "string",
8508
+ format: "credential",
8509
+ title: "Client Secret",
8510
+ description: "OAuth client secret (for client_credentials auth)"
8511
+ },
8512
+ auth_private_key: {
8513
+ type: "string",
8514
+ format: "credential",
8515
+ title: "Private Key",
8516
+ description: "PEM or JWK private key (for private_key_jwt auth)"
8517
+ },
8518
+ auth_algorithm: {
8519
+ type: "string",
8520
+ title: "Algorithm",
8521
+ description: "JWT signing algorithm, e.g. RS256, ES256 (for private_key_jwt auth)"
8522
+ },
8523
+ auth_jwt_bearer_assertion: {
8524
+ type: "string",
8525
+ format: "credential",
8526
+ title: "JWT Assertion",
8527
+ description: "Pre-built JWT assertion (for static_private_key_jwt auth)"
8528
+ },
8529
+ auth_redirect_url: {
8530
+ type: "string",
8531
+ format: "uri",
8532
+ title: "Redirect URL",
8533
+ description: "OAuth redirect URL (for authorization_code auth)"
8534
+ },
8535
+ auth_scope: {
8536
+ type: "string",
8537
+ title: "Scope",
8538
+ description: "OAuth scope (space-separated)"
8539
+ },
8540
+ auth_client_name: {
8541
+ type: "string",
8542
+ title: "Client Name",
8543
+ description: "Optional OAuth client display name"
8544
+ },
8545
+ auth_jwt_lifetime_seconds: {
8546
+ type: "number",
8547
+ title: "JWT Lifetime",
8548
+ description: "JWT lifetime in seconds (default: 300)",
8549
+ minimum: 1
8550
+ }
8551
+ },
8552
+ allOf: [
8553
+ {
8554
+ if: { properties: { auth_type: { const: "bearer" } }, required: ["auth_type"] },
8555
+ then: {
8556
+ required: ["auth_token"],
8557
+ properties: { auth_token: true }
8558
+ }
8559
+ },
8560
+ {
8561
+ if: {
8562
+ properties: { auth_type: { const: "client_credentials" } },
8563
+ required: ["auth_type"]
8564
+ },
8565
+ then: {
8566
+ required: ["auth_client_id", "auth_client_secret"],
8567
+ properties: {
8568
+ auth_client_id: true,
8569
+ auth_client_secret: true,
8570
+ auth_client_name: true,
8571
+ auth_scope: true
8572
+ }
8573
+ }
8574
+ },
8575
+ {
8576
+ if: { properties: { auth_type: { const: "private_key_jwt" } }, required: ["auth_type"] },
8577
+ then: {
8578
+ required: ["auth_client_id", "auth_private_key", "auth_algorithm"],
8579
+ properties: {
8580
+ auth_client_id: true,
8581
+ auth_private_key: true,
8582
+ auth_algorithm: true,
8583
+ auth_client_name: true,
8584
+ auth_jwt_lifetime_seconds: true,
8585
+ auth_scope: true
8586
+ }
8587
+ }
8588
+ },
8589
+ {
8590
+ if: {
8591
+ properties: { auth_type: { const: "static_private_key_jwt" } },
8592
+ required: ["auth_type"]
8593
+ },
8594
+ then: {
8595
+ required: ["auth_client_id", "auth_jwt_bearer_assertion"],
8596
+ properties: {
8597
+ auth_client_id: true,
8598
+ auth_jwt_bearer_assertion: true,
8599
+ auth_client_name: true,
8600
+ auth_scope: true
8601
+ }
8602
+ }
8603
+ },
8604
+ {
8605
+ if: { properties: { auth_type: { const: "authorization_code" } }, required: ["auth_type"] },
8606
+ then: {
8607
+ required: ["auth_client_id", "auth_redirect_url"],
8608
+ properties: {
8609
+ auth_client_id: true,
8610
+ auth_client_secret: true,
8611
+ auth_redirect_url: true,
8612
+ auth_scope: true
8613
+ }
8614
+ }
8615
+ }
8616
+ ]
8617
+ };
8618
+ function isMcpAuthType(value) {
8619
+ return typeof value === "string" && mcpAuthTypes.includes(value);
8620
+ }
8621
+ function asNonEmptyString(value) {
8622
+ if (typeof value !== "string")
8623
+ return;
8624
+ const trimmed = value.trim();
8625
+ return trimmed === "" ? undefined : trimmed;
8626
+ }
8627
+ function asNumber(value) {
8628
+ return typeof value === "number" ? value : undefined;
8629
+ }
8630
+ function buildAuthConfig(flat) {
8631
+ const rawAuthType = flat.auth_type;
8632
+ if (!isMcpAuthType(rawAuthType) || rawAuthType === "none") {
8633
+ return;
8634
+ }
8635
+ const authType = rawAuthType;
8636
+ switch (authType) {
8637
+ case "bearer": {
8638
+ const token = asNonEmptyString(flat.auth_token);
8639
+ if (!token)
8640
+ return;
8641
+ return { type: "bearer", token };
8642
+ }
8643
+ case "client_credentials": {
8644
+ const client_id = asNonEmptyString(flat.auth_client_id);
8645
+ const client_secret = asNonEmptyString(flat.auth_client_secret);
8646
+ if (!client_id || !client_secret)
8647
+ return;
8648
+ return {
8649
+ type: "client_credentials",
8650
+ client_id,
8651
+ client_secret,
8652
+ client_name: asNonEmptyString(flat.auth_client_name),
8653
+ scope: asNonEmptyString(flat.auth_scope)
8654
+ };
8655
+ }
8656
+ case "private_key_jwt": {
8657
+ const client_id = asNonEmptyString(flat.auth_client_id);
8658
+ const private_key = asNonEmptyString(flat.auth_private_key);
8659
+ const algorithm = asNonEmptyString(flat.auth_algorithm);
8660
+ if (!client_id || !private_key || !algorithm)
8661
+ return;
8662
+ return {
8663
+ type: "private_key_jwt",
8664
+ client_id,
8665
+ private_key,
8666
+ algorithm,
8667
+ client_name: asNonEmptyString(flat.auth_client_name),
8668
+ jwt_lifetime_seconds: asNumber(flat.auth_jwt_lifetime_seconds),
8669
+ scope: asNonEmptyString(flat.auth_scope)
8670
+ };
8671
+ }
8672
+ case "static_private_key_jwt": {
8673
+ const client_id = asNonEmptyString(flat.auth_client_id);
8674
+ const jwt_bearer_assertion = asNonEmptyString(flat.auth_jwt_bearer_assertion);
8675
+ if (!client_id || !jwt_bearer_assertion)
8676
+ return;
8677
+ return {
8678
+ type: "static_private_key_jwt",
8679
+ client_id,
8680
+ jwt_bearer_assertion,
8681
+ client_name: asNonEmptyString(flat.auth_client_name),
8682
+ scope: asNonEmptyString(flat.auth_scope)
8683
+ };
8684
+ }
8685
+ case "authorization_code": {
8686
+ const client_id = asNonEmptyString(flat.auth_client_id);
8687
+ const redirect_url = asNonEmptyString(flat.auth_redirect_url);
8688
+ if (!client_id || !redirect_url)
8689
+ return;
8690
+ return {
8691
+ type: "authorization_code",
8692
+ client_id,
8693
+ client_secret: asNonEmptyString(flat.auth_client_secret),
8694
+ redirect_url,
8695
+ scope: asNonEmptyString(flat.auth_scope)
8696
+ };
8697
+ }
8698
+ default:
8699
+ return;
8700
+ }
8701
+ }
8702
+ // src/util/McpAuthProvider.ts
8703
+ import {
8704
+ ClientCredentialsProvider,
8705
+ PrivateKeyJwtProvider,
8706
+ StaticPrivateKeyJwtProvider,
8707
+ createPrivateKeyJwtAuth
8708
+ } from "@modelcontextprotocol/sdk/client/auth-extensions.js";
8709
+ import { UnauthorizedError } from "@modelcontextprotocol/sdk/client/auth.js";
8710
+ import { getGlobalCredentialStore } from "@workglow/util";
8711
+ function normalizeServerUrl(serverUrl) {
8712
+ try {
8713
+ const u = new URL(serverUrl);
8714
+ return u.origin + u.pathname.replace(/\/+$/, "");
8715
+ } catch {
8716
+ return serverUrl;
8717
+ }
8718
+ }
8719
+ function storeKey(serverUrl, suffix) {
8720
+ return `mcp:oauth:${normalizeServerUrl(serverUrl)}:${suffix}`;
8721
+ }
8316
8722
 
8723
+ class CredentialStoreOAuthProvider {
8724
+ store;
8725
+ serverUrl;
8726
+ _clientMetadata;
8727
+ _redirectUrl;
8728
+ _initialClientInfo;
8729
+ prepareTokenRequest;
8730
+ addClientAuthentication;
8731
+ constructor(options2) {
8732
+ this.store = options2.store;
8733
+ this.serverUrl = options2.serverUrl;
8734
+ this._clientMetadata = options2.clientMetadata;
8735
+ this._redirectUrl = options2.redirectUrl;
8736
+ this._initialClientInfo = options2.initialClientInfo;
8737
+ if (options2.prepareTokenRequest) {
8738
+ this.prepareTokenRequest = options2.prepareTokenRequest;
8739
+ }
8740
+ if (options2.addClientAuthentication) {
8741
+ this.addClientAuthentication = options2.addClientAuthentication;
8742
+ }
8743
+ }
8744
+ get redirectUrl() {
8745
+ return this._redirectUrl;
8746
+ }
8747
+ get clientMetadata() {
8748
+ return this._clientMetadata;
8749
+ }
8750
+ async clientInformation() {
8751
+ const raw = await this.store.get(storeKey(this.serverUrl, "client_info"));
8752
+ if (!raw)
8753
+ return this._initialClientInfo;
8754
+ return JSON.parse(raw);
8755
+ }
8756
+ async saveClientInformation(info) {
8757
+ await this.store.put(storeKey(this.serverUrl, "client_info"), JSON.stringify(info));
8758
+ }
8759
+ async tokens() {
8760
+ const raw = await this.store.get(storeKey(this.serverUrl, "tokens"));
8761
+ if (!raw)
8762
+ return;
8763
+ return JSON.parse(raw);
8764
+ }
8765
+ async saveTokens(tokens) {
8766
+ const expiresAt = tokens.expires_in != null ? new Date(Date.now() + tokens.expires_in * 1000) : undefined;
8767
+ await this.store.put(storeKey(this.serverUrl, "tokens"), JSON.stringify(tokens), {
8768
+ expiresAt
8769
+ });
8770
+ }
8771
+ async redirectToAuthorization(authorizationUrl) {
8772
+ throw new Error(`MCP OAuth authorization required. ` + `Open this URL to authorize: ${authorizationUrl.toString()}`);
8773
+ }
8774
+ async saveCodeVerifier(codeVerifier) {
8775
+ await this.store.put(storeKey(this.serverUrl, "code_verifier"), codeVerifier);
8776
+ }
8777
+ async codeVerifier() {
8778
+ const v = await this.store.get(storeKey(this.serverUrl, "code_verifier"));
8779
+ if (!v)
8780
+ throw new Error("No code verifier saved for this session");
8781
+ return v;
8782
+ }
8783
+ async saveDiscoveryState(state) {
8784
+ await this.store.put(storeKey(this.serverUrl, "discovery"), JSON.stringify(state));
8785
+ }
8786
+ async discoveryState() {
8787
+ const raw = await this.store.get(storeKey(this.serverUrl, "discovery"));
8788
+ if (!raw)
8789
+ return;
8790
+ return JSON.parse(raw);
8791
+ }
8792
+ async invalidateCredentials(scope) {
8793
+ const deleteKey = async (suffix) => {
8794
+ await this.store.delete(storeKey(this.serverUrl, suffix));
8795
+ };
8796
+ switch (scope) {
8797
+ case "all":
8798
+ await deleteKey("tokens");
8799
+ await deleteKey("client_info");
8800
+ await deleteKey("code_verifier");
8801
+ await deleteKey("discovery");
8802
+ break;
8803
+ case "client":
8804
+ await deleteKey("client_info");
8805
+ break;
8806
+ case "tokens":
8807
+ await deleteKey("tokens");
8808
+ break;
8809
+ case "verifier":
8810
+ await deleteKey("code_verifier");
8811
+ break;
8812
+ case "discovery":
8813
+ await deleteKey("discovery");
8814
+ break;
8815
+ }
8816
+ }
8817
+ }
8818
+ function createAuthProvider(auth, serverUrl, credentialStore) {
8819
+ switch (auth.type) {
8820
+ case "none":
8821
+ case "bearer":
8822
+ return;
8823
+ case "client_credentials": {
8824
+ if (!credentialStore) {
8825
+ return new ClientCredentialsProvider({
8826
+ clientId: auth.client_id,
8827
+ clientSecret: auth.client_secret,
8828
+ clientName: auth.client_name,
8829
+ scope: auth.scope
8830
+ });
8831
+ }
8832
+ const prepareTokenRequest = (scope) => {
8833
+ const params = new URLSearchParams({ grant_type: "client_credentials" });
8834
+ const effectiveScope = scope ?? auth.scope;
8835
+ if (effectiveScope)
8836
+ params.set("scope", effectiveScope);
8837
+ return params;
8838
+ };
8839
+ return new CredentialStoreOAuthProvider({
8840
+ store: credentialStore,
8841
+ serverUrl,
8842
+ clientMetadata: {
8843
+ redirect_uris: [],
8844
+ grant_types: ["client_credentials"],
8845
+ token_endpoint_auth_method: "client_secret_basic",
8846
+ client_name: auth.client_name
8847
+ },
8848
+ initialClientInfo: {
8849
+ client_id: auth.client_id,
8850
+ client_secret: auth.client_secret
8851
+ },
8852
+ prepareTokenRequest
8853
+ });
8854
+ }
8855
+ case "private_key_jwt": {
8856
+ if (!credentialStore) {
8857
+ return new PrivateKeyJwtProvider({
8858
+ clientId: auth.client_id,
8859
+ privateKey: auth.private_key,
8860
+ algorithm: auth.algorithm,
8861
+ clientName: auth.client_name,
8862
+ jwtLifetimeSeconds: auth.jwt_lifetime_seconds,
8863
+ scope: auth.scope
8864
+ });
8865
+ }
8866
+ const addClientAuth = createPrivateKeyJwtAuth({
8867
+ issuer: auth.client_id,
8868
+ subject: auth.client_id,
8869
+ privateKey: auth.private_key,
8870
+ alg: auth.algorithm,
8871
+ lifetimeSeconds: auth.jwt_lifetime_seconds
8872
+ });
8873
+ const prepareTokenRequest = (scope) => {
8874
+ const params = new URLSearchParams({ grant_type: "client_credentials" });
8875
+ const effectiveScope = scope ?? auth.scope;
8876
+ if (effectiveScope)
8877
+ params.set("scope", effectiveScope);
8878
+ return params;
8879
+ };
8880
+ return new CredentialStoreOAuthProvider({
8881
+ store: credentialStore,
8882
+ serverUrl,
8883
+ clientMetadata: {
8884
+ redirect_uris: [],
8885
+ grant_types: ["client_credentials"],
8886
+ token_endpoint_auth_method: "private_key_jwt",
8887
+ client_name: auth.client_name
8888
+ },
8889
+ initialClientInfo: { client_id: auth.client_id },
8890
+ prepareTokenRequest,
8891
+ addClientAuthentication: addClientAuth
8892
+ });
8893
+ }
8894
+ case "static_private_key_jwt": {
8895
+ if (!credentialStore) {
8896
+ return new StaticPrivateKeyJwtProvider({
8897
+ clientId: auth.client_id,
8898
+ jwtBearerAssertion: auth.jwt_bearer_assertion,
8899
+ clientName: auth.client_name,
8900
+ scope: auth.scope
8901
+ });
8902
+ }
8903
+ const assertion = auth.jwt_bearer_assertion;
8904
+ const addClientAuth = (_headers, params) => {
8905
+ params.set("client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer");
8906
+ params.set("client_assertion", assertion);
8907
+ };
8908
+ const prepareTokenRequest = (scope) => {
8909
+ const params = new URLSearchParams({ grant_type: "client_credentials" });
8910
+ const effectiveScope = scope ?? auth.scope;
8911
+ if (effectiveScope)
8912
+ params.set("scope", effectiveScope);
8913
+ return params;
8914
+ };
8915
+ return new CredentialStoreOAuthProvider({
8916
+ store: credentialStore,
8917
+ serverUrl,
8918
+ clientMetadata: {
8919
+ redirect_uris: [],
8920
+ grant_types: ["client_credentials"],
8921
+ token_endpoint_auth_method: "private_key_jwt",
8922
+ client_name: auth.client_name
8923
+ },
8924
+ initialClientInfo: { client_id: auth.client_id },
8925
+ prepareTokenRequest,
8926
+ addClientAuthentication: addClientAuth
8927
+ });
8928
+ }
8929
+ case "authorization_code": {
8930
+ if (!credentialStore) {
8931
+ throw new Error("authorization_code auth requires a credential store for token persistence");
8932
+ }
8933
+ return new CredentialStoreOAuthProvider({
8934
+ store: credentialStore,
8935
+ serverUrl,
8936
+ clientMetadata: {
8937
+ redirect_uris: [auth.redirect_url],
8938
+ grant_types: ["authorization_code", "refresh_token"],
8939
+ token_endpoint_auth_method: auth.client_secret ? "client_secret_basic" : "none",
8940
+ scope: auth.scope
8941
+ },
8942
+ initialClientInfo: {
8943
+ client_id: auth.client_id,
8944
+ ...auth.client_secret ? { client_secret: auth.client_secret } : {}
8945
+ },
8946
+ redirectUrl: auth.redirect_url
8947
+ });
8948
+ }
8949
+ default:
8950
+ return;
8951
+ }
8952
+ }
8953
+ async function resolveAuthSecrets(auth, credentialStore) {
8954
+ if (auth.type === "none")
8955
+ return auth;
8956
+ const store = credentialStore ?? getGlobalCredentialStore();
8957
+ async function resolve(value) {
8958
+ if (!value)
8959
+ return value;
8960
+ const resolved = await store.get(value);
8961
+ return resolved ?? value;
8962
+ }
8963
+ switch (auth.type) {
8964
+ case "bearer":
8965
+ return { ...auth, token: await resolve(auth.token) ?? auth.token };
8966
+ case "client_credentials":
8967
+ return {
8968
+ ...auth,
8969
+ client_secret: await resolve(auth.client_secret) ?? auth.client_secret
8970
+ };
8971
+ case "private_key_jwt":
8972
+ return {
8973
+ ...auth,
8974
+ private_key: await resolve(auth.private_key) ?? auth.private_key
8975
+ };
8976
+ case "static_private_key_jwt":
8977
+ return {
8978
+ ...auth,
8979
+ jwt_bearer_assertion: await resolve(auth.jwt_bearer_assertion) ?? auth.jwt_bearer_assertion
8980
+ };
8981
+ case "authorization_code":
8982
+ return {
8983
+ ...auth,
8984
+ client_secret: await resolve(auth.client_secret)
8985
+ };
8986
+ default:
8987
+ return auth;
8988
+ }
8989
+ }
8990
+ // src/util/McpClientUtil.browser.ts
8991
+ import { Client } from "@modelcontextprotocol/sdk/client";
8992
+ import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
8993
+ import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
8994
+ import { getGlobalCredentialStore as getGlobalCredentialStore2 } from "@workglow/util";
8995
+ var mcpTransportTypes = ["streamable-http", "sse"];
8996
+ var mcpServerConfigSchema = {
8997
+ properties: {
8998
+ transport: {
8999
+ type: "string",
9000
+ enum: mcpTransportTypes,
9001
+ title: "Transport",
9002
+ description: "The transport type to use for connecting to the MCP server"
9003
+ },
9004
+ server_url: {
9005
+ type: "string",
9006
+ format: "uri",
9007
+ title: "Server URL",
9008
+ description: "The URL of the MCP server (for streamable-http transport)"
9009
+ },
9010
+ ...mcpAuthConfigSchema.properties
9011
+ },
9012
+ allOf: [
9013
+ {
9014
+ if: { properties: { transport: { const: "sse" } }, required: ["transport"] },
9015
+ then: { required: ["server_url"] }
9016
+ },
9017
+ {
9018
+ if: {
9019
+ properties: { transport: { const: "streamable-http" } },
9020
+ required: ["transport"]
9021
+ },
9022
+ then: { required: ["server_url"] }
9023
+ },
9024
+ ...mcpAuthConfigSchema.allOf
9025
+ ]
9026
+ };
9027
+ async function createMcpClient(config, signal) {
9028
+ const typed = config;
9029
+ let transport;
9030
+ let auth = typed.auth ?? buildAuthConfig({ ...typed });
9031
+ if (auth && auth.type !== "none") {
9032
+ auth = await resolveAuthSecrets(auth, getGlobalCredentialStore2());
9033
+ }
9034
+ const authProvider = typed.authProvider ?? (auth && auth.type !== "none" && auth.type !== "bearer" ? createAuthProvider(auth, typed.server_url ?? "", getGlobalCredentialStore2()) : undefined);
9035
+ const headers = {
9036
+ ...auth?.type === "bearer" ? { Authorization: `Bearer ${auth.token}` } : {}
9037
+ };
9038
+ const requestInit = { headers };
9039
+ switch (typed.transport) {
9040
+ case "sse": {
9041
+ transport = new SSEClientTransport(new URL(typed.server_url), {
9042
+ authProvider,
9043
+ requestInit
9044
+ });
9045
+ break;
9046
+ }
9047
+ case "streamable-http": {
9048
+ transport = new StreamableHTTPClientTransport(new URL(typed.server_url), {
9049
+ authProvider,
9050
+ requestInit
9051
+ });
9052
+ break;
9053
+ }
9054
+ default:
9055
+ throw new Error(`Unsupported transport type: ${typed.transport}`);
9056
+ }
9057
+ const client = new Client({ name: "workglow-mcp-client", version: "1.0.0" });
9058
+ if (signal) {
9059
+ signal.addEventListener("abort", () => {
9060
+ client.close().catch(() => {});
9061
+ }, { once: true });
9062
+ }
9063
+ try {
9064
+ await client.connect(transport);
9065
+ } catch (err) {
9066
+ const message = err instanceof Error ? err.message : String(err);
9067
+ const url = typed.server_url ?? "";
9068
+ const is405 = message.includes("405") || message.includes("Method Not Allowed") || typeof err === "object" && err !== null && "status" in err && err.status === 405;
9069
+ if (is405) {
9070
+ throw new Error(`MCP connection failed with 405 Method Not Allowed for ${url}. ` + `This usually means the server does not accept GET requests. `, { cause: err });
9071
+ }
9072
+ const is406 = message.includes("406") || message.includes("Not Acceptable") || typeof err === "object" && err !== null && "code" in err && err.code === 406;
9073
+ if (is406) {
9074
+ throw new Error(`MCP connection failed with 406 Not Acceptable for ${url}. ` + `Try using transport "sse" instead of "streamable-http", or ensure the server accepts the request format (Accept: application/json, text/event-stream and MCP-Protocol-Version).`, { cause: err });
9075
+ }
9076
+ throw err;
9077
+ }
9078
+ return { client, transport };
9079
+ }
9080
+ var mcpClientFactory = {
9081
+ create: createMcpClient
9082
+ };
8317
9083
  // src/task/FileLoaderTask.ts
8318
9084
  import {
8319
- CreateWorkflow as CreateWorkflow49,
8320
- Task as Task47,
9085
+ CreateWorkflow as CreateWorkflow50,
9086
+ Task as Task48,
8321
9087
  TaskAbortedError as TaskAbortedError2,
8322
- Workflow as Workflow50
9088
+ Workflow as Workflow51
8323
9089
  } from "@workglow/task-graph";
8324
9090
  import Papa from "papaparse";
8325
- var inputSchema45 = {
9091
+ var inputSchema44 = {
8326
9092
  type: "object",
8327
9093
  properties: {
8328
9094
  url: {
@@ -8393,14 +9159,14 @@ var outputSchema44 = {
8393
9159
  additionalProperties: false
8394
9160
  };
8395
9161
 
8396
- class FileLoaderTask extends Task47 {
9162
+ class FileLoaderTask extends Task48 {
8397
9163
  static type = "FileLoaderTask";
8398
9164
  static category = "Document";
8399
9165
  static title = "File Loader";
8400
9166
  static description = "Load documents from URLs (http://, https://)";
8401
9167
  static cacheable = true;
8402
9168
  static inputSchema() {
8403
- return inputSchema45;
9169
+ return inputSchema44;
8404
9170
  }
8405
9171
  static outputSchema() {
8406
9172
  return outputSchema44;
@@ -8759,9 +9525,10 @@ class FileLoaderTask extends Task47 {
8759
9525
  var fileLoader = (input2, config) => {
8760
9526
  return new FileLoaderTask({}, config).run(input2);
8761
9527
  };
8762
- Workflow50.prototype.fileLoader = CreateWorkflow49(FileLoaderTask);
8763
-
9528
+ Workflow51.prototype.fileLoader = CreateWorkflow50(FileLoaderTask);
8764
9529
  // src/browser.ts
9530
+ import { TaskRegistry as TaskRegistry2 } from "@workglow/task-graph";
9531
+ registerMcpTaskDeps({ mcpClientFactory, mcpServerConfigSchema });
8765
9532
  var registerCommonTasks2 = () => {
8766
9533
  const tasks = registerCommonTasks();
8767
9534
  TaskRegistry2.registerTask(FileLoaderTask);
@@ -8769,21 +9536,36 @@ var registerCommonTasks2 = () => {
8769
9536
  };
8770
9537
  export {
8771
9538
  split,
9539
+ searchMcpRegistryPage,
9540
+ searchMcpRegistry,
9541
+ resolveAuthSecrets,
9542
+ registerMcpTaskDeps,
8772
9543
  registerCommonTasks2 as registerCommonTasks,
8773
9544
  process,
8774
9545
  merge,
9546
+ mcpTransportTypes,
8775
9547
  mcpToolCall,
9548
+ mcpServerConfigSchema,
9549
+ mcpSearch,
8776
9550
  mcpResourceRead,
8777
9551
  mcpPromptGet,
8778
9552
  mcpList,
9553
+ mcpClientFactory,
9554
+ mcpAuthTypes,
9555
+ mcpAuthConfigSchema,
9556
+ mapMcpRegistryResult,
8779
9557
  lambdaTaskConfigSchema,
8780
9558
  lambda,
8781
9559
  json,
8782
9560
  javaScript,
9561
+ getMcpTaskDeps,
8783
9562
  fileLoader,
8784
9563
  fetchUrl,
8785
9564
  delay,
8786
9565
  debugLog,
9566
+ createMcpClient,
9567
+ createAuthProvider,
9568
+ buildAuthConfig,
8787
9569
  VectorSumTask,
8788
9570
  VectorSubtractTask,
8789
9571
  VectorScaleTask,
@@ -8792,6 +9574,7 @@ export {
8792
9574
  VectorDotProductTask,
8793
9575
  VectorDivideTask,
8794
9576
  VectorDistanceTask,
9577
+ UnauthorizedError,
8795
9578
  TypeReplicateArray,
8796
9579
  TemplateTask,
8797
9580
  StringUpperCaseTask,
@@ -8821,9 +9604,11 @@ export {
8821
9604
  OutputTask,
8822
9605
  MergeTask,
8823
9606
  McpToolCallTask,
9607
+ McpSearchTask,
8824
9608
  McpResourceReadTask,
8825
9609
  McpPromptGetTask,
8826
9610
  McpListTask,
9611
+ MCP_TASK_DEPS,
8827
9612
  LambdaTask,
8828
9613
  JsonTask,
8829
9614
  JsonPathTask,
@@ -8835,7 +9620,8 @@ export {
8835
9620
  DelayTask,
8836
9621
  DebugLogTask,
8837
9622
  DateFormatTask,
9623
+ CredentialStoreOAuthProvider,
8838
9624
  ArrayTask
8839
9625
  };
8840
9626
 
8841
- //# debugId=88F4435D1AD728AF64756E2164756E21
9627
+ //# debugId=6DEDB97A37FAB74D64756E2164756E21