@composio/core 0.1.51 → 0.1.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -103,7 +103,7 @@ __export(index_exports, {
103
103
  IncomingTriggerPayloadSchema: () => IncomingTriggerPayloadSchema,
104
104
  JSONSchemaPropertySchema: () => JSONSchemaPropertySchema,
105
105
  JsonSchemaToZodError: () => JsonSchemaToZodError,
106
- MCP: () => MCP,
106
+ MCP: () => MCP2,
107
107
  MCPAuthOptionsSchema: () => MCPAuthOptionsSchema,
108
108
  MCPGenerateURLParamsSchema: () => MCPGenerateURLParamsSchema,
109
109
  MCPGetServerParamsSchema: () => MCPGetServerParamsSchema,
@@ -206,7 +206,8 @@ var AuthSchemeTypes = {
206
206
  GOOGLE_SERVICE_ACCOUNT: "GOOGLE_SERVICE_ACCOUNT",
207
207
  NO_AUTH: "NO_AUTH",
208
208
  BASIC_WITH_JWT: "BASIC_WITH_JWT",
209
- CALCOM_AUTH: "CALCOM_AUTH"
209
+ CALCOM_AUTH: "CALCOM_AUTH",
210
+ SERVICE_ACCOUNT: "SERVICE_ACCOUNT"
210
211
  };
211
212
  var AuthConfigCreationToolAccessConfigSchema = import_zod.z.object({
212
213
  toolsForConnectedAccountCreation: import_zod.z.array(import_zod.z.string()).optional()
@@ -225,7 +226,8 @@ var AuthSchemeEnum = import_zod.z.enum([
225
226
  "GOOGLE_SERVICE_ACCOUNT",
226
227
  "NO_AUTH",
227
228
  "BASIC_WITH_JWT",
228
- "CALCOM_AUTH"
229
+ "CALCOM_AUTH",
230
+ "SERVICE_ACCOUNT"
229
231
  ]);
230
232
  var CreateCustomAuthConfigParamsSchema = import_zod.z.object({
231
233
  type: import_zod.z.literal("use_custom_auth"),
@@ -849,10 +851,11 @@ var ToolSchema = import_zod3.z.object({
849
851
  description: import_zod3.z.string().optional().describe("The description of the tool"),
850
852
  inputParameters: ParametersSchema.optional().describe("The input parameters of the tool"),
851
853
  outputParameters: ParametersSchema.optional().describe("The output parameters of the tool"),
852
- tags: import_zod3.z.optional(import_zod3.z.array(import_zod3.z.string())).describe("The tags of the tool. eg: Important").default([]),
853
- toolkit: import_zod3.z.optional(ToolkitSchema).describe("The toolkit of the tool"),
854
- version: import_zod3.z.optional(import_zod3.z.string()).describe('The version of the tool, e.g. "1.0.0"'),
855
- scopes: import_zod3.z.optional(import_zod3.z.array(import_zod3.z.string())).describe('The scopes of the tool. eg: ["task:add"]')
854
+ tags: import_zod3.z.array(import_zod3.z.string()).describe("The tags of the tool. eg: Important").default([]).optional(),
855
+ toolkit: ToolkitSchema.describe("The toolkit of the tool").optional(),
856
+ version: import_zod3.z.string().describe('The version of the tool, e.g. "20250909_00"').optional(),
857
+ availableVersions: import_zod3.z.array(import_zod3.z.string()).describe("Available versions of the tool.").default([]).optional(),
858
+ scopes: import_zod3.z.array(import_zod3.z.string()).describe('The scopes of the tool. eg: ["task:add"]').optional()
856
859
  });
857
860
  var ToolListResponseSchema = import_zod3.z.object({
858
861
  items: import_zod3.z.array(ToolSchema),
@@ -886,8 +889,8 @@ var ToolExecuteParamsSchema = import_zod3.z.object({
886
889
  customConnectionData: CustomConnectionDataSchema.optional(),
887
890
  arguments: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown()).optional(),
888
891
  userId: import_zod3.z.string().optional(),
889
- //
890
- version: import_zod3.z.string().optional(),
892
+ // we have no auth apps which can be execute
893
+ version: import_zod3.z.union([import_zod3.z.literal("latest"), import_zod3.z.string()]).optional(),
891
894
  text: import_zod3.z.string().optional()
892
895
  });
893
896
  var ToolExecuteResponseSchema = import_zod3.z.object({
@@ -940,6 +943,19 @@ var getEnvVariable = (name, defaultValue = void 0) => {
940
943
  return defaultValue;
941
944
  }
942
945
  };
946
+ var getEnvsWithPrefix = (prefix) => {
947
+ try {
948
+ if (process && process.env) {
949
+ return Object.fromEntries(
950
+ Object.entries(process.env).filter(([key]) => key.startsWith(prefix))
951
+ );
952
+ } else {
953
+ return {};
954
+ }
955
+ } catch (error) {
956
+ return {};
957
+ }
958
+ };
943
959
 
944
960
  // src/utils/constants.ts
945
961
  var COMPOSIO_DIR = ".composio";
@@ -2679,13 +2695,26 @@ var FileToolModifier = class {
2679
2695
  }
2680
2696
  };
2681
2697
 
2698
+ // src/utils/toolkitVersion.ts
2699
+ var getToolkitVersion = (toolkitSlug, toolkitVersions) => {
2700
+ if (typeof toolkitVersions === "string") {
2701
+ return toolkitVersions;
2702
+ }
2703
+ const hasToolkitVersion = toolkitVersions && Object.keys(toolkitVersions).length > 0;
2704
+ if (hasToolkitVersion) {
2705
+ return toolkitVersions[toolkitSlug] ?? "latest";
2706
+ }
2707
+ return "latest";
2708
+ };
2709
+
2682
2710
  // src/models/Tools.ts
2683
2711
  var Tools = class {
2684
2712
  client;
2685
2713
  customTools;
2686
2714
  provider;
2687
2715
  autoUploadDownloadFiles;
2688
- constructor(client, provider, options) {
2716
+ toolkitVersions;
2717
+ constructor(client, provider, config) {
2689
2718
  if (!client) {
2690
2719
  throw new Error("ComposioClient is required");
2691
2720
  }
@@ -2695,7 +2724,8 @@ var Tools = class {
2695
2724
  this.client = client;
2696
2725
  this.customTools = new CustomTools(client);
2697
2726
  this.provider = provider;
2698
- this.autoUploadDownloadFiles = options?.autoUploadDownloadFiles ?? true;
2727
+ this.autoUploadDownloadFiles = config?.autoUploadDownloadFiles ?? true;
2728
+ this.toolkitVersions = config?.toolkitVersions ?? "latest";
2699
2729
  this.execute = this.execute.bind(this);
2700
2730
  this.provider._setExecuteToolFn(this.execute);
2701
2731
  this.getRawComposioToolBySlug = this.getRawComposioToolBySlug.bind(this);
@@ -2717,7 +2747,8 @@ var Tools = class {
2717
2747
  return ToolSchema.parse({
2718
2748
  ...tool,
2719
2749
  inputParameters: tool.input_parameters,
2720
- outputParameters: tool.output_parameters
2750
+ outputParameters: tool.output_parameters,
2751
+ availableVersions: tool.available_versions
2721
2752
  });
2722
2753
  }
2723
2754
  /**
@@ -2740,46 +2771,6 @@ var Tools = class {
2740
2771
  sessionInfo: response.session_info
2741
2772
  });
2742
2773
  }
2743
- /**
2744
- * Check if the connected account exists for the given tools.
2745
- * @param {string} userId - The user id.
2746
- * @param {ToolList} tools - The tools to check.
2747
- * @returns {Promise<boolean>} True if the connected account exists for the given tools, false otherwise.
2748
- */
2749
- async checkIfConnectedAccountExistsForTools(userIds, tools) {
2750
- if (!tools.length) {
2751
- return true;
2752
- }
2753
- const connectedAccounts = await this.client.connectedAccounts.list({
2754
- user_ids: userIds
2755
- });
2756
- if (connectedAccounts.items.length === 0) {
2757
- return false;
2758
- }
2759
- const connectedToolkitSlugs = connectedAccounts.items.reduce(
2760
- (acc, account) => {
2761
- if (account.toolkit.slug) {
2762
- acc[account.toolkit.slug] = true;
2763
- }
2764
- return acc;
2765
- },
2766
- {}
2767
- );
2768
- const toolSlugs = tools.reduce(
2769
- (acc, tool) => {
2770
- acc[tool.slug] = true;
2771
- return acc;
2772
- },
2773
- {}
2774
- );
2775
- for (const tool of Object.keys(toolSlugs)) {
2776
- if (!connectedToolkitSlugs[tool]) {
2777
- logger_default.warn(`Tool ${tool} requires a connected account but no connected account was found`);
2778
- return false;
2779
- }
2780
- }
2781
- return true;
2782
- }
2783
2774
  /**
2784
2775
  * Get the connected account id for a given tool
2785
2776
  * @param {string} userId - The user id
@@ -2905,32 +2896,59 @@ var Tools = class {
2905
2896
  *
2906
2897
  * This method fetches tools from the Composio API in raw format and combines them with
2907
2898
  * any registered custom tools. The response can be filtered and modified as needed.
2899
+ * It provides access to the underlying tool data without provider-specific wrapping.
2908
2900
  *
2909
- * @param {ToolListParams} [query={}] - Optional query parameters to filter the tools
2910
- * @param {TransformToolSchemaModifier} [modifier] - Optional function to transform tool schemas
2901
+ * @param {ToolListParams} query - Query parameters to filter the tools (required)
2902
+ * @param {GetRawComposioToolsOptions} [options] - Optional configuration for tool retrieval
2903
+ * @param {TransformToolSchemaModifier} [options.modifySchema] - Function to transform tool schemas
2911
2904
  * @returns {Promise<ToolList>} List of tools matching the query criteria
2912
2905
  *
2913
2906
  * @example
2914
2907
  * ```typescript
2915
- * // Get all tools
2916
- * const tools = await composio.tools.getRawComposioTools();
2908
+ * // Get tools from specific toolkits
2909
+ * const githubTools = await composio.tools.getRawComposioTools({
2910
+ * toolkits: ['github'],
2911
+ * limit: 10
2912
+ * });
2913
+ *
2914
+ * // Get specific tools by slug
2915
+ * const specificTools = await composio.tools.getRawComposioTools({
2916
+ * tools: ['GITHUB_GET_REPOS', 'HACKERNEWS_GET_USER']
2917
+ * });
2917
2918
  *
2918
- * // Get tools with filters
2919
+ * // Get tools from specific toolkits
2919
2920
  * const githubTools = await composio.tools.getRawComposioTools({
2920
2921
  * toolkits: ['github'],
2921
2922
  * limit: 10
2922
2923
  * });
2923
2924
  *
2924
2925
  * // Get tools with schema transformation
2925
- * const tools = await composio.tools.getRawComposioTools({},
2926
- * (toolSlug, toolkitSlug, tool) => {
2926
+ * const customizedTools = await composio.tools.getRawComposioTools({
2927
+ * toolkits: ['github'],
2928
+ * limit: 5
2929
+ * }, {
2930
+ * modifySchema: ({ toolSlug, toolkitSlug, schema }) => {
2927
2931
  * // Add custom properties to tool schema
2928
- * return {...tool, customProperty: 'value'};
2932
+ * return {
2933
+ * ...schema,
2934
+ * customProperty: `Modified ${toolSlug} from ${toolkitSlug}`,
2935
+ * tags: [...(schema.tags || []), 'customized']
2936
+ * };
2929
2937
  * }
2930
- * );
2938
+ * });
2939
+ *
2940
+ * // Search for tools
2941
+ * const searchResults = await composio.tools.getRawComposioTools({
2942
+ * search: 'user management'
2943
+ * });
2944
+ *
2945
+ * // Get tools by authentication config
2946
+ * const authSpecificTools = await composio.tools.getRawComposioTools({
2947
+ * authConfigIds: ['auth_config_123']
2948
+ * });
2931
2949
  * ```
2932
2950
  */
2933
- async getRawComposioTools(query, modifier) {
2951
+ async getRawComposioTools(query, options) {
2934
2952
  if ("tools" in query && "toolkits" in query) {
2935
2953
  throw new ValidationError(
2936
2954
  "Invalid tool list parameters. You should not use tools and toolkits filter together."
@@ -2958,7 +2976,8 @@ var Tools = class {
2958
2976
  ..."tags" in queryParams.data ? { tags: queryParams.data.tags } : {},
2959
2977
  ..."scopes" in queryParams.data ? { scopes: queryParams.data.scopes } : {},
2960
2978
  ..."search" in queryParams.data ? { search: queryParams.data.search } : {},
2961
- ..."authConfigIds" in queryParams.data ? { auth_config_ids: queryParams.data.authConfigIds } : {}
2979
+ ..."authConfigIds" in queryParams.data ? { auth_config_ids: queryParams.data.authConfigIds } : {},
2980
+ ...{ toolkit_versions: this.toolkitVersions }
2962
2981
  };
2963
2982
  logger_default.debug(`Fetching tools with filters: ${JSON.stringify(filters, null, 2)}`);
2964
2983
  const tools = await this.client.tools.list(filters);
@@ -2973,7 +2992,8 @@ var Tools = class {
2973
2992
  ...caseTransformedTools,
2974
2993
  ...customTools
2975
2994
  ]);
2976
- if (modifier) {
2995
+ if (options?.modifySchema) {
2996
+ const modifier = options.modifySchema;
2977
2997
  if (typeof modifier === "function") {
2978
2998
  const modifiedPromises = modifiedTools.map(
2979
2999
  (tool) => modifier({
@@ -2990,17 +3010,56 @@ var Tools = class {
2990
3010
  return modifiedTools;
2991
3011
  }
2992
3012
  /**
2993
- * Retrieves a tool by its Slug.
2994
- * This method is used to get the raw tools from the composio API.
2995
- * @param slug The ID of the tool to be retrieved
2996
- * @returns {Promise<Tool>} The tool
3013
+ * Retrieves a specific tool by its slug from the Composio API.
3014
+ *
3015
+ * This method fetches a single tool in raw format without provider-specific wrapping,
3016
+ * providing direct access to the tool's schema and metadata. Tool versions are controlled
3017
+ * at the Composio SDK initialization level through the `toolkitVersions` configuration.
3018
+ *
3019
+ * @param {string} slug - The unique identifier of the tool (e.g., 'GITHUB_GET_REPOS')
3020
+ * @param {GetRawComposioToolBySlugOptions} [options] - Optional configuration for tool retrieval
3021
+ * @param {TransformToolSchemaModifier} [options.modifySchema] - Function to transform the tool schema
3022
+ * @returns {Promise<Tool>} The requested tool with its complete schema and metadata
2997
3023
  *
2998
3024
  * @example
2999
- * ```ts
3000
- * const tool = await composio.tools.getRawComposioToolBySlug('github');
3025
+ * ```typescript
3026
+ * // Get a tool by slug
3027
+ * const tool = await composio.tools.getRawComposioToolBySlug('GITHUB_GET_REPOS');
3028
+ * console.log(tool.name, tool.description);
3029
+ *
3030
+ * // Get a tool with schema transformation
3031
+ * const customizedTool = await composio.tools.getRawComposioToolBySlug(
3032
+ * 'SLACK_SEND_MESSAGE',
3033
+ * {
3034
+ * modifySchema: ({ toolSlug, toolkitSlug, schema }) => {
3035
+ * return {
3036
+ * ...schema,
3037
+ * description: `Enhanced ${schema.description} with custom modifications`,
3038
+ * customMetadata: {
3039
+ * lastModified: new Date().toISOString(),
3040
+ * toolkit: toolkitSlug
3041
+ * }
3042
+ * };
3043
+ * }
3044
+ * }
3045
+ * );
3046
+ *
3047
+ * // Get a custom tool (will check custom tools first)
3048
+ * const customTool = await composio.tools.getRawComposioToolBySlug('MY_CUSTOM_TOOL');
3049
+ *
3050
+ * // Access tool properties
3051
+ * const githubTool = await composio.tools.getRawComposioToolBySlug('GITHUB_CREATE_ISSUE');
3052
+ * console.log({
3053
+ * slug: githubTool.slug,
3054
+ * name: githubTool.name,
3055
+ * toolkit: githubTool.toolkit?.name,
3056
+ * version: githubTool.version,
3057
+ * availableVersions: githubTool.availableVersions,
3058
+ * inputParameters: githubTool.inputParameters
3059
+ * });
3001
3060
  * ```
3002
3061
  */
3003
- async getRawComposioToolBySlug(slug, modifier) {
3062
+ async getRawComposioToolBySlug(slug, options) {
3004
3063
  const customTool = await this.customTools.getCustomToolBySlug(slug);
3005
3064
  if (customTool) {
3006
3065
  logger_default.debug(`Found ${slug} to be a custom tool`, JSON.stringify(customTool, null, 2));
@@ -3010,14 +3069,17 @@ var Tools = class {
3010
3069
  }
3011
3070
  let tool;
3012
3071
  try {
3013
- tool = await this.client.tools.retrieve(slug);
3072
+ tool = await this.client.tools.retrieve(slug, {
3073
+ toolkit_versions: this.toolkitVersions
3074
+ });
3014
3075
  } catch (error) {
3015
3076
  throw new ComposioToolNotFoundError(`Unable to retrieve tool with slug ${slug}`, {
3016
3077
  cause: error
3017
3078
  });
3018
3079
  }
3019
3080
  let [modifiedTool] = await this.applyDefaultSchemaModifiers([this.transformToolCases(tool)]);
3020
- if (modifier) {
3081
+ if (options?.modifySchema) {
3082
+ const modifier = options.modifySchema;
3021
3083
  if (typeof modifier === "function") {
3022
3084
  modifiedTool = await modifier({
3023
3085
  toolSlug: slug,
@@ -3032,20 +3094,26 @@ var Tools = class {
3032
3094
  }
3033
3095
  /**
3034
3096
  * Get a tool or list of tools based on the provided arguments.
3035
- * This is an implementation method that handles both overloads.
3097
+ * This is an implementation method that handles all overloads.
3036
3098
  *
3037
3099
  * @param {string} userId - The user id to get the tool(s) for
3038
3100
  * @param {ToolListParams | string} arg2 - Either a slug string or filters object
3039
- * @param {ProviderOptions<TProvider>} [options] - Optional provider options
3101
+ * @param {ProviderOptions<TProvider> | ToolkitVersion} [arg3] - Optional provider options or version string
3102
+ * @param {ProviderOptions<TProvider>} [arg4] - Optional provider options (when arg3 is version)
3040
3103
  * @returns {Promise<TToolCollection>} The tool collection
3041
3104
  */
3042
- async get(userId, arg2, options) {
3105
+ async get(userId, arg2, arg3) {
3106
+ const options = arg3;
3043
3107
  const executeToolFn = this.createExecuteToolFn(userId, options);
3044
3108
  if (typeof arg2 === "string") {
3045
- const tool = await this.getRawComposioToolBySlug(arg2, options?.modifySchema);
3109
+ const tool = await this.getRawComposioToolBySlug(arg2, {
3110
+ modifySchema: options?.modifySchema
3111
+ });
3046
3112
  return this.provider.wrapTools([tool], executeToolFn);
3047
3113
  } else {
3048
- const tools = await this.getRawComposioTools(arg2, options?.modifySchema);
3114
+ const tools = await this.getRawComposioTools(arg2, {
3115
+ modifySchema: options?.modifySchema
3116
+ });
3049
3117
  return this.provider.wrapTools(tools, executeToolFn);
3050
3118
  }
3051
3119
  }
@@ -3135,7 +3203,7 @@ var Tools = class {
3135
3203
  custom_connection_data: body.customConnectionData,
3136
3204
  arguments: body.arguments,
3137
3205
  user_id: body.userId,
3138
- version: body.version,
3206
+ version: body.version ?? getToolkitVersion(tool.toolkit?.slug ?? "unknown", this.toolkitVersions),
3139
3207
  text: body.text
3140
3208
  });
3141
3209
  result = this.transformToolExecuteResponse(result);
@@ -3195,25 +3263,34 @@ var Tools = class {
3195
3263
  "CustomTools not initialized. Make sure Tools class is properly constructed."
3196
3264
  );
3197
3265
  }
3266
+ const executeParams = ToolExecuteParamsSchema.safeParse(body);
3267
+ if (!executeParams.success) {
3268
+ throw new ValidationError("Invalid tool execute parameters", { cause: executeParams.error });
3269
+ }
3198
3270
  try {
3199
3271
  const customTool = await this.customTools.getCustomToolBySlug(slug);
3200
3272
  if (customTool) {
3201
- return this.handleCustomToolExecution(customTool, body, modifiers);
3273
+ return this.handleCustomToolExecution(customTool, executeParams.data, modifiers);
3202
3274
  } else {
3203
3275
  const composioTool = await this.getRawComposioToolBySlug(slug);
3204
3276
  if (!composioTool) {
3205
- throw new ComposioToolNotFoundError(`Tool with slug ${slug} not found`);
3277
+ throw new ComposioToolNotFoundError(
3278
+ `Tool with slug ${slug} version:${executeParams.data.version} not found`
3279
+ );
3206
3280
  }
3207
- return this.handleComposioToolExecution(composioTool, body, modifiers);
3281
+ return this.handleComposioToolExecution(composioTool, executeParams.data, modifiers);
3208
3282
  }
3209
3283
  } catch (error) {
3210
- throw new ComposioToolExecutionError(`Error executing tool ${slug}`, {
3211
- originalError: error,
3212
- meta: {
3213
- toolSlug: slug,
3214
- body
3284
+ throw new ComposioToolExecutionError(
3285
+ `Error executing tool ${slug} version:${executeParams.data.version}`,
3286
+ {
3287
+ originalError: error,
3288
+ meta: {
3289
+ toolSlug: slug,
3290
+ body
3291
+ }
3215
3292
  }
3216
- });
3293
+ );
3217
3294
  }
3218
3295
  }
3219
3296
  /**
@@ -3394,8 +3471,10 @@ var ToolKitItemSchema = import_zod7.z.object({
3394
3471
  });
3395
3472
  var ToolKitListResponseSchema = import_zod7.z.array(ToolKitItemSchema);
3396
3473
  var ToolkitAuthFieldSchema = import_zod7.z.object({
3397
- name: import_zod7.z.string(),
3474
+ description: import_zod7.z.string(),
3398
3475
  displayName: import_zod7.z.string(),
3476
+ required: import_zod7.z.boolean(),
3477
+ name: import_zod7.z.string(),
3399
3478
  type: import_zod7.z.string(),
3400
3479
  default: import_zod7.z.string().nullable().optional()
3401
3480
  });
@@ -5265,24 +5344,506 @@ var Triggers = class {
5265
5344
  }
5266
5345
  };
5267
5346
 
5347
+ // src/types/mcp.experimental.types.ts
5348
+ var import_zod10 = __toESM(require("zod"), 1);
5349
+ var MCPServerInstanceSchema = import_zod10.default.object({
5350
+ id: import_zod10.default.string(),
5351
+ name: import_zod10.default.string(),
5352
+ type: import_zod10.default.literal("streamable_http"),
5353
+ url: import_zod10.default.string(),
5354
+ userId: import_zod10.default.string(),
5355
+ allowedTools: import_zod10.default.array(import_zod10.default.string()),
5356
+ authConfigs: import_zod10.default.array(import_zod10.default.string())
5357
+ });
5358
+ var MCPConfigToolkitsSchema = import_zod10.default.object({
5359
+ toolkit: import_zod10.default.string().describe("Id of the toolkit").optional(),
5360
+ authConfigId: import_zod10.default.string().describe("Id of the auth config").optional()
5361
+ });
5362
+ var MCPConfigCreationParamsSchema = import_zod10.default.object({
5363
+ toolkits: import_zod10.default.array(import_zod10.default.union([MCPConfigToolkitsSchema, import_zod10.default.string()])),
5364
+ allowedTools: import_zod10.default.array(import_zod10.default.string()).optional(),
5365
+ manuallyManageConnections: import_zod10.default.boolean().default(false).optional().describe(
5366
+ `Whether to manually manage accounts. If true, you need to manage accounts manually connect user accounts.
5367
+ If set to false, composio will inject account maangement tools into your mcp server for agents to request and authenticate accounts.
5368
+ defaults to false`
5369
+ )
5370
+ });
5371
+ var MCPConfigResponseSchema = import_zod10.default.object({
5372
+ /**
5373
+ * Unique identifier for the newly created custom MCP server
5374
+ */
5375
+ id: import_zod10.default.string(),
5376
+ /**
5377
+ * Human-readable name of the custom MCP server
5378
+ */
5379
+ name: import_zod10.default.string(),
5380
+ /**
5381
+ * List of tool identifiers that are enabled for this server
5382
+ */
5383
+ allowedTools: import_zod10.default.array(import_zod10.default.string()),
5384
+ /**
5385
+ * ID references to the auth configurations used by this server
5386
+ */
5387
+ authConfigIds: import_zod10.default.array(import_zod10.default.string()),
5388
+ /**
5389
+ * Set of command line instructions for connecting various clients to this MCP server
5390
+ */
5391
+ commands: import_zod10.default.object({
5392
+ /**
5393
+ * Command line instruction for Claude client setup
5394
+ */
5395
+ claude: import_zod10.default.string(),
5396
+ /**
5397
+ * Command line instruction for Cursor client setup
5398
+ */
5399
+ cursor: import_zod10.default.string(),
5400
+ /**
5401
+ * Command line instruction for Windsurf client setup
5402
+ */
5403
+ windsurf: import_zod10.default.string()
5404
+ }),
5405
+ /**
5406
+ * URL endpoint for establishing Server-Sent Events (SSE) connection to this MCP server
5407
+ */
5408
+ MCPUrl: import_zod10.default.string()
5409
+ });
5410
+ var MCPGetInstanceParamsSchema = import_zod10.default.object({
5411
+ manuallyManageConnections: import_zod10.default.boolean().default(false).optional().describe(
5412
+ `Whether to manually manage accounts. If true, you need to manage accounts manually connect user accounts.
5413
+ If set to false, composio will inject account maangement tools into your mcp server for agents to request and authenticate accounts.
5414
+ defaults to false`
5415
+ )
5416
+ });
5417
+ var MCPListParamsSchema = import_zod10.default.object({
5418
+ page: import_zod10.default.number().optional().default(1),
5419
+ limit: import_zod10.default.number().optional().default(10),
5420
+ toolkits: import_zod10.default.array(import_zod10.default.string()).optional().default([]),
5421
+ authConfigs: import_zod10.default.array(import_zod10.default.string()).optional().default([]),
5422
+ name: import_zod10.default.string().optional()
5423
+ });
5424
+ var MCPItemSchema = MCPConfigResponseSchema.extend({
5425
+ ...import_zod10.default.object({
5426
+ toolkitIcons: import_zod10.default.record(import_zod10.default.string(), import_zod10.default.string()),
5427
+ serverInstanceCount: import_zod10.default.number(),
5428
+ toolkits: import_zod10.default.array(import_zod10.default.string())
5429
+ }).shape
5430
+ });
5431
+ var MCPListResponseSchema = import_zod10.default.object({
5432
+ items: import_zod10.default.array(MCPItemSchema),
5433
+ currentPage: import_zod10.default.number(),
5434
+ totalPages: import_zod10.default.number()
5435
+ });
5436
+ var MCPUpdateParamsSchema = import_zod10.default.object({
5437
+ name: import_zod10.default.string().optional(),
5438
+ toolkits: import_zod10.default.array(import_zod10.default.union([MCPConfigToolkitsSchema, import_zod10.default.string()])).optional(),
5439
+ allowedTools: import_zod10.default.array(import_zod10.default.string()).optional(),
5440
+ manuallyManageConnections: import_zod10.default.boolean().optional().describe(
5441
+ `Whether to manually manage accounts. If true, you need to manage accounts manually connect user accounts.
5442
+ If set to false, composio will inject account maangement tools into your mcp server for agents to request and authenticate accounts.
5443
+ defaults to false`
5444
+ )
5445
+ });
5446
+ var MCPServerConnectionStatus = import_zod10.default.object({
5447
+ connected: import_zod10.default.boolean(),
5448
+ toolkit: import_zod10.default.string(),
5449
+ connectedAccountId: import_zod10.default.string()
5450
+ });
5451
+ var MCPServerConnectedAccountsSchema = import_zod10.default.record(
5452
+ import_zod10.default.string(),
5453
+ import_zod10.default.array(
5454
+ import_zod10.default.object({
5455
+ toolkit: import_zod10.default.string(),
5456
+ authConfigId: import_zod10.default.string(),
5457
+ connectedAccountId: import_zod10.default.string()
5458
+ })
5459
+ )
5460
+ );
5461
+
5462
+ // src/models/MCP.experimental.ts
5463
+ function transformMCPItemResponse(response) {
5464
+ return transform(response).with(MCPItemSchema).using((raw) => ({
5465
+ name: raw.name,
5466
+ allowedTools: raw.allowed_tools,
5467
+ id: raw.id,
5468
+ authConfigIds: raw.auth_config_ids,
5469
+ commands: raw.commands,
5470
+ MCPUrl: raw.mcp_url,
5471
+ toolkitIcons: raw.toolkit_icons,
5472
+ serverInstanceCount: raw.server_instance_count,
5473
+ toolkits: raw.toolkits
5474
+ }));
5475
+ }
5476
+ var MCP = class {
5477
+ client;
5478
+ constructor(client) {
5479
+ this.client = client;
5480
+ telemetry.instrument(this);
5481
+ }
5482
+ /**
5483
+ * Create a new MCP configuration.
5484
+ * @param {Object} params - Parameters for creating the MCP configuration
5485
+ * @param {Array} params.authConfig - Array of auth configurations with id and allowed tools
5486
+ * @param {Object} params.options - Configuration options
5487
+ * @param {string} params.options.name - Unique name for the MCP configuration
5488
+ * @param {boolean} [params.options.manuallyManageConnections] - Whether to use chat-based authentication or manually connect accounts
5489
+ * @returns {Promise<McpServerCreateResponse<T>>} Created server details with instance getter
5490
+ *
5491
+ * @example
5492
+ * ```typescript
5493
+ * const server = await composio.mcpConfig.create("personal-mcp-server", {
5494
+ * toolkits: ["github", "slack"],
5495
+ * allowedTools: ["GMAIL_FETCH_EMAILS", "SLACK_SEND_MESSAGE"],
5496
+ * manuallyManageConnections: false
5497
+ * }
5498
+ * });
5499
+ *
5500
+ * const server = await composio.mcpConfig.create("personal-mcp-server", {
5501
+ * toolkits: [{ toolkit: "gmail", authConfigId: "ac_243434343" }],
5502
+ * allowedTools: ["GMAIL_FETCH_EMAILS"],
5503
+ * manuallyManageConnections: false
5504
+ * }
5505
+ * });
5506
+ * ```
5507
+ */
5508
+ async create(name, mcpConfig) {
5509
+ const config = MCPConfigCreationParamsSchema.safeParse(mcpConfig);
5510
+ if (config.error) {
5511
+ throw new ValidationError("Invalid parameters passed to create mcp config", {
5512
+ cause: config.error
5513
+ });
5514
+ }
5515
+ const toolkits = [];
5516
+ const auth_config_ids = [];
5517
+ const custom_tools = config.data.allowedTools ?? [];
5518
+ config.data.toolkits.forEach((toolkit) => {
5519
+ if (typeof toolkit === "string") {
5520
+ toolkits.push(toolkit);
5521
+ } else if (toolkit.toolkit) {
5522
+ toolkits.push(toolkit.toolkit);
5523
+ } else if (toolkit.authConfigId) {
5524
+ auth_config_ids.push(toolkit.authConfigId);
5525
+ }
5526
+ });
5527
+ const server = await this.client.mcp.custom.create({
5528
+ name,
5529
+ toolkits,
5530
+ auth_config_ids,
5531
+ custom_tools,
5532
+ // if manually manage account is set to true, disable composio account management tools
5533
+ managed_auth_via_composio: config.data.manuallyManageConnections ? false : true
5534
+ });
5535
+ const camelCaseServer = transform(server).with(MCPConfigResponseSchema).using((raw) => ({
5536
+ name: raw.name,
5537
+ allowedTools: raw.allowed_tools,
5538
+ id: raw.id,
5539
+ authConfigIds: raw.auth_config_ids,
5540
+ commands: raw.commands,
5541
+ MCPUrl: raw.mcp_url
5542
+ }));
5543
+ return {
5544
+ ...camelCaseServer,
5545
+ generate: async (userId) => {
5546
+ return await this.generate(userId, server.id, {
5547
+ manuallyManageConnections: config.data.manuallyManageConnections
5548
+ });
5549
+ }
5550
+ };
5551
+ }
5552
+ /**
5553
+ * List the MCP servers with optional filtering and pagination
5554
+ * @param {Object} options - Filtering and pagination options
5555
+ * @param {number} [options.page=1] - Page number for pagination (1-based)
5556
+ * @param {number} [options.limit=10] - Maximum number of items to return per page
5557
+ * @param {string[]} [options.toolkits=[]] - Array of toolkit names to filter by
5558
+ * @param {string[]} [options.authConfigs=[]] - Array of auth configuration IDs to filter by
5559
+ * @param {string} [options.name] - Filter by MCP server name (partial match)
5560
+ * @returns {Promise<MCPListResponse>} Paginated list of MCP servers with metadata
5561
+ *
5562
+ * @example
5563
+ * ```typescript
5564
+ * // List all MCP servers
5565
+ * const allServers = await composio.experimental.mcp.list({});
5566
+ *
5567
+ * // List with pagination
5568
+ * const pagedServers = await composio.experimental.mcp.list({
5569
+ * page: 2,
5570
+ * limit: 5
5571
+ * });
5572
+ *
5573
+ * // Filter by toolkit
5574
+ * const githubServers = await composio.experimental.mcp.list({
5575
+ * toolkits: ['github', 'slack']
5576
+ * });
5577
+ *
5578
+ * // Filter by name
5579
+ * const namedServers = await composio.experimental.mcp.list({
5580
+ * name: 'personal'
5581
+ * });
5582
+ * ```
5583
+ */
5584
+ async list(options) {
5585
+ const { data: params, error } = MCPListParamsSchema.safeParse(options);
5586
+ if (error) {
5587
+ throw new ValidationError("Failed to validate list options", {
5588
+ cause: error
5589
+ });
5590
+ }
5591
+ const listResponse = await this.client.mcp.list({
5592
+ page_no: params.page,
5593
+ limit: params.limit,
5594
+ toolkits: params.toolkits?.length > 0 ? params.toolkits.join(",") : void 0,
5595
+ auth_config_ids: params.authConfigs?.length > 0 ? params.authConfigs.join(",") : void 0,
5596
+ name: params.name
5597
+ });
5598
+ const transformedListResponse = transform(listResponse).with(MCPListResponseSchema).using((raw) => ({
5599
+ currentPage: raw.current_page,
5600
+ totalPages: raw.total_pages,
5601
+ items: raw.items.map((item) => ({
5602
+ name: item.name,
5603
+ allowedTools: item.allowed_tools,
5604
+ id: item.id,
5605
+ authConfigIds: item.auth_config_ids,
5606
+ commands: item.commands,
5607
+ MCPUrl: item.mcp_url,
5608
+ toolkitIcons: item.toolkit_icons,
5609
+ serverInstanceCount: item.server_instance_count,
5610
+ toolkits: item.toolkits
5611
+ }))
5612
+ }));
5613
+ return transformedListResponse;
5614
+ }
5615
+ /**
5616
+ * Retrieve detailed information about a specific MCP server by its ID
5617
+ * @param {string} serverId - The unique identifier of the MCP server to retrieve
5618
+ * @returns {Promise<MCPItem>} Complete MCP server details including configuration, tools, and metadata
5619
+ *
5620
+ * @example
5621
+ * ```typescript
5622
+ * // Get a specific MCP server by ID
5623
+ * const server = await composio.experimental.mcp.get("mcp_12345");
5624
+ *
5625
+ * console.log(server.name); // "My Personal MCP Server"
5626
+ * console.log(server.allowedTools); // ["GITHUB_CREATE_ISSUE", "SLACK_SEND_MESSAGE"]
5627
+ * console.log(server.toolkits); // ["github", "slack"]
5628
+ * console.log(server.serverInstanceCount); // 3
5629
+ *
5630
+ * // Access setup commands for different clients
5631
+ * console.log(server.commands.claude); // Claude setup command
5632
+ * console.log(server.commands.cursor); // Cursor setup command
5633
+ * console.log(server.commands.windsurf); // Windsurf setup command
5634
+ *
5635
+ * // Use the MCP URL for direct connections
5636
+ * const mcpUrl = server.MCPUrl;
5637
+ * ```
5638
+ *
5639
+ * @throws {ValidationError} When the server ID is invalid or server not found
5640
+ */
5641
+ async get(serverId) {
5642
+ const response = await this.client.mcp.retrieve(serverId);
5643
+ return transformMCPItemResponse(response);
5644
+ }
5645
+ /**
5646
+ * Delete an MCP server configuration permanently
5647
+ * @param {string} serverId - The unique identifier of the MCP server to delete
5648
+ * @returns {Promise<{id: string; deleted: boolean}>} Confirmation object with server ID and deletion status
5649
+ *
5650
+ * @example
5651
+ * ```typescript
5652
+ * // Delete an MCP server by ID
5653
+ * const result = await composio.experimental.mcp.delete("mcp_12345");
5654
+ *
5655
+ * if (result.deleted) {
5656
+ * console.log(`Server ${result.id} has been successfully deleted`);
5657
+ * } else {
5658
+ * console.log(`Failed to delete server ${result.id}`);
5659
+ * }
5660
+ *
5661
+ * // Example with error handling
5662
+ * try {
5663
+ * const result = await composio.experimental.mcp.delete("mcp_12345");
5664
+ * console.log("Deletion successful:", result);
5665
+ * } catch (error) {
5666
+ * console.error("Failed to delete MCP server:", error.message);
5667
+ * }
5668
+ *
5669
+ * // Delete and verify from list
5670
+ * await composio.experimental.mcp.delete("mcp_12345");
5671
+ * const servers = await composio.experimental.mcp.list({});
5672
+ * const serverExists = servers.items.some(server => server.id === "mcp_12345");
5673
+ * console.log("Server still exists:", serverExists); // Should be false
5674
+ * ```
5675
+ *
5676
+ * @throws {ValidationError} When the server ID is invalid or server not found
5677
+ * @throws {Error} When the server cannot be deleted due to active connections or other constraints
5678
+ *
5679
+ * @warning This operation is irreversible. Once deleted, the MCP server configuration and all its associated data will be permanently removed.
5680
+ */
5681
+ async delete(serverId) {
5682
+ return await this.client.mcp.delete(serverId);
5683
+ }
5684
+ /**
5685
+ * Update an existing MCP server configuration with new settings
5686
+ * @param {string} serverId - The unique identifier of the MCP server to update
5687
+ * @param {Object} config - Update configuration parameters
5688
+ * @param {string} [config.name] - New name for the MCP server
5689
+ * @param {Array} [config.toolkits] - Updated toolkit configurations
5690
+ * @param {string} [config.toolkits[].toolkit] - Toolkit identifier (e.g., "github", "slack")
5691
+ * @param {string} [config.toolkits[].authConfigId] - Auth configuration ID for the toolkit
5692
+ * @param {string[]} [config.toolkits[].allowedTools] - Specific tools to enable for this toolkit
5693
+ * @param {boolean} [config.manuallyManageConnections] - Whether to manually manage account connections
5694
+ * @returns {Promise<MCPItem>} Updated MCP server configuration with all details
5695
+ *
5696
+ * @example
5697
+ * ```typescript
5698
+ * // Update server name only
5699
+ * const updatedServer = await composio.experimental.mcp.update("mcp_12345", {
5700
+ * name: "My Updated MCP Server"
5701
+ * });
5702
+ *
5703
+ * // Update toolkits and tools
5704
+ * const serverWithNewTools = await composio.experimental.mcp.update("mcp_12345", {
5705
+ * toolkits: [
5706
+ * {
5707
+ * toolkit: "github",
5708
+ * authConfigId: "auth_abc123",
5709
+ * allowedTools: ["GITHUB_CREATE_ISSUE", "GITHUB_LIST_REPOS"]
5710
+ * },
5711
+ * {
5712
+ * toolkit: "slack",
5713
+ * authConfigId: "auth_xyz789",
5714
+ * allowedTools: ["SLACK_SEND_MESSAGE", "SLACK_LIST_CHANNELS"]
5715
+ * }
5716
+ * ]
5717
+ * });
5718
+ *
5719
+ * // Update connection management setting
5720
+ * const serverWithManualAuth = await composio.experimental.mcp.update("mcp_12345", {
5721
+ * name: "Manual Auth Server",
5722
+ * manuallyManageConnections: true
5723
+ * });
5724
+ *
5725
+ * // Complete update example
5726
+ * const fullyUpdatedServer = await composio.experimental.mcp.update("mcp_12345", {
5727
+ * name: "Production MCP Server",
5728
+ * toolkits: [
5729
+ * {
5730
+ * toolkit: "gmail",
5731
+ * authConfigId: "auth_gmail_prod",
5732
+ * }
5733
+ * ],
5734
+ * allowedTools: ["GMAIL_SEND_EMAIL", "GMAIL_FETCH_EMAILS"]
5735
+ * manuallyManageConnections: false
5736
+ * });
5737
+ *
5738
+ * console.log("Updated server:", fullyUpdatedServer.name);
5739
+ * console.log("New tools:", fullyUpdatedServer.allowedTools);
5740
+ * ```
5741
+ *
5742
+ * @throws {ValidationError} When the update parameters are invalid or malformed
5743
+ * @throws {Error} When the server ID doesn't exist or update fails
5744
+ *
5745
+ * @note Only provided fields will be updated. Omitted fields will retain their current values.
5746
+ * @note When updating toolkits, the entire toolkit configuration is replaced, not merged.
5747
+ */
5748
+ async update(serverId, config) {
5749
+ const { data: params, error } = MCPUpdateParamsSchema.safeParse(config);
5750
+ if (error) {
5751
+ throw new ValidationError("Failed to validate update params", {
5752
+ cause: error
5753
+ });
5754
+ }
5755
+ const toolkits = [];
5756
+ const auth_config_ids = [];
5757
+ const custom_tools = params.allowedTools ?? void 0;
5758
+ params.toolkits?.forEach((toolkit) => {
5759
+ if (typeof toolkit === "string") {
5760
+ toolkits.push(toolkit);
5761
+ } else if (toolkit.toolkit) {
5762
+ toolkits.push(toolkit.toolkit);
5763
+ } else if (toolkit.authConfigId) {
5764
+ auth_config_ids.push(toolkit.authConfigId);
5765
+ }
5766
+ });
5767
+ const response = await this.client.mcp.update(serverId, {
5768
+ ...{ name: params.name ?? void 0 },
5769
+ ...params.toolkits ? {
5770
+ custom_tools,
5771
+ toolkits,
5772
+ auth_config_ids
5773
+ } : {},
5774
+ ...{ managed_auth_via_composio: params.manuallyManageConnections ?? void 0 }
5775
+ });
5776
+ return transformMCPItemResponse(response);
5777
+ }
5778
+ /**
5779
+ * Get server URLs for an existing MCP server.
5780
+ * The response is wrapped according to the provider's specifications.
5781
+ *
5782
+ * @example
5783
+ * ```typescript
5784
+ * import { Composio } from "@composio/code";
5785
+ *
5786
+ * const composio = new Composio();
5787
+ * const mcp = await composio.experimental.mcp.generate("default", "<mcp_config_id>");
5788
+ * ```
5789
+ *
5790
+ * @param userId {string} external user id from your database for whom you want the server for
5791
+ * @param mcpConfigId {string} config id of the MCPConfig for which you want to create a server for
5792
+ * @param options {object} additional options
5793
+ * @param options.isChatAuth {boolean} Authenticate the users via chat when they use the MCP Server
5794
+ */
5795
+ async generate(userId, mcpConfigId, options) {
5796
+ const server = await this.client.mcp.retrieve(mcpConfigId);
5797
+ const params = MCPGetInstanceParamsSchema.safeParse(
5798
+ options ?? { manuallyManageConnections: false }
5799
+ );
5800
+ if (params.error) {
5801
+ throw new ValidationError("Invalid params passed for Get Instance Params", {
5802
+ cause: params.error
5803
+ });
5804
+ }
5805
+ const urlResponse = await this.client.mcp.generate.url({
5806
+ mcp_server_id: mcpConfigId,
5807
+ user_ids: [userId],
5808
+ managed_auth_by_composio: options?.manuallyManageConnections ? false : true
5809
+ });
5810
+ const userIdsURL = urlResponse.user_ids_url[0];
5811
+ const serverInstance = MCPServerInstanceSchema.safeParse({
5812
+ id: server.id,
5813
+ name: server.name,
5814
+ type: "streamable_http",
5815
+ url: userIdsURL,
5816
+ userId,
5817
+ allowedTools: server.allowed_tools,
5818
+ authConfigs: server.auth_config_ids
5819
+ });
5820
+ if (serverInstance.error) {
5821
+ throw new ValidationError("Failed to parse MCP server instance", {
5822
+ cause: serverInstance.error
5823
+ });
5824
+ }
5825
+ return serverInstance.data;
5826
+ }
5827
+ };
5828
+
5268
5829
  // src/types/mcp.types.ts
5269
- var import_zod10 = require("zod");
5270
- var MCPToolkitConfigSchema = import_zod10.z.object({
5271
- toolkit: import_zod10.z.string().min(1, "Toolkit name cannot be empty"),
5272
- authConfigId: import_zod10.z.string().min(1, "Auth config ID cannot be empty"),
5273
- allowedTools: import_zod10.z.array(import_zod10.z.string().min(1, "Tool name cannot be empty")).min(1, "At least one tool must be specified")
5830
+ var import_zod11 = require("zod");
5831
+ var MCPToolkitConfigSchema = import_zod11.z.object({
5832
+ toolkit: import_zod11.z.string().min(1, "Toolkit name cannot be empty"),
5833
+ authConfigId: import_zod11.z.string().min(1, "Auth config ID cannot be empty"),
5834
+ allowedTools: import_zod11.z.array(import_zod11.z.string().min(1, "Tool name cannot be empty")).min(1, "At least one tool must be specified")
5274
5835
  });
5275
- var MCPToolkitConfigsArraySchema = import_zod10.z.array(MCPToolkitConfigSchema).min(1, "At least one toolkit configuration is required").refine((configs) => {
5836
+ var MCPToolkitConfigsArraySchema = import_zod11.z.array(MCPToolkitConfigSchema).min(1, "At least one toolkit configuration is required").refine((configs) => {
5276
5837
  const toolkits = configs.map((config) => config.toolkit);
5277
5838
  const uniqueToolkits = new Set(toolkits);
5278
5839
  return uniqueToolkits.size === toolkits.length;
5279
5840
  }, "Duplicate toolkits are not allowed. Each toolkit must be unique.");
5280
- var MCPAuthOptionsSchema = import_zod10.z.object({
5281
- isChatAuth: import_zod10.z.boolean().optional()
5841
+ var MCPAuthOptionsSchema = import_zod11.z.object({
5842
+ isChatAuth: import_zod11.z.boolean().optional()
5282
5843
  });
5283
- var MCPGetServerParamsSchema = import_zod10.z.object({
5284
- userId: import_zod10.z.string().min(1, "User ID cannot be empty").optional(),
5285
- connectedAccountIds: import_zod10.z.record(import_zod10.z.string(), import_zod10.z.string().min(1, "Account ID cannot be empty")).optional()
5844
+ var MCPGetServerParamsSchema = import_zod11.z.object({
5845
+ userId: import_zod11.z.string().min(1, "User ID cannot be empty").optional(),
5846
+ connectedAccountIds: import_zod11.z.record(import_zod11.z.string(), import_zod11.z.string().min(1, "Account ID cannot be empty")).optional()
5286
5847
  }).refine(
5287
5848
  (data) => {
5288
5849
  const hasUserId = !!data.userId;
@@ -5293,61 +5854,61 @@ var MCPGetServerParamsSchema = import_zod10.z.object({
5293
5854
  message: "Must provide either userId or connectedAccountIds, but not both"
5294
5855
  }
5295
5856
  );
5296
- var MCPGenerateURLParamsSchema = import_zod10.z.object({
5297
- userIds: import_zod10.z.array(import_zod10.z.string()).optional(),
5298
- connectedAccountIds: import_zod10.z.array(import_zod10.z.string()).optional(),
5299
- isChatAuth: import_zod10.z.boolean().optional()
5857
+ var MCPGenerateURLParamsSchema = import_zod11.z.object({
5858
+ userIds: import_zod11.z.array(import_zod11.z.string()).optional(),
5859
+ connectedAccountIds: import_zod11.z.array(import_zod11.z.string()).optional(),
5860
+ isChatAuth: import_zod11.z.boolean().optional()
5300
5861
  });
5301
- var ComposioGenerateURLParamsSchema = import_zod10.z.object({
5302
- user_ids: import_zod10.z.array(import_zod10.z.string()).optional(),
5303
- connected_account_ids: import_zod10.z.array(import_zod10.z.string()).optional(),
5304
- mcp_server_id: import_zod10.z.string(),
5305
- managed_auth_by_composio: import_zod10.z.boolean().optional()
5862
+ var ComposioGenerateURLParamsSchema = import_zod11.z.object({
5863
+ user_ids: import_zod11.z.array(import_zod11.z.string()).optional(),
5864
+ connected_account_ids: import_zod11.z.array(import_zod11.z.string()).optional(),
5865
+ mcp_server_id: import_zod11.z.string(),
5866
+ managed_auth_by_composio: import_zod11.z.boolean().optional()
5306
5867
  });
5307
- var GenerateURLParamsSchema = import_zod10.z.object({
5308
- userIds: import_zod10.z.array(import_zod10.z.string()).optional(),
5309
- connectedAccountIds: import_zod10.z.array(import_zod10.z.string()).optional(),
5310
- mcpServerId: import_zod10.z.string(),
5311
- composioManagedAuth: import_zod10.z.boolean().optional()
5868
+ var GenerateURLParamsSchema = import_zod11.z.object({
5869
+ userIds: import_zod11.z.array(import_zod11.z.string()).optional(),
5870
+ connectedAccountIds: import_zod11.z.array(import_zod11.z.string()).optional(),
5871
+ mcpServerId: import_zod11.z.string(),
5872
+ composioManagedAuth: import_zod11.z.boolean().optional()
5312
5873
  });
5313
- var GenerateURLResponseSchema = import_zod10.z.object({
5314
- connectedAccountUrls: import_zod10.z.array(import_zod10.z.string()).optional(),
5315
- userIdsUrl: import_zod10.z.array(import_zod10.z.string()).optional(),
5316
- mcpUrl: import_zod10.z.string().min(1, "MCP URL cannot be empty")
5874
+ var GenerateURLResponseSchema = import_zod11.z.object({
5875
+ connectedAccountUrls: import_zod11.z.array(import_zod11.z.string()).optional(),
5876
+ userIdsUrl: import_zod11.z.array(import_zod11.z.string()).optional(),
5877
+ mcpUrl: import_zod11.z.string().min(1, "MCP URL cannot be empty")
5317
5878
  });
5318
- var ComposioGenerateURLResponseSchema = import_zod10.z.object({
5319
- connected_account_urls: import_zod10.z.array(import_zod10.z.string()).optional(),
5320
- user_ids_url: import_zod10.z.array(import_zod10.z.string()).optional(),
5321
- mcp_url: import_zod10.z.string().min(1, "MCP URL cannot be empty")
5879
+ var ComposioGenerateURLResponseSchema = import_zod11.z.object({
5880
+ connected_account_urls: import_zod11.z.array(import_zod11.z.string()).optional(),
5881
+ user_ids_url: import_zod11.z.array(import_zod11.z.string()).optional(),
5882
+ mcp_url: import_zod11.z.string().min(1, "MCP URL cannot be empty")
5322
5883
  });
5323
- var MCPSingleAppServerSchema = import_zod10.z.object({
5324
- name: import_zod10.z.string().describe("Name of the MCP server"),
5325
- tools: import_zod10.z.array(import_zod10.z.string()).describe("List of allowed tools"),
5326
- authConfigId: import_zod10.z.string().optional().describe("Auth config ID for the server")
5884
+ var MCPSingleAppServerSchema = import_zod11.z.object({
5885
+ name: import_zod11.z.string().describe("Name of the MCP server"),
5886
+ tools: import_zod11.z.array(import_zod11.z.string()).describe("List of allowed tools"),
5887
+ authConfigId: import_zod11.z.string().optional().describe("Auth config ID for the server")
5327
5888
  });
5328
- var MCPMultiAppServerSchema = import_zod10.z.object({
5329
- name: import_zod10.z.string().describe("Name of the MCP server"),
5330
- tools: import_zod10.z.array(import_zod10.z.string()).describe("List of allowed tools across toolkits"),
5331
- toolkits: import_zod10.z.array(import_zod10.z.string()).describe("List of allowed toolkits")
5889
+ var MCPMultiAppServerSchema = import_zod11.z.object({
5890
+ name: import_zod11.z.string().describe("Name of the MCP server"),
5891
+ tools: import_zod11.z.array(import_zod11.z.string()).describe("List of allowed tools across toolkits"),
5892
+ toolkits: import_zod11.z.array(import_zod11.z.string()).describe("List of allowed toolkits")
5332
5893
  });
5333
- var MCPServerSchema = import_zod10.z.object({
5334
- id: import_zod10.z.string().describe("Unique identifier for the MCP server"),
5335
- type: import_zod10.z.enum(["single", "multi"]).describe("Type of MCP server"),
5336
- createdAt: import_zod10.z.string().describe("Creation timestamp"),
5337
- updatedAt: import_zod10.z.string().describe("Last update timestamp"),
5338
- status: import_zod10.z.enum(["active", "inactive", "error"]).default("active"),
5339
- config: import_zod10.z.union([MCPSingleAppServerSchema, MCPMultiAppServerSchema])
5894
+ var MCPServerSchema = import_zod11.z.object({
5895
+ id: import_zod11.z.string().describe("Unique identifier for the MCP server"),
5896
+ type: import_zod11.z.enum(["single", "multi"]).describe("Type of MCP server"),
5897
+ createdAt: import_zod11.z.string().describe("Creation timestamp"),
5898
+ updatedAt: import_zod11.z.string().describe("Last update timestamp"),
5899
+ status: import_zod11.z.enum(["active", "inactive", "error"]).default("active"),
5900
+ config: import_zod11.z.union([MCPSingleAppServerSchema, MCPMultiAppServerSchema])
5340
5901
  });
5341
- var MCPServerListResponseSchema = import_zod10.z.object({
5342
- items: import_zod10.z.array(MCPServerSchema),
5343
- total: import_zod10.z.number(),
5344
- page: import_zod10.z.number(),
5345
- pageSize: import_zod10.z.number()
5902
+ var MCPServerListResponseSchema = import_zod11.z.object({
5903
+ items: import_zod11.z.array(MCPServerSchema),
5904
+ total: import_zod11.z.number(),
5905
+ page: import_zod11.z.number(),
5906
+ pageSize: import_zod11.z.number()
5346
5907
  });
5347
- var MCPServerUpdateParamsSchema = import_zod10.z.object({
5348
- name: import_zod10.z.string().optional().describe("New name for the server"),
5349
- toolkits: import_zod10.z.array(import_zod10.z.string()).optional().describe("Updated list of toolkits"),
5350
- allowedTools: import_zod10.z.array(import_zod10.z.string()).optional().describe("Updated list of allowed tools")
5908
+ var MCPServerUpdateParamsSchema = import_zod11.z.object({
5909
+ name: import_zod11.z.string().optional().describe("New name for the server"),
5910
+ toolkits: import_zod11.z.array(import_zod11.z.string()).optional().describe("Updated list of toolkits"),
5911
+ allowedTools: import_zod11.z.array(import_zod11.z.string()).optional().describe("Updated list of allowed tools")
5351
5912
  });
5352
5913
  var MCPServerCreateResponseSchema = MCPServerSchema;
5353
5914
  var ConnectionStatus = /* @__PURE__ */ ((ConnectionStatus2) => {
@@ -5355,96 +5916,96 @@ var ConnectionStatus = /* @__PURE__ */ ((ConnectionStatus2) => {
5355
5916
  ConnectionStatus2["DISCONNECTED"] = "DISCONNECTED";
5356
5917
  return ConnectionStatus2;
5357
5918
  })(ConnectionStatus || {});
5358
- var CustomCreateResponseSchema = import_zod10.z.object({
5359
- id: import_zod10.z.string().min(1, "Server ID cannot be empty"),
5360
- name: import_zod10.z.string().min(1, "Server name cannot be empty"),
5361
- createdAt: import_zod10.z.string().nullish(),
5362
- updatedAt: import_zod10.z.string().nullish(),
5363
- status: import_zod10.z.string().nullish()
5919
+ var CustomCreateResponseSchema = import_zod11.z.object({
5920
+ id: import_zod11.z.string().min(1, "Server ID cannot be empty"),
5921
+ name: import_zod11.z.string().min(1, "Server name cannot be empty"),
5922
+ createdAt: import_zod11.z.string().nullish(),
5923
+ updatedAt: import_zod11.z.string().nullish(),
5924
+ status: import_zod11.z.string().nullish()
5364
5925
  });
5365
- var ComposioCustomCreateResponseSchema = import_zod10.z.object({
5366
- id: import_zod10.z.string().min(1, "Server ID cannot be empty"),
5367
- name: import_zod10.z.string().min(1, "Server name cannot be empty"),
5368
- created_at: import_zod10.z.string().nullish(),
5369
- updated_at: import_zod10.z.string().nullish(),
5370
- status: import_zod10.z.string().nullish()
5926
+ var ComposioCustomCreateResponseSchema = import_zod11.z.object({
5927
+ id: import_zod11.z.string().min(1, "Server ID cannot be empty"),
5928
+ name: import_zod11.z.string().min(1, "Server name cannot be empty"),
5929
+ created_at: import_zod11.z.string().nullish(),
5930
+ updated_at: import_zod11.z.string().nullish(),
5931
+ status: import_zod11.z.string().nullish()
5371
5932
  });
5372
- var McpListResponseSchema = import_zod10.z.object({
5373
- items: import_zod10.z.array(
5374
- import_zod10.z.object({
5375
- id: import_zod10.z.string().min(1, "Server ID cannot be empty"),
5376
- name: import_zod10.z.string().min(1, "Server name cannot be empty"),
5377
- createdAt: import_zod10.z.string().optional(),
5378
- updatedAt: import_zod10.z.string().optional(),
5379
- status: import_zod10.z.string().optional()
5933
+ var McpListResponseSchema = import_zod11.z.object({
5934
+ items: import_zod11.z.array(
5935
+ import_zod11.z.object({
5936
+ id: import_zod11.z.string().min(1, "Server ID cannot be empty"),
5937
+ name: import_zod11.z.string().min(1, "Server name cannot be empty"),
5938
+ createdAt: import_zod11.z.string().optional(),
5939
+ updatedAt: import_zod11.z.string().optional(),
5940
+ status: import_zod11.z.string().optional()
5380
5941
  })
5381
5942
  ).optional()
5382
5943
  });
5383
- var ComposioMcpListResponseSchema = import_zod10.z.object({
5384
- items: import_zod10.z.array(
5385
- import_zod10.z.object({
5386
- id: import_zod10.z.string().min(1, "Server ID cannot be empty"),
5387
- name: import_zod10.z.string().min(1, "Server name cannot be empty"),
5388
- created_at: import_zod10.z.string().optional(),
5389
- updated_at: import_zod10.z.string().optional(),
5390
- status: import_zod10.z.string().optional()
5944
+ var ComposioMcpListResponseSchema = import_zod11.z.object({
5945
+ items: import_zod11.z.array(
5946
+ import_zod11.z.object({
5947
+ id: import_zod11.z.string().min(1, "Server ID cannot be empty"),
5948
+ name: import_zod11.z.string().min(1, "Server name cannot be empty"),
5949
+ created_at: import_zod11.z.string().optional(),
5950
+ updated_at: import_zod11.z.string().optional(),
5951
+ status: import_zod11.z.string().optional()
5391
5952
  })
5392
5953
  ).optional()
5393
5954
  });
5394
- var McpRetrieveResponseSchema = import_zod10.z.object({
5395
- id: import_zod10.z.string().min(1, "Server ID cannot be empty"),
5396
- name: import_zod10.z.string().min(1, "Server name cannot be empty"),
5397
- createdAt: import_zod10.z.string().optional(),
5398
- updatedAt: import_zod10.z.string().optional(),
5399
- status: import_zod10.z.string().optional(),
5400
- toolkits: import_zod10.z.array(import_zod10.z.string()).optional(),
5401
- tools: import_zod10.z.array(import_zod10.z.string()).optional(),
5402
- managedAuthViaComposio: import_zod10.z.boolean().optional(),
5403
- authConfigIds: import_zod10.z.array(import_zod10.z.string()).optional(),
5404
- mcpUrl: import_zod10.z.string(),
5405
- commands: import_zod10.z.object({
5406
- claude: import_zod10.z.string(),
5407
- cursor: import_zod10.z.string(),
5408
- windsurf: import_zod10.z.string()
5955
+ var McpRetrieveResponseSchema = import_zod11.z.object({
5956
+ id: import_zod11.z.string().min(1, "Server ID cannot be empty"),
5957
+ name: import_zod11.z.string().min(1, "Server name cannot be empty"),
5958
+ createdAt: import_zod11.z.string().optional(),
5959
+ updatedAt: import_zod11.z.string().optional(),
5960
+ status: import_zod11.z.string().optional(),
5961
+ toolkits: import_zod11.z.array(import_zod11.z.string()).optional(),
5962
+ tools: import_zod11.z.array(import_zod11.z.string()).optional(),
5963
+ managedAuthViaComposio: import_zod11.z.boolean().optional(),
5964
+ authConfigIds: import_zod11.z.array(import_zod11.z.string()).optional(),
5965
+ mcpUrl: import_zod11.z.string(),
5966
+ commands: import_zod11.z.object({
5967
+ claude: import_zod11.z.string(),
5968
+ cursor: import_zod11.z.string(),
5969
+ windsurf: import_zod11.z.string()
5409
5970
  })
5410
5971
  });
5411
- var ComposioMcpRetrieveResponseSchema = import_zod10.z.object({
5412
- id: import_zod10.z.string().min(1, "Server ID cannot be empty"),
5413
- name: import_zod10.z.string().min(1, "Server name cannot be empty"),
5414
- created_at: import_zod10.z.string().optional(),
5415
- updated_at: import_zod10.z.string().optional(),
5416
- status: import_zod10.z.string().optional(),
5417
- toolkits: import_zod10.z.array(import_zod10.z.string()).optional(),
5418
- tools: import_zod10.z.array(import_zod10.z.string()).optional(),
5419
- managed_auth_via_composio: import_zod10.z.boolean().optional()
5972
+ var ComposioMcpRetrieveResponseSchema = import_zod11.z.object({
5973
+ id: import_zod11.z.string().min(1, "Server ID cannot be empty"),
5974
+ name: import_zod11.z.string().min(1, "Server name cannot be empty"),
5975
+ created_at: import_zod11.z.string().optional(),
5976
+ updated_at: import_zod11.z.string().optional(),
5977
+ status: import_zod11.z.string().optional(),
5978
+ toolkits: import_zod11.z.array(import_zod11.z.string()).optional(),
5979
+ tools: import_zod11.z.array(import_zod11.z.string()).optional(),
5980
+ managed_auth_via_composio: import_zod11.z.boolean().optional()
5420
5981
  });
5421
- var McpDeleteResponseSchema = import_zod10.z.object({
5422
- id: import_zod10.z.string().min(1, "Server ID cannot be empty"),
5423
- deleted: import_zod10.z.boolean().optional(),
5424
- message: import_zod10.z.string().optional()
5982
+ var McpDeleteResponseSchema = import_zod11.z.object({
5983
+ id: import_zod11.z.string().min(1, "Server ID cannot be empty"),
5984
+ deleted: import_zod11.z.boolean().optional(),
5985
+ message: import_zod11.z.string().optional()
5425
5986
  });
5426
- var ComposioMcpDeleteResponseSchema = import_zod10.z.object({
5427
- id: import_zod10.z.string().min(1, "Server ID cannot be empty"),
5428
- deleted: import_zod10.z.boolean().optional(),
5429
- message: import_zod10.z.string().optional()
5987
+ var ComposioMcpDeleteResponseSchema = import_zod11.z.object({
5988
+ id: import_zod11.z.string().min(1, "Server ID cannot be empty"),
5989
+ deleted: import_zod11.z.boolean().optional(),
5990
+ message: import_zod11.z.string().optional()
5430
5991
  });
5431
- var McpUpdateResponseSchema = import_zod10.z.object({
5432
- id: import_zod10.z.string().min(1, "Server ID cannot be empty"),
5433
- name: import_zod10.z.string().min(1, "Server name cannot be empty"),
5434
- createdAt: import_zod10.z.string().optional(),
5435
- updatedAt: import_zod10.z.string().optional(),
5436
- status: import_zod10.z.string().optional(),
5437
- toolkits: import_zod10.z.array(import_zod10.z.string()).optional(),
5438
- tools: import_zod10.z.array(import_zod10.z.string()).optional()
5992
+ var McpUpdateResponseSchema = import_zod11.z.object({
5993
+ id: import_zod11.z.string().min(1, "Server ID cannot be empty"),
5994
+ name: import_zod11.z.string().min(1, "Server name cannot be empty"),
5995
+ createdAt: import_zod11.z.string().optional(),
5996
+ updatedAt: import_zod11.z.string().optional(),
5997
+ status: import_zod11.z.string().optional(),
5998
+ toolkits: import_zod11.z.array(import_zod11.z.string()).optional(),
5999
+ tools: import_zod11.z.array(import_zod11.z.string()).optional()
5439
6000
  });
5440
- var ComposioMcpUpdateResponseSchema = import_zod10.z.object({
5441
- id: import_zod10.z.string().min(1, "Server ID cannot be empty"),
5442
- name: import_zod10.z.string().min(1, "Server name cannot be empty"),
5443
- created_at: import_zod10.z.string().optional(),
5444
- updated_at: import_zod10.z.string().optional(),
5445
- status: import_zod10.z.string().optional(),
5446
- toolkits: import_zod10.z.array(import_zod10.z.string()).optional(),
5447
- tools: import_zod10.z.array(import_zod10.z.string()).optional()
6001
+ var ComposioMcpUpdateResponseSchema = import_zod11.z.object({
6002
+ id: import_zod11.z.string().min(1, "Server ID cannot be empty"),
6003
+ name: import_zod11.z.string().min(1, "Server name cannot be empty"),
6004
+ created_at: import_zod11.z.string().optional(),
6005
+ updated_at: import_zod11.z.string().optional(),
6006
+ status: import_zod11.z.string().optional(),
6007
+ toolkits: import_zod11.z.array(import_zod11.z.string()).optional(),
6008
+ tools: import_zod11.z.array(import_zod11.z.string()).optional()
5448
6009
  });
5449
6010
 
5450
6011
  // src/utils/transformers/mcp.ts
@@ -5547,10 +6108,10 @@ function transformMcpGenerateUrlResponse(response) {
5547
6108
  }
5548
6109
 
5549
6110
  // src/models/MCP.ts
5550
- var MCP = class {
6111
+ var MCP2 = class {
5551
6112
  client;
5552
- provider;
5553
6113
  toolkits;
6114
+ provider;
5554
6115
  constructor(client, provider) {
5555
6116
  this.client = client;
5556
6117
  this.provider = provider;
@@ -5587,7 +6148,7 @@ var MCP = class {
5587
6148
  * @param {Object} params.options - Server creation options
5588
6149
  * @param {string} params.options.name - Unique name for the MCP server
5589
6150
  * @param {boolean} [params.options.isChatAuth] - Whether to use chat-based authentication
5590
- * @returns {Promise<McpServerCreateResponse<T>>} Created server details with instance getter
6151
+ * @returns {Promise<McpServerCreateResponse<TMcpResponse>>} Created server details with instance getter
5591
6152
  *
5592
6153
  * @example
5593
6154
  * ```typescript
@@ -5850,7 +6411,7 @@ var MCP = class {
5850
6411
  * @param {Object} [options] - Additional options for server configuration
5851
6412
  * @param {string[]} [options.limitTools] - Subset of tools to limit (from MCP config)
5852
6413
  * @param {boolean} [options.isChatAuth] - Whether to use chat-based authentication
5853
- * @returns {Promise<T>} Transformed server URLs in provider-specific format
6414
+ * @returns {Promise<TMcpResponse>} Transformed server URLs in provider-specific format
5854
6415
  *
5855
6416
  * @example
5856
6417
  * ```typescript
@@ -5863,6 +6424,7 @@ var MCP = class {
5863
6424
  * isChatAuth: true
5864
6425
  * });
5865
6426
  * ```
6427
+ *
5866
6428
  */
5867
6429
  async getServer(serverId, userId, options) {
5868
6430
  const serverDetails = await this.get(serverId);
@@ -6116,6 +6678,7 @@ var MCP = class {
6116
6678
  * @param serverName - Name of the MCP server
6117
6679
 
6118
6680
  * @returns Transformed response in appropriate format
6681
+ * @deprecated
6119
6682
  */
6120
6683
  wrapMcpServerResponse(data, serverName, connectedAccountIds, userIds, toolkits) {
6121
6684
  if (this.provider && typeof this.provider.wrapMcpServerResponse === "function") {
@@ -6141,6 +6704,7 @@ var MCP = class {
6141
6704
  const transformed = this.provider.wrapMcpServerResponse(snakeCaseData);
6142
6705
  return transformed;
6143
6706
  }
6707
+ const self = this;
6144
6708
  if (connectedAccountIds?.length && data.connectedAccountUrls) {
6145
6709
  return data.connectedAccountUrls.map((url, index) => ({
6146
6710
  url: new URL(url),
@@ -6238,6 +6802,31 @@ function getSDKConfig(baseUrl, apiKey) {
6238
6802
  logger_default.debug("Environment", `Base URL: ${baseURLParsed}`);
6239
6803
  return { baseURL: baseURLParsed, apiKey: apiKeyParsed };
6240
6804
  }
6805
+ function getToolkitVersionsFromEnv(defaultVersions) {
6806
+ if (defaultVersions && typeof defaultVersions === "string") {
6807
+ return defaultVersions;
6808
+ }
6809
+ const envPrefixedVersions = getEnvsWithPrefix(`COMPOSIO_TOOLKIT_VERSION_`);
6810
+ const toolkitVersionsFromEnv = Object.entries(envPrefixedVersions).reduce((acc, [key, value]) => {
6811
+ const toolkitName = key.replace("COMPOSIO_TOOLKIT_VERSION_", "");
6812
+ acc[toolkitName.toLowerCase()] = value;
6813
+ return acc;
6814
+ }, {});
6815
+ let userProvidedToolkitVersions = {};
6816
+ if (defaultVersions && typeof defaultVersions === "object") {
6817
+ userProvidedToolkitVersions = Object.fromEntries(
6818
+ Object.entries(defaultVersions).map(([key, value]) => [key.toLowerCase(), value])
6819
+ );
6820
+ }
6821
+ const toolkitVersions = {
6822
+ ...toolkitVersionsFromEnv,
6823
+ ...userProvidedToolkitVersions
6824
+ };
6825
+ if (Object.keys(toolkitVersions).length === 0) {
6826
+ return "latest";
6827
+ }
6828
+ return toolkitVersions;
6829
+ }
6241
6830
 
6242
6831
  // src/utils/version.ts
6243
6832
  var import_semver = __toESM(require("semver"), 1);
@@ -6759,7 +7348,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
6759
7348
  };
6760
7349
 
6761
7350
  // package.json
6762
- var version = "0.1.51";
7351
+ var version = "0.1.53";
6763
7352
 
6764
7353
  // src/models/Files.ts
6765
7354
  var Files = class {
@@ -6817,6 +7406,82 @@ var getDefaultHeaders = (headers, provider) => {
6817
7406
  };
6818
7407
  };
6819
7408
 
7409
+ // src/types/toolRouter.types.ts
7410
+ var import_zod12 = __toESM(require("zod"), 1);
7411
+ var ToolRouterToolkitConfigSchema = import_zod12.default.object({
7412
+ toolkit: import_zod12.default.string(),
7413
+ authConfigId: import_zod12.default.string().optional()
7414
+ });
7415
+ var ToolRouterConfigSchema = import_zod12.default.object({
7416
+ toolkits: import_zod12.default.array(import_zod12.default.union([import_zod12.default.string(), ToolRouterToolkitConfigSchema])).optional(),
7417
+ manuallyManageConnections: import_zod12.default.boolean().optional()
7418
+ });
7419
+ var ToolRouterSessionSchema = import_zod12.default.object({
7420
+ sessionId: import_zod12.default.string(),
7421
+ url: import_zod12.default.string()
7422
+ });
7423
+
7424
+ // src/models/ToolRouter.experimental.ts
7425
+ var ToolRouter = class {
7426
+ constructor(client) {
7427
+ this.client = client;
7428
+ this.client = client;
7429
+ telemetry.instrument(this);
7430
+ }
7431
+ /**
7432
+ * Creates a new Session for the tool router
7433
+ *
7434
+ * @param userId {string} The user id to create the session for
7435
+ * @param routerConfig {ToolRouterConfig} The router config to use
7436
+ * @returns {Promise<ToolRouterSession>} The tool router session
7437
+ *
7438
+ * @example
7439
+ * ```typescript
7440
+ * import { Composio } form "@composio/core"
7441
+ *
7442
+ * const composio = new Composio()
7443
+ * const userId = "xxx-ooo-xxxx"
7444
+ *
7445
+ * const mcpSession = await composio.experimental.toolRouter.createSession(userId, {
7446
+ * toolkits: ["github", "hackernews", "slack"]
7447
+ * })
7448
+ *
7449
+ * // with auth configs
7450
+ * const mcpSession = await composio.experimental.toolRouter.createSession(userId, {
7451
+ * toolkits: [{ toolkit: "github", authConfingId: "ac_123455344"}]
7452
+ * ```
7453
+ */
7454
+ async createSession(userId, routerConfig) {
7455
+ const config = ToolRouterConfigSchema.safeParse(routerConfig ?? {});
7456
+ if (config.error) {
7457
+ throw new ValidationError("Failed to parse tool router config", {
7458
+ cause: config.error
7459
+ });
7460
+ }
7461
+ const toolkitConfig = config.data.toolkits?.map((config2) => {
7462
+ if (typeof config2 === "string") {
7463
+ return { toolkit: config2 };
7464
+ } else {
7465
+ return {
7466
+ toolkit: config2.toolkit,
7467
+ auth_config_id: config2.authConfigId
7468
+ };
7469
+ }
7470
+ });
7471
+ const session = await this.client.toolRouter.createSession({
7472
+ user_id: userId,
7473
+ config: {
7474
+ toolkits: toolkitConfig,
7475
+ manually_manage_connections: config.data.manuallyManageConnections
7476
+ }
7477
+ });
7478
+ return transform(session).with(ToolRouterSessionSchema).using((raw) => ({
7479
+ sessionId: raw.session_id,
7480
+ url: raw.chat_session_mcp_url
7481
+ }));
7482
+ }
7483
+ };
7484
+
6820
7485
  // src/composio.ts
6821
7486
  var Composio = class _Composio {
6822
7487
  /**
@@ -6837,11 +7502,17 @@ var Composio = class _Composio {
6837
7502
  triggers;
6838
7503
  provider;
6839
7504
  files;
6840
- // auth configs
6841
7505
  authConfigs;
6842
- // connected accounts
6843
7506
  connectedAccounts;
6844
7507
  mcp;
7508
+ /**
7509
+ * Experimental features
7510
+ */
7511
+ experimental;
7512
+ /**
7513
+ * Deprecated features
7514
+ */
7515
+ deprecated;
6845
7516
  /**
6846
7517
  * Creates a new instance of the Composio SDK.
6847
7518
  *
@@ -6882,7 +7553,11 @@ var Composio = class _Composio {
6882
7553
  }
6883
7554
  this.config = {
6884
7555
  ...config,
6885
- allowTracking: config?.allowTracking ?? true
7556
+ baseURL: baseURLParsed,
7557
+ apiKey: apiKeyParsed,
7558
+ toolkitVersions: getToolkitVersionsFromEnv(config?.toolkitVersions),
7559
+ allowTracking: config?.allowTracking ?? true,
7560
+ autoUploadDownloadFiles: config?.autoUploadDownloadFiles ?? true
6886
7561
  };
6887
7562
  this.provider = config?.provider ?? new OpenAIProvider();
6888
7563
  const defaultHeaders = getDefaultHeaders(this.config.defaultHeaders, this.provider);
@@ -6892,15 +7567,28 @@ var Composio = class _Composio {
6892
7567
  defaultHeaders,
6893
7568
  logLevel: COMPOSIO_LOG_LEVEL
6894
7569
  });
6895
- this.tools = new Tools(this.client, this.provider, {
6896
- autoUploadDownloadFiles: config?.autoUploadDownloadFiles ?? true
6897
- });
6898
- this.mcp = new MCP(this.client, this.provider);
7570
+ this.tools = new Tools(this.client, this.provider, this.config);
7571
+ this.mcp = new MCP(this.client);
6899
7572
  this.toolkits = new Toolkits(this.client);
6900
7573
  this.triggers = new Triggers(this.client);
6901
7574
  this.authConfigs = new AuthConfigs(this.client);
6902
7575
  this.files = new Files(this.client);
6903
7576
  this.connectedAccounts = new ConnectedAccounts(this.client);
7577
+ this.experimental = {
7578
+ /**
7579
+ * Experimental tool router
7580
+ * Helps you create a single MCP server containing all the tools with smart routing.
7581
+ *
7582
+ * @description Allows you to create an isolated toolRouter MCP session for a user
7583
+ */
7584
+ toolRouter: new ToolRouter(this.client)
7585
+ };
7586
+ this.deprecated = {
7587
+ /**
7588
+ * @deprecated this feature will be removed soon, use `composio.mcp`
7589
+ */
7590
+ mcp: new MCP2(this.client, this.provider)
7591
+ };
6904
7592
  if (this.config.allowTracking) {
6905
7593
  telemetry.setup({
6906
7594
  apiKey: apiKeyParsed ?? "",
@@ -6928,6 +7616,13 @@ var Composio = class _Composio {
6928
7616
  }
6929
7617
  return this.client;
6930
7618
  }
7619
+ /**
7620
+ * Get the configuration SDK is initialized with
7621
+ * @returns {ComposioConfig<TProvider>} The configuration SDK is initialized with
7622
+ */
7623
+ getConfig() {
7624
+ return this.config;
7625
+ }
6931
7626
  /**
6932
7627
  * Creates a new instance of the Composio SDK with custom request options while preserving the existing configuration.
6933
7628
  * This method is particularly useful when you need to: