@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.cjs
CHANGED
|
@@ -103,7 +103,7 @@ __export(index_exports, {
|
|
|
103
103
|
IncomingTriggerPayloadSchema: () => IncomingTriggerPayloadSchema,
|
|
104
104
|
JSONSchemaPropertySchema: () => JSONSchemaPropertySchema,
|
|
105
105
|
JsonSchemaToZodError: () => JsonSchemaToZodError,
|
|
106
|
-
MCP: () =>
|
|
106
|
+
MCP: () => MCP2,
|
|
107
107
|
MCPAuthOptionsSchema: () => MCPAuthOptionsSchema,
|
|
108
108
|
MCPGenerateURLParamsSchema: () => MCPGenerateURLParamsSchema,
|
|
109
109
|
MCPGetServerParamsSchema: () => MCPGetServerParamsSchema,
|
|
@@ -206,7 +206,8 @@ var AuthSchemeTypes = {
|
|
|
206
206
|
GOOGLE_SERVICE_ACCOUNT: "GOOGLE_SERVICE_ACCOUNT",
|
|
207
207
|
NO_AUTH: "NO_AUTH",
|
|
208
208
|
BASIC_WITH_JWT: "BASIC_WITH_JWT",
|
|
209
|
-
CALCOM_AUTH: "CALCOM_AUTH"
|
|
209
|
+
CALCOM_AUTH: "CALCOM_AUTH",
|
|
210
|
+
SERVICE_ACCOUNT: "SERVICE_ACCOUNT"
|
|
210
211
|
};
|
|
211
212
|
var AuthConfigCreationToolAccessConfigSchema = import_zod.z.object({
|
|
212
213
|
toolsForConnectedAccountCreation: import_zod.z.array(import_zod.z.string()).optional()
|
|
@@ -225,7 +226,8 @@ var AuthSchemeEnum = import_zod.z.enum([
|
|
|
225
226
|
"GOOGLE_SERVICE_ACCOUNT",
|
|
226
227
|
"NO_AUTH",
|
|
227
228
|
"BASIC_WITH_JWT",
|
|
228
|
-
"CALCOM_AUTH"
|
|
229
|
+
"CALCOM_AUTH",
|
|
230
|
+
"SERVICE_ACCOUNT"
|
|
229
231
|
]);
|
|
230
232
|
var CreateCustomAuthConfigParamsSchema = import_zod.z.object({
|
|
231
233
|
type: import_zod.z.literal("use_custom_auth"),
|
|
@@ -3469,8 +3471,10 @@ var ToolKitItemSchema = import_zod7.z.object({
|
|
|
3469
3471
|
});
|
|
3470
3472
|
var ToolKitListResponseSchema = import_zod7.z.array(ToolKitItemSchema);
|
|
3471
3473
|
var ToolkitAuthFieldSchema = import_zod7.z.object({
|
|
3472
|
-
|
|
3474
|
+
description: import_zod7.z.string(),
|
|
3473
3475
|
displayName: import_zod7.z.string(),
|
|
3476
|
+
required: import_zod7.z.boolean(),
|
|
3477
|
+
name: import_zod7.z.string(),
|
|
3474
3478
|
type: import_zod7.z.string(),
|
|
3475
3479
|
default: import_zod7.z.string().nullable().optional()
|
|
3476
3480
|
});
|
|
@@ -5340,24 +5344,506 @@ var Triggers = class {
|
|
|
5340
5344
|
}
|
|
5341
5345
|
};
|
|
5342
5346
|
|
|
5347
|
+
// src/types/mcp.experimental.types.ts
|
|
5348
|
+
var import_zod10 = __toESM(require("zod"), 1);
|
|
5349
|
+
var MCPServerInstanceSchema = import_zod10.default.object({
|
|
5350
|
+
id: import_zod10.default.string(),
|
|
5351
|
+
name: import_zod10.default.string(),
|
|
5352
|
+
type: import_zod10.default.literal("streamable_http"),
|
|
5353
|
+
url: import_zod10.default.string(),
|
|
5354
|
+
userId: import_zod10.default.string(),
|
|
5355
|
+
allowedTools: import_zod10.default.array(import_zod10.default.string()),
|
|
5356
|
+
authConfigs: import_zod10.default.array(import_zod10.default.string())
|
|
5357
|
+
});
|
|
5358
|
+
var MCPConfigToolkitsSchema = import_zod10.default.object({
|
|
5359
|
+
toolkit: import_zod10.default.string().describe("Id of the toolkit").optional(),
|
|
5360
|
+
authConfigId: import_zod10.default.string().describe("Id of the auth config").optional()
|
|
5361
|
+
});
|
|
5362
|
+
var MCPConfigCreationParamsSchema = import_zod10.default.object({
|
|
5363
|
+
toolkits: import_zod10.default.array(import_zod10.default.union([MCPConfigToolkitsSchema, import_zod10.default.string()])),
|
|
5364
|
+
allowedTools: import_zod10.default.array(import_zod10.default.string()).optional(),
|
|
5365
|
+
manuallyManageConnections: import_zod10.default.boolean().default(false).optional().describe(
|
|
5366
|
+
`Whether to manually manage accounts. If true, you need to manage accounts manually connect user accounts.
|
|
5367
|
+
If set to false, composio will inject account maangement tools into your mcp server for agents to request and authenticate accounts.
|
|
5368
|
+
defaults to false`
|
|
5369
|
+
)
|
|
5370
|
+
});
|
|
5371
|
+
var MCPConfigResponseSchema = import_zod10.default.object({
|
|
5372
|
+
/**
|
|
5373
|
+
* Unique identifier for the newly created custom MCP server
|
|
5374
|
+
*/
|
|
5375
|
+
id: import_zod10.default.string(),
|
|
5376
|
+
/**
|
|
5377
|
+
* Human-readable name of the custom MCP server
|
|
5378
|
+
*/
|
|
5379
|
+
name: import_zod10.default.string(),
|
|
5380
|
+
/**
|
|
5381
|
+
* List of tool identifiers that are enabled for this server
|
|
5382
|
+
*/
|
|
5383
|
+
allowedTools: import_zod10.default.array(import_zod10.default.string()),
|
|
5384
|
+
/**
|
|
5385
|
+
* ID references to the auth configurations used by this server
|
|
5386
|
+
*/
|
|
5387
|
+
authConfigIds: import_zod10.default.array(import_zod10.default.string()),
|
|
5388
|
+
/**
|
|
5389
|
+
* Set of command line instructions for connecting various clients to this MCP server
|
|
5390
|
+
*/
|
|
5391
|
+
commands: import_zod10.default.object({
|
|
5392
|
+
/**
|
|
5393
|
+
* Command line instruction for Claude client setup
|
|
5394
|
+
*/
|
|
5395
|
+
claude: import_zod10.default.string(),
|
|
5396
|
+
/**
|
|
5397
|
+
* Command line instruction for Cursor client setup
|
|
5398
|
+
*/
|
|
5399
|
+
cursor: import_zod10.default.string(),
|
|
5400
|
+
/**
|
|
5401
|
+
* Command line instruction for Windsurf client setup
|
|
5402
|
+
*/
|
|
5403
|
+
windsurf: import_zod10.default.string()
|
|
5404
|
+
}),
|
|
5405
|
+
/**
|
|
5406
|
+
* URL endpoint for establishing Server-Sent Events (SSE) connection to this MCP server
|
|
5407
|
+
*/
|
|
5408
|
+
MCPUrl: import_zod10.default.string()
|
|
5409
|
+
});
|
|
5410
|
+
var MCPGetInstanceParamsSchema = import_zod10.default.object({
|
|
5411
|
+
manuallyManageConnections: import_zod10.default.boolean().default(false).optional().describe(
|
|
5412
|
+
`Whether to manually manage accounts. If true, you need to manage accounts manually connect user accounts.
|
|
5413
|
+
If set to false, composio will inject account maangement tools into your mcp server for agents to request and authenticate accounts.
|
|
5414
|
+
defaults to false`
|
|
5415
|
+
)
|
|
5416
|
+
});
|
|
5417
|
+
var MCPListParamsSchema = import_zod10.default.object({
|
|
5418
|
+
page: import_zod10.default.number().optional().default(1),
|
|
5419
|
+
limit: import_zod10.default.number().optional().default(10),
|
|
5420
|
+
toolkits: import_zod10.default.array(import_zod10.default.string()).optional().default([]),
|
|
5421
|
+
authConfigs: import_zod10.default.array(import_zod10.default.string()).optional().default([]),
|
|
5422
|
+
name: import_zod10.default.string().optional()
|
|
5423
|
+
});
|
|
5424
|
+
var MCPItemSchema = MCPConfigResponseSchema.extend({
|
|
5425
|
+
...import_zod10.default.object({
|
|
5426
|
+
toolkitIcons: import_zod10.default.record(import_zod10.default.string(), import_zod10.default.string()),
|
|
5427
|
+
serverInstanceCount: import_zod10.default.number(),
|
|
5428
|
+
toolkits: import_zod10.default.array(import_zod10.default.string())
|
|
5429
|
+
}).shape
|
|
5430
|
+
});
|
|
5431
|
+
var MCPListResponseSchema = import_zod10.default.object({
|
|
5432
|
+
items: import_zod10.default.array(MCPItemSchema),
|
|
5433
|
+
currentPage: import_zod10.default.number(),
|
|
5434
|
+
totalPages: import_zod10.default.number()
|
|
5435
|
+
});
|
|
5436
|
+
var MCPUpdateParamsSchema = import_zod10.default.object({
|
|
5437
|
+
name: import_zod10.default.string().optional(),
|
|
5438
|
+
toolkits: import_zod10.default.array(import_zod10.default.union([MCPConfigToolkitsSchema, import_zod10.default.string()])).optional(),
|
|
5439
|
+
allowedTools: import_zod10.default.array(import_zod10.default.string()).optional(),
|
|
5440
|
+
manuallyManageConnections: import_zod10.default.boolean().optional().describe(
|
|
5441
|
+
`Whether to manually manage accounts. If true, you need to manage accounts manually connect user accounts.
|
|
5442
|
+
If set to false, composio will inject account maangement tools into your mcp server for agents to request and authenticate accounts.
|
|
5443
|
+
defaults to false`
|
|
5444
|
+
)
|
|
5445
|
+
});
|
|
5446
|
+
var MCPServerConnectionStatus = import_zod10.default.object({
|
|
5447
|
+
connected: import_zod10.default.boolean(),
|
|
5448
|
+
toolkit: import_zod10.default.string(),
|
|
5449
|
+
connectedAccountId: import_zod10.default.string()
|
|
5450
|
+
});
|
|
5451
|
+
var MCPServerConnectedAccountsSchema = import_zod10.default.record(
|
|
5452
|
+
import_zod10.default.string(),
|
|
5453
|
+
import_zod10.default.array(
|
|
5454
|
+
import_zod10.default.object({
|
|
5455
|
+
toolkit: import_zod10.default.string(),
|
|
5456
|
+
authConfigId: import_zod10.default.string(),
|
|
5457
|
+
connectedAccountId: import_zod10.default.string()
|
|
5458
|
+
})
|
|
5459
|
+
)
|
|
5460
|
+
);
|
|
5461
|
+
|
|
5462
|
+
// src/models/MCP.experimental.ts
|
|
5463
|
+
function transformMCPItemResponse(response) {
|
|
5464
|
+
return transform(response).with(MCPItemSchema).using((raw) => ({
|
|
5465
|
+
name: raw.name,
|
|
5466
|
+
allowedTools: raw.allowed_tools,
|
|
5467
|
+
id: raw.id,
|
|
5468
|
+
authConfigIds: raw.auth_config_ids,
|
|
5469
|
+
commands: raw.commands,
|
|
5470
|
+
MCPUrl: raw.mcp_url,
|
|
5471
|
+
toolkitIcons: raw.toolkit_icons,
|
|
5472
|
+
serverInstanceCount: raw.server_instance_count,
|
|
5473
|
+
toolkits: raw.toolkits
|
|
5474
|
+
}));
|
|
5475
|
+
}
|
|
5476
|
+
var MCP = class {
|
|
5477
|
+
client;
|
|
5478
|
+
constructor(client) {
|
|
5479
|
+
this.client = client;
|
|
5480
|
+
telemetry.instrument(this);
|
|
5481
|
+
}
|
|
5482
|
+
/**
|
|
5483
|
+
* Create a new MCP configuration.
|
|
5484
|
+
* @param {Object} params - Parameters for creating the MCP configuration
|
|
5485
|
+
* @param {Array} params.authConfig - Array of auth configurations with id and allowed tools
|
|
5486
|
+
* @param {Object} params.options - Configuration options
|
|
5487
|
+
* @param {string} params.options.name - Unique name for the MCP configuration
|
|
5488
|
+
* @param {boolean} [params.options.manuallyManageConnections] - Whether to use chat-based authentication or manually connect accounts
|
|
5489
|
+
* @returns {Promise<McpServerCreateResponse<T>>} Created server details with instance getter
|
|
5490
|
+
*
|
|
5491
|
+
* @example
|
|
5492
|
+
* ```typescript
|
|
5493
|
+
* const server = await composio.mcpConfig.create("personal-mcp-server", {
|
|
5494
|
+
* toolkits: ["github", "slack"],
|
|
5495
|
+
* allowedTools: ["GMAIL_FETCH_EMAILS", "SLACK_SEND_MESSAGE"],
|
|
5496
|
+
* manuallyManageConnections: false
|
|
5497
|
+
* }
|
|
5498
|
+
* });
|
|
5499
|
+
*
|
|
5500
|
+
* const server = await composio.mcpConfig.create("personal-mcp-server", {
|
|
5501
|
+
* toolkits: [{ toolkit: "gmail", authConfigId: "ac_243434343" }],
|
|
5502
|
+
* allowedTools: ["GMAIL_FETCH_EMAILS"],
|
|
5503
|
+
* manuallyManageConnections: false
|
|
5504
|
+
* }
|
|
5505
|
+
* });
|
|
5506
|
+
* ```
|
|
5507
|
+
*/
|
|
5508
|
+
async create(name, mcpConfig) {
|
|
5509
|
+
const config = MCPConfigCreationParamsSchema.safeParse(mcpConfig);
|
|
5510
|
+
if (config.error) {
|
|
5511
|
+
throw new ValidationError("Invalid parameters passed to create mcp config", {
|
|
5512
|
+
cause: config.error
|
|
5513
|
+
});
|
|
5514
|
+
}
|
|
5515
|
+
const toolkits = [];
|
|
5516
|
+
const auth_config_ids = [];
|
|
5517
|
+
const custom_tools = config.data.allowedTools ?? [];
|
|
5518
|
+
config.data.toolkits.forEach((toolkit) => {
|
|
5519
|
+
if (typeof toolkit === "string") {
|
|
5520
|
+
toolkits.push(toolkit);
|
|
5521
|
+
} else if (toolkit.toolkit) {
|
|
5522
|
+
toolkits.push(toolkit.toolkit);
|
|
5523
|
+
} else if (toolkit.authConfigId) {
|
|
5524
|
+
auth_config_ids.push(toolkit.authConfigId);
|
|
5525
|
+
}
|
|
5526
|
+
});
|
|
5527
|
+
const server = await this.client.mcp.custom.create({
|
|
5528
|
+
name,
|
|
5529
|
+
toolkits,
|
|
5530
|
+
auth_config_ids,
|
|
5531
|
+
custom_tools,
|
|
5532
|
+
// if manually manage account is set to true, disable composio account management tools
|
|
5533
|
+
managed_auth_via_composio: config.data.manuallyManageConnections ? false : true
|
|
5534
|
+
});
|
|
5535
|
+
const camelCaseServer = transform(server).with(MCPConfigResponseSchema).using((raw) => ({
|
|
5536
|
+
name: raw.name,
|
|
5537
|
+
allowedTools: raw.allowed_tools,
|
|
5538
|
+
id: raw.id,
|
|
5539
|
+
authConfigIds: raw.auth_config_ids,
|
|
5540
|
+
commands: raw.commands,
|
|
5541
|
+
MCPUrl: raw.mcp_url
|
|
5542
|
+
}));
|
|
5543
|
+
return {
|
|
5544
|
+
...camelCaseServer,
|
|
5545
|
+
generate: async (userId) => {
|
|
5546
|
+
return await this.generate(userId, server.id, {
|
|
5547
|
+
manuallyManageConnections: config.data.manuallyManageConnections
|
|
5548
|
+
});
|
|
5549
|
+
}
|
|
5550
|
+
};
|
|
5551
|
+
}
|
|
5552
|
+
/**
|
|
5553
|
+
* List the MCP servers with optional filtering and pagination
|
|
5554
|
+
* @param {Object} options - Filtering and pagination options
|
|
5555
|
+
* @param {number} [options.page=1] - Page number for pagination (1-based)
|
|
5556
|
+
* @param {number} [options.limit=10] - Maximum number of items to return per page
|
|
5557
|
+
* @param {string[]} [options.toolkits=[]] - Array of toolkit names to filter by
|
|
5558
|
+
* @param {string[]} [options.authConfigs=[]] - Array of auth configuration IDs to filter by
|
|
5559
|
+
* @param {string} [options.name] - Filter by MCP server name (partial match)
|
|
5560
|
+
* @returns {Promise<MCPListResponse>} Paginated list of MCP servers with metadata
|
|
5561
|
+
*
|
|
5562
|
+
* @example
|
|
5563
|
+
* ```typescript
|
|
5564
|
+
* // List all MCP servers
|
|
5565
|
+
* const allServers = await composio.experimental.mcp.list({});
|
|
5566
|
+
*
|
|
5567
|
+
* // List with pagination
|
|
5568
|
+
* const pagedServers = await composio.experimental.mcp.list({
|
|
5569
|
+
* page: 2,
|
|
5570
|
+
* limit: 5
|
|
5571
|
+
* });
|
|
5572
|
+
*
|
|
5573
|
+
* // Filter by toolkit
|
|
5574
|
+
* const githubServers = await composio.experimental.mcp.list({
|
|
5575
|
+
* toolkits: ['github', 'slack']
|
|
5576
|
+
* });
|
|
5577
|
+
*
|
|
5578
|
+
* // Filter by name
|
|
5579
|
+
* const namedServers = await composio.experimental.mcp.list({
|
|
5580
|
+
* name: 'personal'
|
|
5581
|
+
* });
|
|
5582
|
+
* ```
|
|
5583
|
+
*/
|
|
5584
|
+
async list(options) {
|
|
5585
|
+
const { data: params, error } = MCPListParamsSchema.safeParse(options);
|
|
5586
|
+
if (error) {
|
|
5587
|
+
throw new ValidationError("Failed to validate list options", {
|
|
5588
|
+
cause: error
|
|
5589
|
+
});
|
|
5590
|
+
}
|
|
5591
|
+
const listResponse = await this.client.mcp.list({
|
|
5592
|
+
page_no: params.page,
|
|
5593
|
+
limit: params.limit,
|
|
5594
|
+
toolkits: params.toolkits?.length > 0 ? params.toolkits.join(",") : void 0,
|
|
5595
|
+
auth_config_ids: params.authConfigs?.length > 0 ? params.authConfigs.join(",") : void 0,
|
|
5596
|
+
name: params.name
|
|
5597
|
+
});
|
|
5598
|
+
const transformedListResponse = transform(listResponse).with(MCPListResponseSchema).using((raw) => ({
|
|
5599
|
+
currentPage: raw.current_page,
|
|
5600
|
+
totalPages: raw.total_pages,
|
|
5601
|
+
items: raw.items.map((item) => ({
|
|
5602
|
+
name: item.name,
|
|
5603
|
+
allowedTools: item.allowed_tools,
|
|
5604
|
+
id: item.id,
|
|
5605
|
+
authConfigIds: item.auth_config_ids,
|
|
5606
|
+
commands: item.commands,
|
|
5607
|
+
MCPUrl: item.mcp_url,
|
|
5608
|
+
toolkitIcons: item.toolkit_icons,
|
|
5609
|
+
serverInstanceCount: item.server_instance_count,
|
|
5610
|
+
toolkits: item.toolkits
|
|
5611
|
+
}))
|
|
5612
|
+
}));
|
|
5613
|
+
return transformedListResponse;
|
|
5614
|
+
}
|
|
5615
|
+
/**
|
|
5616
|
+
* Retrieve detailed information about a specific MCP server by its ID
|
|
5617
|
+
* @param {string} serverId - The unique identifier of the MCP server to retrieve
|
|
5618
|
+
* @returns {Promise<MCPItem>} Complete MCP server details including configuration, tools, and metadata
|
|
5619
|
+
*
|
|
5620
|
+
* @example
|
|
5621
|
+
* ```typescript
|
|
5622
|
+
* // Get a specific MCP server by ID
|
|
5623
|
+
* const server = await composio.experimental.mcp.get("mcp_12345");
|
|
5624
|
+
*
|
|
5625
|
+
* console.log(server.name); // "My Personal MCP Server"
|
|
5626
|
+
* console.log(server.allowedTools); // ["GITHUB_CREATE_ISSUE", "SLACK_SEND_MESSAGE"]
|
|
5627
|
+
* console.log(server.toolkits); // ["github", "slack"]
|
|
5628
|
+
* console.log(server.serverInstanceCount); // 3
|
|
5629
|
+
*
|
|
5630
|
+
* // Access setup commands for different clients
|
|
5631
|
+
* console.log(server.commands.claude); // Claude setup command
|
|
5632
|
+
* console.log(server.commands.cursor); // Cursor setup command
|
|
5633
|
+
* console.log(server.commands.windsurf); // Windsurf setup command
|
|
5634
|
+
*
|
|
5635
|
+
* // Use the MCP URL for direct connections
|
|
5636
|
+
* const mcpUrl = server.MCPUrl;
|
|
5637
|
+
* ```
|
|
5638
|
+
*
|
|
5639
|
+
* @throws {ValidationError} When the server ID is invalid or server not found
|
|
5640
|
+
*/
|
|
5641
|
+
async get(serverId) {
|
|
5642
|
+
const response = await this.client.mcp.retrieve(serverId);
|
|
5643
|
+
return transformMCPItemResponse(response);
|
|
5644
|
+
}
|
|
5645
|
+
/**
|
|
5646
|
+
* Delete an MCP server configuration permanently
|
|
5647
|
+
* @param {string} serverId - The unique identifier of the MCP server to delete
|
|
5648
|
+
* @returns {Promise<{id: string; deleted: boolean}>} Confirmation object with server ID and deletion status
|
|
5649
|
+
*
|
|
5650
|
+
* @example
|
|
5651
|
+
* ```typescript
|
|
5652
|
+
* // Delete an MCP server by ID
|
|
5653
|
+
* const result = await composio.experimental.mcp.delete("mcp_12345");
|
|
5654
|
+
*
|
|
5655
|
+
* if (result.deleted) {
|
|
5656
|
+
* console.log(`Server ${result.id} has been successfully deleted`);
|
|
5657
|
+
* } else {
|
|
5658
|
+
* console.log(`Failed to delete server ${result.id}`);
|
|
5659
|
+
* }
|
|
5660
|
+
*
|
|
5661
|
+
* // Example with error handling
|
|
5662
|
+
* try {
|
|
5663
|
+
* const result = await composio.experimental.mcp.delete("mcp_12345");
|
|
5664
|
+
* console.log("Deletion successful:", result);
|
|
5665
|
+
* } catch (error) {
|
|
5666
|
+
* console.error("Failed to delete MCP server:", error.message);
|
|
5667
|
+
* }
|
|
5668
|
+
*
|
|
5669
|
+
* // Delete and verify from list
|
|
5670
|
+
* await composio.experimental.mcp.delete("mcp_12345");
|
|
5671
|
+
* const servers = await composio.experimental.mcp.list({});
|
|
5672
|
+
* const serverExists = servers.items.some(server => server.id === "mcp_12345");
|
|
5673
|
+
* console.log("Server still exists:", serverExists); // Should be false
|
|
5674
|
+
* ```
|
|
5675
|
+
*
|
|
5676
|
+
* @throws {ValidationError} When the server ID is invalid or server not found
|
|
5677
|
+
* @throws {Error} When the server cannot be deleted due to active connections or other constraints
|
|
5678
|
+
*
|
|
5679
|
+
* @warning This operation is irreversible. Once deleted, the MCP server configuration and all its associated data will be permanently removed.
|
|
5680
|
+
*/
|
|
5681
|
+
async delete(serverId) {
|
|
5682
|
+
return await this.client.mcp.delete(serverId);
|
|
5683
|
+
}
|
|
5684
|
+
/**
|
|
5685
|
+
* Update an existing MCP server configuration with new settings
|
|
5686
|
+
* @param {string} serverId - The unique identifier of the MCP server to update
|
|
5687
|
+
* @param {Object} config - Update configuration parameters
|
|
5688
|
+
* @param {string} [config.name] - New name for the MCP server
|
|
5689
|
+
* @param {Array} [config.toolkits] - Updated toolkit configurations
|
|
5690
|
+
* @param {string} [config.toolkits[].toolkit] - Toolkit identifier (e.g., "github", "slack")
|
|
5691
|
+
* @param {string} [config.toolkits[].authConfigId] - Auth configuration ID for the toolkit
|
|
5692
|
+
* @param {string[]} [config.toolkits[].allowedTools] - Specific tools to enable for this toolkit
|
|
5693
|
+
* @param {boolean} [config.manuallyManageConnections] - Whether to manually manage account connections
|
|
5694
|
+
* @returns {Promise<MCPItem>} Updated MCP server configuration with all details
|
|
5695
|
+
*
|
|
5696
|
+
* @example
|
|
5697
|
+
* ```typescript
|
|
5698
|
+
* // Update server name only
|
|
5699
|
+
* const updatedServer = await composio.experimental.mcp.update("mcp_12345", {
|
|
5700
|
+
* name: "My Updated MCP Server"
|
|
5701
|
+
* });
|
|
5702
|
+
*
|
|
5703
|
+
* // Update toolkits and tools
|
|
5704
|
+
* const serverWithNewTools = await composio.experimental.mcp.update("mcp_12345", {
|
|
5705
|
+
* toolkits: [
|
|
5706
|
+
* {
|
|
5707
|
+
* toolkit: "github",
|
|
5708
|
+
* authConfigId: "auth_abc123",
|
|
5709
|
+
* allowedTools: ["GITHUB_CREATE_ISSUE", "GITHUB_LIST_REPOS"]
|
|
5710
|
+
* },
|
|
5711
|
+
* {
|
|
5712
|
+
* toolkit: "slack",
|
|
5713
|
+
* authConfigId: "auth_xyz789",
|
|
5714
|
+
* allowedTools: ["SLACK_SEND_MESSAGE", "SLACK_LIST_CHANNELS"]
|
|
5715
|
+
* }
|
|
5716
|
+
* ]
|
|
5717
|
+
* });
|
|
5718
|
+
*
|
|
5719
|
+
* // Update connection management setting
|
|
5720
|
+
* const serverWithManualAuth = await composio.experimental.mcp.update("mcp_12345", {
|
|
5721
|
+
* name: "Manual Auth Server",
|
|
5722
|
+
* manuallyManageConnections: true
|
|
5723
|
+
* });
|
|
5724
|
+
*
|
|
5725
|
+
* // Complete update example
|
|
5726
|
+
* const fullyUpdatedServer = await composio.experimental.mcp.update("mcp_12345", {
|
|
5727
|
+
* name: "Production MCP Server",
|
|
5728
|
+
* toolkits: [
|
|
5729
|
+
* {
|
|
5730
|
+
* toolkit: "gmail",
|
|
5731
|
+
* authConfigId: "auth_gmail_prod",
|
|
5732
|
+
* }
|
|
5733
|
+
* ],
|
|
5734
|
+
* allowedTools: ["GMAIL_SEND_EMAIL", "GMAIL_FETCH_EMAILS"]
|
|
5735
|
+
* manuallyManageConnections: false
|
|
5736
|
+
* });
|
|
5737
|
+
*
|
|
5738
|
+
* console.log("Updated server:", fullyUpdatedServer.name);
|
|
5739
|
+
* console.log("New tools:", fullyUpdatedServer.allowedTools);
|
|
5740
|
+
* ```
|
|
5741
|
+
*
|
|
5742
|
+
* @throws {ValidationError} When the update parameters are invalid or malformed
|
|
5743
|
+
* @throws {Error} When the server ID doesn't exist or update fails
|
|
5744
|
+
*
|
|
5745
|
+
* @note Only provided fields will be updated. Omitted fields will retain their current values.
|
|
5746
|
+
* @note When updating toolkits, the entire toolkit configuration is replaced, not merged.
|
|
5747
|
+
*/
|
|
5748
|
+
async update(serverId, config) {
|
|
5749
|
+
const { data: params, error } = MCPUpdateParamsSchema.safeParse(config);
|
|
5750
|
+
if (error) {
|
|
5751
|
+
throw new ValidationError("Failed to validate update params", {
|
|
5752
|
+
cause: error
|
|
5753
|
+
});
|
|
5754
|
+
}
|
|
5755
|
+
const toolkits = [];
|
|
5756
|
+
const auth_config_ids = [];
|
|
5757
|
+
const custom_tools = params.allowedTools ?? void 0;
|
|
5758
|
+
params.toolkits?.forEach((toolkit) => {
|
|
5759
|
+
if (typeof toolkit === "string") {
|
|
5760
|
+
toolkits.push(toolkit);
|
|
5761
|
+
} else if (toolkit.toolkit) {
|
|
5762
|
+
toolkits.push(toolkit.toolkit);
|
|
5763
|
+
} else if (toolkit.authConfigId) {
|
|
5764
|
+
auth_config_ids.push(toolkit.authConfigId);
|
|
5765
|
+
}
|
|
5766
|
+
});
|
|
5767
|
+
const response = await this.client.mcp.update(serverId, {
|
|
5768
|
+
...{ name: params.name ?? void 0 },
|
|
5769
|
+
...params.toolkits ? {
|
|
5770
|
+
custom_tools,
|
|
5771
|
+
toolkits,
|
|
5772
|
+
auth_config_ids
|
|
5773
|
+
} : {},
|
|
5774
|
+
...{ managed_auth_via_composio: params.manuallyManageConnections ?? void 0 }
|
|
5775
|
+
});
|
|
5776
|
+
return transformMCPItemResponse(response);
|
|
5777
|
+
}
|
|
5778
|
+
/**
|
|
5779
|
+
* Get server URLs for an existing MCP server.
|
|
5780
|
+
* The response is wrapped according to the provider's specifications.
|
|
5781
|
+
*
|
|
5782
|
+
* @example
|
|
5783
|
+
* ```typescript
|
|
5784
|
+
* import { Composio } from "@composio/code";
|
|
5785
|
+
*
|
|
5786
|
+
* const composio = new Composio();
|
|
5787
|
+
* const mcp = await composio.experimental.mcp.generate("default", "<mcp_config_id>");
|
|
5788
|
+
* ```
|
|
5789
|
+
*
|
|
5790
|
+
* @param userId {string} external user id from your database for whom you want the server for
|
|
5791
|
+
* @param mcpConfigId {string} config id of the MCPConfig for which you want to create a server for
|
|
5792
|
+
* @param options {object} additional options
|
|
5793
|
+
* @param options.isChatAuth {boolean} Authenticate the users via chat when they use the MCP Server
|
|
5794
|
+
*/
|
|
5795
|
+
async generate(userId, mcpConfigId, options) {
|
|
5796
|
+
const server = await this.client.mcp.retrieve(mcpConfigId);
|
|
5797
|
+
const params = MCPGetInstanceParamsSchema.safeParse(
|
|
5798
|
+
options ?? { manuallyManageConnections: false }
|
|
5799
|
+
);
|
|
5800
|
+
if (params.error) {
|
|
5801
|
+
throw new ValidationError("Invalid params passed for Get Instance Params", {
|
|
5802
|
+
cause: params.error
|
|
5803
|
+
});
|
|
5804
|
+
}
|
|
5805
|
+
const urlResponse = await this.client.mcp.generate.url({
|
|
5806
|
+
mcp_server_id: mcpConfigId,
|
|
5807
|
+
user_ids: [userId],
|
|
5808
|
+
managed_auth_by_composio: options?.manuallyManageConnections ? false : true
|
|
5809
|
+
});
|
|
5810
|
+
const userIdsURL = urlResponse.user_ids_url[0];
|
|
5811
|
+
const serverInstance = MCPServerInstanceSchema.safeParse({
|
|
5812
|
+
id: server.id,
|
|
5813
|
+
name: server.name,
|
|
5814
|
+
type: "streamable_http",
|
|
5815
|
+
url: userIdsURL,
|
|
5816
|
+
userId,
|
|
5817
|
+
allowedTools: server.allowed_tools,
|
|
5818
|
+
authConfigs: server.auth_config_ids
|
|
5819
|
+
});
|
|
5820
|
+
if (serverInstance.error) {
|
|
5821
|
+
throw new ValidationError("Failed to parse MCP server instance", {
|
|
5822
|
+
cause: serverInstance.error
|
|
5823
|
+
});
|
|
5824
|
+
}
|
|
5825
|
+
return serverInstance.data;
|
|
5826
|
+
}
|
|
5827
|
+
};
|
|
5828
|
+
|
|
5343
5829
|
// src/types/mcp.types.ts
|
|
5344
|
-
var
|
|
5345
|
-
var MCPToolkitConfigSchema =
|
|
5346
|
-
toolkit:
|
|
5347
|
-
authConfigId:
|
|
5348
|
-
allowedTools:
|
|
5830
|
+
var import_zod11 = require("zod");
|
|
5831
|
+
var MCPToolkitConfigSchema = import_zod11.z.object({
|
|
5832
|
+
toolkit: import_zod11.z.string().min(1, "Toolkit name cannot be empty"),
|
|
5833
|
+
authConfigId: import_zod11.z.string().min(1, "Auth config ID cannot be empty"),
|
|
5834
|
+
allowedTools: import_zod11.z.array(import_zod11.z.string().min(1, "Tool name cannot be empty")).min(1, "At least one tool must be specified")
|
|
5349
5835
|
});
|
|
5350
|
-
var MCPToolkitConfigsArraySchema =
|
|
5836
|
+
var MCPToolkitConfigsArraySchema = import_zod11.z.array(MCPToolkitConfigSchema).min(1, "At least one toolkit configuration is required").refine((configs) => {
|
|
5351
5837
|
const toolkits = configs.map((config) => config.toolkit);
|
|
5352
5838
|
const uniqueToolkits = new Set(toolkits);
|
|
5353
5839
|
return uniqueToolkits.size === toolkits.length;
|
|
5354
5840
|
}, "Duplicate toolkits are not allowed. Each toolkit must be unique.");
|
|
5355
|
-
var MCPAuthOptionsSchema =
|
|
5356
|
-
isChatAuth:
|
|
5841
|
+
var MCPAuthOptionsSchema = import_zod11.z.object({
|
|
5842
|
+
isChatAuth: import_zod11.z.boolean().optional()
|
|
5357
5843
|
});
|
|
5358
|
-
var MCPGetServerParamsSchema =
|
|
5359
|
-
userId:
|
|
5360
|
-
connectedAccountIds:
|
|
5844
|
+
var MCPGetServerParamsSchema = import_zod11.z.object({
|
|
5845
|
+
userId: import_zod11.z.string().min(1, "User ID cannot be empty").optional(),
|
|
5846
|
+
connectedAccountIds: import_zod11.z.record(import_zod11.z.string(), import_zod11.z.string().min(1, "Account ID cannot be empty")).optional()
|
|
5361
5847
|
}).refine(
|
|
5362
5848
|
(data) => {
|
|
5363
5849
|
const hasUserId = !!data.userId;
|
|
@@ -5368,61 +5854,61 @@ var MCPGetServerParamsSchema = import_zod10.z.object({
|
|
|
5368
5854
|
message: "Must provide either userId or connectedAccountIds, but not both"
|
|
5369
5855
|
}
|
|
5370
5856
|
);
|
|
5371
|
-
var MCPGenerateURLParamsSchema =
|
|
5372
|
-
userIds:
|
|
5373
|
-
connectedAccountIds:
|
|
5374
|
-
isChatAuth:
|
|
5857
|
+
var MCPGenerateURLParamsSchema = import_zod11.z.object({
|
|
5858
|
+
userIds: import_zod11.z.array(import_zod11.z.string()).optional(),
|
|
5859
|
+
connectedAccountIds: import_zod11.z.array(import_zod11.z.string()).optional(),
|
|
5860
|
+
isChatAuth: import_zod11.z.boolean().optional()
|
|
5375
5861
|
});
|
|
5376
|
-
var ComposioGenerateURLParamsSchema =
|
|
5377
|
-
user_ids:
|
|
5378
|
-
connected_account_ids:
|
|
5379
|
-
mcp_server_id:
|
|
5380
|
-
managed_auth_by_composio:
|
|
5862
|
+
var ComposioGenerateURLParamsSchema = import_zod11.z.object({
|
|
5863
|
+
user_ids: import_zod11.z.array(import_zod11.z.string()).optional(),
|
|
5864
|
+
connected_account_ids: import_zod11.z.array(import_zod11.z.string()).optional(),
|
|
5865
|
+
mcp_server_id: import_zod11.z.string(),
|
|
5866
|
+
managed_auth_by_composio: import_zod11.z.boolean().optional()
|
|
5381
5867
|
});
|
|
5382
|
-
var GenerateURLParamsSchema =
|
|
5383
|
-
userIds:
|
|
5384
|
-
connectedAccountIds:
|
|
5385
|
-
mcpServerId:
|
|
5386
|
-
composioManagedAuth:
|
|
5868
|
+
var GenerateURLParamsSchema = import_zod11.z.object({
|
|
5869
|
+
userIds: import_zod11.z.array(import_zod11.z.string()).optional(),
|
|
5870
|
+
connectedAccountIds: import_zod11.z.array(import_zod11.z.string()).optional(),
|
|
5871
|
+
mcpServerId: import_zod11.z.string(),
|
|
5872
|
+
composioManagedAuth: import_zod11.z.boolean().optional()
|
|
5387
5873
|
});
|
|
5388
|
-
var GenerateURLResponseSchema =
|
|
5389
|
-
connectedAccountUrls:
|
|
5390
|
-
userIdsUrl:
|
|
5391
|
-
mcpUrl:
|
|
5874
|
+
var GenerateURLResponseSchema = import_zod11.z.object({
|
|
5875
|
+
connectedAccountUrls: import_zod11.z.array(import_zod11.z.string()).optional(),
|
|
5876
|
+
userIdsUrl: import_zod11.z.array(import_zod11.z.string()).optional(),
|
|
5877
|
+
mcpUrl: import_zod11.z.string().min(1, "MCP URL cannot be empty")
|
|
5392
5878
|
});
|
|
5393
|
-
var ComposioGenerateURLResponseSchema =
|
|
5394
|
-
connected_account_urls:
|
|
5395
|
-
user_ids_url:
|
|
5396
|
-
mcp_url:
|
|
5879
|
+
var ComposioGenerateURLResponseSchema = import_zod11.z.object({
|
|
5880
|
+
connected_account_urls: import_zod11.z.array(import_zod11.z.string()).optional(),
|
|
5881
|
+
user_ids_url: import_zod11.z.array(import_zod11.z.string()).optional(),
|
|
5882
|
+
mcp_url: import_zod11.z.string().min(1, "MCP URL cannot be empty")
|
|
5397
5883
|
});
|
|
5398
|
-
var MCPSingleAppServerSchema =
|
|
5399
|
-
name:
|
|
5400
|
-
tools:
|
|
5401
|
-
authConfigId:
|
|
5884
|
+
var MCPSingleAppServerSchema = import_zod11.z.object({
|
|
5885
|
+
name: import_zod11.z.string().describe("Name of the MCP server"),
|
|
5886
|
+
tools: import_zod11.z.array(import_zod11.z.string()).describe("List of allowed tools"),
|
|
5887
|
+
authConfigId: import_zod11.z.string().optional().describe("Auth config ID for the server")
|
|
5402
5888
|
});
|
|
5403
|
-
var MCPMultiAppServerSchema =
|
|
5404
|
-
name:
|
|
5405
|
-
tools:
|
|
5406
|
-
toolkits:
|
|
5889
|
+
var MCPMultiAppServerSchema = import_zod11.z.object({
|
|
5890
|
+
name: import_zod11.z.string().describe("Name of the MCP server"),
|
|
5891
|
+
tools: import_zod11.z.array(import_zod11.z.string()).describe("List of allowed tools across toolkits"),
|
|
5892
|
+
toolkits: import_zod11.z.array(import_zod11.z.string()).describe("List of allowed toolkits")
|
|
5407
5893
|
});
|
|
5408
|
-
var MCPServerSchema =
|
|
5409
|
-
id:
|
|
5410
|
-
type:
|
|
5411
|
-
createdAt:
|
|
5412
|
-
updatedAt:
|
|
5413
|
-
status:
|
|
5414
|
-
config:
|
|
5894
|
+
var MCPServerSchema = import_zod11.z.object({
|
|
5895
|
+
id: import_zod11.z.string().describe("Unique identifier for the MCP server"),
|
|
5896
|
+
type: import_zod11.z.enum(["single", "multi"]).describe("Type of MCP server"),
|
|
5897
|
+
createdAt: import_zod11.z.string().describe("Creation timestamp"),
|
|
5898
|
+
updatedAt: import_zod11.z.string().describe("Last update timestamp"),
|
|
5899
|
+
status: import_zod11.z.enum(["active", "inactive", "error"]).default("active"),
|
|
5900
|
+
config: import_zod11.z.union([MCPSingleAppServerSchema, MCPMultiAppServerSchema])
|
|
5415
5901
|
});
|
|
5416
|
-
var MCPServerListResponseSchema =
|
|
5417
|
-
items:
|
|
5418
|
-
total:
|
|
5419
|
-
page:
|
|
5420
|
-
pageSize:
|
|
5902
|
+
var MCPServerListResponseSchema = import_zod11.z.object({
|
|
5903
|
+
items: import_zod11.z.array(MCPServerSchema),
|
|
5904
|
+
total: import_zod11.z.number(),
|
|
5905
|
+
page: import_zod11.z.number(),
|
|
5906
|
+
pageSize: import_zod11.z.number()
|
|
5421
5907
|
});
|
|
5422
|
-
var MCPServerUpdateParamsSchema =
|
|
5423
|
-
name:
|
|
5424
|
-
toolkits:
|
|
5425
|
-
allowedTools:
|
|
5908
|
+
var MCPServerUpdateParamsSchema = import_zod11.z.object({
|
|
5909
|
+
name: import_zod11.z.string().optional().describe("New name for the server"),
|
|
5910
|
+
toolkits: import_zod11.z.array(import_zod11.z.string()).optional().describe("Updated list of toolkits"),
|
|
5911
|
+
allowedTools: import_zod11.z.array(import_zod11.z.string()).optional().describe("Updated list of allowed tools")
|
|
5426
5912
|
});
|
|
5427
5913
|
var MCPServerCreateResponseSchema = MCPServerSchema;
|
|
5428
5914
|
var ConnectionStatus = /* @__PURE__ */ ((ConnectionStatus2) => {
|
|
@@ -5430,96 +5916,96 @@ var ConnectionStatus = /* @__PURE__ */ ((ConnectionStatus2) => {
|
|
|
5430
5916
|
ConnectionStatus2["DISCONNECTED"] = "DISCONNECTED";
|
|
5431
5917
|
return ConnectionStatus2;
|
|
5432
5918
|
})(ConnectionStatus || {});
|
|
5433
|
-
var CustomCreateResponseSchema =
|
|
5434
|
-
id:
|
|
5435
|
-
name:
|
|
5436
|
-
createdAt:
|
|
5437
|
-
updatedAt:
|
|
5438
|
-
status:
|
|
5919
|
+
var CustomCreateResponseSchema = import_zod11.z.object({
|
|
5920
|
+
id: import_zod11.z.string().min(1, "Server ID cannot be empty"),
|
|
5921
|
+
name: import_zod11.z.string().min(1, "Server name cannot be empty"),
|
|
5922
|
+
createdAt: import_zod11.z.string().nullish(),
|
|
5923
|
+
updatedAt: import_zod11.z.string().nullish(),
|
|
5924
|
+
status: import_zod11.z.string().nullish()
|
|
5439
5925
|
});
|
|
5440
|
-
var ComposioCustomCreateResponseSchema =
|
|
5441
|
-
id:
|
|
5442
|
-
name:
|
|
5443
|
-
created_at:
|
|
5444
|
-
updated_at:
|
|
5445
|
-
status:
|
|
5926
|
+
var ComposioCustomCreateResponseSchema = import_zod11.z.object({
|
|
5927
|
+
id: import_zod11.z.string().min(1, "Server ID cannot be empty"),
|
|
5928
|
+
name: import_zod11.z.string().min(1, "Server name cannot be empty"),
|
|
5929
|
+
created_at: import_zod11.z.string().nullish(),
|
|
5930
|
+
updated_at: import_zod11.z.string().nullish(),
|
|
5931
|
+
status: import_zod11.z.string().nullish()
|
|
5446
5932
|
});
|
|
5447
|
-
var McpListResponseSchema =
|
|
5448
|
-
items:
|
|
5449
|
-
|
|
5450
|
-
id:
|
|
5451
|
-
name:
|
|
5452
|
-
createdAt:
|
|
5453
|
-
updatedAt:
|
|
5454
|
-
status:
|
|
5933
|
+
var McpListResponseSchema = import_zod11.z.object({
|
|
5934
|
+
items: import_zod11.z.array(
|
|
5935
|
+
import_zod11.z.object({
|
|
5936
|
+
id: import_zod11.z.string().min(1, "Server ID cannot be empty"),
|
|
5937
|
+
name: import_zod11.z.string().min(1, "Server name cannot be empty"),
|
|
5938
|
+
createdAt: import_zod11.z.string().optional(),
|
|
5939
|
+
updatedAt: import_zod11.z.string().optional(),
|
|
5940
|
+
status: import_zod11.z.string().optional()
|
|
5455
5941
|
})
|
|
5456
5942
|
).optional()
|
|
5457
5943
|
});
|
|
5458
|
-
var ComposioMcpListResponseSchema =
|
|
5459
|
-
items:
|
|
5460
|
-
|
|
5461
|
-
id:
|
|
5462
|
-
name:
|
|
5463
|
-
created_at:
|
|
5464
|
-
updated_at:
|
|
5465
|
-
status:
|
|
5944
|
+
var ComposioMcpListResponseSchema = import_zod11.z.object({
|
|
5945
|
+
items: import_zod11.z.array(
|
|
5946
|
+
import_zod11.z.object({
|
|
5947
|
+
id: import_zod11.z.string().min(1, "Server ID cannot be empty"),
|
|
5948
|
+
name: import_zod11.z.string().min(1, "Server name cannot be empty"),
|
|
5949
|
+
created_at: import_zod11.z.string().optional(),
|
|
5950
|
+
updated_at: import_zod11.z.string().optional(),
|
|
5951
|
+
status: import_zod11.z.string().optional()
|
|
5466
5952
|
})
|
|
5467
5953
|
).optional()
|
|
5468
5954
|
});
|
|
5469
|
-
var McpRetrieveResponseSchema =
|
|
5470
|
-
id:
|
|
5471
|
-
name:
|
|
5472
|
-
createdAt:
|
|
5473
|
-
updatedAt:
|
|
5474
|
-
status:
|
|
5475
|
-
toolkits:
|
|
5476
|
-
tools:
|
|
5477
|
-
managedAuthViaComposio:
|
|
5478
|
-
authConfigIds:
|
|
5479
|
-
mcpUrl:
|
|
5480
|
-
commands:
|
|
5481
|
-
claude:
|
|
5482
|
-
cursor:
|
|
5483
|
-
windsurf:
|
|
5955
|
+
var McpRetrieveResponseSchema = import_zod11.z.object({
|
|
5956
|
+
id: import_zod11.z.string().min(1, "Server ID cannot be empty"),
|
|
5957
|
+
name: import_zod11.z.string().min(1, "Server name cannot be empty"),
|
|
5958
|
+
createdAt: import_zod11.z.string().optional(),
|
|
5959
|
+
updatedAt: import_zod11.z.string().optional(),
|
|
5960
|
+
status: import_zod11.z.string().optional(),
|
|
5961
|
+
toolkits: import_zod11.z.array(import_zod11.z.string()).optional(),
|
|
5962
|
+
tools: import_zod11.z.array(import_zod11.z.string()).optional(),
|
|
5963
|
+
managedAuthViaComposio: import_zod11.z.boolean().optional(),
|
|
5964
|
+
authConfigIds: import_zod11.z.array(import_zod11.z.string()).optional(),
|
|
5965
|
+
mcpUrl: import_zod11.z.string(),
|
|
5966
|
+
commands: import_zod11.z.object({
|
|
5967
|
+
claude: import_zod11.z.string(),
|
|
5968
|
+
cursor: import_zod11.z.string(),
|
|
5969
|
+
windsurf: import_zod11.z.string()
|
|
5484
5970
|
})
|
|
5485
5971
|
});
|
|
5486
|
-
var ComposioMcpRetrieveResponseSchema =
|
|
5487
|
-
id:
|
|
5488
|
-
name:
|
|
5489
|
-
created_at:
|
|
5490
|
-
updated_at:
|
|
5491
|
-
status:
|
|
5492
|
-
toolkits:
|
|
5493
|
-
tools:
|
|
5494
|
-
managed_auth_via_composio:
|
|
5972
|
+
var ComposioMcpRetrieveResponseSchema = import_zod11.z.object({
|
|
5973
|
+
id: import_zod11.z.string().min(1, "Server ID cannot be empty"),
|
|
5974
|
+
name: import_zod11.z.string().min(1, "Server name cannot be empty"),
|
|
5975
|
+
created_at: import_zod11.z.string().optional(),
|
|
5976
|
+
updated_at: import_zod11.z.string().optional(),
|
|
5977
|
+
status: import_zod11.z.string().optional(),
|
|
5978
|
+
toolkits: import_zod11.z.array(import_zod11.z.string()).optional(),
|
|
5979
|
+
tools: import_zod11.z.array(import_zod11.z.string()).optional(),
|
|
5980
|
+
managed_auth_via_composio: import_zod11.z.boolean().optional()
|
|
5495
5981
|
});
|
|
5496
|
-
var McpDeleteResponseSchema =
|
|
5497
|
-
id:
|
|
5498
|
-
deleted:
|
|
5499
|
-
message:
|
|
5982
|
+
var McpDeleteResponseSchema = import_zod11.z.object({
|
|
5983
|
+
id: import_zod11.z.string().min(1, "Server ID cannot be empty"),
|
|
5984
|
+
deleted: import_zod11.z.boolean().optional(),
|
|
5985
|
+
message: import_zod11.z.string().optional()
|
|
5500
5986
|
});
|
|
5501
|
-
var ComposioMcpDeleteResponseSchema =
|
|
5502
|
-
id:
|
|
5503
|
-
deleted:
|
|
5504
|
-
message:
|
|
5987
|
+
var ComposioMcpDeleteResponseSchema = import_zod11.z.object({
|
|
5988
|
+
id: import_zod11.z.string().min(1, "Server ID cannot be empty"),
|
|
5989
|
+
deleted: import_zod11.z.boolean().optional(),
|
|
5990
|
+
message: import_zod11.z.string().optional()
|
|
5505
5991
|
});
|
|
5506
|
-
var McpUpdateResponseSchema =
|
|
5507
|
-
id:
|
|
5508
|
-
name:
|
|
5509
|
-
createdAt:
|
|
5510
|
-
updatedAt:
|
|
5511
|
-
status:
|
|
5512
|
-
toolkits:
|
|
5513
|
-
tools:
|
|
5992
|
+
var McpUpdateResponseSchema = import_zod11.z.object({
|
|
5993
|
+
id: import_zod11.z.string().min(1, "Server ID cannot be empty"),
|
|
5994
|
+
name: import_zod11.z.string().min(1, "Server name cannot be empty"),
|
|
5995
|
+
createdAt: import_zod11.z.string().optional(),
|
|
5996
|
+
updatedAt: import_zod11.z.string().optional(),
|
|
5997
|
+
status: import_zod11.z.string().optional(),
|
|
5998
|
+
toolkits: import_zod11.z.array(import_zod11.z.string()).optional(),
|
|
5999
|
+
tools: import_zod11.z.array(import_zod11.z.string()).optional()
|
|
5514
6000
|
});
|
|
5515
|
-
var ComposioMcpUpdateResponseSchema =
|
|
5516
|
-
id:
|
|
5517
|
-
name:
|
|
5518
|
-
created_at:
|
|
5519
|
-
updated_at:
|
|
5520
|
-
status:
|
|
5521
|
-
toolkits:
|
|
5522
|
-
tools:
|
|
6001
|
+
var ComposioMcpUpdateResponseSchema = import_zod11.z.object({
|
|
6002
|
+
id: import_zod11.z.string().min(1, "Server ID cannot be empty"),
|
|
6003
|
+
name: import_zod11.z.string().min(1, "Server name cannot be empty"),
|
|
6004
|
+
created_at: import_zod11.z.string().optional(),
|
|
6005
|
+
updated_at: import_zod11.z.string().optional(),
|
|
6006
|
+
status: import_zod11.z.string().optional(),
|
|
6007
|
+
toolkits: import_zod11.z.array(import_zod11.z.string()).optional(),
|
|
6008
|
+
tools: import_zod11.z.array(import_zod11.z.string()).optional()
|
|
5523
6009
|
});
|
|
5524
6010
|
|
|
5525
6011
|
// src/utils/transformers/mcp.ts
|
|
@@ -5622,10 +6108,10 @@ function transformMcpGenerateUrlResponse(response) {
|
|
|
5622
6108
|
}
|
|
5623
6109
|
|
|
5624
6110
|
// src/models/MCP.ts
|
|
5625
|
-
var
|
|
6111
|
+
var MCP2 = class {
|
|
5626
6112
|
client;
|
|
5627
|
-
provider;
|
|
5628
6113
|
toolkits;
|
|
6114
|
+
provider;
|
|
5629
6115
|
constructor(client, provider) {
|
|
5630
6116
|
this.client = client;
|
|
5631
6117
|
this.provider = provider;
|
|
@@ -5662,7 +6148,7 @@ var MCP = class {
|
|
|
5662
6148
|
* @param {Object} params.options - Server creation options
|
|
5663
6149
|
* @param {string} params.options.name - Unique name for the MCP server
|
|
5664
6150
|
* @param {boolean} [params.options.isChatAuth] - Whether to use chat-based authentication
|
|
5665
|
-
* @returns {Promise<McpServerCreateResponse<
|
|
6151
|
+
* @returns {Promise<McpServerCreateResponse<TMcpResponse>>} Created server details with instance getter
|
|
5666
6152
|
*
|
|
5667
6153
|
* @example
|
|
5668
6154
|
* ```typescript
|
|
@@ -5925,7 +6411,7 @@ var MCP = class {
|
|
|
5925
6411
|
* @param {Object} [options] - Additional options for server configuration
|
|
5926
6412
|
* @param {string[]} [options.limitTools] - Subset of tools to limit (from MCP config)
|
|
5927
6413
|
* @param {boolean} [options.isChatAuth] - Whether to use chat-based authentication
|
|
5928
|
-
* @returns {Promise<
|
|
6414
|
+
* @returns {Promise<TMcpResponse>} Transformed server URLs in provider-specific format
|
|
5929
6415
|
*
|
|
5930
6416
|
* @example
|
|
5931
6417
|
* ```typescript
|
|
@@ -5938,6 +6424,7 @@ var MCP = class {
|
|
|
5938
6424
|
* isChatAuth: true
|
|
5939
6425
|
* });
|
|
5940
6426
|
* ```
|
|
6427
|
+
*
|
|
5941
6428
|
*/
|
|
5942
6429
|
async getServer(serverId, userId, options) {
|
|
5943
6430
|
const serverDetails = await this.get(serverId);
|
|
@@ -6191,6 +6678,7 @@ var MCP = class {
|
|
|
6191
6678
|
* @param serverName - Name of the MCP server
|
|
6192
6679
|
|
|
6193
6680
|
* @returns Transformed response in appropriate format
|
|
6681
|
+
* @deprecated
|
|
6194
6682
|
*/
|
|
6195
6683
|
wrapMcpServerResponse(data, serverName, connectedAccountIds, userIds, toolkits) {
|
|
6196
6684
|
if (this.provider && typeof this.provider.wrapMcpServerResponse === "function") {
|
|
@@ -6216,6 +6704,7 @@ var MCP = class {
|
|
|
6216
6704
|
const transformed = this.provider.wrapMcpServerResponse(snakeCaseData);
|
|
6217
6705
|
return transformed;
|
|
6218
6706
|
}
|
|
6707
|
+
const self = this;
|
|
6219
6708
|
if (connectedAccountIds?.length && data.connectedAccountUrls) {
|
|
6220
6709
|
return data.connectedAccountUrls.map((url, index) => ({
|
|
6221
6710
|
url: new URL(url),
|
|
@@ -6859,7 +7348,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
6859
7348
|
};
|
|
6860
7349
|
|
|
6861
7350
|
// package.json
|
|
6862
|
-
var version = "0.1.
|
|
7351
|
+
var version = "0.1.53";
|
|
6863
7352
|
|
|
6864
7353
|
// src/models/Files.ts
|
|
6865
7354
|
var Files = class {
|
|
@@ -6917,6 +7406,82 @@ var getDefaultHeaders = (headers, provider) => {
|
|
|
6917
7406
|
};
|
|
6918
7407
|
};
|
|
6919
7408
|
|
|
7409
|
+
// src/types/toolRouter.types.ts
|
|
7410
|
+
var import_zod12 = __toESM(require("zod"), 1);
|
|
7411
|
+
var ToolRouterToolkitConfigSchema = import_zod12.default.object({
|
|
7412
|
+
toolkit: import_zod12.default.string(),
|
|
7413
|
+
authConfigId: import_zod12.default.string().optional()
|
|
7414
|
+
});
|
|
7415
|
+
var ToolRouterConfigSchema = import_zod12.default.object({
|
|
7416
|
+
toolkits: import_zod12.default.array(import_zod12.default.union([import_zod12.default.string(), ToolRouterToolkitConfigSchema])).optional(),
|
|
7417
|
+
manuallyManageConnections: import_zod12.default.boolean().optional()
|
|
7418
|
+
});
|
|
7419
|
+
var ToolRouterSessionSchema = import_zod12.default.object({
|
|
7420
|
+
sessionId: import_zod12.default.string(),
|
|
7421
|
+
url: import_zod12.default.string()
|
|
7422
|
+
});
|
|
7423
|
+
|
|
7424
|
+
// src/models/ToolRouter.experimental.ts
|
|
7425
|
+
var ToolRouter = class {
|
|
7426
|
+
constructor(client) {
|
|
7427
|
+
this.client = client;
|
|
7428
|
+
this.client = client;
|
|
7429
|
+
telemetry.instrument(this);
|
|
7430
|
+
}
|
|
7431
|
+
/**
|
|
7432
|
+
* Creates a new Session for the tool router
|
|
7433
|
+
*
|
|
7434
|
+
* @param userId {string} The user id to create the session for
|
|
7435
|
+
* @param routerConfig {ToolRouterConfig} The router config to use
|
|
7436
|
+
* @returns {Promise<ToolRouterSession>} The tool router session
|
|
7437
|
+
*
|
|
7438
|
+
* @example
|
|
7439
|
+
* ```typescript
|
|
7440
|
+
* import { Composio } form "@composio/core"
|
|
7441
|
+
*
|
|
7442
|
+
* const composio = new Composio()
|
|
7443
|
+
* const userId = "xxx-ooo-xxxx"
|
|
7444
|
+
*
|
|
7445
|
+
* const mcpSession = await composio.experimental.toolRouter.createSession(userId, {
|
|
7446
|
+
* toolkits: ["github", "hackernews", "slack"]
|
|
7447
|
+
* })
|
|
7448
|
+
*
|
|
7449
|
+
* // with auth configs
|
|
7450
|
+
* const mcpSession = await composio.experimental.toolRouter.createSession(userId, {
|
|
7451
|
+
* toolkits: [{ toolkit: "github", authConfingId: "ac_123455344"}]
|
|
7452
|
+
* ```
|
|
7453
|
+
*/
|
|
7454
|
+
async createSession(userId, routerConfig) {
|
|
7455
|
+
const config = ToolRouterConfigSchema.safeParse(routerConfig ?? {});
|
|
7456
|
+
if (config.error) {
|
|
7457
|
+
throw new ValidationError("Failed to parse tool router config", {
|
|
7458
|
+
cause: config.error
|
|
7459
|
+
});
|
|
7460
|
+
}
|
|
7461
|
+
const toolkitConfig = config.data.toolkits?.map((config2) => {
|
|
7462
|
+
if (typeof config2 === "string") {
|
|
7463
|
+
return { toolkit: config2 };
|
|
7464
|
+
} else {
|
|
7465
|
+
return {
|
|
7466
|
+
toolkit: config2.toolkit,
|
|
7467
|
+
auth_config_id: config2.authConfigId
|
|
7468
|
+
};
|
|
7469
|
+
}
|
|
7470
|
+
});
|
|
7471
|
+
const session = await this.client.toolRouter.createSession({
|
|
7472
|
+
user_id: userId,
|
|
7473
|
+
config: {
|
|
7474
|
+
toolkits: toolkitConfig,
|
|
7475
|
+
manually_manage_connections: config.data.manuallyManageConnections
|
|
7476
|
+
}
|
|
7477
|
+
});
|
|
7478
|
+
return transform(session).with(ToolRouterSessionSchema).using((raw) => ({
|
|
7479
|
+
sessionId: raw.session_id,
|
|
7480
|
+
url: raw.chat_session_mcp_url
|
|
7481
|
+
}));
|
|
7482
|
+
}
|
|
7483
|
+
};
|
|
7484
|
+
|
|
6920
7485
|
// src/composio.ts
|
|
6921
7486
|
var Composio = class _Composio {
|
|
6922
7487
|
/**
|
|
@@ -6937,11 +7502,17 @@ var Composio = class _Composio {
|
|
|
6937
7502
|
triggers;
|
|
6938
7503
|
provider;
|
|
6939
7504
|
files;
|
|
6940
|
-
// auth configs
|
|
6941
7505
|
authConfigs;
|
|
6942
|
-
// connected accounts
|
|
6943
7506
|
connectedAccounts;
|
|
6944
7507
|
mcp;
|
|
7508
|
+
/**
|
|
7509
|
+
* Experimental features
|
|
7510
|
+
*/
|
|
7511
|
+
experimental;
|
|
7512
|
+
/**
|
|
7513
|
+
* Deprecated features
|
|
7514
|
+
*/
|
|
7515
|
+
deprecated;
|
|
6945
7516
|
/**
|
|
6946
7517
|
* Creates a new instance of the Composio SDK.
|
|
6947
7518
|
*
|
|
@@ -6997,12 +7568,27 @@ var Composio = class _Composio {
|
|
|
6997
7568
|
logLevel: COMPOSIO_LOG_LEVEL
|
|
6998
7569
|
});
|
|
6999
7570
|
this.tools = new Tools(this.client, this.provider, this.config);
|
|
7000
|
-
this.mcp = new MCP(this.client
|
|
7571
|
+
this.mcp = new MCP(this.client);
|
|
7001
7572
|
this.toolkits = new Toolkits(this.client);
|
|
7002
7573
|
this.triggers = new Triggers(this.client);
|
|
7003
7574
|
this.authConfigs = new AuthConfigs(this.client);
|
|
7004
7575
|
this.files = new Files(this.client);
|
|
7005
7576
|
this.connectedAccounts = new ConnectedAccounts(this.client);
|
|
7577
|
+
this.experimental = {
|
|
7578
|
+
/**
|
|
7579
|
+
* Experimental tool router
|
|
7580
|
+
* Helps you create a single MCP server containing all the tools with smart routing.
|
|
7581
|
+
*
|
|
7582
|
+
* @description Allows you to create an isolated toolRouter MCP session for a user
|
|
7583
|
+
*/
|
|
7584
|
+
toolRouter: new ToolRouter(this.client)
|
|
7585
|
+
};
|
|
7586
|
+
this.deprecated = {
|
|
7587
|
+
/**
|
|
7588
|
+
* @deprecated this feature will be removed soon, use `composio.mcp`
|
|
7589
|
+
*/
|
|
7590
|
+
mcp: new MCP2(this.client, this.provider)
|
|
7591
|
+
};
|
|
7006
7592
|
if (this.config.allowTracking) {
|
|
7007
7593
|
telemetry.setup({
|
|
7008
7594
|
apiKey: apiKeyParsed ?? "",
|