@composio/core 0.1.52 → 0.1.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +731 -145
- package/dist/index.d.cts +919 -47
- package/dist/index.d.ts +919 -47
- package/dist/index.js +731 -145
- package/package.json +13 -11
package/dist/index.js
CHANGED
|
@@ -35,7 +35,8 @@ var AuthSchemeTypes = {
|
|
|
35
35
|
GOOGLE_SERVICE_ACCOUNT: "GOOGLE_SERVICE_ACCOUNT",
|
|
36
36
|
NO_AUTH: "NO_AUTH",
|
|
37
37
|
BASIC_WITH_JWT: "BASIC_WITH_JWT",
|
|
38
|
-
CALCOM_AUTH: "CALCOM_AUTH"
|
|
38
|
+
CALCOM_AUTH: "CALCOM_AUTH",
|
|
39
|
+
SERVICE_ACCOUNT: "SERVICE_ACCOUNT"
|
|
39
40
|
};
|
|
40
41
|
var AuthConfigCreationToolAccessConfigSchema = z.object({
|
|
41
42
|
toolsForConnectedAccountCreation: z.array(z.string()).optional()
|
|
@@ -54,7 +55,8 @@ var AuthSchemeEnum = z.enum([
|
|
|
54
55
|
"GOOGLE_SERVICE_ACCOUNT",
|
|
55
56
|
"NO_AUTH",
|
|
56
57
|
"BASIC_WITH_JWT",
|
|
57
|
-
"CALCOM_AUTH"
|
|
58
|
+
"CALCOM_AUTH",
|
|
59
|
+
"SERVICE_ACCOUNT"
|
|
58
60
|
]);
|
|
59
61
|
var CreateCustomAuthConfigParamsSchema = z.object({
|
|
60
62
|
type: z.literal("use_custom_auth"),
|
|
@@ -3298,8 +3300,10 @@ var ToolKitItemSchema = z5.object({
|
|
|
3298
3300
|
});
|
|
3299
3301
|
var ToolKitListResponseSchema = z5.array(ToolKitItemSchema);
|
|
3300
3302
|
var ToolkitAuthFieldSchema = z5.object({
|
|
3301
|
-
|
|
3303
|
+
description: z5.string(),
|
|
3302
3304
|
displayName: z5.string(),
|
|
3305
|
+
required: z5.boolean(),
|
|
3306
|
+
name: z5.string(),
|
|
3303
3307
|
type: z5.string(),
|
|
3304
3308
|
default: z5.string().nullable().optional()
|
|
3305
3309
|
});
|
|
@@ -5169,24 +5173,506 @@ var Triggers = class {
|
|
|
5169
5173
|
}
|
|
5170
5174
|
};
|
|
5171
5175
|
|
|
5176
|
+
// src/types/mcp.experimental.types.ts
|
|
5177
|
+
import z8 from "zod";
|
|
5178
|
+
var MCPServerInstanceSchema = z8.object({
|
|
5179
|
+
id: z8.string(),
|
|
5180
|
+
name: z8.string(),
|
|
5181
|
+
type: z8.literal("streamable_http"),
|
|
5182
|
+
url: z8.string(),
|
|
5183
|
+
userId: z8.string(),
|
|
5184
|
+
allowedTools: z8.array(z8.string()),
|
|
5185
|
+
authConfigs: z8.array(z8.string())
|
|
5186
|
+
});
|
|
5187
|
+
var MCPConfigToolkitsSchema = z8.object({
|
|
5188
|
+
toolkit: z8.string().describe("Id of the toolkit").optional(),
|
|
5189
|
+
authConfigId: z8.string().describe("Id of the auth config").optional()
|
|
5190
|
+
});
|
|
5191
|
+
var MCPConfigCreationParamsSchema = z8.object({
|
|
5192
|
+
toolkits: z8.array(z8.union([MCPConfigToolkitsSchema, z8.string()])),
|
|
5193
|
+
allowedTools: z8.array(z8.string()).optional(),
|
|
5194
|
+
manuallyManageConnections: z8.boolean().default(false).optional().describe(
|
|
5195
|
+
`Whether to manually manage accounts. If true, you need to manage accounts manually connect user accounts.
|
|
5196
|
+
If set to false, composio will inject account maangement tools into your mcp server for agents to request and authenticate accounts.
|
|
5197
|
+
defaults to false`
|
|
5198
|
+
)
|
|
5199
|
+
});
|
|
5200
|
+
var MCPConfigResponseSchema = z8.object({
|
|
5201
|
+
/**
|
|
5202
|
+
* Unique identifier for the newly created custom MCP server
|
|
5203
|
+
*/
|
|
5204
|
+
id: z8.string(),
|
|
5205
|
+
/**
|
|
5206
|
+
* Human-readable name of the custom MCP server
|
|
5207
|
+
*/
|
|
5208
|
+
name: z8.string(),
|
|
5209
|
+
/**
|
|
5210
|
+
* List of tool identifiers that are enabled for this server
|
|
5211
|
+
*/
|
|
5212
|
+
allowedTools: z8.array(z8.string()),
|
|
5213
|
+
/**
|
|
5214
|
+
* ID references to the auth configurations used by this server
|
|
5215
|
+
*/
|
|
5216
|
+
authConfigIds: z8.array(z8.string()),
|
|
5217
|
+
/**
|
|
5218
|
+
* Set of command line instructions for connecting various clients to this MCP server
|
|
5219
|
+
*/
|
|
5220
|
+
commands: z8.object({
|
|
5221
|
+
/**
|
|
5222
|
+
* Command line instruction for Claude client setup
|
|
5223
|
+
*/
|
|
5224
|
+
claude: z8.string(),
|
|
5225
|
+
/**
|
|
5226
|
+
* Command line instruction for Cursor client setup
|
|
5227
|
+
*/
|
|
5228
|
+
cursor: z8.string(),
|
|
5229
|
+
/**
|
|
5230
|
+
* Command line instruction for Windsurf client setup
|
|
5231
|
+
*/
|
|
5232
|
+
windsurf: z8.string()
|
|
5233
|
+
}),
|
|
5234
|
+
/**
|
|
5235
|
+
* URL endpoint for establishing Server-Sent Events (SSE) connection to this MCP server
|
|
5236
|
+
*/
|
|
5237
|
+
MCPUrl: z8.string()
|
|
5238
|
+
});
|
|
5239
|
+
var MCPGetInstanceParamsSchema = z8.object({
|
|
5240
|
+
manuallyManageConnections: z8.boolean().default(false).optional().describe(
|
|
5241
|
+
`Whether to manually manage accounts. If true, you need to manage accounts manually connect user accounts.
|
|
5242
|
+
If set to false, composio will inject account maangement tools into your mcp server for agents to request and authenticate accounts.
|
|
5243
|
+
defaults to false`
|
|
5244
|
+
)
|
|
5245
|
+
});
|
|
5246
|
+
var MCPListParamsSchema = z8.object({
|
|
5247
|
+
page: z8.number().optional().default(1),
|
|
5248
|
+
limit: z8.number().optional().default(10),
|
|
5249
|
+
toolkits: z8.array(z8.string()).optional().default([]),
|
|
5250
|
+
authConfigs: z8.array(z8.string()).optional().default([]),
|
|
5251
|
+
name: z8.string().optional()
|
|
5252
|
+
});
|
|
5253
|
+
var MCPItemSchema = MCPConfigResponseSchema.extend({
|
|
5254
|
+
...z8.object({
|
|
5255
|
+
toolkitIcons: z8.record(z8.string(), z8.string()),
|
|
5256
|
+
serverInstanceCount: z8.number(),
|
|
5257
|
+
toolkits: z8.array(z8.string())
|
|
5258
|
+
}).shape
|
|
5259
|
+
});
|
|
5260
|
+
var MCPListResponseSchema = z8.object({
|
|
5261
|
+
items: z8.array(MCPItemSchema),
|
|
5262
|
+
currentPage: z8.number(),
|
|
5263
|
+
totalPages: z8.number()
|
|
5264
|
+
});
|
|
5265
|
+
var MCPUpdateParamsSchema = z8.object({
|
|
5266
|
+
name: z8.string().optional(),
|
|
5267
|
+
toolkits: z8.array(z8.union([MCPConfigToolkitsSchema, z8.string()])).optional(),
|
|
5268
|
+
allowedTools: z8.array(z8.string()).optional(),
|
|
5269
|
+
manuallyManageConnections: z8.boolean().optional().describe(
|
|
5270
|
+
`Whether to manually manage accounts. If true, you need to manage accounts manually connect user accounts.
|
|
5271
|
+
If set to false, composio will inject account maangement tools into your mcp server for agents to request and authenticate accounts.
|
|
5272
|
+
defaults to false`
|
|
5273
|
+
)
|
|
5274
|
+
});
|
|
5275
|
+
var MCPServerConnectionStatus = z8.object({
|
|
5276
|
+
connected: z8.boolean(),
|
|
5277
|
+
toolkit: z8.string(),
|
|
5278
|
+
connectedAccountId: z8.string()
|
|
5279
|
+
});
|
|
5280
|
+
var MCPServerConnectedAccountsSchema = z8.record(
|
|
5281
|
+
z8.string(),
|
|
5282
|
+
z8.array(
|
|
5283
|
+
z8.object({
|
|
5284
|
+
toolkit: z8.string(),
|
|
5285
|
+
authConfigId: z8.string(),
|
|
5286
|
+
connectedAccountId: z8.string()
|
|
5287
|
+
})
|
|
5288
|
+
)
|
|
5289
|
+
);
|
|
5290
|
+
|
|
5291
|
+
// src/models/MCP.experimental.ts
|
|
5292
|
+
function transformMCPItemResponse(response) {
|
|
5293
|
+
return transform(response).with(MCPItemSchema).using((raw) => ({
|
|
5294
|
+
name: raw.name,
|
|
5295
|
+
allowedTools: raw.allowed_tools,
|
|
5296
|
+
id: raw.id,
|
|
5297
|
+
authConfigIds: raw.auth_config_ids,
|
|
5298
|
+
commands: raw.commands,
|
|
5299
|
+
MCPUrl: raw.mcp_url,
|
|
5300
|
+
toolkitIcons: raw.toolkit_icons,
|
|
5301
|
+
serverInstanceCount: raw.server_instance_count,
|
|
5302
|
+
toolkits: raw.toolkits
|
|
5303
|
+
}));
|
|
5304
|
+
}
|
|
5305
|
+
var MCP = class {
|
|
5306
|
+
client;
|
|
5307
|
+
constructor(client) {
|
|
5308
|
+
this.client = client;
|
|
5309
|
+
telemetry.instrument(this);
|
|
5310
|
+
}
|
|
5311
|
+
/**
|
|
5312
|
+
* Create a new MCP configuration.
|
|
5313
|
+
* @param {Object} params - Parameters for creating the MCP configuration
|
|
5314
|
+
* @param {Array} params.authConfig - Array of auth configurations with id and allowed tools
|
|
5315
|
+
* @param {Object} params.options - Configuration options
|
|
5316
|
+
* @param {string} params.options.name - Unique name for the MCP configuration
|
|
5317
|
+
* @param {boolean} [params.options.manuallyManageConnections] - Whether to use chat-based authentication or manually connect accounts
|
|
5318
|
+
* @returns {Promise<McpServerCreateResponse<T>>} Created server details with instance getter
|
|
5319
|
+
*
|
|
5320
|
+
* @example
|
|
5321
|
+
* ```typescript
|
|
5322
|
+
* const server = await composio.mcpConfig.create("personal-mcp-server", {
|
|
5323
|
+
* toolkits: ["github", "slack"],
|
|
5324
|
+
* allowedTools: ["GMAIL_FETCH_EMAILS", "SLACK_SEND_MESSAGE"],
|
|
5325
|
+
* manuallyManageConnections: false
|
|
5326
|
+
* }
|
|
5327
|
+
* });
|
|
5328
|
+
*
|
|
5329
|
+
* const server = await composio.mcpConfig.create("personal-mcp-server", {
|
|
5330
|
+
* toolkits: [{ toolkit: "gmail", authConfigId: "ac_243434343" }],
|
|
5331
|
+
* allowedTools: ["GMAIL_FETCH_EMAILS"],
|
|
5332
|
+
* manuallyManageConnections: false
|
|
5333
|
+
* }
|
|
5334
|
+
* });
|
|
5335
|
+
* ```
|
|
5336
|
+
*/
|
|
5337
|
+
async create(name, mcpConfig) {
|
|
5338
|
+
const config = MCPConfigCreationParamsSchema.safeParse(mcpConfig);
|
|
5339
|
+
if (config.error) {
|
|
5340
|
+
throw new ValidationError("Invalid parameters passed to create mcp config", {
|
|
5341
|
+
cause: config.error
|
|
5342
|
+
});
|
|
5343
|
+
}
|
|
5344
|
+
const toolkits = [];
|
|
5345
|
+
const auth_config_ids = [];
|
|
5346
|
+
const custom_tools = config.data.allowedTools ?? [];
|
|
5347
|
+
config.data.toolkits.forEach((toolkit) => {
|
|
5348
|
+
if (typeof toolkit === "string") {
|
|
5349
|
+
toolkits.push(toolkit);
|
|
5350
|
+
} else if (toolkit.toolkit) {
|
|
5351
|
+
toolkits.push(toolkit.toolkit);
|
|
5352
|
+
} else if (toolkit.authConfigId) {
|
|
5353
|
+
auth_config_ids.push(toolkit.authConfigId);
|
|
5354
|
+
}
|
|
5355
|
+
});
|
|
5356
|
+
const server = await this.client.mcp.custom.create({
|
|
5357
|
+
name,
|
|
5358
|
+
toolkits,
|
|
5359
|
+
auth_config_ids,
|
|
5360
|
+
custom_tools,
|
|
5361
|
+
// if manually manage account is set to true, disable composio account management tools
|
|
5362
|
+
managed_auth_via_composio: config.data.manuallyManageConnections ? false : true
|
|
5363
|
+
});
|
|
5364
|
+
const camelCaseServer = transform(server).with(MCPConfigResponseSchema).using((raw) => ({
|
|
5365
|
+
name: raw.name,
|
|
5366
|
+
allowedTools: raw.allowed_tools,
|
|
5367
|
+
id: raw.id,
|
|
5368
|
+
authConfigIds: raw.auth_config_ids,
|
|
5369
|
+
commands: raw.commands,
|
|
5370
|
+
MCPUrl: raw.mcp_url
|
|
5371
|
+
}));
|
|
5372
|
+
return {
|
|
5373
|
+
...camelCaseServer,
|
|
5374
|
+
generate: async (userId) => {
|
|
5375
|
+
return await this.generate(userId, server.id, {
|
|
5376
|
+
manuallyManageConnections: config.data.manuallyManageConnections
|
|
5377
|
+
});
|
|
5378
|
+
}
|
|
5379
|
+
};
|
|
5380
|
+
}
|
|
5381
|
+
/**
|
|
5382
|
+
* List the MCP servers with optional filtering and pagination
|
|
5383
|
+
* @param {Object} options - Filtering and pagination options
|
|
5384
|
+
* @param {number} [options.page=1] - Page number for pagination (1-based)
|
|
5385
|
+
* @param {number} [options.limit=10] - Maximum number of items to return per page
|
|
5386
|
+
* @param {string[]} [options.toolkits=[]] - Array of toolkit names to filter by
|
|
5387
|
+
* @param {string[]} [options.authConfigs=[]] - Array of auth configuration IDs to filter by
|
|
5388
|
+
* @param {string} [options.name] - Filter by MCP server name (partial match)
|
|
5389
|
+
* @returns {Promise<MCPListResponse>} Paginated list of MCP servers with metadata
|
|
5390
|
+
*
|
|
5391
|
+
* @example
|
|
5392
|
+
* ```typescript
|
|
5393
|
+
* // List all MCP servers
|
|
5394
|
+
* const allServers = await composio.experimental.mcp.list({});
|
|
5395
|
+
*
|
|
5396
|
+
* // List with pagination
|
|
5397
|
+
* const pagedServers = await composio.experimental.mcp.list({
|
|
5398
|
+
* page: 2,
|
|
5399
|
+
* limit: 5
|
|
5400
|
+
* });
|
|
5401
|
+
*
|
|
5402
|
+
* // Filter by toolkit
|
|
5403
|
+
* const githubServers = await composio.experimental.mcp.list({
|
|
5404
|
+
* toolkits: ['github', 'slack']
|
|
5405
|
+
* });
|
|
5406
|
+
*
|
|
5407
|
+
* // Filter by name
|
|
5408
|
+
* const namedServers = await composio.experimental.mcp.list({
|
|
5409
|
+
* name: 'personal'
|
|
5410
|
+
* });
|
|
5411
|
+
* ```
|
|
5412
|
+
*/
|
|
5413
|
+
async list(options) {
|
|
5414
|
+
const { data: params, error } = MCPListParamsSchema.safeParse(options);
|
|
5415
|
+
if (error) {
|
|
5416
|
+
throw new ValidationError("Failed to validate list options", {
|
|
5417
|
+
cause: error
|
|
5418
|
+
});
|
|
5419
|
+
}
|
|
5420
|
+
const listResponse = await this.client.mcp.list({
|
|
5421
|
+
page_no: params.page,
|
|
5422
|
+
limit: params.limit,
|
|
5423
|
+
toolkits: params.toolkits?.length > 0 ? params.toolkits.join(",") : void 0,
|
|
5424
|
+
auth_config_ids: params.authConfigs?.length > 0 ? params.authConfigs.join(",") : void 0,
|
|
5425
|
+
name: params.name
|
|
5426
|
+
});
|
|
5427
|
+
const transformedListResponse = transform(listResponse).with(MCPListResponseSchema).using((raw) => ({
|
|
5428
|
+
currentPage: raw.current_page,
|
|
5429
|
+
totalPages: raw.total_pages,
|
|
5430
|
+
items: raw.items.map((item) => ({
|
|
5431
|
+
name: item.name,
|
|
5432
|
+
allowedTools: item.allowed_tools,
|
|
5433
|
+
id: item.id,
|
|
5434
|
+
authConfigIds: item.auth_config_ids,
|
|
5435
|
+
commands: item.commands,
|
|
5436
|
+
MCPUrl: item.mcp_url,
|
|
5437
|
+
toolkitIcons: item.toolkit_icons,
|
|
5438
|
+
serverInstanceCount: item.server_instance_count,
|
|
5439
|
+
toolkits: item.toolkits
|
|
5440
|
+
}))
|
|
5441
|
+
}));
|
|
5442
|
+
return transformedListResponse;
|
|
5443
|
+
}
|
|
5444
|
+
/**
|
|
5445
|
+
* Retrieve detailed information about a specific MCP server by its ID
|
|
5446
|
+
* @param {string} serverId - The unique identifier of the MCP server to retrieve
|
|
5447
|
+
* @returns {Promise<MCPItem>} Complete MCP server details including configuration, tools, and metadata
|
|
5448
|
+
*
|
|
5449
|
+
* @example
|
|
5450
|
+
* ```typescript
|
|
5451
|
+
* // Get a specific MCP server by ID
|
|
5452
|
+
* const server = await composio.experimental.mcp.get("mcp_12345");
|
|
5453
|
+
*
|
|
5454
|
+
* console.log(server.name); // "My Personal MCP Server"
|
|
5455
|
+
* console.log(server.allowedTools); // ["GITHUB_CREATE_ISSUE", "SLACK_SEND_MESSAGE"]
|
|
5456
|
+
* console.log(server.toolkits); // ["github", "slack"]
|
|
5457
|
+
* console.log(server.serverInstanceCount); // 3
|
|
5458
|
+
*
|
|
5459
|
+
* // Access setup commands for different clients
|
|
5460
|
+
* console.log(server.commands.claude); // Claude setup command
|
|
5461
|
+
* console.log(server.commands.cursor); // Cursor setup command
|
|
5462
|
+
* console.log(server.commands.windsurf); // Windsurf setup command
|
|
5463
|
+
*
|
|
5464
|
+
* // Use the MCP URL for direct connections
|
|
5465
|
+
* const mcpUrl = server.MCPUrl;
|
|
5466
|
+
* ```
|
|
5467
|
+
*
|
|
5468
|
+
* @throws {ValidationError} When the server ID is invalid or server not found
|
|
5469
|
+
*/
|
|
5470
|
+
async get(serverId) {
|
|
5471
|
+
const response = await this.client.mcp.retrieve(serverId);
|
|
5472
|
+
return transformMCPItemResponse(response);
|
|
5473
|
+
}
|
|
5474
|
+
/**
|
|
5475
|
+
* Delete an MCP server configuration permanently
|
|
5476
|
+
* @param {string} serverId - The unique identifier of the MCP server to delete
|
|
5477
|
+
* @returns {Promise<{id: string; deleted: boolean}>} Confirmation object with server ID and deletion status
|
|
5478
|
+
*
|
|
5479
|
+
* @example
|
|
5480
|
+
* ```typescript
|
|
5481
|
+
* // Delete an MCP server by ID
|
|
5482
|
+
* const result = await composio.experimental.mcp.delete("mcp_12345");
|
|
5483
|
+
*
|
|
5484
|
+
* if (result.deleted) {
|
|
5485
|
+
* console.log(`Server ${result.id} has been successfully deleted`);
|
|
5486
|
+
* } else {
|
|
5487
|
+
* console.log(`Failed to delete server ${result.id}`);
|
|
5488
|
+
* }
|
|
5489
|
+
*
|
|
5490
|
+
* // Example with error handling
|
|
5491
|
+
* try {
|
|
5492
|
+
* const result = await composio.experimental.mcp.delete("mcp_12345");
|
|
5493
|
+
* console.log("Deletion successful:", result);
|
|
5494
|
+
* } catch (error) {
|
|
5495
|
+
* console.error("Failed to delete MCP server:", error.message);
|
|
5496
|
+
* }
|
|
5497
|
+
*
|
|
5498
|
+
* // Delete and verify from list
|
|
5499
|
+
* await composio.experimental.mcp.delete("mcp_12345");
|
|
5500
|
+
* const servers = await composio.experimental.mcp.list({});
|
|
5501
|
+
* const serverExists = servers.items.some(server => server.id === "mcp_12345");
|
|
5502
|
+
* console.log("Server still exists:", serverExists); // Should be false
|
|
5503
|
+
* ```
|
|
5504
|
+
*
|
|
5505
|
+
* @throws {ValidationError} When the server ID is invalid or server not found
|
|
5506
|
+
* @throws {Error} When the server cannot be deleted due to active connections or other constraints
|
|
5507
|
+
*
|
|
5508
|
+
* @warning This operation is irreversible. Once deleted, the MCP server configuration and all its associated data will be permanently removed.
|
|
5509
|
+
*/
|
|
5510
|
+
async delete(serverId) {
|
|
5511
|
+
return await this.client.mcp.delete(serverId);
|
|
5512
|
+
}
|
|
5513
|
+
/**
|
|
5514
|
+
* Update an existing MCP server configuration with new settings
|
|
5515
|
+
* @param {string} serverId - The unique identifier of the MCP server to update
|
|
5516
|
+
* @param {Object} config - Update configuration parameters
|
|
5517
|
+
* @param {string} [config.name] - New name for the MCP server
|
|
5518
|
+
* @param {Array} [config.toolkits] - Updated toolkit configurations
|
|
5519
|
+
* @param {string} [config.toolkits[].toolkit] - Toolkit identifier (e.g., "github", "slack")
|
|
5520
|
+
* @param {string} [config.toolkits[].authConfigId] - Auth configuration ID for the toolkit
|
|
5521
|
+
* @param {string[]} [config.toolkits[].allowedTools] - Specific tools to enable for this toolkit
|
|
5522
|
+
* @param {boolean} [config.manuallyManageConnections] - Whether to manually manage account connections
|
|
5523
|
+
* @returns {Promise<MCPItem>} Updated MCP server configuration with all details
|
|
5524
|
+
*
|
|
5525
|
+
* @example
|
|
5526
|
+
* ```typescript
|
|
5527
|
+
* // Update server name only
|
|
5528
|
+
* const updatedServer = await composio.experimental.mcp.update("mcp_12345", {
|
|
5529
|
+
* name: "My Updated MCP Server"
|
|
5530
|
+
* });
|
|
5531
|
+
*
|
|
5532
|
+
* // Update toolkits and tools
|
|
5533
|
+
* const serverWithNewTools = await composio.experimental.mcp.update("mcp_12345", {
|
|
5534
|
+
* toolkits: [
|
|
5535
|
+
* {
|
|
5536
|
+
* toolkit: "github",
|
|
5537
|
+
* authConfigId: "auth_abc123",
|
|
5538
|
+
* allowedTools: ["GITHUB_CREATE_ISSUE", "GITHUB_LIST_REPOS"]
|
|
5539
|
+
* },
|
|
5540
|
+
* {
|
|
5541
|
+
* toolkit: "slack",
|
|
5542
|
+
* authConfigId: "auth_xyz789",
|
|
5543
|
+
* allowedTools: ["SLACK_SEND_MESSAGE", "SLACK_LIST_CHANNELS"]
|
|
5544
|
+
* }
|
|
5545
|
+
* ]
|
|
5546
|
+
* });
|
|
5547
|
+
*
|
|
5548
|
+
* // Update connection management setting
|
|
5549
|
+
* const serverWithManualAuth = await composio.experimental.mcp.update("mcp_12345", {
|
|
5550
|
+
* name: "Manual Auth Server",
|
|
5551
|
+
* manuallyManageConnections: true
|
|
5552
|
+
* });
|
|
5553
|
+
*
|
|
5554
|
+
* // Complete update example
|
|
5555
|
+
* const fullyUpdatedServer = await composio.experimental.mcp.update("mcp_12345", {
|
|
5556
|
+
* name: "Production MCP Server",
|
|
5557
|
+
* toolkits: [
|
|
5558
|
+
* {
|
|
5559
|
+
* toolkit: "gmail",
|
|
5560
|
+
* authConfigId: "auth_gmail_prod",
|
|
5561
|
+
* }
|
|
5562
|
+
* ],
|
|
5563
|
+
* allowedTools: ["GMAIL_SEND_EMAIL", "GMAIL_FETCH_EMAILS"]
|
|
5564
|
+
* manuallyManageConnections: false
|
|
5565
|
+
* });
|
|
5566
|
+
*
|
|
5567
|
+
* console.log("Updated server:", fullyUpdatedServer.name);
|
|
5568
|
+
* console.log("New tools:", fullyUpdatedServer.allowedTools);
|
|
5569
|
+
* ```
|
|
5570
|
+
*
|
|
5571
|
+
* @throws {ValidationError} When the update parameters are invalid or malformed
|
|
5572
|
+
* @throws {Error} When the server ID doesn't exist or update fails
|
|
5573
|
+
*
|
|
5574
|
+
* @note Only provided fields will be updated. Omitted fields will retain their current values.
|
|
5575
|
+
* @note When updating toolkits, the entire toolkit configuration is replaced, not merged.
|
|
5576
|
+
*/
|
|
5577
|
+
async update(serverId, config) {
|
|
5578
|
+
const { data: params, error } = MCPUpdateParamsSchema.safeParse(config);
|
|
5579
|
+
if (error) {
|
|
5580
|
+
throw new ValidationError("Failed to validate update params", {
|
|
5581
|
+
cause: error
|
|
5582
|
+
});
|
|
5583
|
+
}
|
|
5584
|
+
const toolkits = [];
|
|
5585
|
+
const auth_config_ids = [];
|
|
5586
|
+
const custom_tools = params.allowedTools ?? void 0;
|
|
5587
|
+
params.toolkits?.forEach((toolkit) => {
|
|
5588
|
+
if (typeof toolkit === "string") {
|
|
5589
|
+
toolkits.push(toolkit);
|
|
5590
|
+
} else if (toolkit.toolkit) {
|
|
5591
|
+
toolkits.push(toolkit.toolkit);
|
|
5592
|
+
} else if (toolkit.authConfigId) {
|
|
5593
|
+
auth_config_ids.push(toolkit.authConfigId);
|
|
5594
|
+
}
|
|
5595
|
+
});
|
|
5596
|
+
const response = await this.client.mcp.update(serverId, {
|
|
5597
|
+
...{ name: params.name ?? void 0 },
|
|
5598
|
+
...params.toolkits ? {
|
|
5599
|
+
custom_tools,
|
|
5600
|
+
toolkits,
|
|
5601
|
+
auth_config_ids
|
|
5602
|
+
} : {},
|
|
5603
|
+
...{ managed_auth_via_composio: params.manuallyManageConnections ?? void 0 }
|
|
5604
|
+
});
|
|
5605
|
+
return transformMCPItemResponse(response);
|
|
5606
|
+
}
|
|
5607
|
+
/**
|
|
5608
|
+
* Get server URLs for an existing MCP server.
|
|
5609
|
+
* The response is wrapped according to the provider's specifications.
|
|
5610
|
+
*
|
|
5611
|
+
* @example
|
|
5612
|
+
* ```typescript
|
|
5613
|
+
* import { Composio } from "@composio/code";
|
|
5614
|
+
*
|
|
5615
|
+
* const composio = new Composio();
|
|
5616
|
+
* const mcp = await composio.experimental.mcp.generate("default", "<mcp_config_id>");
|
|
5617
|
+
* ```
|
|
5618
|
+
*
|
|
5619
|
+
* @param userId {string} external user id from your database for whom you want the server for
|
|
5620
|
+
* @param mcpConfigId {string} config id of the MCPConfig for which you want to create a server for
|
|
5621
|
+
* @param options {object} additional options
|
|
5622
|
+
* @param options.isChatAuth {boolean} Authenticate the users via chat when they use the MCP Server
|
|
5623
|
+
*/
|
|
5624
|
+
async generate(userId, mcpConfigId, options) {
|
|
5625
|
+
const server = await this.client.mcp.retrieve(mcpConfigId);
|
|
5626
|
+
const params = MCPGetInstanceParamsSchema.safeParse(
|
|
5627
|
+
options ?? { manuallyManageConnections: false }
|
|
5628
|
+
);
|
|
5629
|
+
if (params.error) {
|
|
5630
|
+
throw new ValidationError("Invalid params passed for Get Instance Params", {
|
|
5631
|
+
cause: params.error
|
|
5632
|
+
});
|
|
5633
|
+
}
|
|
5634
|
+
const urlResponse = await this.client.mcp.generate.url({
|
|
5635
|
+
mcp_server_id: mcpConfigId,
|
|
5636
|
+
user_ids: [userId],
|
|
5637
|
+
managed_auth_by_composio: options?.manuallyManageConnections ? false : true
|
|
5638
|
+
});
|
|
5639
|
+
const userIdsURL = urlResponse.user_ids_url[0];
|
|
5640
|
+
const serverInstance = MCPServerInstanceSchema.safeParse({
|
|
5641
|
+
id: server.id,
|
|
5642
|
+
name: server.name,
|
|
5643
|
+
type: "streamable_http",
|
|
5644
|
+
url: userIdsURL,
|
|
5645
|
+
userId,
|
|
5646
|
+
allowedTools: server.allowed_tools,
|
|
5647
|
+
authConfigs: server.auth_config_ids
|
|
5648
|
+
});
|
|
5649
|
+
if (serverInstance.error) {
|
|
5650
|
+
throw new ValidationError("Failed to parse MCP server instance", {
|
|
5651
|
+
cause: serverInstance.error
|
|
5652
|
+
});
|
|
5653
|
+
}
|
|
5654
|
+
return serverInstance.data;
|
|
5655
|
+
}
|
|
5656
|
+
};
|
|
5657
|
+
|
|
5172
5658
|
// src/types/mcp.types.ts
|
|
5173
|
-
import { z as
|
|
5174
|
-
var MCPToolkitConfigSchema =
|
|
5175
|
-
toolkit:
|
|
5176
|
-
authConfigId:
|
|
5177
|
-
allowedTools:
|
|
5659
|
+
import { z as z9 } from "zod";
|
|
5660
|
+
var MCPToolkitConfigSchema = z9.object({
|
|
5661
|
+
toolkit: z9.string().min(1, "Toolkit name cannot be empty"),
|
|
5662
|
+
authConfigId: z9.string().min(1, "Auth config ID cannot be empty"),
|
|
5663
|
+
allowedTools: z9.array(z9.string().min(1, "Tool name cannot be empty")).min(1, "At least one tool must be specified")
|
|
5178
5664
|
});
|
|
5179
|
-
var MCPToolkitConfigsArraySchema =
|
|
5665
|
+
var MCPToolkitConfigsArraySchema = z9.array(MCPToolkitConfigSchema).min(1, "At least one toolkit configuration is required").refine((configs) => {
|
|
5180
5666
|
const toolkits = configs.map((config) => config.toolkit);
|
|
5181
5667
|
const uniqueToolkits = new Set(toolkits);
|
|
5182
5668
|
return uniqueToolkits.size === toolkits.length;
|
|
5183
5669
|
}, "Duplicate toolkits are not allowed. Each toolkit must be unique.");
|
|
5184
|
-
var MCPAuthOptionsSchema =
|
|
5185
|
-
isChatAuth:
|
|
5670
|
+
var MCPAuthOptionsSchema = z9.object({
|
|
5671
|
+
isChatAuth: z9.boolean().optional()
|
|
5186
5672
|
});
|
|
5187
|
-
var MCPGetServerParamsSchema =
|
|
5188
|
-
userId:
|
|
5189
|
-
connectedAccountIds:
|
|
5673
|
+
var MCPGetServerParamsSchema = z9.object({
|
|
5674
|
+
userId: z9.string().min(1, "User ID cannot be empty").optional(),
|
|
5675
|
+
connectedAccountIds: z9.record(z9.string(), z9.string().min(1, "Account ID cannot be empty")).optional()
|
|
5190
5676
|
}).refine(
|
|
5191
5677
|
(data) => {
|
|
5192
5678
|
const hasUserId = !!data.userId;
|
|
@@ -5197,61 +5683,61 @@ var MCPGetServerParamsSchema = z8.object({
|
|
|
5197
5683
|
message: "Must provide either userId or connectedAccountIds, but not both"
|
|
5198
5684
|
}
|
|
5199
5685
|
);
|
|
5200
|
-
var MCPGenerateURLParamsSchema =
|
|
5201
|
-
userIds:
|
|
5202
|
-
connectedAccountIds:
|
|
5203
|
-
isChatAuth:
|
|
5686
|
+
var MCPGenerateURLParamsSchema = z9.object({
|
|
5687
|
+
userIds: z9.array(z9.string()).optional(),
|
|
5688
|
+
connectedAccountIds: z9.array(z9.string()).optional(),
|
|
5689
|
+
isChatAuth: z9.boolean().optional()
|
|
5204
5690
|
});
|
|
5205
|
-
var ComposioGenerateURLParamsSchema =
|
|
5206
|
-
user_ids:
|
|
5207
|
-
connected_account_ids:
|
|
5208
|
-
mcp_server_id:
|
|
5209
|
-
managed_auth_by_composio:
|
|
5691
|
+
var ComposioGenerateURLParamsSchema = z9.object({
|
|
5692
|
+
user_ids: z9.array(z9.string()).optional(),
|
|
5693
|
+
connected_account_ids: z9.array(z9.string()).optional(),
|
|
5694
|
+
mcp_server_id: z9.string(),
|
|
5695
|
+
managed_auth_by_composio: z9.boolean().optional()
|
|
5210
5696
|
});
|
|
5211
|
-
var GenerateURLParamsSchema =
|
|
5212
|
-
userIds:
|
|
5213
|
-
connectedAccountIds:
|
|
5214
|
-
mcpServerId:
|
|
5215
|
-
composioManagedAuth:
|
|
5697
|
+
var GenerateURLParamsSchema = z9.object({
|
|
5698
|
+
userIds: z9.array(z9.string()).optional(),
|
|
5699
|
+
connectedAccountIds: z9.array(z9.string()).optional(),
|
|
5700
|
+
mcpServerId: z9.string(),
|
|
5701
|
+
composioManagedAuth: z9.boolean().optional()
|
|
5216
5702
|
});
|
|
5217
|
-
var GenerateURLResponseSchema =
|
|
5218
|
-
connectedAccountUrls:
|
|
5219
|
-
userIdsUrl:
|
|
5220
|
-
mcpUrl:
|
|
5703
|
+
var GenerateURLResponseSchema = z9.object({
|
|
5704
|
+
connectedAccountUrls: z9.array(z9.string()).optional(),
|
|
5705
|
+
userIdsUrl: z9.array(z9.string()).optional(),
|
|
5706
|
+
mcpUrl: z9.string().min(1, "MCP URL cannot be empty")
|
|
5221
5707
|
});
|
|
5222
|
-
var ComposioGenerateURLResponseSchema =
|
|
5223
|
-
connected_account_urls:
|
|
5224
|
-
user_ids_url:
|
|
5225
|
-
mcp_url:
|
|
5708
|
+
var ComposioGenerateURLResponseSchema = z9.object({
|
|
5709
|
+
connected_account_urls: z9.array(z9.string()).optional(),
|
|
5710
|
+
user_ids_url: z9.array(z9.string()).optional(),
|
|
5711
|
+
mcp_url: z9.string().min(1, "MCP URL cannot be empty")
|
|
5226
5712
|
});
|
|
5227
|
-
var MCPSingleAppServerSchema =
|
|
5228
|
-
name:
|
|
5229
|
-
tools:
|
|
5230
|
-
authConfigId:
|
|
5713
|
+
var MCPSingleAppServerSchema = z9.object({
|
|
5714
|
+
name: z9.string().describe("Name of the MCP server"),
|
|
5715
|
+
tools: z9.array(z9.string()).describe("List of allowed tools"),
|
|
5716
|
+
authConfigId: z9.string().optional().describe("Auth config ID for the server")
|
|
5231
5717
|
});
|
|
5232
|
-
var MCPMultiAppServerSchema =
|
|
5233
|
-
name:
|
|
5234
|
-
tools:
|
|
5235
|
-
toolkits:
|
|
5718
|
+
var MCPMultiAppServerSchema = z9.object({
|
|
5719
|
+
name: z9.string().describe("Name of the MCP server"),
|
|
5720
|
+
tools: z9.array(z9.string()).describe("List of allowed tools across toolkits"),
|
|
5721
|
+
toolkits: z9.array(z9.string()).describe("List of allowed toolkits")
|
|
5236
5722
|
});
|
|
5237
|
-
var MCPServerSchema =
|
|
5238
|
-
id:
|
|
5239
|
-
type:
|
|
5240
|
-
createdAt:
|
|
5241
|
-
updatedAt:
|
|
5242
|
-
status:
|
|
5243
|
-
config:
|
|
5723
|
+
var MCPServerSchema = z9.object({
|
|
5724
|
+
id: z9.string().describe("Unique identifier for the MCP server"),
|
|
5725
|
+
type: z9.enum(["single", "multi"]).describe("Type of MCP server"),
|
|
5726
|
+
createdAt: z9.string().describe("Creation timestamp"),
|
|
5727
|
+
updatedAt: z9.string().describe("Last update timestamp"),
|
|
5728
|
+
status: z9.enum(["active", "inactive", "error"]).default("active"),
|
|
5729
|
+
config: z9.union([MCPSingleAppServerSchema, MCPMultiAppServerSchema])
|
|
5244
5730
|
});
|
|
5245
|
-
var MCPServerListResponseSchema =
|
|
5246
|
-
items:
|
|
5247
|
-
total:
|
|
5248
|
-
page:
|
|
5249
|
-
pageSize:
|
|
5731
|
+
var MCPServerListResponseSchema = z9.object({
|
|
5732
|
+
items: z9.array(MCPServerSchema),
|
|
5733
|
+
total: z9.number(),
|
|
5734
|
+
page: z9.number(),
|
|
5735
|
+
pageSize: z9.number()
|
|
5250
5736
|
});
|
|
5251
|
-
var MCPServerUpdateParamsSchema =
|
|
5252
|
-
name:
|
|
5253
|
-
toolkits:
|
|
5254
|
-
allowedTools:
|
|
5737
|
+
var MCPServerUpdateParamsSchema = z9.object({
|
|
5738
|
+
name: z9.string().optional().describe("New name for the server"),
|
|
5739
|
+
toolkits: z9.array(z9.string()).optional().describe("Updated list of toolkits"),
|
|
5740
|
+
allowedTools: z9.array(z9.string()).optional().describe("Updated list of allowed tools")
|
|
5255
5741
|
});
|
|
5256
5742
|
var MCPServerCreateResponseSchema = MCPServerSchema;
|
|
5257
5743
|
var ConnectionStatus = /* @__PURE__ */ ((ConnectionStatus2) => {
|
|
@@ -5259,96 +5745,96 @@ var ConnectionStatus = /* @__PURE__ */ ((ConnectionStatus2) => {
|
|
|
5259
5745
|
ConnectionStatus2["DISCONNECTED"] = "DISCONNECTED";
|
|
5260
5746
|
return ConnectionStatus2;
|
|
5261
5747
|
})(ConnectionStatus || {});
|
|
5262
|
-
var CustomCreateResponseSchema =
|
|
5263
|
-
id:
|
|
5264
|
-
name:
|
|
5265
|
-
createdAt:
|
|
5266
|
-
updatedAt:
|
|
5267
|
-
status:
|
|
5748
|
+
var CustomCreateResponseSchema = z9.object({
|
|
5749
|
+
id: z9.string().min(1, "Server ID cannot be empty"),
|
|
5750
|
+
name: z9.string().min(1, "Server name cannot be empty"),
|
|
5751
|
+
createdAt: z9.string().nullish(),
|
|
5752
|
+
updatedAt: z9.string().nullish(),
|
|
5753
|
+
status: z9.string().nullish()
|
|
5268
5754
|
});
|
|
5269
|
-
var ComposioCustomCreateResponseSchema =
|
|
5270
|
-
id:
|
|
5271
|
-
name:
|
|
5272
|
-
created_at:
|
|
5273
|
-
updated_at:
|
|
5274
|
-
status:
|
|
5755
|
+
var ComposioCustomCreateResponseSchema = z9.object({
|
|
5756
|
+
id: z9.string().min(1, "Server ID cannot be empty"),
|
|
5757
|
+
name: z9.string().min(1, "Server name cannot be empty"),
|
|
5758
|
+
created_at: z9.string().nullish(),
|
|
5759
|
+
updated_at: z9.string().nullish(),
|
|
5760
|
+
status: z9.string().nullish()
|
|
5275
5761
|
});
|
|
5276
|
-
var McpListResponseSchema =
|
|
5277
|
-
items:
|
|
5278
|
-
|
|
5279
|
-
id:
|
|
5280
|
-
name:
|
|
5281
|
-
createdAt:
|
|
5282
|
-
updatedAt:
|
|
5283
|
-
status:
|
|
5762
|
+
var McpListResponseSchema = z9.object({
|
|
5763
|
+
items: z9.array(
|
|
5764
|
+
z9.object({
|
|
5765
|
+
id: z9.string().min(1, "Server ID cannot be empty"),
|
|
5766
|
+
name: z9.string().min(1, "Server name cannot be empty"),
|
|
5767
|
+
createdAt: z9.string().optional(),
|
|
5768
|
+
updatedAt: z9.string().optional(),
|
|
5769
|
+
status: z9.string().optional()
|
|
5284
5770
|
})
|
|
5285
5771
|
).optional()
|
|
5286
5772
|
});
|
|
5287
|
-
var ComposioMcpListResponseSchema =
|
|
5288
|
-
items:
|
|
5289
|
-
|
|
5290
|
-
id:
|
|
5291
|
-
name:
|
|
5292
|
-
created_at:
|
|
5293
|
-
updated_at:
|
|
5294
|
-
status:
|
|
5773
|
+
var ComposioMcpListResponseSchema = z9.object({
|
|
5774
|
+
items: z9.array(
|
|
5775
|
+
z9.object({
|
|
5776
|
+
id: z9.string().min(1, "Server ID cannot be empty"),
|
|
5777
|
+
name: z9.string().min(1, "Server name cannot be empty"),
|
|
5778
|
+
created_at: z9.string().optional(),
|
|
5779
|
+
updated_at: z9.string().optional(),
|
|
5780
|
+
status: z9.string().optional()
|
|
5295
5781
|
})
|
|
5296
5782
|
).optional()
|
|
5297
5783
|
});
|
|
5298
|
-
var McpRetrieveResponseSchema =
|
|
5299
|
-
id:
|
|
5300
|
-
name:
|
|
5301
|
-
createdAt:
|
|
5302
|
-
updatedAt:
|
|
5303
|
-
status:
|
|
5304
|
-
toolkits:
|
|
5305
|
-
tools:
|
|
5306
|
-
managedAuthViaComposio:
|
|
5307
|
-
authConfigIds:
|
|
5308
|
-
mcpUrl:
|
|
5309
|
-
commands:
|
|
5310
|
-
claude:
|
|
5311
|
-
cursor:
|
|
5312
|
-
windsurf:
|
|
5784
|
+
var McpRetrieveResponseSchema = z9.object({
|
|
5785
|
+
id: z9.string().min(1, "Server ID cannot be empty"),
|
|
5786
|
+
name: z9.string().min(1, "Server name cannot be empty"),
|
|
5787
|
+
createdAt: z9.string().optional(),
|
|
5788
|
+
updatedAt: z9.string().optional(),
|
|
5789
|
+
status: z9.string().optional(),
|
|
5790
|
+
toolkits: z9.array(z9.string()).optional(),
|
|
5791
|
+
tools: z9.array(z9.string()).optional(),
|
|
5792
|
+
managedAuthViaComposio: z9.boolean().optional(),
|
|
5793
|
+
authConfigIds: z9.array(z9.string()).optional(),
|
|
5794
|
+
mcpUrl: z9.string(),
|
|
5795
|
+
commands: z9.object({
|
|
5796
|
+
claude: z9.string(),
|
|
5797
|
+
cursor: z9.string(),
|
|
5798
|
+
windsurf: z9.string()
|
|
5313
5799
|
})
|
|
5314
5800
|
});
|
|
5315
|
-
var ComposioMcpRetrieveResponseSchema =
|
|
5316
|
-
id:
|
|
5317
|
-
name:
|
|
5318
|
-
created_at:
|
|
5319
|
-
updated_at:
|
|
5320
|
-
status:
|
|
5321
|
-
toolkits:
|
|
5322
|
-
tools:
|
|
5323
|
-
managed_auth_via_composio:
|
|
5801
|
+
var ComposioMcpRetrieveResponseSchema = z9.object({
|
|
5802
|
+
id: z9.string().min(1, "Server ID cannot be empty"),
|
|
5803
|
+
name: z9.string().min(1, "Server name cannot be empty"),
|
|
5804
|
+
created_at: z9.string().optional(),
|
|
5805
|
+
updated_at: z9.string().optional(),
|
|
5806
|
+
status: z9.string().optional(),
|
|
5807
|
+
toolkits: z9.array(z9.string()).optional(),
|
|
5808
|
+
tools: z9.array(z9.string()).optional(),
|
|
5809
|
+
managed_auth_via_composio: z9.boolean().optional()
|
|
5324
5810
|
});
|
|
5325
|
-
var McpDeleteResponseSchema =
|
|
5326
|
-
id:
|
|
5327
|
-
deleted:
|
|
5328
|
-
message:
|
|
5811
|
+
var McpDeleteResponseSchema = z9.object({
|
|
5812
|
+
id: z9.string().min(1, "Server ID cannot be empty"),
|
|
5813
|
+
deleted: z9.boolean().optional(),
|
|
5814
|
+
message: z9.string().optional()
|
|
5329
5815
|
});
|
|
5330
|
-
var ComposioMcpDeleteResponseSchema =
|
|
5331
|
-
id:
|
|
5332
|
-
deleted:
|
|
5333
|
-
message:
|
|
5816
|
+
var ComposioMcpDeleteResponseSchema = z9.object({
|
|
5817
|
+
id: z9.string().min(1, "Server ID cannot be empty"),
|
|
5818
|
+
deleted: z9.boolean().optional(),
|
|
5819
|
+
message: z9.string().optional()
|
|
5334
5820
|
});
|
|
5335
|
-
var McpUpdateResponseSchema =
|
|
5336
|
-
id:
|
|
5337
|
-
name:
|
|
5338
|
-
createdAt:
|
|
5339
|
-
updatedAt:
|
|
5340
|
-
status:
|
|
5341
|
-
toolkits:
|
|
5342
|
-
tools:
|
|
5821
|
+
var McpUpdateResponseSchema = z9.object({
|
|
5822
|
+
id: z9.string().min(1, "Server ID cannot be empty"),
|
|
5823
|
+
name: z9.string().min(1, "Server name cannot be empty"),
|
|
5824
|
+
createdAt: z9.string().optional(),
|
|
5825
|
+
updatedAt: z9.string().optional(),
|
|
5826
|
+
status: z9.string().optional(),
|
|
5827
|
+
toolkits: z9.array(z9.string()).optional(),
|
|
5828
|
+
tools: z9.array(z9.string()).optional()
|
|
5343
5829
|
});
|
|
5344
|
-
var ComposioMcpUpdateResponseSchema =
|
|
5345
|
-
id:
|
|
5346
|
-
name:
|
|
5347
|
-
created_at:
|
|
5348
|
-
updated_at:
|
|
5349
|
-
status:
|
|
5350
|
-
toolkits:
|
|
5351
|
-
tools:
|
|
5830
|
+
var ComposioMcpUpdateResponseSchema = z9.object({
|
|
5831
|
+
id: z9.string().min(1, "Server ID cannot be empty"),
|
|
5832
|
+
name: z9.string().min(1, "Server name cannot be empty"),
|
|
5833
|
+
created_at: z9.string().optional(),
|
|
5834
|
+
updated_at: z9.string().optional(),
|
|
5835
|
+
status: z9.string().optional(),
|
|
5836
|
+
toolkits: z9.array(z9.string()).optional(),
|
|
5837
|
+
tools: z9.array(z9.string()).optional()
|
|
5352
5838
|
});
|
|
5353
5839
|
|
|
5354
5840
|
// src/utils/transformers/mcp.ts
|
|
@@ -5451,10 +5937,10 @@ function transformMcpGenerateUrlResponse(response) {
|
|
|
5451
5937
|
}
|
|
5452
5938
|
|
|
5453
5939
|
// src/models/MCP.ts
|
|
5454
|
-
var
|
|
5940
|
+
var MCP2 = class {
|
|
5455
5941
|
client;
|
|
5456
|
-
provider;
|
|
5457
5942
|
toolkits;
|
|
5943
|
+
provider;
|
|
5458
5944
|
constructor(client, provider) {
|
|
5459
5945
|
this.client = client;
|
|
5460
5946
|
this.provider = provider;
|
|
@@ -5491,7 +5977,7 @@ var MCP = class {
|
|
|
5491
5977
|
* @param {Object} params.options - Server creation options
|
|
5492
5978
|
* @param {string} params.options.name - Unique name for the MCP server
|
|
5493
5979
|
* @param {boolean} [params.options.isChatAuth] - Whether to use chat-based authentication
|
|
5494
|
-
* @returns {Promise<McpServerCreateResponse<
|
|
5980
|
+
* @returns {Promise<McpServerCreateResponse<TMcpResponse>>} Created server details with instance getter
|
|
5495
5981
|
*
|
|
5496
5982
|
* @example
|
|
5497
5983
|
* ```typescript
|
|
@@ -5754,7 +6240,7 @@ var MCP = class {
|
|
|
5754
6240
|
* @param {Object} [options] - Additional options for server configuration
|
|
5755
6241
|
* @param {string[]} [options.limitTools] - Subset of tools to limit (from MCP config)
|
|
5756
6242
|
* @param {boolean} [options.isChatAuth] - Whether to use chat-based authentication
|
|
5757
|
-
* @returns {Promise<
|
|
6243
|
+
* @returns {Promise<TMcpResponse>} Transformed server URLs in provider-specific format
|
|
5758
6244
|
*
|
|
5759
6245
|
* @example
|
|
5760
6246
|
* ```typescript
|
|
@@ -5767,6 +6253,7 @@ var MCP = class {
|
|
|
5767
6253
|
* isChatAuth: true
|
|
5768
6254
|
* });
|
|
5769
6255
|
* ```
|
|
6256
|
+
*
|
|
5770
6257
|
*/
|
|
5771
6258
|
async getServer(serverId, userId, options) {
|
|
5772
6259
|
const serverDetails = await this.get(serverId);
|
|
@@ -6020,6 +6507,7 @@ var MCP = class {
|
|
|
6020
6507
|
* @param serverName - Name of the MCP server
|
|
6021
6508
|
|
|
6022
6509
|
* @returns Transformed response in appropriate format
|
|
6510
|
+
* @deprecated
|
|
6023
6511
|
*/
|
|
6024
6512
|
wrapMcpServerResponse(data, serverName, connectedAccountIds, userIds, toolkits) {
|
|
6025
6513
|
if (this.provider && typeof this.provider.wrapMcpServerResponse === "function") {
|
|
@@ -6045,6 +6533,7 @@ var MCP = class {
|
|
|
6045
6533
|
const transformed = this.provider.wrapMcpServerResponse(snakeCaseData);
|
|
6046
6534
|
return transformed;
|
|
6047
6535
|
}
|
|
6536
|
+
const self = this;
|
|
6048
6537
|
if (connectedAccountIds?.length && data.connectedAccountUrls) {
|
|
6049
6538
|
return data.connectedAccountUrls.map((url, index) => ({
|
|
6050
6539
|
url: new URL(url),
|
|
@@ -6688,7 +7177,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
6688
7177
|
};
|
|
6689
7178
|
|
|
6690
7179
|
// package.json
|
|
6691
|
-
var version = "0.1.
|
|
7180
|
+
var version = "0.1.53";
|
|
6692
7181
|
|
|
6693
7182
|
// src/models/Files.ts
|
|
6694
7183
|
var Files = class {
|
|
@@ -6746,6 +7235,82 @@ var getDefaultHeaders = (headers, provider) => {
|
|
|
6746
7235
|
};
|
|
6747
7236
|
};
|
|
6748
7237
|
|
|
7238
|
+
// src/types/toolRouter.types.ts
|
|
7239
|
+
import z10 from "zod";
|
|
7240
|
+
var ToolRouterToolkitConfigSchema = z10.object({
|
|
7241
|
+
toolkit: z10.string(),
|
|
7242
|
+
authConfigId: z10.string().optional()
|
|
7243
|
+
});
|
|
7244
|
+
var ToolRouterConfigSchema = z10.object({
|
|
7245
|
+
toolkits: z10.array(z10.union([z10.string(), ToolRouterToolkitConfigSchema])).optional(),
|
|
7246
|
+
manuallyManageConnections: z10.boolean().optional()
|
|
7247
|
+
});
|
|
7248
|
+
var ToolRouterSessionSchema = z10.object({
|
|
7249
|
+
sessionId: z10.string(),
|
|
7250
|
+
url: z10.string()
|
|
7251
|
+
});
|
|
7252
|
+
|
|
7253
|
+
// src/models/ToolRouter.experimental.ts
|
|
7254
|
+
var ToolRouter = class {
|
|
7255
|
+
constructor(client) {
|
|
7256
|
+
this.client = client;
|
|
7257
|
+
this.client = client;
|
|
7258
|
+
telemetry.instrument(this);
|
|
7259
|
+
}
|
|
7260
|
+
/**
|
|
7261
|
+
* Creates a new Session for the tool router
|
|
7262
|
+
*
|
|
7263
|
+
* @param userId {string} The user id to create the session for
|
|
7264
|
+
* @param routerConfig {ToolRouterConfig} The router config to use
|
|
7265
|
+
* @returns {Promise<ToolRouterSession>} The tool router session
|
|
7266
|
+
*
|
|
7267
|
+
* @example
|
|
7268
|
+
* ```typescript
|
|
7269
|
+
* import { Composio } form "@composio/core"
|
|
7270
|
+
*
|
|
7271
|
+
* const composio = new Composio()
|
|
7272
|
+
* const userId = "xxx-ooo-xxxx"
|
|
7273
|
+
*
|
|
7274
|
+
* const mcpSession = await composio.experimental.toolRouter.createSession(userId, {
|
|
7275
|
+
* toolkits: ["github", "hackernews", "slack"]
|
|
7276
|
+
* })
|
|
7277
|
+
*
|
|
7278
|
+
* // with auth configs
|
|
7279
|
+
* const mcpSession = await composio.experimental.toolRouter.createSession(userId, {
|
|
7280
|
+
* toolkits: [{ toolkit: "github", authConfingId: "ac_123455344"}]
|
|
7281
|
+
* ```
|
|
7282
|
+
*/
|
|
7283
|
+
async createSession(userId, routerConfig) {
|
|
7284
|
+
const config = ToolRouterConfigSchema.safeParse(routerConfig ?? {});
|
|
7285
|
+
if (config.error) {
|
|
7286
|
+
throw new ValidationError("Failed to parse tool router config", {
|
|
7287
|
+
cause: config.error
|
|
7288
|
+
});
|
|
7289
|
+
}
|
|
7290
|
+
const toolkitConfig = config.data.toolkits?.map((config2) => {
|
|
7291
|
+
if (typeof config2 === "string") {
|
|
7292
|
+
return { toolkit: config2 };
|
|
7293
|
+
} else {
|
|
7294
|
+
return {
|
|
7295
|
+
toolkit: config2.toolkit,
|
|
7296
|
+
auth_config_id: config2.authConfigId
|
|
7297
|
+
};
|
|
7298
|
+
}
|
|
7299
|
+
});
|
|
7300
|
+
const session = await this.client.toolRouter.createSession({
|
|
7301
|
+
user_id: userId,
|
|
7302
|
+
config: {
|
|
7303
|
+
toolkits: toolkitConfig,
|
|
7304
|
+
manually_manage_connections: config.data.manuallyManageConnections
|
|
7305
|
+
}
|
|
7306
|
+
});
|
|
7307
|
+
return transform(session).with(ToolRouterSessionSchema).using((raw) => ({
|
|
7308
|
+
sessionId: raw.session_id,
|
|
7309
|
+
url: raw.chat_session_mcp_url
|
|
7310
|
+
}));
|
|
7311
|
+
}
|
|
7312
|
+
};
|
|
7313
|
+
|
|
6749
7314
|
// src/composio.ts
|
|
6750
7315
|
var Composio = class _Composio {
|
|
6751
7316
|
/**
|
|
@@ -6766,11 +7331,17 @@ var Composio = class _Composio {
|
|
|
6766
7331
|
triggers;
|
|
6767
7332
|
provider;
|
|
6768
7333
|
files;
|
|
6769
|
-
// auth configs
|
|
6770
7334
|
authConfigs;
|
|
6771
|
-
// connected accounts
|
|
6772
7335
|
connectedAccounts;
|
|
6773
7336
|
mcp;
|
|
7337
|
+
/**
|
|
7338
|
+
* Experimental features
|
|
7339
|
+
*/
|
|
7340
|
+
experimental;
|
|
7341
|
+
/**
|
|
7342
|
+
* Deprecated features
|
|
7343
|
+
*/
|
|
7344
|
+
deprecated;
|
|
6774
7345
|
/**
|
|
6775
7346
|
* Creates a new instance of the Composio SDK.
|
|
6776
7347
|
*
|
|
@@ -6826,12 +7397,27 @@ var Composio = class _Composio {
|
|
|
6826
7397
|
logLevel: COMPOSIO_LOG_LEVEL
|
|
6827
7398
|
});
|
|
6828
7399
|
this.tools = new Tools(this.client, this.provider, this.config);
|
|
6829
|
-
this.mcp = new MCP(this.client
|
|
7400
|
+
this.mcp = new MCP(this.client);
|
|
6830
7401
|
this.toolkits = new Toolkits(this.client);
|
|
6831
7402
|
this.triggers = new Triggers(this.client);
|
|
6832
7403
|
this.authConfigs = new AuthConfigs(this.client);
|
|
6833
7404
|
this.files = new Files(this.client);
|
|
6834
7405
|
this.connectedAccounts = new ConnectedAccounts(this.client);
|
|
7406
|
+
this.experimental = {
|
|
7407
|
+
/**
|
|
7408
|
+
* Experimental tool router
|
|
7409
|
+
* Helps you create a single MCP server containing all the tools with smart routing.
|
|
7410
|
+
*
|
|
7411
|
+
* @description Allows you to create an isolated toolRouter MCP session for a user
|
|
7412
|
+
*/
|
|
7413
|
+
toolRouter: new ToolRouter(this.client)
|
|
7414
|
+
};
|
|
7415
|
+
this.deprecated = {
|
|
7416
|
+
/**
|
|
7417
|
+
* @deprecated this feature will be removed soon, use `composio.mcp`
|
|
7418
|
+
*/
|
|
7419
|
+
mcp: new MCP2(this.client, this.provider)
|
|
7420
|
+
};
|
|
6835
7421
|
if (this.config.allowTracking) {
|
|
6836
7422
|
telemetry.setup({
|
|
6837
7423
|
apiKey: apiKeyParsed ?? "",
|
|
@@ -7170,7 +7756,7 @@ export {
|
|
|
7170
7756
|
IncomingTriggerPayloadSchema,
|
|
7171
7757
|
JSONSchemaPropertySchema,
|
|
7172
7758
|
JsonSchemaToZodError,
|
|
7173
|
-
MCP,
|
|
7759
|
+
MCP2 as MCP,
|
|
7174
7760
|
MCPAuthOptionsSchema,
|
|
7175
7761
|
MCPGenerateURLParamsSchema,
|
|
7176
7762
|
MCPGetServerParamsSchema,
|