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