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

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
@@ -3988,22 +3988,24 @@ var Toolkits = class {
3988
3988
  * const connectionRequest = await composio.toolkits.authorize(userId, 'github');
3989
3989
  * ```
3990
3990
  */
3991
- async authorize(userId, toolkitSlug) {
3991
+ async authorize(userId, toolkitSlug, authConfigId) {
3992
3992
  const toolkit = await this.getToolkitBySlug(toolkitSlug);
3993
3993
  const composioAuthConfig = new AuthConfigs(this.client);
3994
- let authConfigIdToUse;
3995
- const authConfig = await composioAuthConfig.list({
3996
- toolkit: toolkitSlug
3997
- });
3998
- authConfigIdToUse = authConfig.items[0]?.id;
3994
+ let authConfigIdToUse = authConfigId;
3995
+ if (!authConfigIdToUse) {
3996
+ const authConfig = await composioAuthConfig.list({
3997
+ toolkit: toolkitSlug
3998
+ });
3999
+ authConfigIdToUse = authConfig.items[0]?.id;
4000
+ }
3999
4001
  if (!authConfigIdToUse) {
4000
4002
  if (toolkit.authConfigDetails && toolkit.authConfigDetails.length > 0) {
4001
4003
  try {
4002
- const authConfig2 = await composioAuthConfig.create(toolkitSlug, {
4004
+ const authConfig = await composioAuthConfig.create(toolkitSlug, {
4003
4005
  type: "use_composio_managed_auth",
4004
4006
  name: `${toolkit.name} Auth Config`
4005
4007
  });
4006
- authConfigIdToUse = authConfig2.id;
4008
+ authConfigIdToUse = authConfig.id;
4007
4009
  } catch (error) {
4008
4010
  if (error instanceof ComposioClient2.APIError && error.status === 400) {
4009
4011
  throw new ComposioAuthConfigNotFoundError(
@@ -4827,7 +4829,7 @@ var MCPToolkitConfigsArraySchema = z8.array(MCPToolkitConfigSchema).min(1, "At l
4827
4829
  return uniqueToolkits.size === toolkits.length;
4828
4830
  }, "Duplicate toolkits are not allowed. Each toolkit must be unique.");
4829
4831
  var MCPAuthOptionsSchema = z8.object({
4830
- useComposioManagedAuth: z8.boolean().optional()
4832
+ isChatAuth: z8.boolean().optional()
4831
4833
  });
4832
4834
  var MCPGetServerParamsSchema = z8.object({
4833
4835
  userId: z8.string().min(1, "User ID cannot be empty").optional(),
@@ -4845,7 +4847,7 @@ var MCPGetServerParamsSchema = z8.object({
4845
4847
  var MCPGenerateURLParamsSchema = z8.object({
4846
4848
  userIds: z8.array(z8.string()).optional(),
4847
4849
  connectedAccountIds: z8.array(z8.string()).optional(),
4848
- useComposioManagedAuth: z8.boolean().optional()
4850
+ isChatAuth: z8.boolean().optional()
4849
4851
  });
4850
4852
  var ComposioGenerateURLParamsSchema = z8.object({
4851
4853
  user_ids: z8.array(z8.string()).optional(),
@@ -4899,6 +4901,11 @@ var MCPServerUpdateParamsSchema = z8.object({
4899
4901
  allowedTools: z8.array(z8.string()).optional().describe("Updated list of allowed tools")
4900
4902
  });
4901
4903
  var MCPServerCreateResponseSchema = MCPServerSchema;
4904
+ var ConnectionStatus = /* @__PURE__ */ ((ConnectionStatus2) => {
4905
+ ConnectionStatus2["CONNECTED"] = "CONNECTED";
4906
+ ConnectionStatus2["DISCONNECTED"] = "DISCONNECTED";
4907
+ return ConnectionStatus2;
4908
+ })(ConnectionStatus || {});
4902
4909
  var CustomCreateResponseSchema = z8.object({
4903
4910
  id: z8.string().min(1, "Server ID cannot be empty"),
4904
4911
  name: z8.string().min(1, "Server name cannot be empty"),
@@ -4943,7 +4950,14 @@ var McpRetrieveResponseSchema = z8.object({
4943
4950
  status: z8.string().optional(),
4944
4951
  toolkits: z8.array(z8.string()).optional(),
4945
4952
  tools: z8.array(z8.string()).optional(),
4946
- managedAuthViaComposio: z8.boolean().optional()
4953
+ managedAuthViaComposio: z8.boolean().optional(),
4954
+ authConfigIds: z8.array(z8.string()).optional(),
4955
+ mcpUrl: z8.string(),
4956
+ commands: z8.object({
4957
+ claude: z8.string(),
4958
+ cursor: z8.string(),
4959
+ windsurf: z8.string()
4960
+ })
4947
4961
  });
4948
4962
  var ComposioMcpRetrieveResponseSchema = z8.object({
4949
4963
  id: z8.string().min(1, "Server ID cannot be empty"),
@@ -5026,8 +5040,11 @@ function transformMcpRetrieveResponse(response) {
5026
5040
  updatedAt: response.updated_at,
5027
5041
  status: response.status,
5028
5042
  toolkits: response.toolkits,
5029
- tools: response.tools,
5030
- managedAuthViaComposio: response.managed_auth_via_composio
5043
+ tools: response.allowed_tools,
5044
+ managedAuthViaComposio: response.managed_auth_via_composio,
5045
+ authConfigIds: response.auth_config_ids,
5046
+ mcpUrl: response.mcp_url,
5047
+ commands: response.commands
5031
5048
  });
5032
5049
  if (!result.success) {
5033
5050
  throw new ValidationError("Failed to parse MCP retrieve response", {
@@ -5084,9 +5101,11 @@ function transformMcpGenerateUrlResponse(response) {
5084
5101
  var MCP = class {
5085
5102
  client;
5086
5103
  provider;
5104
+ toolkits;
5087
5105
  constructor(client, provider) {
5088
5106
  this.client = client;
5089
5107
  this.provider = provider;
5108
+ this.toolkits = new Toolkits(client);
5090
5109
  telemetry.instrument(this);
5091
5110
  }
5092
5111
  /**
@@ -5114,47 +5133,100 @@ var MCP = class {
5114
5133
  }
5115
5134
  /**
5116
5135
  * Create a new MCP server
5117
- * @param {string} name - Unique name for the MCP server
5118
- * @param {MCPToolkitConfig[]} toolkitConfigs - Array of toolkit configurations
5119
- * @param {MCPAuthOptions} [authOptions] - Authentication configuration options
5136
+ * @param {Object} params - Parameters for creating the MCP server
5137
+ * @param {Array} params.authConfig - Array of auth configurations with id and allowed tools
5138
+ * @param {Object} params.options - Server creation options
5139
+ * @param {string} params.options.name - Unique name for the MCP server
5140
+ * @param {boolean} [params.options.isChatAuth] - Whether to use chat-based authentication
5120
5141
  * @returns {Promise<McpServerCreateResponse<T>>} Created server details with instance getter
5121
5142
  *
5122
5143
  * @example
5123
5144
  * ```typescript
5124
- * const server = await composio.mcp.create(
5125
- * "personal-mcp-server",
5126
- * [
5145
+ * const server = await composio.mcp.create("personal-mcp-server", [
5127
5146
  * {
5128
- * toolkit: "GMAIL",
5129
- * authConfigId: "ac_sdhkjfhjksdk",
5130
- * allowedTools: ["GMAIL_FETCH_EMAILS"],
5131
- * },
5147
+ * authConfigId: "ac_xyz",
5148
+ * allowedTools: ["GMAIL_FETCH_EMAILS", "SLACK_SEND_MESSAGE"]
5149
+ * }
5132
5150
  * ],
5133
- * { useComposioManagedAuth: true },
5134
- * );
5135
- *
5136
- * // Option 1: Use convenience method on response
5137
- * const urls = await server.getServer({
5138
- * connectedAccountIds: { gmail: "account_id" }
5151
+ * {
5152
+ * isChatAuth: true
5153
+ * }
5139
5154
  * });
5140
5155
  *
5141
- * // Option 2: Use standalone method later
5142
- * const urlsLater = await composio.mcp.getServer(server.id, {
5143
- * connectedAccountIds: { gmail: "account_id" }
5156
+ * // Use convenience method on response
5157
+ * const urls = await server.getServer({
5158
+ * userId: "user123"
5144
5159
  * });
5145
5160
  * ```
5146
5161
  */
5147
- async create(name, toolkitConfigs, authOptions) {
5148
- this.validateInputs(toolkitConfigs, authOptions);
5149
- const toolkits = toolkitConfigs.map((config) => config.toolkit);
5162
+ async create(name, serverConfig, options) {
5163
+ if (!serverConfig || serverConfig.length === 0) {
5164
+ throw new ValidationError("At least one auth config is required", {});
5165
+ }
5166
+ if (!name) {
5167
+ throw new ValidationError("Server name is required", {});
5168
+ }
5169
+ try {
5170
+ const mcpServer = await this.getByName(name);
5171
+ const authConfigs = mcpServer.authConfigIds?.sort();
5172
+ const sortedCurrentAuthConfigs = serverConfig.map((config) => config.authConfigId).sort();
5173
+ if (authConfigs.length > 0 && !authConfigs.every((config, index) => config === sortedCurrentAuthConfigs[index])) {
5174
+ throw new ValidationError(
5175
+ "MCP server with this name already exists with different auth configs",
5176
+ {
5177
+ meta: { serverName: name }
5178
+ }
5179
+ );
5180
+ }
5181
+ const tools = mcpServer.tools?.sort();
5182
+ const sortedCurrentTools = serverConfig.flatMap((config) => config.allowedTools).sort();
5183
+ console.log(tools, sortedCurrentTools, "tools");
5184
+ if (tools?.length > 0 && !tools.every((tool, index) => tool === sortedCurrentTools[index])) {
5185
+ throw new ValidationError("MCP server with this name already exists with different tools", {
5186
+ meta: { serverName: name }
5187
+ });
5188
+ }
5189
+ const authConfigDetails2 = await Promise.all(
5190
+ serverConfig.map((config) => this.client.authConfigs.retrieve(config.authConfigId))
5191
+ );
5192
+ const toolkits2 = authConfigDetails2.map((config) => config.toolkit.slug);
5193
+ const camelCaseResponse2 = transformMcpCreateResponse({
5194
+ id: mcpServer.id,
5195
+ name: mcpServer.name,
5196
+ auth_config_ids: serverConfig.map((config) => config.authConfigId),
5197
+ allowed_tools: serverConfig.flatMap((config) => config.allowedTools),
5198
+ managed_auth_via_composio: options.isChatAuth || false,
5199
+ commands: mcpServer.commands,
5200
+ created_at: mcpServer.createdAt,
5201
+ updated_at: mcpServer.updatedAt,
5202
+ mcp_url: mcpServer.mcpUrl
5203
+ });
5204
+ return {
5205
+ ...camelCaseResponse2,
5206
+ toolkits: toolkits2,
5207
+ getServer: async (params) => {
5208
+ return this.getServer(camelCaseResponse2.id, params.userId || "", {
5209
+ isChatAuth: options.isChatAuth
5210
+ });
5211
+ }
5212
+ };
5213
+ } catch (error) {
5214
+ if (error instanceof ValidationError && !error.message.includes("not found")) {
5215
+ throw error;
5216
+ }
5217
+ }
5218
+ const authConfigDetails = await Promise.all(
5219
+ serverConfig.map((config) => this.client.authConfigs.retrieve(config.authConfigId))
5220
+ );
5221
+ const toolkits = authConfigDetails.map((config) => config.toolkit.slug);
5150
5222
  let mcpServerCreatedResponse;
5151
5223
  try {
5152
5224
  mcpServerCreatedResponse = await this.client.mcp.custom.create({
5153
5225
  name,
5154
5226
  toolkits,
5155
- custom_tools: toolkitConfigs.flatMap((config) => config.allowedTools),
5156
- managed_auth_via_composio: authOptions?.useComposioManagedAuth || false,
5157
- auth_config_ids: toolkitConfigs.map((config) => config.authConfigId)
5227
+ custom_tools: serverConfig.flatMap((config) => config.allowedTools),
5228
+ managed_auth_via_composio: options.isChatAuth || false,
5229
+ auth_config_ids: serverConfig.map((config) => config.authConfigId)
5158
5230
  });
5159
5231
  } catch (error) {
5160
5232
  throw new ValidationError("Failed to create MCP server", {
@@ -5172,53 +5244,200 @@ var MCP = class {
5172
5244
  ...camelCaseResponse,
5173
5245
  toolkits,
5174
5246
  getServer: async (params) => {
5175
- return this.getServer(camelCaseResponse.id, params, authOptions);
5247
+ return this.getServer(camelCaseResponse.id, params.userId || "", {
5248
+ isChatAuth: options.isChatAuth
5249
+ });
5176
5250
  }
5177
5251
  };
5178
5252
  }
5179
5253
  /**
5180
- * Get server URLs for an existing MCP server
5181
- * @param {string} id - Server UUID
5182
- * @param {MCPGetServerParams} params - Parameters for getting server URLs
5183
- * @param {MCPAuthOptions} [authOptions] - Authentication options (optional, will use server's default if not provided)
5184
- * @returns {Promise<T>} Transformed server URLs in provider-specific format
5254
+ * Get the connection status of a user for an MCP server
5255
+ *
5256
+ * Checks whether a user has the necessary connected accounts to use all toolkits
5257
+ * configured in the specified MCP server. Returns both overall connection status
5258
+ * and individual status for each toolkit.
5259
+ *
5260
+ * @param {Object} params - Parameters for checking connection status
5261
+ * @param {string} params.id - The UUID of the MCP server to check
5262
+ * @param {string} params.userId - The ID of the user to check connection status for
5263
+ * @returns {Promise<McpUserConnectionStatus>} Complete connection status including:
5264
+ * - `type`: Overall status (CONNECTED if all toolkits are connected, DISCONNECTED otherwise)
5265
+ * - `connected`: Boolean indicating if user can use the MCP server
5266
+ * - `connectedToolkits`: Record mapping each toolkit name to its individual connection status
5267
+ *
5268
+ * @throws {ValidationError} When MCP server has no toolkits configured
5269
+ * @throws {ValidationError} When MCP server retrieval fails
5185
5270
  *
5186
5271
  * @example
5187
5272
  * ```typescript
5188
- * // Get URLs for an existing server
5189
- * const urls = await composio.mcp.getServer("server-id", {
5190
- * connectedAccountIds: {
5191
- * gmail: "connected_account_id"
5273
+ * // Check if user can access an MCP server with Gmail and Slack toolkits
5274
+ * const connectionStatus = await composio.mcp.getUserConnectionStatus('user123', 'mcp-server-uuid');
5275
+ *
5276
+ * if (connectionStatus.connected) {
5277
+ * console.log('User can access all required toolkits');
5278
+ * // connectionStatus.type === ConnectionStatus.CONNECTED
5279
+ * } else {
5280
+ * console.log('User is missing some toolkit connections');
5281
+ * // Check individual toolkit statuses
5282
+ * Object.entries(connectionStatus.connectedToolkits).forEach(([toolkit, status]) => {
5283
+ * if (!status.connected) {
5284
+ * console.log(`Missing connection for toolkit: ${toolkit}`);
5285
+ * }
5286
+ * });
5287
+ * }
5288
+ * ```
5289
+ *
5290
+ * @example
5291
+ * ```typescript
5292
+ * // Example response when user has Gmail connected but missing Slack
5293
+ * {
5294
+ * type: ConnectionStatus.DISCONNECTED,
5295
+ * connected: false,
5296
+ * connectedToolkits: {
5297
+ * GMAIL: {
5298
+ * type: ConnectionStatus.CONNECTED,
5299
+ * connected: true,
5300
+ * toolkit: 'GMAIL',
5301
+ * connectedAccountId: 'conn_gmail_123'
5302
+ * },
5303
+ * SLACK: {
5304
+ * type: ConnectionStatus.DISCONNECTED,
5305
+ * connected: false,
5306
+ * toolkit: 'SLACK'
5307
+ * }
5192
5308
  * }
5193
- * });
5309
+ * }
5194
5310
  * ```
5195
5311
  */
5196
- async getServer(id, params, authOptions) {
5197
- const serverDetails = await this.get(id);
5198
- const paramsResult = MCPGetServerParamsSchema.safeParse(params);
5199
- if (paramsResult.error) {
5200
- throw new ValidationError("Failed to parse get server parameters", {
5201
- cause: paramsResult.error
5312
+ async getUserConnectionStatus(userId, serverId) {
5313
+ const serverDetails = await this.get(serverId);
5314
+ if (!serverDetails.toolkits || serverDetails.toolkits.length === 0) {
5315
+ throw new ValidationError("MCP server has no toolkits configured", {
5316
+ meta: { serverId }
5202
5317
  });
5203
5318
  }
5204
- const toolkits = serverDetails.toolkits || [];
5205
- if (paramsResult.data.connectedAccountIds) {
5206
- const providedToolkits = Object.keys(paramsResult.data.connectedAccountIds);
5207
- const invalidToolkits = providedToolkits.filter((toolkit) => !toolkits.includes(toolkit));
5208
- if (invalidToolkits.length > 0) {
5209
- throw new ValidationError(
5210
- `Invalid toolkits provided: ${invalidToolkits.join(", ")}. Available toolkits are: ${toolkits.join(", ")}`,
5211
- {}
5212
- );
5319
+ const connectedAccounts = await this.client.connectedAccounts.list({
5320
+ user_ids: [userId],
5321
+ toolkit_slugs: serverDetails.toolkits.map((toolkit) => toolkit.toLowerCase()),
5322
+ statuses: ["ACTIVE"]
5323
+ });
5324
+ const connectedAccountsByToolkit = /* @__PURE__ */ new Map();
5325
+ connectedAccounts.items?.forEach((account) => {
5326
+ connectedAccountsByToolkit.set(account.toolkit.slug.toLowerCase(), account.id);
5327
+ });
5328
+ const connectedToolkits = {};
5329
+ let allToolkitsConnected = true;
5330
+ for (const toolkit of serverDetails.toolkits) {
5331
+ const connectedAccountId = connectedAccountsByToolkit.get(toolkit.toLowerCase());
5332
+ if (connectedAccountId) {
5333
+ connectedToolkits[toolkit] = {
5334
+ type: "CONNECTED" /* CONNECTED */,
5335
+ connected: true,
5336
+ toolkit,
5337
+ connectedAccountId
5338
+ };
5339
+ } else {
5340
+ connectedToolkits[toolkit] = {
5341
+ type: "DISCONNECTED" /* DISCONNECTED */,
5342
+ connected: false,
5343
+ toolkit
5344
+ };
5345
+ allToolkitsConnected = false;
5213
5346
  }
5214
5347
  }
5348
+ if (allToolkitsConnected) {
5349
+ return {
5350
+ type: "CONNECTED" /* CONNECTED */,
5351
+ connected: true,
5352
+ connectedToolkits
5353
+ };
5354
+ } else {
5355
+ return {
5356
+ type: "DISCONNECTED" /* DISCONNECTED */,
5357
+ connected: false,
5358
+ connectedToolkits
5359
+ };
5360
+ }
5361
+ }
5362
+ /**
5363
+ * Get the connection parameters for a toolkit
5364
+ * @param {string} serverId - The UUID of the MCP server
5365
+ * @param {string} toolkit - The toolkit to get connection parameters for
5366
+ * @returns {Promise<ToolkitAuthFieldsResponse>} Connection parameters for the toolkit
5367
+ */
5368
+ async getConnectionParams(serverId, toolkit) {
5369
+ const mcpServerDetails = await this.get(serverId);
5370
+ const authConfigs = mcpServerDetails.authConfigIds ? await Promise.all(
5371
+ mcpServerDetails.authConfigIds.map((id) => this.client.authConfigs.retrieve(id))
5372
+ ) : [];
5373
+ const authConfig = authConfigs.find((config) => config.toolkit.slug === toolkit);
5374
+ if (!authConfig) {
5375
+ throw new ValidationError("Auth config not found", {
5376
+ meta: { serverId, toolkit }
5377
+ });
5378
+ }
5379
+ const connectionParams = await this.toolkits.getConnectedAccountInitiationFields(
5380
+ toolkit,
5381
+ authConfig.auth_scheme
5382
+ );
5383
+ return connectionParams;
5384
+ }
5385
+ /**
5386
+ * Authorize a user for a toolkit
5387
+ * @param {string} serverId - The UUID of the MCP server
5388
+ * @param {string} userId - The ID of the user to authorize
5389
+ * @param {string} toolkit - The toolkit to authorize
5390
+ * @returns {Promise<ConnectionRequest>} Connection request for the toolkit
5391
+ */
5392
+ async authorize(userId, serverId, toolkit) {
5393
+ const mcpServerDetails = await this.get(serverId);
5394
+ const authConfigId = mcpServerDetails.authConfigIds?.[0];
5395
+ return this.toolkits.authorize(userId, toolkit, authConfigId);
5396
+ }
5397
+ /**
5398
+ * Get server URLs for an existing MCP server
5399
+ * @param {string} serverId - Server UUID
5400
+ * @param {string} userId - User ID to get server URLs for
5401
+ * @param {Object} [options] - Additional options for server configuration
5402
+ * @param {string[]} [options.limitTools] - Subset of tools to limit (from MCP config)
5403
+ * @param {boolean} [options.isChatAuth] - Whether to use chat-based authentication
5404
+ * @returns {Promise<T>} Transformed server URLs in provider-specific format
5405
+ *
5406
+ * @example
5407
+ * ```typescript
5408
+ * // Get URLs for an existing server with basic user ID
5409
+ * const urls = await composio.mcp.getServer("mcp_xyz", "hey@example.com");
5410
+ *
5411
+ * // Get URLs with additional options
5412
+ * const urls = await composio.mcp.getServer("mcp_xyz", "hey@example.com", {
5413
+ * limitTools: ["GMAIL_FETCH_EMAILS", "SLACK_SEND_MESSAGE"],
5414
+ * isChatAuth: true
5415
+ * });
5416
+ * ```
5417
+ */
5418
+ async getServer(serverId, userId, options) {
5419
+ const serverDetails = await this.get(serverId);
5420
+ if (!userId) {
5421
+ throw new ValidationError("User ID is required", {});
5422
+ }
5423
+ const toolkits = serverDetails.toolkits || [];
5424
+ const connectedAccountIds = (await Promise.all(
5425
+ toolkits.map(
5426
+ (toolkit) => this.client.connectedAccounts.list({
5427
+ user_ids: [userId],
5428
+ toolkit_slugs: [toolkit],
5429
+ statuses: ["ACTIVE"]
5430
+ }).then((res) => res.items?.[0]?.id)
5431
+ )
5432
+ )).filter(Boolean);
5215
5433
  let data;
5216
5434
  try {
5217
5435
  data = await this.client.mcp.generate.url({
5218
- user_ids: paramsResult.data.userId ? [paramsResult.data.userId] : [],
5219
- connected_account_ids: paramsResult.data.connectedAccountIds ? Object.values(paramsResult.data.connectedAccountIds) : [],
5220
- mcp_server_id: id,
5221
- managed_auth_by_composio: authOptions?.useComposioManagedAuth ?? serverDetails.managedAuthViaComposio ?? false
5436
+ user_ids: [userId],
5437
+ // @TODO(utkarsh-dixit): Add support for this later
5438
+ connected_account_ids: [],
5439
+ mcp_server_id: serverId,
5440
+ managed_auth_by_composio: options?.isChatAuth ?? serverDetails.managedAuthViaComposio ?? false
5222
5441
  });
5223
5442
  } catch (error) {
5224
5443
  throw new ValidationError("Failed to generate MCP server URL", {
@@ -5235,9 +5454,9 @@ var MCP = class {
5235
5454
  return this.wrapMcpServerResponse(
5236
5455
  camelCaseData,
5237
5456
  serverDetails.name,
5238
- paramsResult.data.connectedAccountIds ? Object.values(paramsResult.data.connectedAccountIds) : void 0,
5239
- paramsResult.data.userId ? [paramsResult.data.userId] : void 0,
5240
- paramsResult.data.connectedAccountIds ? Object.keys(paramsResult.data.connectedAccountIds) : void 0
5457
+ connectedAccountIds,
5458
+ [userId],
5459
+ toolkits
5241
5460
  );
5242
5461
  }
5243
5462
  /**
@@ -5272,8 +5491,8 @@ var MCP = class {
5272
5491
  listResponse = await this.client.mcp.list({
5273
5492
  page_no: options.page || 1,
5274
5493
  limit: options.limit || 10,
5275
- toolkits: options?.toolkits?.join(",") || "",
5276
- auth_config_ids: options?.authConfigs?.join(",") || "",
5494
+ toolkits: options?.toolkits?.join(",") || void 0,
5495
+ auth_config_ids: options?.authConfigs?.join(",") || void 0,
5277
5496
  name: options?.name
5278
5497
  });
5279
5498
  } catch (error) {
@@ -5291,7 +5510,7 @@ var MCP = class {
5291
5510
  }
5292
5511
  /**
5293
5512
  * Get details of a specific MCP server
5294
- * @param {string} id - Server UUID
5513
+ * @param {string} serverId - Server UUID
5295
5514
  * @returns {Promise<McpRetrieveResponse>} Server details
5296
5515
  *
5297
5516
  * @example
@@ -5299,16 +5518,19 @@ var MCP = class {
5299
5518
  * const serverDetails = await composio.mcp.get('server-uuid');
5300
5519
  * ```
5301
5520
  */
5302
- async get(id) {
5521
+ async get(serverId) {
5303
5522
  let retrieveResponse;
5304
5523
  try {
5305
- retrieveResponse = await this.client.mcp.retrieve(id);
5524
+ retrieveResponse = await this.client.mcp.retrieve(serverId);
5306
5525
  } catch (error) {
5307
5526
  throw new ValidationError("Failed to retrieve MCP server", {
5308
5527
  cause: error
5309
5528
  });
5310
5529
  }
5311
- const retrieveResponseResult = McpRetrieveResponseSchema.safeParse(retrieveResponse);
5530
+ const retrieveResponseResult = McpRetrieveResponseSchema.safeParse({
5531
+ ...retrieveResponse,
5532
+ mcpUrl: retrieveResponse.mcp_url
5533
+ });
5312
5534
  if (retrieveResponseResult.error) {
5313
5535
  throw new ValidationError("Failed to parse MCP server retrieve response", {
5314
5536
  cause: retrieveResponseResult.error
@@ -5318,7 +5540,7 @@ var MCP = class {
5318
5540
  }
5319
5541
  /**
5320
5542
  * Delete an MCP server
5321
- * @param {string} id - Server UUID
5543
+ * @param {string} serverId - Server UUID
5322
5544
  * @returns {Promise<McpDeleteResponse>} Deletion response
5323
5545
  *
5324
5546
  * @example
@@ -5326,10 +5548,10 @@ var MCP = class {
5326
5548
  * const result = await composio.mcp.delete('server-uuid');
5327
5549
  * ```
5328
5550
  */
5329
- async delete(id) {
5551
+ async delete(serverId) {
5330
5552
  let deleteResponse;
5331
5553
  try {
5332
- deleteResponse = await this.client.mcp.delete(id);
5554
+ deleteResponse = await this.client.mcp.delete(serverId);
5333
5555
  } catch (error) {
5334
5556
  throw new ValidationError("Failed to delete MCP server", {
5335
5557
  cause: error
@@ -5364,21 +5586,21 @@ var MCP = class {
5364
5586
  * },
5365
5587
  * ],
5366
5588
  * {
5367
- * useComposioManagedAuth: true,
5589
+ * isChatAuth: true,
5368
5590
  * }
5369
5591
  * );
5370
5592
  * ```
5371
5593
  */
5372
- async update(id, name, toolkitConfigs, authOptions) {
5594
+ async update(serverId, name, toolkitConfigs, authOptions) {
5373
5595
  this.validateInputs(toolkitConfigs, authOptions);
5374
5596
  const toolkits = toolkitConfigs.map((config) => config.toolkit);
5375
5597
  let updateResponse;
5376
5598
  try {
5377
- updateResponse = await this.client.mcp.update(id, {
5599
+ updateResponse = await this.client.mcp.update(serverId, {
5378
5600
  name,
5379
5601
  toolkits,
5380
5602
  allowed_tools: toolkitConfigs.flatMap((config) => config.allowedTools),
5381
- managed_auth_via_composio: authOptions?.useComposioManagedAuth || false
5603
+ managed_auth_via_composio: authOptions?.isChatAuth || false
5382
5604
  });
5383
5605
  } catch (error) {
5384
5606
  throw new ValidationError("Failed to update MCP server", {
@@ -5395,20 +5617,20 @@ var MCP = class {
5395
5617
  }
5396
5618
  /**
5397
5619
  * Generate URL for an MCP server
5620
+ * @param {string} serverId - Server UUID
5398
5621
  * @param {GenerateURLParams} params - Parameters for URL generation
5399
5622
  * @returns {Promise<GenerateURLResponse>} Generated URL response
5400
5623
  *
5401
5624
  * @example
5402
5625
  * ```typescript
5403
- * const urlResponse = await composio.mcp.generateUrl({
5626
+ * const urlResponse = await composio.mcp.generateUrl('server-uuid', {
5404
5627
  * userIds: ['user123'],
5405
5628
  * connectedAccountIds: ['account456'],
5406
- * mcpServerId: 'server-uuid',
5407
- * composioManagedAuth: true
5629
+ * isChatAuth: true
5408
5630
  * });
5409
5631
  * ```
5410
5632
  */
5411
- async generateUrl(params) {
5633
+ async generateUrl(serverId, params) {
5412
5634
  const paramsResult = GenerateURLParamsSchema.safeParse(params);
5413
5635
  if (paramsResult.error) {
5414
5636
  throw new ValidationError("Failed to parse generateUrl parameters", {
@@ -5418,7 +5640,7 @@ var MCP = class {
5418
5640
  let urlResponse;
5419
5641
  try {
5420
5642
  urlResponse = await this.client.mcp.generate.url({
5421
- mcp_server_id: params.mcpServerId,
5643
+ mcp_server_id: serverId,
5422
5644
  user_ids: params.userIds,
5423
5645
  connected_account_ids: params.connectedAccountIds,
5424
5646
  managed_auth_by_composio: params.composioManagedAuth
@@ -5488,6 +5710,48 @@ var MCP = class {
5488
5710
  name: serverName
5489
5711
  };
5490
5712
  }
5713
+ /**
5714
+ * Get details of a specific MCP server by name
5715
+ * @param {string} name - Server name
5716
+ * @returns {Promise<McpRetrieveResponse>} Server details
5717
+ * @throws {ValidationError} If no server found with the given name
5718
+ * @throws {ValidationError} If multiple servers found with the same name
5719
+ *
5720
+ * @example
5721
+ * ```typescript
5722
+ * const serverDetails = await composio.mcp.getByName('my-gmail-server');
5723
+ * ```
5724
+ */
5725
+ async getByName(serverName) {
5726
+ if (!serverName) {
5727
+ throw new ValidationError("Server name is required", {});
5728
+ }
5729
+ let listResponse;
5730
+ try {
5731
+ listResponse = await this.client.mcp.list({
5732
+ name: serverName,
5733
+ limit: 10
5734
+ });
5735
+ } catch (error) {
5736
+ console.error(error);
5737
+ throw new ValidationError("Failed to search MCP servers by name", {
5738
+ cause: error
5739
+ });
5740
+ }
5741
+ const listResponseResult = ComposioMcpListResponseSchema.safeParse(listResponse);
5742
+ if (listResponseResult.error) {
5743
+ throw new ValidationError("Failed to parse MCP server list response", {
5744
+ cause: listResponseResult.error
5745
+ });
5746
+ }
5747
+ const servers = listResponse.items || [];
5748
+ if (servers.length === 0) {
5749
+ throw new ValidationError(`MCP server with name '${serverName}' not found`, {
5750
+ meta: { serverName }
5751
+ });
5752
+ }
5753
+ return this.get(servers[0].id);
5754
+ }
5491
5755
  };
5492
5756
 
5493
5757
  // src/utils/sdk.ts
@@ -6027,7 +6291,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
6027
6291
  };
6028
6292
 
6029
6293
  // package.json
6030
- var version = "0.1.36-next.11";
6294
+ var version = "0.1.36-next.13";
6031
6295
 
6032
6296
  // src/models/Files.ts
6033
6297
  var Files = class {
@@ -6469,6 +6733,7 @@ export {
6469
6733
  ConnectionRequestErrorCodes,
6470
6734
  ConnectionRequestFailedError,
6471
6735
  ConnectionRequestTimeoutError,
6736
+ ConnectionStatus,
6472
6737
  ConnectionStatuses,
6473
6738
  CreateAuthConfigParamsSchema,
6474
6739
  CreateAuthConfigResponseSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@composio/core",
3
- "version": "0.1.36-next.11",
3
+ "version": "0.1.36-next.13",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -32,11 +32,11 @@
32
32
  "tsx": "^4.19.3",
33
33
  "typescript": "^5.8.3",
34
34
  "vitest": "^3.1.4",
35
- "@composio/json-schema-to-zod": "0.1.10-next.4"
35
+ "@composio/json-schema-to-zod": "0.1.10-next.5"
36
36
  },
37
37
  "dependencies": {
38
38
  "@composio/client": "0.1.0-alpha.27",
39
- "@composio/json-schema-to-zod": "0.1.10-next.4",
39
+ "@composio/json-schema-to-zod": "0.1.10-next.5",
40
40
  "@types/json-schema": "^7.0.15",
41
41
  "chalk": "^4.1.2",
42
42
  "openai": "^4.94.0",