@composio/core 0.1.24 → 0.1.26

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.js CHANGED
@@ -1,9 +1,14 @@
1
+ var __defProp = Object.defineProperty;
1
2
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
3
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
4
  }) : x)(function(x) {
4
5
  if (typeof require !== "undefined") return require.apply(this, arguments);
5
6
  throw Error('Dynamic require of "' + x + '" is not supported');
6
7
  });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
7
12
 
8
13
  // src/composio.ts
9
14
  import ComposioClient4 from "@composio/client";
@@ -721,7 +726,8 @@ var TelemetryTransport = class {
721
726
  service: this.telemetryServiceName,
722
727
  language: this.telemetryLanguage,
723
728
  version: this.telemetryMetadata?.version,
724
- platform: this.telemetryMetadata?.isBrowser ? "browser" : "node"
729
+ platform: this.telemetryMetadata?.isBrowser ? "browser" : "node",
730
+ environment: getEnvVariable("NODE_ENV", "production")
725
731
  };
726
732
  this.sendMetric([
727
733
  {
@@ -2036,7 +2042,7 @@ var Tools = class {
2036
2042
  * @returns {Promise<string | null>} The connected account id or null if the toolkit is a no auth app
2037
2043
  */
2038
2044
  async getConnectedAccountIdForTool(userId, toolSlug) {
2039
- const tool = await this.getRawComposioToolBySlug(userId, toolSlug);
2045
+ const tool = await this.getRawComposioToolBySlug(toolSlug);
2040
2046
  if (!tool.toolkit) {
2041
2047
  throw new Error(`Unable to find toolkit for tool ${toolSlug}`);
2042
2048
  }
@@ -2068,7 +2074,6 @@ var Tools = class {
2068
2074
  * This method fetches tools from the Composio API in raw format and combines them with
2069
2075
  * any registered custom tools. The response can be filtered and modified as needed.
2070
2076
  *
2071
- * @param {string} userId - The user ID for whom to fetch the tools
2072
2077
  * @param {ToolListParams} [query={}] - Optional query parameters to filter the tools
2073
2078
  * @param {TransformToolSchemaModifier} [modifier] - Optional function to transform tool schemas
2074
2079
  * @returns {Promise<ToolList>} List of tools matching the query criteria
@@ -2076,16 +2081,16 @@ var Tools = class {
2076
2081
  * @example
2077
2082
  * ```typescript
2078
2083
  * // Get all tools
2079
- * const tools = await composio.tools.getRawComposioTools('default');
2084
+ * const tools = await composio.tools.getRawComposioTools();
2080
2085
  *
2081
2086
  * // Get tools with filters
2082
- * const githubTools = await composio.tools.getRawComposioTools('default', {
2087
+ * const githubTools = await composio.tools.getRawComposioTools({
2083
2088
  * toolkits: ['github'],
2084
2089
  * important: true
2085
2090
  * });
2086
2091
  *
2087
2092
  * // Get tools with schema transformation
2088
- * const tools = await composio.tools.getRawComposioTools('default', {},
2093
+ * const tools = await composio.tools.getRawComposioTools({},
2089
2094
  * (toolSlug, toolkitSlug, tool) => {
2090
2095
  * // Add custom properties to tool schema
2091
2096
  * return {...tool, customProperty: 'value'};
@@ -2093,7 +2098,7 @@ var Tools = class {
2093
2098
  * );
2094
2099
  * ```
2095
2100
  */
2096
- async getRawComposioTools(userId, query, modifier) {
2101
+ async getRawComposioTools(query, modifier) {
2097
2102
  if ("tools" in query && "toolkits" in query) {
2098
2103
  throw new ValidationError(
2099
2104
  "Invalid tool list parameters. You should not use tools and toolkits filter together."
@@ -2150,10 +2155,10 @@ var Tools = class {
2150
2155
  *
2151
2156
  * @example
2152
2157
  * ```ts
2153
- * const tool = await composio.tools.getRawComposioToolBySlug('default', 'github');
2158
+ * const tool = await composio.tools.getRawComposioToolBySlug('github');
2154
2159
  * ```
2155
2160
  */
2156
- async getRawComposioToolBySlug(userId, slug, modifier) {
2161
+ async getRawComposioToolBySlug(slug, modifier) {
2157
2162
  const customTool = await this.customTools.getCustomToolBySlug(slug);
2158
2163
  if (customTool) {
2159
2164
  logger_default.debug(`Found ${slug} to be a custom tool`, JSON.stringify(customTool, null, 2));
@@ -2191,10 +2196,10 @@ var Tools = class {
2191
2196
  async get(userId, arg2, options) {
2192
2197
  const executeToolFn = this.createExecuteToolFn(userId, options);
2193
2198
  if (typeof arg2 === "string") {
2194
- const tool = await this.getRawComposioToolBySlug(userId, arg2, options?.modifySchema);
2199
+ const tool = await this.getRawComposioToolBySlug(arg2, options?.modifySchema);
2195
2200
  return this.provider.wrapTools([tool], executeToolFn);
2196
2201
  } else {
2197
- const tools = await this.getRawComposioTools(userId, arg2, options?.modifySchema);
2202
+ const tools = await this.getRawComposioTools(arg2, options?.modifySchema);
2198
2203
  return this.provider.wrapTools(tools, executeToolFn);
2199
2204
  }
2200
2205
  }
@@ -2336,7 +2341,7 @@ var Tools = class {
2336
2341
  if (customTool) {
2337
2342
  return this.handleCustomToolExecution(customTool, body, modifiers);
2338
2343
  } else {
2339
- const composioTool = await this.getRawComposioToolBySlug(body.userId, slug);
2344
+ const composioTool = await this.getRawComposioToolBySlug(slug);
2340
2345
  if (!composioTool) {
2341
2346
  throw new ComposioToolNotFoundError(`Tool with slug ${slug} not found`);
2342
2347
  }
@@ -2568,14 +2573,11 @@ var ToolkitRetrieveCategoriesResponseSchema = z5.object({
2568
2573
  nextCursor: z5.string().nullable(),
2569
2574
  totalPages: z5.number()
2570
2575
  });
2571
- var ToolkitAuthFieldsResponseSchema = z5.object({
2572
- authScheme: AuthSchemeEnum,
2573
- fields: z5.array(
2574
- ToolkitAuthFieldSchema.extend({
2575
- required: z5.boolean().optional()
2576
- })
2577
- )
2578
- });
2576
+ var ToolkitAuthFieldsResponseSchema = z5.array(
2577
+ ToolkitAuthFieldSchema.extend({
2578
+ required: z5.boolean().optional()
2579
+ })
2580
+ );
2579
2581
 
2580
2582
  // src/models/AuthConfigs.ts
2581
2583
  var AuthConfigs = class {
@@ -3467,43 +3469,37 @@ var Toolkits = class {
3467
3469
  }
3468
3470
  const authConfig = authScheme ? toolkit.authConfigDetails.find((authConfig2) => authConfig2.mode === authScheme) : toolkit.authConfigDetails[0];
3469
3471
  if (!authConfig) {
3470
- throw new ComposioAuthConfigNotFoundError("No auth config found for toolkit", {
3471
- meta: {
3472
- toolkitSlug,
3473
- authScheme
3472
+ throw new ComposioAuthConfigNotFoundError(
3473
+ `Auth schema ${authScheme} not found for toolkit ${toolkitSlug} with auth scheme ${authScheme}`,
3474
+ {
3475
+ meta: {
3476
+ toolkitSlug,
3477
+ authScheme
3478
+ }
3474
3479
  }
3475
- });
3480
+ );
3476
3481
  }
3477
3482
  const requiredFields = authConfig.fields[authConfigType].required.map((field) => ({
3478
3483
  ...field,
3479
3484
  required: true
3480
3485
  }));
3481
3486
  if (requiredOnly) {
3482
- return {
3483
- authScheme: AuthSchemeEnum.parse(authConfig.mode),
3484
- fields: requiredFields
3485
- };
3487
+ return requiredFields;
3486
3488
  }
3487
3489
  const optionalFields = authConfig.fields[authConfigType].optional.map((field) => ({
3488
3490
  ...field,
3489
3491
  required: false
3490
3492
  }));
3491
- return {
3492
- authScheme: AuthSchemeEnum.parse(authConfig.mode),
3493
- fields: [...requiredFields, ...optionalFields]
3494
- };
3493
+ return [...requiredFields, ...optionalFields];
3495
3494
  }
3496
3495
  /**
3497
3496
  * Retrieves the fields required for creating an auth config for a toolkit.
3498
3497
  * @param toolkitSlug - The slug of the toolkit to retrieve the fields for
3499
3498
  * @param authScheme - The auth scheme to retrieve the fields for
3500
- * @param requiredOnly - Whether to only return the required fields
3499
+ * @param options.requiredOnly - Whether to only return the required fields
3501
3500
  * @returns {Promise<ToolkitAuthFieldsResponse>} The fields required for creating an auth config
3502
3501
  */
3503
- async getAuthConfigCreationFields(toolkitSlug, {
3504
- authScheme,
3505
- requiredOnly = false
3506
- } = {}) {
3502
+ async getAuthConfigCreationFields(toolkitSlug, authScheme, { requiredOnly = false } = {}) {
3507
3503
  return this.getAuthConfigFields(
3508
3504
  toolkitSlug,
3509
3505
  authScheme ?? null,
@@ -3515,13 +3511,10 @@ var Toolkits = class {
3515
3511
  * Retrieves the fields required for initiating a connected account for a toolkit.
3516
3512
  * @param toolkitSlug - The slug of the toolkit to retrieve the fields for
3517
3513
  * @param authScheme - The auth scheme to retrieve the fields for
3518
- * @param requiredOnly - Whether to only return the required fields
3514
+ * @param options.requiredOnly - Whether to only return the required fields
3519
3515
  * @returns {Promise<ToolkitAuthFieldsResponse>} The fields required for initiating a connected account
3520
3516
  */
3521
- async getConnectedAccountInitiationFields(toolkitSlug, {
3522
- authScheme,
3523
- requiredOnly = false
3524
- } = {}) {
3517
+ async getConnectedAccountInitiationFields(toolkitSlug, authScheme, { requiredOnly = false } = {}) {
3525
3518
  return this.getAuthConfigFields(
3526
3519
  toolkitSlug,
3527
3520
  authScheme ?? null,
@@ -4357,10 +4350,686 @@ var Triggers = class {
4357
4350
  }
4358
4351
  };
4359
4352
 
4353
+ // src/types/mcp.types.ts
4354
+ import { z as z8 } from "zod";
4355
+ var MCPToolkitConfigSchema = z8.object({
4356
+ toolkit: z8.string().min(1, "Toolkit name cannot be empty"),
4357
+ authConfigId: z8.string().min(1, "Auth config ID cannot be empty"),
4358
+ allowedTools: z8.array(z8.string().min(1, "Tool name cannot be empty")).min(1, "At least one tool must be specified")
4359
+ });
4360
+ var MCPToolkitConfigsArraySchema = z8.array(MCPToolkitConfigSchema).min(1, "At least one toolkit configuration is required").refine((configs) => {
4361
+ const toolkits = configs.map((config) => config.toolkit);
4362
+ const uniqueToolkits = new Set(toolkits);
4363
+ return uniqueToolkits.size === toolkits.length;
4364
+ }, "Duplicate toolkits are not allowed. Each toolkit must be unique.");
4365
+ var MCPAuthOptionsSchema = z8.object({
4366
+ useComposioManagedAuth: z8.boolean().optional()
4367
+ });
4368
+ var MCPGetServerParamsSchema = z8.object({
4369
+ userId: z8.string().min(1, "User ID cannot be empty").optional(),
4370
+ connectedAccountIds: z8.record(z8.string(), z8.string().min(1, "Account ID cannot be empty")).optional()
4371
+ }).refine(
4372
+ (data) => {
4373
+ const hasUserId = !!data.userId;
4374
+ const hasConnectedAccountIds = !!data.connectedAccountIds && Object.keys(data.connectedAccountIds).length > 0;
4375
+ return hasUserId !== hasConnectedAccountIds;
4376
+ },
4377
+ {
4378
+ message: "Must provide either userId or connectedAccountIds, but not both"
4379
+ }
4380
+ );
4381
+ var MCPGenerateURLParamsSchema = z8.object({
4382
+ userIds: z8.array(z8.string()).optional(),
4383
+ connectedAccountIds: z8.array(z8.string()).optional(),
4384
+ useComposioManagedAuth: z8.boolean().optional()
4385
+ });
4386
+ var GenerateURLParamsSnakeCaseSchema = z8.object({
4387
+ user_ids: z8.array(z8.string()).optional(),
4388
+ connected_account_ids: z8.array(z8.string()).optional(),
4389
+ mcp_server_id: z8.string(),
4390
+ managed_auth_by_composio: z8.boolean().optional()
4391
+ });
4392
+ var GenerateURLParamsSchema = z8.object({
4393
+ userIds: z8.array(z8.string()).optional(),
4394
+ connectedAccountIds: z8.array(z8.string()).optional(),
4395
+ mcpServerId: z8.string(),
4396
+ managedAuthByComposio: z8.boolean().optional()
4397
+ });
4398
+ var GenerateURLResponseCamelCaseSchema = z8.object({
4399
+ connectedAccountUrls: z8.array(z8.string()).optional(),
4400
+ userIdsUrl: z8.array(z8.string()).optional(),
4401
+ mcpUrl: z8.string().min(1, "MCP URL cannot be empty")
4402
+ });
4403
+ var GenerateURLResponseSchema = z8.object({
4404
+ connected_account_urls: z8.array(z8.string()).optional(),
4405
+ user_ids_url: z8.array(z8.string()).optional(),
4406
+ mcp_url: z8.string().min(1, "MCP URL cannot be empty")
4407
+ });
4408
+ var MCPSingleAppServerSchema = z8.object({
4409
+ name: z8.string().describe("Name of the MCP server"),
4410
+ tools: z8.array(z8.string()).describe("List of allowed tools"),
4411
+ authConfigId: z8.string().optional().describe("Auth config ID for the server")
4412
+ });
4413
+ var MCPMultiAppServerSchema = z8.object({
4414
+ name: z8.string().describe("Name of the MCP server"),
4415
+ tools: z8.array(z8.string()).describe("List of allowed tools across toolkits"),
4416
+ toolkits: z8.array(z8.string()).describe("List of allowed toolkits")
4417
+ });
4418
+ var MCPServerSchema = z8.object({
4419
+ id: z8.string().describe("Unique identifier for the MCP server"),
4420
+ type: z8.enum(["single", "multi"]).describe("Type of MCP server"),
4421
+ createdAt: z8.string().describe("Creation timestamp"),
4422
+ updatedAt: z8.string().describe("Last update timestamp"),
4423
+ status: z8.enum(["active", "inactive", "error"]).default("active"),
4424
+ config: z8.union([MCPSingleAppServerSchema, MCPMultiAppServerSchema])
4425
+ });
4426
+ var MCPServerListResponseSchema = z8.object({
4427
+ items: z8.array(MCPServerSchema),
4428
+ total: z8.number(),
4429
+ page: z8.number(),
4430
+ pageSize: z8.number()
4431
+ });
4432
+ var MCPServerUpdateParamsSchema = z8.object({
4433
+ name: z8.string().optional().describe("New name for the server"),
4434
+ toolkits: z8.array(z8.string()).optional().describe("Updated list of toolkits"),
4435
+ allowedTools: z8.array(z8.string()).optional().describe("Updated list of allowed tools")
4436
+ });
4437
+ var MCPServerCreateResponseSchema = MCPServerSchema;
4438
+ var CustomCreateResponseCamelCaseSchema = z8.object({
4439
+ id: z8.string().min(1, "Server ID cannot be empty"),
4440
+ name: z8.string().min(1, "Server name cannot be empty"),
4441
+ createdAt: z8.string().nullish(),
4442
+ updatedAt: z8.string().nullish(),
4443
+ status: z8.string().nullish()
4444
+ });
4445
+ var CustomCreateResponseSchema = z8.object({
4446
+ id: z8.string().min(1, "Server ID cannot be empty"),
4447
+ name: z8.string().min(1, "Server name cannot be empty"),
4448
+ created_at: z8.string().nullish(),
4449
+ updated_at: z8.string().nullish(),
4450
+ status: z8.string().nullish()
4451
+ });
4452
+ var McpListResponseCamelCaseSchema = z8.object({
4453
+ items: z8.array(
4454
+ z8.object({
4455
+ id: z8.string().min(1, "Server ID cannot be empty"),
4456
+ name: z8.string().min(1, "Server name cannot be empty"),
4457
+ createdAt: z8.string().optional(),
4458
+ updatedAt: z8.string().optional(),
4459
+ status: z8.string().optional()
4460
+ })
4461
+ ).optional()
4462
+ });
4463
+ var McpListResponseSchema = z8.object({
4464
+ items: z8.array(
4465
+ z8.object({
4466
+ id: z8.string().min(1, "Server ID cannot be empty"),
4467
+ name: z8.string().min(1, "Server name cannot be empty"),
4468
+ created_at: z8.string().optional(),
4469
+ updated_at: z8.string().optional(),
4470
+ status: z8.string().optional()
4471
+ })
4472
+ ).optional()
4473
+ });
4474
+ var McpRetrieveResponseCamelCaseSchema = z8.object({
4475
+ id: z8.string().min(1, "Server ID cannot be empty"),
4476
+ name: z8.string().min(1, "Server name cannot be empty"),
4477
+ createdAt: z8.string().optional(),
4478
+ updatedAt: z8.string().optional(),
4479
+ status: z8.string().optional(),
4480
+ toolkits: z8.array(z8.string()).optional(),
4481
+ tools: z8.array(z8.string()).optional(),
4482
+ managedAuthViaComposio: z8.boolean().optional()
4483
+ });
4484
+ var McpRetrieveResponseSchema = z8.object({
4485
+ id: z8.string().min(1, "Server ID cannot be empty"),
4486
+ name: z8.string().min(1, "Server name cannot be empty"),
4487
+ created_at: z8.string().optional(),
4488
+ updated_at: z8.string().optional(),
4489
+ status: z8.string().optional(),
4490
+ toolkits: z8.array(z8.string()).optional(),
4491
+ tools: z8.array(z8.string()).optional(),
4492
+ managed_auth_via_composio: z8.boolean().optional()
4493
+ });
4494
+ var McpDeleteResponseCamelCaseSchema = z8.object({
4495
+ id: z8.string().min(1, "Server ID cannot be empty"),
4496
+ deleted: z8.boolean().optional(),
4497
+ message: z8.string().optional()
4498
+ });
4499
+ var McpDeleteResponseSchema = z8.object({
4500
+ id: z8.string().min(1, "Server ID cannot be empty"),
4501
+ deleted: z8.boolean().optional(),
4502
+ message: z8.string().optional()
4503
+ });
4504
+ var McpUpdateResponseCamelCaseSchema = z8.object({
4505
+ id: z8.string().min(1, "Server ID cannot be empty"),
4506
+ name: z8.string().min(1, "Server name cannot be empty"),
4507
+ createdAt: z8.string().optional(),
4508
+ updatedAt: z8.string().optional(),
4509
+ status: z8.string().optional(),
4510
+ toolkits: z8.array(z8.string()).optional(),
4511
+ tools: z8.array(z8.string()).optional()
4512
+ });
4513
+ var McpUpdateResponseSchema = z8.object({
4514
+ id: z8.string().min(1, "Server ID cannot be empty"),
4515
+ name: z8.string().min(1, "Server name cannot be empty"),
4516
+ created_at: z8.string().optional(),
4517
+ updated_at: z8.string().optional(),
4518
+ status: z8.string().optional(),
4519
+ toolkits: z8.array(z8.string()).optional(),
4520
+ tools: z8.array(z8.string()).optional()
4521
+ });
4522
+
4523
+ // src/utils/transformers/mcp.ts
4524
+ function transformMcpCreateResponse(response) {
4525
+ const result = CustomCreateResponseCamelCaseSchema.safeParse({
4526
+ id: response.id,
4527
+ name: response.name,
4528
+ createdAt: response.created_at,
4529
+ updatedAt: response.updated_at,
4530
+ status: response.status
4531
+ });
4532
+ if (!result.success) {
4533
+ throw new ValidationError("Failed to parse MCP create response", {
4534
+ cause: result.error
4535
+ });
4536
+ }
4537
+ return result.data;
4538
+ }
4539
+ function transformMcpListResponse(response) {
4540
+ const transformedItems = response.items?.map((item) => ({
4541
+ id: item.id,
4542
+ name: item.name,
4543
+ createdAt: item.created_at,
4544
+ updatedAt: item.updated_at,
4545
+ status: item.status
4546
+ }));
4547
+ const result = McpListResponseCamelCaseSchema.safeParse({
4548
+ items: transformedItems
4549
+ });
4550
+ if (!result.success) {
4551
+ throw new ValidationError("Failed to parse MCP list response", {
4552
+ cause: result.error
4553
+ });
4554
+ }
4555
+ return result.data;
4556
+ }
4557
+ function transformMcpRetrieveResponse(response) {
4558
+ const result = McpRetrieveResponseCamelCaseSchema.safeParse({
4559
+ id: response.id,
4560
+ name: response.name,
4561
+ createdAt: response.created_at,
4562
+ updatedAt: response.updated_at,
4563
+ status: response.status,
4564
+ toolkits: response.toolkits,
4565
+ tools: response.tools,
4566
+ managedAuthViaComposio: response.managed_auth_via_composio
4567
+ });
4568
+ if (!result.success) {
4569
+ throw new ValidationError("Failed to parse MCP retrieve response", {
4570
+ cause: result.error
4571
+ });
4572
+ }
4573
+ return result.data;
4574
+ }
4575
+ function transformMcpDeleteResponse(response) {
4576
+ const result = McpDeleteResponseCamelCaseSchema.safeParse({
4577
+ id: response.id,
4578
+ deleted: response.deleted,
4579
+ message: response.message
4580
+ });
4581
+ if (!result.success) {
4582
+ throw new ValidationError("Failed to parse MCP delete response", {
4583
+ cause: result.error
4584
+ });
4585
+ }
4586
+ return result.data;
4587
+ }
4588
+ function transformMcpUpdateResponse(response) {
4589
+ const result = McpUpdateResponseCamelCaseSchema.safeParse({
4590
+ id: response.id,
4591
+ name: response.name,
4592
+ createdAt: response.created_at,
4593
+ updatedAt: response.updated_at,
4594
+ status: response.status,
4595
+ toolkits: response.toolkits,
4596
+ tools: response.tools
4597
+ });
4598
+ if (!result.success) {
4599
+ throw new ValidationError("Failed to parse MCP update response", {
4600
+ cause: result.error
4601
+ });
4602
+ }
4603
+ return result.data;
4604
+ }
4605
+ function transformMcpGenerateUrlResponse(response) {
4606
+ const result = GenerateURLResponseCamelCaseSchema.safeParse({
4607
+ connectedAccountUrls: response.connected_account_urls,
4608
+ userIdsUrl: response.user_ids_url,
4609
+ mcpUrl: response.mcp_url
4610
+ });
4611
+ if (!result.success) {
4612
+ throw new ValidationError("Failed to parse MCP generate URL response", {
4613
+ cause: result.error
4614
+ });
4615
+ }
4616
+ return result.data;
4617
+ }
4618
+
4619
+ // src/models/MCP.ts
4620
+ var MCP = class {
4621
+ client;
4622
+ provider;
4623
+ constructor(client, provider) {
4624
+ this.client = client;
4625
+ this.provider = provider;
4626
+ telemetry.instrument(this);
4627
+ }
4628
+ /**
4629
+ * Validates toolkit configurations using Zod schema
4630
+ * @private
4631
+ * @param {MCPToolkitConfig[]} toolkitConfigs - Array of toolkit configurations to validate
4632
+ * @param {MCPAuthOptions} [authOptions] - Authentication options to validate
4633
+ * @throws {ValidationError} If validation fails
4634
+ */
4635
+ validateInputs(toolkitConfigs, authOptions) {
4636
+ const toolkitConfigsResult = MCPToolkitConfigsArraySchema.safeParse(toolkitConfigs);
4637
+ if (toolkitConfigsResult.error) {
4638
+ throw new ValidationError("Failed to parse toolkit configurations", {
4639
+ cause: toolkitConfigsResult.error
4640
+ });
4641
+ }
4642
+ if (authOptions !== void 0) {
4643
+ const authOptionsResult = MCPAuthOptionsSchema.safeParse(authOptions);
4644
+ if (authOptionsResult.error) {
4645
+ throw new ValidationError("Failed to parse auth options", {
4646
+ cause: authOptionsResult.error
4647
+ });
4648
+ }
4649
+ }
4650
+ }
4651
+ /**
4652
+ * Create a new MCP server
4653
+ * @param {string} name - Unique name for the MCP server
4654
+ * @param {MCPToolkitConfig[]} toolkitConfigs - Array of toolkit configurations
4655
+ * @param {MCPAuthOptions} [authOptions] - Authentication configuration options
4656
+ * @returns {Promise<McpServerCreateResponse<T>>} Created server details with instance getter
4657
+ *
4658
+ * @example
4659
+ * ```typescript
4660
+ * const server = await composio.mcp.create(
4661
+ * "personal-mcp-server",
4662
+ * [
4663
+ * {
4664
+ * toolkit: "GMAIL",
4665
+ * authConfigId: "ac_sdhkjfhjksdk",
4666
+ * allowedTools: ["GMAIL_FETCH_EMAILS"],
4667
+ * },
4668
+ * ],
4669
+ * { useComposioManagedAuth: true },
4670
+ * );
4671
+ *
4672
+ * // Option 1: Use convenience method on response
4673
+ * const urls = await server.getServer({
4674
+ * connectedAccountIds: { gmail: "account_id" }
4675
+ * });
4676
+ *
4677
+ * // Option 2: Use standalone method later
4678
+ * const urlsLater = await composio.mcp.getServer(server.id, {
4679
+ * connectedAccountIds: { gmail: "account_id" }
4680
+ * });
4681
+ * ```
4682
+ */
4683
+ async create(name, toolkitConfigs, authOptions) {
4684
+ this.validateInputs(toolkitConfigs, authOptions);
4685
+ const toolkits = toolkitConfigs.map((config) => config.toolkit);
4686
+ let mcpServerCreatedResponse;
4687
+ try {
4688
+ mcpServerCreatedResponse = await this.client.mcp.custom.create({
4689
+ name,
4690
+ toolkits,
4691
+ custom_tools: toolkitConfigs.flatMap((config) => config.allowedTools),
4692
+ managed_auth_via_composio: authOptions?.useComposioManagedAuth || false,
4693
+ auth_config_ids: toolkitConfigs.map((config) => config.authConfigId)
4694
+ });
4695
+ } catch (error) {
4696
+ throw new ValidationError("Failed to create MCP server", {
4697
+ cause: error
4698
+ });
4699
+ }
4700
+ const serverResponseResult = CustomCreateResponseSchema.safeParse(mcpServerCreatedResponse);
4701
+ if (serverResponseResult.error) {
4702
+ throw new ValidationError("Failed to parse MCP server creation response", {
4703
+ cause: serverResponseResult.error
4704
+ });
4705
+ }
4706
+ const camelCaseResponse = transformMcpCreateResponse(mcpServerCreatedResponse);
4707
+ return {
4708
+ ...camelCaseResponse,
4709
+ toolkits,
4710
+ getServer: async (params) => {
4711
+ return this.getServer(camelCaseResponse.id, params, authOptions);
4712
+ }
4713
+ };
4714
+ }
4715
+ /**
4716
+ * Get server URLs for an existing MCP server
4717
+ * @param {string} id - Server UUID
4718
+ * @param {MCPGetServerParams} params - Parameters for getting server URLs
4719
+ * @param {MCPAuthOptions} [authOptions] - Authentication options (optional, will use server's default if not provided)
4720
+ * @returns {Promise<T>} Transformed server URLs in provider-specific format
4721
+ *
4722
+ * @example
4723
+ * ```typescript
4724
+ * // Get URLs for an existing server
4725
+ * const urls = await composio.mcp.getServer("server-id", {
4726
+ * connectedAccountIds: {
4727
+ * gmail: "connected_account_id"
4728
+ * }
4729
+ * });
4730
+ * ```
4731
+ */
4732
+ async getServer(id, params, authOptions) {
4733
+ const serverDetails = await this.get(id);
4734
+ const paramsResult = MCPGetServerParamsSchema.safeParse(params);
4735
+ if (paramsResult.error) {
4736
+ throw new ValidationError("Failed to parse get server parameters", {
4737
+ cause: paramsResult.error
4738
+ });
4739
+ }
4740
+ const toolkits = serverDetails.toolkits || [];
4741
+ if (paramsResult.data.connectedAccountIds) {
4742
+ const providedToolkits = Object.keys(paramsResult.data.connectedAccountIds);
4743
+ const invalidToolkits = providedToolkits.filter((toolkit) => !toolkits.includes(toolkit));
4744
+ if (invalidToolkits.length > 0) {
4745
+ throw new ValidationError(
4746
+ `Invalid toolkits provided: ${invalidToolkits.join(", ")}. Available toolkits are: ${toolkits.join(", ")}`,
4747
+ {}
4748
+ );
4749
+ }
4750
+ }
4751
+ let data;
4752
+ try {
4753
+ data = await this.client.mcp.generate.url({
4754
+ user_ids: paramsResult.data.userId ? [paramsResult.data.userId] : [],
4755
+ connected_account_ids: paramsResult.data.connectedAccountIds ? Object.values(paramsResult.data.connectedAccountIds) : [],
4756
+ mcp_server_id: id,
4757
+ managed_auth_by_composio: authOptions?.useComposioManagedAuth ?? serverDetails.managedAuthViaComposio ?? false
4758
+ });
4759
+ } catch (error) {
4760
+ throw new ValidationError("Failed to generate MCP server URL", {
4761
+ cause: error
4762
+ });
4763
+ }
4764
+ const urlResponseResult = GenerateURLResponseSchema.safeParse(data);
4765
+ if (urlResponseResult.error) {
4766
+ throw new ValidationError("Failed to parse MCP URL generation response", {
4767
+ cause: urlResponseResult.error
4768
+ });
4769
+ }
4770
+ const camelCaseData = transformMcpGenerateUrlResponse(data);
4771
+ return this.wrapMcpServerResponse(
4772
+ camelCaseData,
4773
+ serverDetails.name,
4774
+ paramsResult.data.connectedAccountIds ? Object.values(paramsResult.data.connectedAccountIds) : void 0,
4775
+ paramsResult.data.userId ? [paramsResult.data.userId] : void 0,
4776
+ paramsResult.data.connectedAccountIds ? Object.keys(paramsResult.data.connectedAccountIds) : void 0
4777
+ );
4778
+ }
4779
+ /**
4780
+ * List MCP server configurations with filtering options
4781
+ * @param {Object} options - Filtering and pagination options
4782
+ * @param {number} [options.page] - Page number for pagination
4783
+ * @param {number} [options.limit] - Number of items per page
4784
+ * @param {string[]} [options.toolkits] - Filter servers by toolkit names
4785
+ * @param {string[]} [options.authConfigs] - Filter servers by auth config IDs
4786
+ * @param {string} [options.name] - Filter servers by name
4787
+ * @param {string} [options.user] - Filter servers by user ID
4788
+ * @returns {Promise<McpListResponse>} List of MCP servers matching the filters
4789
+ *
4790
+ * @example
4791
+ * ```typescript
4792
+ * // List all servers with pagination
4793
+ * const servers = await composio.mcp.list({
4794
+ * page: 1,
4795
+ * limit: 10
4796
+ * });
4797
+ *
4798
+ * // List Gmail and Supabase servers
4799
+ * const filteredServers = await composio.mcp.list({
4800
+ * toolkits: ['GMAIL', 'SUPABASE'],
4801
+ * authConfigIds: ['auth_123', 'auth_456']
4802
+ * });
4803
+ * ```
4804
+ */
4805
+ async list(options) {
4806
+ let listResponse;
4807
+ try {
4808
+ listResponse = await this.client.mcp.list({
4809
+ page_no: options.page || 1,
4810
+ limit: options.limit || 10,
4811
+ toolkits: options?.toolkits?.join(",") || "",
4812
+ auth_config_ids: options?.authConfigs?.join(",") || "",
4813
+ name: options?.name
4814
+ });
4815
+ } catch (error) {
4816
+ throw new ValidationError("Failed to list MCP servers", {
4817
+ cause: error
4818
+ });
4819
+ }
4820
+ const listResponseResult = McpListResponseSchema.safeParse(listResponse);
4821
+ if (listResponseResult.error) {
4822
+ throw new ValidationError("Failed to parse MCP server list response", {
4823
+ cause: listResponseResult.error
4824
+ });
4825
+ }
4826
+ return transformMcpListResponse(listResponse);
4827
+ }
4828
+ /**
4829
+ * Get details of a specific MCP server
4830
+ * @param {string} id - Server UUID
4831
+ * @returns {Promise<ReturnType<typeof transformMcpRetrieveResponse>>} Server details
4832
+ *
4833
+ * @example
4834
+ * ```typescript
4835
+ * const serverDetails = await composio.mcp.get('server-uuid');
4836
+ * ```
4837
+ */
4838
+ async get(id) {
4839
+ let retrieveResponse;
4840
+ try {
4841
+ retrieveResponse = await this.client.mcp.retrieve(id);
4842
+ } catch (error) {
4843
+ throw new ValidationError("Failed to retrieve MCP server", {
4844
+ cause: error
4845
+ });
4846
+ }
4847
+ const retrieveResponseResult = McpRetrieveResponseSchema.safeParse(retrieveResponse);
4848
+ if (retrieveResponseResult.error) {
4849
+ throw new ValidationError("Failed to parse MCP server retrieve response", {
4850
+ cause: retrieveResponseResult.error
4851
+ });
4852
+ }
4853
+ return transformMcpRetrieveResponse(retrieveResponse);
4854
+ }
4855
+ /**
4856
+ * Delete an MCP server
4857
+ * @param {string} id - Server UUID
4858
+ * @returns {Promise<ReturnType<typeof transformMcpDeleteResponse>>} Deletion response
4859
+ *
4860
+ * @example
4861
+ * ```typescript
4862
+ * const result = await composio.mcp.delete('server-uuid');
4863
+ * ```
4864
+ */
4865
+ async delete(id) {
4866
+ let deleteResponse;
4867
+ try {
4868
+ deleteResponse = await this.client.mcp.delete(id);
4869
+ } catch (error) {
4870
+ throw new ValidationError("Failed to delete MCP server", {
4871
+ cause: error
4872
+ });
4873
+ }
4874
+ const deleteResponseResult = McpDeleteResponseSchema.safeParse(deleteResponse);
4875
+ if (deleteResponseResult.error) {
4876
+ throw new ValidationError("Failed to parse MCP server delete response", {
4877
+ cause: deleteResponseResult.error
4878
+ });
4879
+ }
4880
+ return transformMcpDeleteResponse(deleteResponse);
4881
+ }
4882
+ /**
4883
+ * Update an MCP server configuration
4884
+ * @param {string} id - Server UUID
4885
+ * @param {string} name - New unique name for the server
4886
+ * @param {MCPToolkitConfig[]} toolkitConfigs - Array of toolkit configurations
4887
+ * @param {MCPAuthOptions} [authOptions] - Updated authentication options
4888
+ * @returns {Promise<ReturnType<typeof transformMcpUpdateResponse>>} Updated server details
4889
+ *
4890
+ * @example
4891
+ * ```typescript
4892
+ * const updatedServer = await composio.mcp.update(
4893
+ * "server-uuid",
4894
+ * "my-updated-server",
4895
+ * [
4896
+ * {
4897
+ * toolkit: "GMAIL",
4898
+ * authConfigId: "ac_sdhkjfhjksdk",
4899
+ * allowedTools: ["GMAIL_FETCH_EMAILS"],
4900
+ * },
4901
+ * ],
4902
+ * {
4903
+ * useComposioManagedAuth: true,
4904
+ * }
4905
+ * );
4906
+ * ```
4907
+ */
4908
+ async update(id, name, toolkitConfigs, authOptions) {
4909
+ this.validateInputs(toolkitConfigs, authOptions);
4910
+ const toolkits = toolkitConfigs.map((config) => config.toolkit);
4911
+ let updateResponse;
4912
+ try {
4913
+ updateResponse = await this.client.mcp.update(id, {
4914
+ name,
4915
+ toolkits,
4916
+ allowed_tools: toolkitConfigs.flatMap((config) => config.allowedTools),
4917
+ managed_auth_via_composio: authOptions?.useComposioManagedAuth || false
4918
+ });
4919
+ } catch (error) {
4920
+ throw new ValidationError("Failed to update MCP server", {
4921
+ cause: error
4922
+ });
4923
+ }
4924
+ const updateResponseResult = McpUpdateResponseSchema.safeParse(updateResponse);
4925
+ if (updateResponseResult.error) {
4926
+ throw new ValidationError("Failed to parse MCP server update response", {
4927
+ cause: updateResponseResult.error
4928
+ });
4929
+ }
4930
+ return transformMcpUpdateResponse(updateResponse);
4931
+ }
4932
+ /**
4933
+ * Generate URL for an MCP server
4934
+ * @param {GenerateURLParams} params - Parameters for URL generation
4935
+ * @returns {Promise<ReturnType<typeof transformMcpGenerateUrlResponse>>} Generated URL response
4936
+ *
4937
+ * @example
4938
+ * ```typescript
4939
+ * const urlResponse = await composio.mcp.generateUrl({
4940
+ * user_ids: ['user123'],
4941
+ * connected_account_ids: ['account456'],
4942
+ * mcp_server_id: 'server-uuid',
4943
+ * managed_auth_by_composio: true
4944
+ * });
4945
+ * ```
4946
+ */
4947
+ async generateUrl(params) {
4948
+ const paramsResult = GenerateURLParamsSnakeCaseSchema.safeParse(params);
4949
+ if (paramsResult.error) {
4950
+ throw new ValidationError("Failed to parse generateUrl parameters", {
4951
+ cause: paramsResult.error
4952
+ });
4953
+ }
4954
+ let urlResponse;
4955
+ try {
4956
+ urlResponse = await this.client.mcp.generate.url(params);
4957
+ } catch (error) {
4958
+ throw new ValidationError("Failed to generate MCP URL", {
4959
+ cause: error
4960
+ });
4961
+ }
4962
+ const responseResult = GenerateURLResponseSchema.safeParse(urlResponse);
4963
+ if (responseResult.error) {
4964
+ throw new ValidationError("Failed to parse MCP URL generation response", {
4965
+ cause: responseResult.error
4966
+ });
4967
+ }
4968
+ return transformMcpGenerateUrlResponse(urlResponse);
4969
+ }
4970
+ /**
4971
+ * Transform MCP URL response into the appropriate format.
4972
+ * If the provider has a custom transform method, use it.
4973
+ * Otherwise, use the default transformation.
4974
+ *
4975
+ * @param data - The MCP URL response data (in camelCase)
4976
+ * @param serverName - Name of the MCP server
4977
+ * @param connectedAccountIds - Optional array of connected account IDs
4978
+ * @param userIds - Optional array of user IDs
4979
+ * @param toolkits - Optional array of toolkit names
4980
+ * @returns Transformed response in appropriate format
4981
+ */
4982
+ wrapMcpServerResponse(data, serverName, connectedAccountIds, userIds, toolkits) {
4983
+ if (this.provider && typeof this.provider.wrapMcpServerResponse === "function") {
4984
+ const snakeCaseData = {
4985
+ mcp_url: data.mcpUrl,
4986
+ ...data.connectedAccountUrls && { connected_account_urls: data.connectedAccountUrls },
4987
+ ...data.userIdsUrl && { user_ids_url: data.userIdsUrl }
4988
+ };
4989
+ const transformed = this.provider.wrapMcpServerResponse(
4990
+ snakeCaseData,
4991
+ serverName,
4992
+ connectedAccountIds,
4993
+ userIds,
4994
+ toolkits
4995
+ );
4996
+ return transformed;
4997
+ }
4998
+ if (connectedAccountIds?.length && data.connectedAccountUrls) {
4999
+ return data.connectedAccountUrls.map((url, index) => ({
5000
+ url: new URL(url),
5001
+ name: `${serverName}-${connectedAccountIds[index]}`,
5002
+ toolkit: toolkits?.[index]
5003
+ }));
5004
+ } else if (userIds?.length && data.userIdsUrl) {
5005
+ return data.userIdsUrl.map((url, index) => ({
5006
+ url: new URL(url),
5007
+ name: `${serverName}-${userIds[index]}`,
5008
+ toolkit: toolkits?.[index]
5009
+ }));
5010
+ }
5011
+ return {
5012
+ url: new URL(data.mcpUrl),
5013
+ name: serverName
5014
+ };
5015
+ }
5016
+ };
5017
+
4360
5018
  // src/utils/constants.ts
5019
+ var constants_exports = {};
5020
+ __export(constants_exports, {
5021
+ COMPOSIO_DIR: () => COMPOSIO_DIR,
5022
+ DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
5023
+ IS_DEVELOPMENT_OR_CI: () => IS_DEVELOPMENT_OR_CI,
5024
+ TELEMETRY_URL: () => TELEMETRY_URL2,
5025
+ TEMP_FILES_DIRECTORY_NAME: () => TEMP_FILES_DIRECTORY_NAME,
5026
+ USER_DATA_FILE_NAME: () => USER_DATA_FILE_NAME
5027
+ });
4361
5028
  var COMPOSIO_DIR = ".composio";
4362
5029
  var USER_DATA_FILE_NAME = "user_data.json";
5030
+ var TEMP_FILES_DIRECTORY_NAME = "files";
4363
5031
  var DEFAULT_BASE_URL = "https://backend.composio.dev";
5032
+ var TELEMETRY_URL2 = "https://app.composio.dev";
4364
5033
  var IS_DEVELOPMENT_OR_CI = process.env.DEVELOPMENT || process.env.CI || false;
4365
5034
 
4366
5035
  // src/utils/sdk.ts
@@ -4469,17 +5138,17 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
4469
5138
  name = "openai";
4470
5139
  /**
4471
5140
  * Creates a new instance of the OpenAIProvider.
4472
- *
5141
+ *
4473
5142
  * This is the default provider for the Composio SDK and is automatically
4474
5143
  * available without additional installation.
4475
- *
5144
+ *
4476
5145
  * @example
4477
5146
  * ```typescript
4478
5147
  * // The OpenAIProvider is used by default when initializing Composio
4479
5148
  * const composio = new Composio({
4480
5149
  * apiKey: 'your-api-key'
4481
5150
  * });
4482
- *
5151
+ *
4483
5152
  * // You can also explicitly specify it
4484
5153
  * const composio = new Composio({
4485
5154
  * apiKey: 'your-api-key',
@@ -4490,15 +5159,45 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
4490
5159
  constructor() {
4491
5160
  super();
4492
5161
  }
5162
+ /**
5163
+ * Transform MCP URL response into OpenAI-specific format.
5164
+ * OpenAI uses the standard format by default.
5165
+ *
5166
+ * @param data - The MCP URL response data
5167
+ * @param serverName - Name of the MCP server
5168
+ * @param connectedAccountIds - Optional array of connected account IDs
5169
+ * @param userIds - Optional array of user IDs
5170
+ * @param toolkits - Optional array of toolkit names
5171
+ * @returns Standard MCP server response format
5172
+ */
5173
+ wrapMcpServerResponse(data, serverName, connectedAccountIds, userIds, toolkits) {
5174
+ if (connectedAccountIds?.length && data.connected_account_urls) {
5175
+ return data.connected_account_urls.map((url, index) => ({
5176
+ url: new URL(url),
5177
+ name: `${serverName}-${connectedAccountIds[index]}`,
5178
+ toolkit: toolkits?.[index]
5179
+ }));
5180
+ } else if (userIds?.length && data.user_ids_url) {
5181
+ return data.user_ids_url.map((url, index) => ({
5182
+ url: new URL(url),
5183
+ name: `${serverName}-${userIds[index]}`,
5184
+ toolkit: toolkits?.[index]
5185
+ }));
5186
+ }
5187
+ return {
5188
+ url: new URL(data.mcp_url),
5189
+ name: serverName
5190
+ };
5191
+ }
4493
5192
  /**
4494
5193
  * Wraps a Composio tool in the OpenAI function calling format.
4495
- *
5194
+ *
4496
5195
  * This method transforms a Composio tool definition into the format
4497
5196
  * expected by OpenAI's function calling API.
4498
- *
5197
+ *
4499
5198
  * @param tool - The Composio tool to wrap
4500
5199
  * @returns The wrapped tool in OpenAI format
4501
- *
5200
+ *
4502
5201
  * @example
4503
5202
  * ```typescript
4504
5203
  * // Wrap a single tool for use with OpenAI
@@ -4513,7 +5212,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
4513
5212
  * required: ['query']
4514
5213
  * }
4515
5214
  * };
4516
- *
5215
+ *
4517
5216
  * const openAITool = provider.wrapTool(composioTool);
4518
5217
  * ```
4519
5218
  */
@@ -4530,13 +5229,13 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
4530
5229
  };
4531
5230
  /**
4532
5231
  * Wraps multiple Composio tools in the OpenAI function calling format.
4533
- *
5232
+ *
4534
5233
  * This method transforms a list of Composio tools into the format
4535
5234
  * expected by OpenAI's function calling API.
4536
- *
5235
+ *
4537
5236
  * @param tools - Array of Composio tools to wrap
4538
5237
  * @returns Array of wrapped tools in OpenAI format
4539
- *
5238
+ *
4540
5239
  * @example
4541
5240
  * ```typescript
4542
5241
  * // Wrap multiple tools for use with OpenAI
@@ -4562,7 +5261,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
4562
5261
  * }
4563
5262
  * }
4564
5263
  * ];
4565
- *
5264
+ *
4566
5265
  * const openAITools = provider.wrapTools(composioTools);
4567
5266
  * ```
4568
5267
  */
@@ -4571,16 +5270,16 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
4571
5270
  };
4572
5271
  /**
4573
5272
  * Executes a tool call from OpenAI's chat completion.
4574
- *
5273
+ *
4575
5274
  * This method processes a tool call from OpenAI's chat completion API,
4576
5275
  * executes the corresponding Composio tool, and returns the result.
4577
- *
5276
+ *
4578
5277
  * @param {string} userId - The user ID for authentication and tracking
4579
5278
  * @param {OpenAI.ChatCompletionMessageToolCall} tool - The tool call from OpenAI
4580
5279
  * @param {ExecuteToolFnOptions} [options] - Optional execution options
4581
5280
  * @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
4582
5281
  * @returns {Promise<string>} The result of the tool call as a JSON string
4583
- *
5282
+ *
4584
5283
  * @example
4585
5284
  * ```typescript
4586
5285
  * // Execute a tool call from OpenAI
@@ -4592,7 +5291,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
4592
5291
  * arguments: '{"query":"composio documentation"}'
4593
5292
  * }
4594
5293
  * };
4595
- *
5294
+ *
4596
5295
  * const result = await provider.executeToolCall(
4597
5296
  * 'user123',
4598
5297
  * toolCall,
@@ -4622,7 +5321,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
4622
5321
  * @param {ExecuteToolFnOptions} [options] - Optional execution options
4623
5322
  * @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
4624
5323
  * @returns {Promise<string[]>} Array of tool execution results as JSON strings
4625
- *
5324
+ *
4626
5325
  * @example
4627
5326
  * ```typescript
4628
5327
  * // Handle tool calls from a chat completion response
@@ -4644,7 +5343,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
4644
5343
  * }
4645
5344
  * ]
4646
5345
  * };
4647
- *
5346
+ *
4648
5347
  * const results = await provider.handleToolCalls(
4649
5348
  * 'user123',
4650
5349
  * chatCompletion,
@@ -4675,7 +5374,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
4675
5374
  * @param {ExecuteToolFnOptions} [options] - Optional execution options
4676
5375
  * @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
4677
5376
  * @returns {Promise<OpenAI.Beta.Threads.Runs.RunSubmitToolOutputsParams.ToolOutput[]>} Array of tool outputs for submission
4678
- *
5377
+ *
4679
5378
  * @example
4680
5379
  * ```typescript
4681
5380
  * // Handle tool calls from an OpenAI Assistant run
@@ -4696,13 +5395,13 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
4696
5395
  * }
4697
5396
  * }
4698
5397
  * };
4699
- *
5398
+ *
4700
5399
  * const toolOutputs = await provider.handleAssistantMessage(
4701
5400
  * 'user123',
4702
5401
  * run,
4703
5402
  * { connectedAccountId: 'conn_xyz456' }
4704
5403
  * );
4705
- *
5404
+ *
4706
5405
  * // Submit tool outputs back to OpenAI
4707
5406
  * await openai.beta.threads.runs.submitToolOutputs(
4708
5407
  * thread.id,
@@ -4745,7 +5444,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
4745
5444
  * @param {ExecuteToolFnOptions} [options] - Optional execution options
4746
5445
  * @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
4747
5446
  * @returns {AsyncGenerator<OpenAI.Beta.Assistants.AssistantStreamEvent, void, unknown>} Generator yielding stream events
4748
- *
5447
+ *
4749
5448
  * @example
4750
5449
  * ```typescript
4751
5450
  * // Process an OpenAI Assistant stream with tool calls
@@ -4754,7 +5453,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
4754
5453
  * assistant_id: 'asst_abc123',
4755
5454
  * tools: provider.wrapTools(composioTools)
4756
5455
  * });
4757
- *
5456
+ *
4758
5457
  * // Process the stream and handle tool calls
4759
5458
  * const streamProcessor = provider.waitAndHandleAssistantStreamToolCalls(
4760
5459
  * 'user123',
@@ -4763,7 +5462,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
4763
5462
  * thread,
4764
5463
  * { connectedAccountId: 'conn_xyz456' }
4765
5464
  * );
4766
- *
5465
+ *
4767
5466
  * // Consume the stream events
4768
5467
  * for await (const event of streamProcessor) {
4769
5468
  * if (event.event === 'thread.message.delta') {
@@ -4833,7 +5532,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
4833
5532
  * @param {ExecuteToolFnOptions} [options] - Optional execution options
4834
5533
  * @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
4835
5534
  * @returns {Promise<OpenAI.Beta.Threads.Run>} The final run object after completion
4836
- *
5535
+ *
4837
5536
  * @example
4838
5537
  * ```typescript
4839
5538
  * // Process an OpenAI Assistant run with tool calls
@@ -4842,12 +5541,12 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
4842
5541
  * role: 'user',
4843
5542
  * content: 'Find information about Composio'
4844
5543
  * });
4845
- *
5544
+ *
4846
5545
  * let run = await openai.beta.threads.runs.create(thread.id, {
4847
5546
  * assistant_id: 'asst_abc123',
4848
5547
  * tools: provider.wrapTools(composioTools)
4849
5548
  * });
4850
- *
5549
+ *
4851
5550
  * // Wait for the run to complete, handling any tool calls
4852
5551
  * run = await provider.waitAndHandleAssistantToolCalls(
4853
5552
  * 'user123',
@@ -4856,7 +5555,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
4856
5555
  * thread,
4857
5556
  * { connectedAccountId: 'conn_xyz456' }
4858
5557
  * );
4859
- *
5558
+ *
4860
5559
  * // Get the final messages after run completion
4861
5560
  * const messages = await openai.beta.threads.messages.list(thread.id);
4862
5561
  * console.log(messages.data[0].content);
@@ -4879,7 +5578,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
4879
5578
  };
4880
5579
 
4881
5580
  // package.json
4882
- var version = "0.1.24";
5581
+ var version = "0.1.26";
4883
5582
 
4884
5583
  // src/composio.ts
4885
5584
  var Composio = class _Composio {
@@ -4904,6 +5603,7 @@ var Composio = class _Composio {
4904
5603
  authConfigs;
4905
5604
  // connected accounts
4906
5605
  connectedAccounts;
5606
+ mcp;
4907
5607
  /**
4908
5608
  * Creates a new instance of the Composio SDK.
4909
5609
  *
@@ -4956,6 +5656,7 @@ var Composio = class _Composio {
4956
5656
  };
4957
5657
  this.provider = config?.provider ?? new OpenAIProvider();
4958
5658
  this.tools = new Tools(this.client, this.provider);
5659
+ this.mcp = new MCP(this.client, this.provider);
4959
5660
  this.toolkits = new Toolkits(this.client);
4960
5661
  this.triggers = new Triggers(this.client);
4961
5662
  this.authConfigs = new AuthConfigs(this.client);
@@ -5034,6 +5735,9 @@ var Composio = class _Composio {
5034
5735
  // src/provider/ComposioProvider.ts
5035
5736
  var ComposioProvider = class extends BaseNonAgenticProvider {
5036
5737
  name = "ComposioProvider";
5738
+ constructor() {
5739
+ super();
5740
+ }
5037
5741
  wrapTool = (tool) => {
5038
5742
  return tool;
5039
5743
  };
@@ -5285,8 +5989,34 @@ export {
5285
5989
  CreateComposioManagedAuthConfigParamsSchema,
5286
5990
  CreateCustomAuthConfigParamsSchema,
5287
5991
  CustomAuthParamsSchema,
5992
+ CustomCreateResponseCamelCaseSchema,
5993
+ CustomCreateResponseSchema,
5994
+ GenerateURLParamsSchema,
5995
+ GenerateURLParamsSnakeCaseSchema,
5996
+ GenerateURLResponseCamelCaseSchema,
5997
+ GenerateURLResponseSchema,
5288
5998
  IncomingTriggerPayloadSchema,
5289
5999
  JsonSchemaToZodError,
6000
+ MCP,
6001
+ MCPAuthOptionsSchema,
6002
+ MCPGenerateURLParamsSchema,
6003
+ MCPGetServerParamsSchema,
6004
+ MCPMultiAppServerSchema,
6005
+ MCPServerCreateResponseSchema,
6006
+ MCPServerListResponseSchema,
6007
+ MCPServerSchema,
6008
+ MCPServerUpdateParamsSchema,
6009
+ MCPSingleAppServerSchema,
6010
+ MCPToolkitConfigSchema,
6011
+ MCPToolkitConfigsArraySchema,
6012
+ McpDeleteResponseCamelCaseSchema,
6013
+ McpDeleteResponseSchema,
6014
+ McpListResponseCamelCaseSchema,
6015
+ McpListResponseSchema,
6016
+ McpRetrieveResponseCamelCaseSchema,
6017
+ McpRetrieveResponseSchema,
6018
+ McpUpdateResponseCamelCaseSchema,
6019
+ McpUpdateResponseSchema,
5290
6020
  Oauth1ActiveConnectionDataSchema,
5291
6021
  Oauth1ConnectionDataSchema,
5292
6022
  Oauth1ExpiredConnectionDataSchema,
@@ -5339,6 +6069,7 @@ export {
5339
6069
  TriggerSubscribeParamSchema,
5340
6070
  ValidationError,
5341
6071
  ValidationErrorCodes,
6072
+ constants_exports as constants,
5342
6073
  jsonSchemaToZodSchema,
5343
6074
  logger_default as logger,
5344
6075
  removeNonRequiredProperties