@composio/core 0.1.36-next.11 → 0.1.36-next.12

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
@@ -79,6 +79,7 @@ __export(index_exports, {
79
79
  ConnectionRequestErrorCodes: () => ConnectionRequestErrorCodes,
80
80
  ConnectionRequestFailedError: () => ConnectionRequestFailedError,
81
81
  ConnectionRequestTimeoutError: () => ConnectionRequestTimeoutError,
82
+ ConnectionStatus: () => ConnectionStatus,
82
83
  ConnectionStatuses: () => ConnectionStatuses,
83
84
  CreateAuthConfigParamsSchema: () => CreateAuthConfigParamsSchema,
84
85
  CreateAuthConfigResponseSchema: () => CreateAuthConfigResponseSchema,
@@ -4151,22 +4152,24 @@ var Toolkits = class {
4151
4152
  * const connectionRequest = await composio.toolkits.authorize(userId, 'github');
4152
4153
  * ```
4153
4154
  */
4154
- async authorize(userId, toolkitSlug) {
4155
+ async authorize(userId, toolkitSlug, authConfigId) {
4155
4156
  const toolkit = await this.getToolkitBySlug(toolkitSlug);
4156
4157
  const composioAuthConfig = new AuthConfigs(this.client);
4157
- let authConfigIdToUse;
4158
- const authConfig = await composioAuthConfig.list({
4159
- toolkit: toolkitSlug
4160
- });
4161
- authConfigIdToUse = authConfig.items[0]?.id;
4158
+ let authConfigIdToUse = authConfigId;
4159
+ if (!authConfigIdToUse) {
4160
+ const authConfig = await composioAuthConfig.list({
4161
+ toolkit: toolkitSlug
4162
+ });
4163
+ authConfigIdToUse = authConfig.items[0]?.id;
4164
+ }
4162
4165
  if (!authConfigIdToUse) {
4163
4166
  if (toolkit.authConfigDetails && toolkit.authConfigDetails.length > 0) {
4164
4167
  try {
4165
- const authConfig2 = await composioAuthConfig.create(toolkitSlug, {
4168
+ const authConfig = await composioAuthConfig.create(toolkitSlug, {
4166
4169
  type: "use_composio_managed_auth",
4167
4170
  name: `${toolkit.name} Auth Config`
4168
4171
  });
4169
- authConfigIdToUse = authConfig2.id;
4172
+ authConfigIdToUse = authConfig.id;
4170
4173
  } catch (error) {
4171
4174
  if (error instanceof import_client4.default.APIError && error.status === 400) {
4172
4175
  throw new ComposioAuthConfigNotFoundError(
@@ -4990,7 +4993,7 @@ var MCPToolkitConfigsArraySchema = import_zod10.z.array(MCPToolkitConfigSchema).
4990
4993
  return uniqueToolkits.size === toolkits.length;
4991
4994
  }, "Duplicate toolkits are not allowed. Each toolkit must be unique.");
4992
4995
  var MCPAuthOptionsSchema = import_zod10.z.object({
4993
- useComposioManagedAuth: import_zod10.z.boolean().optional()
4996
+ isChatAuth: import_zod10.z.boolean().optional()
4994
4997
  });
4995
4998
  var MCPGetServerParamsSchema = import_zod10.z.object({
4996
4999
  userId: import_zod10.z.string().min(1, "User ID cannot be empty").optional(),
@@ -5008,7 +5011,7 @@ var MCPGetServerParamsSchema = import_zod10.z.object({
5008
5011
  var MCPGenerateURLParamsSchema = import_zod10.z.object({
5009
5012
  userIds: import_zod10.z.array(import_zod10.z.string()).optional(),
5010
5013
  connectedAccountIds: import_zod10.z.array(import_zod10.z.string()).optional(),
5011
- useComposioManagedAuth: import_zod10.z.boolean().optional()
5014
+ isChatAuth: import_zod10.z.boolean().optional()
5012
5015
  });
5013
5016
  var ComposioGenerateURLParamsSchema = import_zod10.z.object({
5014
5017
  user_ids: import_zod10.z.array(import_zod10.z.string()).optional(),
@@ -5062,6 +5065,11 @@ var MCPServerUpdateParamsSchema = import_zod10.z.object({
5062
5065
  allowedTools: import_zod10.z.array(import_zod10.z.string()).optional().describe("Updated list of allowed tools")
5063
5066
  });
5064
5067
  var MCPServerCreateResponseSchema = MCPServerSchema;
5068
+ var ConnectionStatus = /* @__PURE__ */ ((ConnectionStatus2) => {
5069
+ ConnectionStatus2["CONNECTED"] = "CONNECTED";
5070
+ ConnectionStatus2["DISCONNECTED"] = "DISCONNECTED";
5071
+ return ConnectionStatus2;
5072
+ })(ConnectionStatus || {});
5065
5073
  var CustomCreateResponseSchema = import_zod10.z.object({
5066
5074
  id: import_zod10.z.string().min(1, "Server ID cannot be empty"),
5067
5075
  name: import_zod10.z.string().min(1, "Server name cannot be empty"),
@@ -5106,7 +5114,14 @@ var McpRetrieveResponseSchema = import_zod10.z.object({
5106
5114
  status: import_zod10.z.string().optional(),
5107
5115
  toolkits: import_zod10.z.array(import_zod10.z.string()).optional(),
5108
5116
  tools: import_zod10.z.array(import_zod10.z.string()).optional(),
5109
- managedAuthViaComposio: import_zod10.z.boolean().optional()
5117
+ managedAuthViaComposio: import_zod10.z.boolean().optional(),
5118
+ authConfigIds: import_zod10.z.array(import_zod10.z.string()).optional(),
5119
+ mcpUrl: import_zod10.z.string(),
5120
+ commands: import_zod10.z.object({
5121
+ claude: import_zod10.z.string(),
5122
+ cursor: import_zod10.z.string(),
5123
+ windsurf: import_zod10.z.string()
5124
+ })
5110
5125
  });
5111
5126
  var ComposioMcpRetrieveResponseSchema = import_zod10.z.object({
5112
5127
  id: import_zod10.z.string().min(1, "Server ID cannot be empty"),
@@ -5189,8 +5204,11 @@ function transformMcpRetrieveResponse(response) {
5189
5204
  updatedAt: response.updated_at,
5190
5205
  status: response.status,
5191
5206
  toolkits: response.toolkits,
5192
- tools: response.tools,
5193
- managedAuthViaComposio: response.managed_auth_via_composio
5207
+ tools: response.allowed_tools,
5208
+ managedAuthViaComposio: response.managed_auth_via_composio,
5209
+ authConfigIds: response.auth_config_ids,
5210
+ mcpUrl: response.mcp_url,
5211
+ commands: response.commands
5194
5212
  });
5195
5213
  if (!result.success) {
5196
5214
  throw new ValidationError("Failed to parse MCP retrieve response", {
@@ -5247,9 +5265,11 @@ function transformMcpGenerateUrlResponse(response) {
5247
5265
  var MCP = class {
5248
5266
  client;
5249
5267
  provider;
5268
+ toolkits;
5250
5269
  constructor(client, provider) {
5251
5270
  this.client = client;
5252
5271
  this.provider = provider;
5272
+ this.toolkits = new Toolkits(client);
5253
5273
  telemetry.instrument(this);
5254
5274
  }
5255
5275
  /**
@@ -5277,47 +5297,100 @@ var MCP = class {
5277
5297
  }
5278
5298
  /**
5279
5299
  * Create a new MCP server
5280
- * @param {string} name - Unique name for the MCP server
5281
- * @param {MCPToolkitConfig[]} toolkitConfigs - Array of toolkit configurations
5282
- * @param {MCPAuthOptions} [authOptions] - Authentication configuration options
5300
+ * @param {Object} params - Parameters for creating the MCP server
5301
+ * @param {Array} params.authConfig - Array of auth configurations with id and allowed tools
5302
+ * @param {Object} params.options - Server creation options
5303
+ * @param {string} params.options.name - Unique name for the MCP server
5304
+ * @param {boolean} [params.options.isChatAuth] - Whether to use chat-based authentication
5283
5305
  * @returns {Promise<McpServerCreateResponse<T>>} Created server details with instance getter
5284
5306
  *
5285
5307
  * @example
5286
5308
  * ```typescript
5287
- * const server = await composio.mcp.create(
5288
- * "personal-mcp-server",
5289
- * [
5309
+ * const server = await composio.mcp.create("personal-mcp-server", [
5290
5310
  * {
5291
- * toolkit: "GMAIL",
5292
- * authConfigId: "ac_sdhkjfhjksdk",
5293
- * allowedTools: ["GMAIL_FETCH_EMAILS"],
5294
- * },
5311
+ * authConfigId: "ac_xyz",
5312
+ * allowedTools: ["GMAIL_FETCH_EMAILS", "SLACK_SEND_MESSAGE"]
5313
+ * }
5295
5314
  * ],
5296
- * { useComposioManagedAuth: true },
5297
- * );
5298
- *
5299
- * // Option 1: Use convenience method on response
5300
- * const urls = await server.getServer({
5301
- * connectedAccountIds: { gmail: "account_id" }
5315
+ * {
5316
+ * isChatAuth: true
5317
+ * }
5302
5318
  * });
5303
5319
  *
5304
- * // Option 2: Use standalone method later
5305
- * const urlsLater = await composio.mcp.getServer(server.id, {
5306
- * connectedAccountIds: { gmail: "account_id" }
5320
+ * // Use convenience method on response
5321
+ * const urls = await server.getServer({
5322
+ * userId: "user123"
5307
5323
  * });
5308
5324
  * ```
5309
5325
  */
5310
- async create(name, toolkitConfigs, authOptions) {
5311
- this.validateInputs(toolkitConfigs, authOptions);
5312
- const toolkits = toolkitConfigs.map((config) => config.toolkit);
5326
+ async create(name, serverConfig, options) {
5327
+ if (!serverConfig || serverConfig.length === 0) {
5328
+ throw new ValidationError("At least one auth config is required", {});
5329
+ }
5330
+ if (!name) {
5331
+ throw new ValidationError("Server name is required", {});
5332
+ }
5333
+ try {
5334
+ const mcpServer = await this.getByName(name);
5335
+ const authConfigs = mcpServer.authConfigIds?.sort();
5336
+ const sortedCurrentAuthConfigs = serverConfig.map((config) => config.authConfigId).sort();
5337
+ if (authConfigs.length > 0 && !authConfigs.every((config, index) => config === sortedCurrentAuthConfigs[index])) {
5338
+ throw new ValidationError(
5339
+ "MCP server with this name already exists with different auth configs",
5340
+ {
5341
+ meta: { serverName: name }
5342
+ }
5343
+ );
5344
+ }
5345
+ const tools = mcpServer.tools?.sort();
5346
+ const sortedCurrentTools = serverConfig.flatMap((config) => config.allowedTools).sort();
5347
+ console.log(tools, sortedCurrentTools, "tools");
5348
+ if (tools?.length > 0 && !tools.every((tool, index) => tool === sortedCurrentTools[index])) {
5349
+ throw new ValidationError("MCP server with this name already exists with different tools", {
5350
+ meta: { serverName: name }
5351
+ });
5352
+ }
5353
+ const authConfigDetails2 = await Promise.all(
5354
+ serverConfig.map((config) => this.client.authConfigs.retrieve(config.authConfigId))
5355
+ );
5356
+ const toolkits2 = authConfigDetails2.map((config) => config.toolkit.slug);
5357
+ const camelCaseResponse2 = transformMcpCreateResponse({
5358
+ id: mcpServer.id,
5359
+ name: mcpServer.name,
5360
+ auth_config_ids: serverConfig.map((config) => config.authConfigId),
5361
+ allowed_tools: serverConfig.flatMap((config) => config.allowedTools),
5362
+ managed_auth_via_composio: options.isChatAuth || false,
5363
+ commands: mcpServer.commands,
5364
+ created_at: mcpServer.createdAt,
5365
+ updated_at: mcpServer.updatedAt,
5366
+ mcp_url: mcpServer.mcpUrl
5367
+ });
5368
+ return {
5369
+ ...camelCaseResponse2,
5370
+ toolkits: toolkits2,
5371
+ getServer: async (params) => {
5372
+ return this.getServer(camelCaseResponse2.id, params.userId || "", {
5373
+ isChatAuth: options.isChatAuth
5374
+ });
5375
+ }
5376
+ };
5377
+ } catch (error) {
5378
+ if (error instanceof ValidationError && !error.message.includes("not found")) {
5379
+ throw error;
5380
+ }
5381
+ }
5382
+ const authConfigDetails = await Promise.all(
5383
+ serverConfig.map((config) => this.client.authConfigs.retrieve(config.authConfigId))
5384
+ );
5385
+ const toolkits = authConfigDetails.map((config) => config.toolkit.slug);
5313
5386
  let mcpServerCreatedResponse;
5314
5387
  try {
5315
5388
  mcpServerCreatedResponse = await this.client.mcp.custom.create({
5316
5389
  name,
5317
5390
  toolkits,
5318
- custom_tools: toolkitConfigs.flatMap((config) => config.allowedTools),
5319
- managed_auth_via_composio: authOptions?.useComposioManagedAuth || false,
5320
- auth_config_ids: toolkitConfigs.map((config) => config.authConfigId)
5391
+ custom_tools: serverConfig.flatMap((config) => config.allowedTools),
5392
+ managed_auth_via_composio: options.isChatAuth || false,
5393
+ auth_config_ids: serverConfig.map((config) => config.authConfigId)
5321
5394
  });
5322
5395
  } catch (error) {
5323
5396
  throw new ValidationError("Failed to create MCP server", {
@@ -5335,53 +5408,200 @@ var MCP = class {
5335
5408
  ...camelCaseResponse,
5336
5409
  toolkits,
5337
5410
  getServer: async (params) => {
5338
- return this.getServer(camelCaseResponse.id, params, authOptions);
5411
+ return this.getServer(camelCaseResponse.id, params.userId || "", {
5412
+ isChatAuth: options.isChatAuth
5413
+ });
5339
5414
  }
5340
5415
  };
5341
5416
  }
5342
5417
  /**
5343
- * Get server URLs for an existing MCP server
5344
- * @param {string} id - Server UUID
5345
- * @param {MCPGetServerParams} params - Parameters for getting server URLs
5346
- * @param {MCPAuthOptions} [authOptions] - Authentication options (optional, will use server's default if not provided)
5347
- * @returns {Promise<T>} Transformed server URLs in provider-specific format
5418
+ * Get the connection status of a user for an MCP server
5419
+ *
5420
+ * Checks whether a user has the necessary connected accounts to use all toolkits
5421
+ * configured in the specified MCP server. Returns both overall connection status
5422
+ * and individual status for each toolkit.
5423
+ *
5424
+ * @param {Object} params - Parameters for checking connection status
5425
+ * @param {string} params.id - The UUID of the MCP server to check
5426
+ * @param {string} params.userId - The ID of the user to check connection status for
5427
+ * @returns {Promise<McpUserConnectionStatus>} Complete connection status including:
5428
+ * - `type`: Overall status (CONNECTED if all toolkits are connected, DISCONNECTED otherwise)
5429
+ * - `connected`: Boolean indicating if user can use the MCP server
5430
+ * - `connectedToolkits`: Record mapping each toolkit name to its individual connection status
5431
+ *
5432
+ * @throws {ValidationError} When MCP server has no toolkits configured
5433
+ * @throws {ValidationError} When MCP server retrieval fails
5348
5434
  *
5349
5435
  * @example
5350
5436
  * ```typescript
5351
- * // Get URLs for an existing server
5352
- * const urls = await composio.mcp.getServer("server-id", {
5353
- * connectedAccountIds: {
5354
- * gmail: "connected_account_id"
5437
+ * // Check if user can access an MCP server with Gmail and Slack toolkits
5438
+ * const connectionStatus = await composio.mcp.getUserConnectionStatus('user123', 'mcp-server-uuid');
5439
+ *
5440
+ * if (connectionStatus.connected) {
5441
+ * console.log('User can access all required toolkits');
5442
+ * // connectionStatus.type === ConnectionStatus.CONNECTED
5443
+ * } else {
5444
+ * console.log('User is missing some toolkit connections');
5445
+ * // Check individual toolkit statuses
5446
+ * Object.entries(connectionStatus.connectedToolkits).forEach(([toolkit, status]) => {
5447
+ * if (!status.connected) {
5448
+ * console.log(`Missing connection for toolkit: ${toolkit}`);
5449
+ * }
5450
+ * });
5451
+ * }
5452
+ * ```
5453
+ *
5454
+ * @example
5455
+ * ```typescript
5456
+ * // Example response when user has Gmail connected but missing Slack
5457
+ * {
5458
+ * type: ConnectionStatus.DISCONNECTED,
5459
+ * connected: false,
5460
+ * connectedToolkits: {
5461
+ * GMAIL: {
5462
+ * type: ConnectionStatus.CONNECTED,
5463
+ * connected: true,
5464
+ * toolkit: 'GMAIL',
5465
+ * connectedAccountId: 'conn_gmail_123'
5466
+ * },
5467
+ * SLACK: {
5468
+ * type: ConnectionStatus.DISCONNECTED,
5469
+ * connected: false,
5470
+ * toolkit: 'SLACK'
5471
+ * }
5355
5472
  * }
5356
- * });
5473
+ * }
5357
5474
  * ```
5358
5475
  */
5359
- async getServer(id, params, authOptions) {
5360
- const serverDetails = await this.get(id);
5361
- const paramsResult = MCPGetServerParamsSchema.safeParse(params);
5362
- if (paramsResult.error) {
5363
- throw new ValidationError("Failed to parse get server parameters", {
5364
- cause: paramsResult.error
5476
+ async getUserConnectionStatus(userId, serverId) {
5477
+ const serverDetails = await this.get(serverId);
5478
+ if (!serverDetails.toolkits || serverDetails.toolkits.length === 0) {
5479
+ throw new ValidationError("MCP server has no toolkits configured", {
5480
+ meta: { serverId }
5365
5481
  });
5366
5482
  }
5367
- const toolkits = serverDetails.toolkits || [];
5368
- if (paramsResult.data.connectedAccountIds) {
5369
- const providedToolkits = Object.keys(paramsResult.data.connectedAccountIds);
5370
- const invalidToolkits = providedToolkits.filter((toolkit) => !toolkits.includes(toolkit));
5371
- if (invalidToolkits.length > 0) {
5372
- throw new ValidationError(
5373
- `Invalid toolkits provided: ${invalidToolkits.join(", ")}. Available toolkits are: ${toolkits.join(", ")}`,
5374
- {}
5375
- );
5483
+ const connectedAccounts = await this.client.connectedAccounts.list({
5484
+ user_ids: [userId],
5485
+ toolkit_slugs: serverDetails.toolkits.map((toolkit) => toolkit.toLowerCase()),
5486
+ statuses: ["ACTIVE"]
5487
+ });
5488
+ const connectedAccountsByToolkit = /* @__PURE__ */ new Map();
5489
+ connectedAccounts.items?.forEach((account) => {
5490
+ connectedAccountsByToolkit.set(account.toolkit.slug.toLowerCase(), account.id);
5491
+ });
5492
+ const connectedToolkits = {};
5493
+ let allToolkitsConnected = true;
5494
+ for (const toolkit of serverDetails.toolkits) {
5495
+ const connectedAccountId = connectedAccountsByToolkit.get(toolkit.toLowerCase());
5496
+ if (connectedAccountId) {
5497
+ connectedToolkits[toolkit] = {
5498
+ type: "CONNECTED" /* CONNECTED */,
5499
+ connected: true,
5500
+ toolkit,
5501
+ connectedAccountId
5502
+ };
5503
+ } else {
5504
+ connectedToolkits[toolkit] = {
5505
+ type: "DISCONNECTED" /* DISCONNECTED */,
5506
+ connected: false,
5507
+ toolkit
5508
+ };
5509
+ allToolkitsConnected = false;
5376
5510
  }
5377
5511
  }
5512
+ if (allToolkitsConnected) {
5513
+ return {
5514
+ type: "CONNECTED" /* CONNECTED */,
5515
+ connected: true,
5516
+ connectedToolkits
5517
+ };
5518
+ } else {
5519
+ return {
5520
+ type: "DISCONNECTED" /* DISCONNECTED */,
5521
+ connected: false,
5522
+ connectedToolkits
5523
+ };
5524
+ }
5525
+ }
5526
+ /**
5527
+ * Get the connection parameters for a toolkit
5528
+ * @param {string} serverId - The UUID of the MCP server
5529
+ * @param {string} toolkit - The toolkit to get connection parameters for
5530
+ * @returns {Promise<ToolkitAuthFieldsResponse>} Connection parameters for the toolkit
5531
+ */
5532
+ async getConnectionParams(serverId, toolkit) {
5533
+ const mcpServerDetails = await this.get(serverId);
5534
+ const authConfigs = mcpServerDetails.authConfigIds ? await Promise.all(
5535
+ mcpServerDetails.authConfigIds.map((id) => this.client.authConfigs.retrieve(id))
5536
+ ) : [];
5537
+ const authConfig = authConfigs.find((config) => config.toolkit.slug === toolkit);
5538
+ if (!authConfig) {
5539
+ throw new ValidationError("Auth config not found", {
5540
+ meta: { serverId, toolkit }
5541
+ });
5542
+ }
5543
+ const connectionParams = await this.toolkits.getConnectedAccountInitiationFields(
5544
+ toolkit,
5545
+ authConfig.auth_scheme
5546
+ );
5547
+ return connectionParams;
5548
+ }
5549
+ /**
5550
+ * Authorize a user for a toolkit
5551
+ * @param {string} serverId - The UUID of the MCP server
5552
+ * @param {string} userId - The ID of the user to authorize
5553
+ * @param {string} toolkit - The toolkit to authorize
5554
+ * @returns {Promise<ConnectionRequest>} Connection request for the toolkit
5555
+ */
5556
+ async authorize(userId, serverId, toolkit) {
5557
+ const mcpServerDetails = await this.get(serverId);
5558
+ const authConfigId = mcpServerDetails.authConfigIds?.[0];
5559
+ return this.toolkits.authorize(userId, toolkit, authConfigId);
5560
+ }
5561
+ /**
5562
+ * Get server URLs for an existing MCP server
5563
+ * @param {string} serverId - Server UUID
5564
+ * @param {string} userId - User ID to get server URLs for
5565
+ * @param {Object} [options] - Additional options for server configuration
5566
+ * @param {string[]} [options.limitTools] - Subset of tools to limit (from MCP config)
5567
+ * @param {boolean} [options.isChatAuth] - Whether to use chat-based authentication
5568
+ * @returns {Promise<T>} Transformed server URLs in provider-specific format
5569
+ *
5570
+ * @example
5571
+ * ```typescript
5572
+ * // Get URLs for an existing server with basic user ID
5573
+ * const urls = await composio.mcp.getServer("mcp_xyz", "hey@example.com");
5574
+ *
5575
+ * // Get URLs with additional options
5576
+ * const urls = await composio.mcp.getServer("mcp_xyz", "hey@example.com", {
5577
+ * limitTools: ["GMAIL_FETCH_EMAILS", "SLACK_SEND_MESSAGE"],
5578
+ * isChatAuth: true
5579
+ * });
5580
+ * ```
5581
+ */
5582
+ async getServer(serverId, userId, options) {
5583
+ const serverDetails = await this.get(serverId);
5584
+ if (!userId) {
5585
+ throw new ValidationError("User ID is required", {});
5586
+ }
5587
+ const toolkits = serverDetails.toolkits || [];
5588
+ const connectedAccountIds = (await Promise.all(
5589
+ toolkits.map(
5590
+ (toolkit) => this.client.connectedAccounts.list({
5591
+ user_ids: [userId],
5592
+ toolkit_slugs: [toolkit],
5593
+ statuses: ["ACTIVE"]
5594
+ }).then((res) => res.items?.[0]?.id)
5595
+ )
5596
+ )).filter(Boolean);
5378
5597
  let data;
5379
5598
  try {
5380
5599
  data = await this.client.mcp.generate.url({
5381
- user_ids: paramsResult.data.userId ? [paramsResult.data.userId] : [],
5382
- connected_account_ids: paramsResult.data.connectedAccountIds ? Object.values(paramsResult.data.connectedAccountIds) : [],
5383
- mcp_server_id: id,
5384
- managed_auth_by_composio: authOptions?.useComposioManagedAuth ?? serverDetails.managedAuthViaComposio ?? false
5600
+ user_ids: [userId],
5601
+ // @TODO(utkarsh-dixit): Add support for this later
5602
+ connected_account_ids: [],
5603
+ mcp_server_id: serverId,
5604
+ managed_auth_by_composio: options?.isChatAuth ?? serverDetails.managedAuthViaComposio ?? false
5385
5605
  });
5386
5606
  } catch (error) {
5387
5607
  throw new ValidationError("Failed to generate MCP server URL", {
@@ -5398,9 +5618,9 @@ var MCP = class {
5398
5618
  return this.wrapMcpServerResponse(
5399
5619
  camelCaseData,
5400
5620
  serverDetails.name,
5401
- paramsResult.data.connectedAccountIds ? Object.values(paramsResult.data.connectedAccountIds) : void 0,
5402
- paramsResult.data.userId ? [paramsResult.data.userId] : void 0,
5403
- paramsResult.data.connectedAccountIds ? Object.keys(paramsResult.data.connectedAccountIds) : void 0
5621
+ connectedAccountIds,
5622
+ [userId],
5623
+ toolkits
5404
5624
  );
5405
5625
  }
5406
5626
  /**
@@ -5435,8 +5655,8 @@ var MCP = class {
5435
5655
  listResponse = await this.client.mcp.list({
5436
5656
  page_no: options.page || 1,
5437
5657
  limit: options.limit || 10,
5438
- toolkits: options?.toolkits?.join(",") || "",
5439
- auth_config_ids: options?.authConfigs?.join(",") || "",
5658
+ toolkits: options?.toolkits?.join(",") || void 0,
5659
+ auth_config_ids: options?.authConfigs?.join(",") || void 0,
5440
5660
  name: options?.name
5441
5661
  });
5442
5662
  } catch (error) {
@@ -5454,7 +5674,7 @@ var MCP = class {
5454
5674
  }
5455
5675
  /**
5456
5676
  * Get details of a specific MCP server
5457
- * @param {string} id - Server UUID
5677
+ * @param {string} serverId - Server UUID
5458
5678
  * @returns {Promise<McpRetrieveResponse>} Server details
5459
5679
  *
5460
5680
  * @example
@@ -5462,16 +5682,19 @@ var MCP = class {
5462
5682
  * const serverDetails = await composio.mcp.get('server-uuid');
5463
5683
  * ```
5464
5684
  */
5465
- async get(id) {
5685
+ async get(serverId) {
5466
5686
  let retrieveResponse;
5467
5687
  try {
5468
- retrieveResponse = await this.client.mcp.retrieve(id);
5688
+ retrieveResponse = await this.client.mcp.retrieve(serverId);
5469
5689
  } catch (error) {
5470
5690
  throw new ValidationError("Failed to retrieve MCP server", {
5471
5691
  cause: error
5472
5692
  });
5473
5693
  }
5474
- const retrieveResponseResult = McpRetrieveResponseSchema.safeParse(retrieveResponse);
5694
+ const retrieveResponseResult = McpRetrieveResponseSchema.safeParse({
5695
+ ...retrieveResponse,
5696
+ mcpUrl: retrieveResponse.mcp_url
5697
+ });
5475
5698
  if (retrieveResponseResult.error) {
5476
5699
  throw new ValidationError("Failed to parse MCP server retrieve response", {
5477
5700
  cause: retrieveResponseResult.error
@@ -5481,7 +5704,7 @@ var MCP = class {
5481
5704
  }
5482
5705
  /**
5483
5706
  * Delete an MCP server
5484
- * @param {string} id - Server UUID
5707
+ * @param {string} serverId - Server UUID
5485
5708
  * @returns {Promise<McpDeleteResponse>} Deletion response
5486
5709
  *
5487
5710
  * @example
@@ -5489,10 +5712,10 @@ var MCP = class {
5489
5712
  * const result = await composio.mcp.delete('server-uuid');
5490
5713
  * ```
5491
5714
  */
5492
- async delete(id) {
5715
+ async delete(serverId) {
5493
5716
  let deleteResponse;
5494
5717
  try {
5495
- deleteResponse = await this.client.mcp.delete(id);
5718
+ deleteResponse = await this.client.mcp.delete(serverId);
5496
5719
  } catch (error) {
5497
5720
  throw new ValidationError("Failed to delete MCP server", {
5498
5721
  cause: error
@@ -5527,21 +5750,21 @@ var MCP = class {
5527
5750
  * },
5528
5751
  * ],
5529
5752
  * {
5530
- * useComposioManagedAuth: true,
5753
+ * isChatAuth: true,
5531
5754
  * }
5532
5755
  * );
5533
5756
  * ```
5534
5757
  */
5535
- async update(id, name, toolkitConfigs, authOptions) {
5758
+ async update(serverId, name, toolkitConfigs, authOptions) {
5536
5759
  this.validateInputs(toolkitConfigs, authOptions);
5537
5760
  const toolkits = toolkitConfigs.map((config) => config.toolkit);
5538
5761
  let updateResponse;
5539
5762
  try {
5540
- updateResponse = await this.client.mcp.update(id, {
5763
+ updateResponse = await this.client.mcp.update(serverId, {
5541
5764
  name,
5542
5765
  toolkits,
5543
5766
  allowed_tools: toolkitConfigs.flatMap((config) => config.allowedTools),
5544
- managed_auth_via_composio: authOptions?.useComposioManagedAuth || false
5767
+ managed_auth_via_composio: authOptions?.isChatAuth || false
5545
5768
  });
5546
5769
  } catch (error) {
5547
5770
  throw new ValidationError("Failed to update MCP server", {
@@ -5558,20 +5781,20 @@ var MCP = class {
5558
5781
  }
5559
5782
  /**
5560
5783
  * Generate URL for an MCP server
5784
+ * @param {string} serverId - Server UUID
5561
5785
  * @param {GenerateURLParams} params - Parameters for URL generation
5562
5786
  * @returns {Promise<GenerateURLResponse>} Generated URL response
5563
5787
  *
5564
5788
  * @example
5565
5789
  * ```typescript
5566
- * const urlResponse = await composio.mcp.generateUrl({
5790
+ * const urlResponse = await composio.mcp.generateUrl('server-uuid', {
5567
5791
  * userIds: ['user123'],
5568
5792
  * connectedAccountIds: ['account456'],
5569
- * mcpServerId: 'server-uuid',
5570
- * composioManagedAuth: true
5793
+ * isChatAuth: true
5571
5794
  * });
5572
5795
  * ```
5573
5796
  */
5574
- async generateUrl(params) {
5797
+ async generateUrl(serverId, params) {
5575
5798
  const paramsResult = GenerateURLParamsSchema.safeParse(params);
5576
5799
  if (paramsResult.error) {
5577
5800
  throw new ValidationError("Failed to parse generateUrl parameters", {
@@ -5581,7 +5804,7 @@ var MCP = class {
5581
5804
  let urlResponse;
5582
5805
  try {
5583
5806
  urlResponse = await this.client.mcp.generate.url({
5584
- mcp_server_id: params.mcpServerId,
5807
+ mcp_server_id: serverId,
5585
5808
  user_ids: params.userIds,
5586
5809
  connected_account_ids: params.connectedAccountIds,
5587
5810
  managed_auth_by_composio: params.composioManagedAuth
@@ -5651,6 +5874,48 @@ var MCP = class {
5651
5874
  name: serverName
5652
5875
  };
5653
5876
  }
5877
+ /**
5878
+ * Get details of a specific MCP server by name
5879
+ * @param {string} name - Server name
5880
+ * @returns {Promise<McpRetrieveResponse>} Server details
5881
+ * @throws {ValidationError} If no server found with the given name
5882
+ * @throws {ValidationError} If multiple servers found with the same name
5883
+ *
5884
+ * @example
5885
+ * ```typescript
5886
+ * const serverDetails = await composio.mcp.getByName('my-gmail-server');
5887
+ * ```
5888
+ */
5889
+ async getByName(serverName) {
5890
+ if (!serverName) {
5891
+ throw new ValidationError("Server name is required", {});
5892
+ }
5893
+ let listResponse;
5894
+ try {
5895
+ listResponse = await this.client.mcp.list({
5896
+ name: serverName,
5897
+ limit: 10
5898
+ });
5899
+ } catch (error) {
5900
+ console.error(error);
5901
+ throw new ValidationError("Failed to search MCP servers by name", {
5902
+ cause: error
5903
+ });
5904
+ }
5905
+ const listResponseResult = ComposioMcpListResponseSchema.safeParse(listResponse);
5906
+ if (listResponseResult.error) {
5907
+ throw new ValidationError("Failed to parse MCP server list response", {
5908
+ cause: listResponseResult.error
5909
+ });
5910
+ }
5911
+ const servers = listResponse.items || [];
5912
+ if (servers.length === 0) {
5913
+ throw new ValidationError(`MCP server with name '${serverName}' not found`, {
5914
+ meta: { serverName }
5915
+ });
5916
+ }
5917
+ return this.get(servers[0].id);
5918
+ }
5654
5919
  };
5655
5920
 
5656
5921
  // src/utils/sdk.ts
@@ -6190,7 +6455,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
6190
6455
  };
6191
6456
 
6192
6457
  // package.json
6193
- var version = "0.1.36-next.11";
6458
+ var version = "0.1.36-next.12";
6194
6459
 
6195
6460
  // src/models/Files.ts
6196
6461
  var Files = class {
@@ -6633,6 +6898,7 @@ var AuthScheme = class {
6633
6898
  ConnectionRequestErrorCodes,
6634
6899
  ConnectionRequestFailedError,
6635
6900
  ConnectionRequestTimeoutError,
6901
+ ConnectionStatus,
6636
6902
  ConnectionStatuses,
6637
6903
  CreateAuthConfigParamsSchema,
6638
6904
  CreateAuthConfigResponseSchema,