@composio/core 0.18.1 → 0.20.0

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.
Files changed (100) hide show
  1. package/dist/{CustomTool-VRfWzMix.d.mts → CustomTool-B3m-188G.d.mts} +1 -1
  2. package/dist/{CustomTool-Bz0f52QR.mjs → CustomTool-fYEFjSLM.mjs} +1 -1
  3. package/dist/{FileModifierErrors-CwB-Inm9.mjs → FileModifierErrors-CdGSABoq.mjs} +1 -1
  4. package/dist/{FileToolModifier.utils.neutral-D_YkHwZP.mjs → FileToolModifier.utils.neutral-DWFpnsj2.mjs} +4 -2
  5. package/dist/{SsrfErrors-xhdVE4yw.mjs → SsrfErrors-DiQldIdC.mjs} +32 -17
  6. package/dist/{Telemetry-Dw9W5RSp.mjs → Telemetry-JRJJYS4I.mjs} +2 -2
  7. package/dist/{cancellation-P5YUlcfz.mjs → cancellation-Dwa9lGHA.mjs} +7 -5
  8. package/dist/{composio-Cb3d1jFe.d.mts → composio-B36OXii1.d.mts} +3017 -144
  9. package/dist/{customTool.types-B6ej_8XZ.d.mts → customTool.types-C436M_D0.d.mts} +525 -101
  10. package/dist/docs/reference/sdk-reference/typescript/auth-configs.mdx +10 -10
  11. package/dist/docs/reference/sdk-reference/typescript/composio.mdx +8 -15
  12. package/dist/docs/reference/sdk-reference/typescript/connected-accounts.mdx +101 -18
  13. package/dist/docs/reference/sdk-reference/typescript/custom-toolkits.mdx +123 -0
  14. package/dist/docs/reference/sdk-reference/typescript/experimental.mdx +9 -2
  15. package/dist/docs/reference/sdk-reference/typescript/index.mdx +7 -0
  16. package/dist/docs/reference/sdk-reference/typescript/keyring.mdx +56 -0
  17. package/dist/docs/reference/sdk-reference/typescript/logs.mdx +78 -0
  18. package/dist/docs/reference/sdk-reference/typescript/mcp.mdx +15 -15
  19. package/dist/docs/reference/sdk-reference/typescript/meta.json +8 -1
  20. package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +10 -10
  21. package/dist/docs/reference/sdk-reference/typescript/session.mdx +117 -24
  22. package/dist/docs/reference/sdk-reference/typescript/sessions.mdx +24 -10
  23. package/dist/docs/reference/sdk-reference/typescript/toolkits.mdx +151 -14
  24. package/dist/docs/reference/sdk-reference/typescript/tools.mdx +50 -40
  25. package/dist/docs/reference/sdk-reference/typescript/triggers.mdx +26 -25
  26. package/dist/docs/reference/sdk-reference/typescript/usage.mdx +78 -0
  27. package/dist/docs/reference/sdk-reference/typescript/webhook-endpoints.mdx +162 -0
  28. package/dist/docs/reference/sdk-reference/typescript/webhook-subscriptions.mdx +218 -0
  29. package/dist/docs/reference/sdk-reference/typescript/webhooks.mdx +20 -0
  30. package/dist/{errors-Ue9wMrPK.mjs → errors-D_A4b2c2.mjs} +143 -4
  31. package/dist/experimental/index.d.mts +2 -2
  32. package/dist/experimental/index.mjs +1 -1
  33. package/dist/{fileUtils.node-KE5Fa-af.mjs → fileUtils.node-DNLhLg0W.mjs} +8 -6
  34. package/dist/index.d.mts +418 -146
  35. package/dist/index.mjs +2728 -349
  36. package/dist/models/Files.node.d.mts +2 -3
  37. package/dist/models/Files.node.mjs +2 -2
  38. package/dist/models/Files.workerd.d.mts +2 -3
  39. package/dist/platform/node.d.mts +2 -3
  40. package/dist/platform/workerd.d.mts +2 -3
  41. package/dist/{sensitiveFileUploadPaths-QN7w4n8v.mjs → sensitiveFileUploadPaths-BlLp-Yo2.mjs} +10 -7
  42. package/dist/{ssrfGuard.node-BLX6b-Rf.mjs → ssrfGuard.node-BZ270bcu.mjs} +104 -14
  43. package/dist/{types-CGdgK442.d.mts → types-Br3GBya5.d.mts} +2 -2
  44. package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +3 -4
  45. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +3 -4
  46. package/dist/utils/modifiers/FileToolModifier.node.d.mts +3 -4
  47. package/dist/utils/modifiers/FileToolModifier.node.mjs +6 -6
  48. package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +3 -4
  49. package/dist/utils/modifiers/FileToolModifier.workerd.mjs +1 -1
  50. package/dist/utils/ssrfGuard.node.d.mts +19 -10
  51. package/dist/utils/ssrfGuard.node.mjs +1 -1
  52. package/dist/utils/ssrfGuard.workerd.d.mts +12 -4
  53. package/dist/utils/ssrfGuard.workerd.mjs +2 -2
  54. package/package.json +9 -9
  55. package/src/composio.ts +207 -10
  56. package/src/errors/ConnectedAccountsErrors.ts +47 -0
  57. package/src/errors/SDKErrors.ts +52 -0
  58. package/src/errors/ToolErrors.ts +24 -0
  59. package/src/errors/ToolRouterErrors.ts +57 -0
  60. package/src/errors/index.ts +3 -0
  61. package/src/index.ts +15 -0
  62. package/src/lib/toolRouterMcp.ts +132 -0
  63. package/src/lib/toolRouterParams.ts +116 -29
  64. package/src/models/ConnectedAccounts.ts +118 -2
  65. package/src/models/CustomToolkits.ts +169 -0
  66. package/src/models/Experimental.ts +27 -0
  67. package/src/models/Keyring.ts +65 -0
  68. package/src/models/Logs.ts +101 -0
  69. package/src/models/MCP.ts +29 -15
  70. package/src/models/ToolRouter.ts +43 -14
  71. package/src/models/ToolRouterSession.ts +224 -16
  72. package/src/models/Toolkits.ts +181 -2
  73. package/src/models/Tools.ts +58 -26
  74. package/src/models/Triggers.ts +10 -90
  75. package/src/models/Usage.ts +119 -0
  76. package/src/models/Webhooks.ts +520 -0
  77. package/src/services/pusher/Pusher.ts +46 -16
  78. package/src/types/authConfigs.types.ts +2 -0
  79. package/src/types/connectedAccounts.types.ts +54 -0
  80. package/src/types/customToolkits.types.ts +102 -0
  81. package/src/types/keyring.types.ts +32 -0
  82. package/src/types/logs.types.ts +108 -0
  83. package/src/types/toolRouter.types.ts +259 -14
  84. package/src/types/toolkit.types.ts +161 -0
  85. package/src/types/usage.types.ts +81 -0
  86. package/src/types/webhooks.types.ts +143 -0
  87. package/src/utils/constants.ts +1 -5
  88. package/src/utils/jsonSchema.ts +4 -1
  89. package/src/utils/logger.ts +39 -7
  90. package/src/utils/sdk.ts +385 -22
  91. package/src/utils/ssrfGuard.node.ts +127 -13
  92. package/src/utils/ssrfGuard.workerd.ts +11 -1
  93. package/src/utils/transformers/connectedAccounts.ts +37 -2
  94. package/src/utils/transformers/customToolkits.ts +98 -0
  95. package/src/utils/transformers/keyring.ts +24 -0
  96. package/src/utils/transformers/logs.ts +85 -0
  97. package/src/utils/transformers/toolkits.ts +183 -3
  98. package/src/utils/transformers/triggers.ts +2 -2
  99. package/src/utils/transformers/usage.ts +77 -0
  100. package/src/utils/transformers/webhooks.ts +139 -0
@@ -21,6 +21,8 @@ import {
21
21
  import { ValidationError } from '../errors/ValidationErrors';
22
22
  import { ComposioAclOnlyForSharedError } from '../errors';
23
23
  import { telemetry } from '../telemetry/Telemetry';
24
+ import { Usage } from './Usage';
25
+ import { CustomToolkits } from './CustomToolkits';
24
26
 
25
27
  /**
26
28
  * Server-side 400 message the API uses to reject ACL writes against a
@@ -129,8 +131,33 @@ export async function updateConnectedAccountAcl(
129
131
  export class Experimental {
130
132
  private client: ComposioClient;
131
133
 
134
+ /**
135
+ * Project-scoped usage metering (`summary()` / `breakdown()`).
136
+ * **Experimental — shape may change in future releases.**
137
+ *
138
+ * @example
139
+ * ```typescript
140
+ * const summary = await composio.experimental.usage.summary();
141
+ * const byTool = await composio.experimental.usage.breakdown('tool_calls');
142
+ * ```
143
+ */
144
+ usage: Usage;
145
+
146
+ /**
147
+ * Register and manage project-owned custom toolkits (`upsert()` / `sync()` / `delete()`).
148
+ * **Experimental — custom toolkits are in pilot; shape may change.**
149
+ *
150
+ * @example
151
+ * ```typescript
152
+ * await composio.experimental.customToolkits.sync('CUSTOM_MY_TOOLKIT');
153
+ * ```
154
+ */
155
+ customToolkits: CustomToolkits;
156
+
132
157
  constructor(client: ComposioClient) {
133
158
  this.client = client;
159
+ this.usage = new Usage(client);
160
+ this.customToolkits = new CustomToolkits(client);
134
161
  telemetry.instrument(this, 'Experimental');
135
162
  }
136
163
 
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @fileoverview The `composio.keyring` namespace: the public transfer keys of
3
+ * the organization's customer-managed keyring.
4
+ *
5
+ * @module Keyring
6
+ */
7
+ import ComposioClient from '@composio/client';
8
+ import { KeyringTransferKeysResponse } from '../types/keyring.types';
9
+ import { ComposioRequestOptions } from '../types/requestOptions.types';
10
+ import { telemetry } from '../telemetry/Telemetry';
11
+ import { withCancellation } from '../utils/cancellation';
12
+ import { transformKeyringTransferKeysResponse } from '../utils/transformers/keyring';
13
+
14
+ /**
15
+ * `composio.keyring` — the organization's customer-managed keyring.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const { activeKid, keys } = await composio.keyring.listTransferKeys();
20
+ * const sealingKey = keys.find(key => key.kid === activeKid);
21
+ * ```
22
+ */
23
+ export class Keyring {
24
+ private client: ComposioClient;
25
+
26
+ constructor(client: ComposioClient) {
27
+ this.client = client;
28
+ telemetry.instrument(this, 'Keyring');
29
+ }
30
+
31
+ /**
32
+ * Lists the public transfer keys of the organization's active customer
33
+ * keyring, the keys a secret is sealed to before it is sent to Composio.
34
+ *
35
+ * Always seal new secrets to the key whose `kid` is `activeKid`: a JWE with
36
+ * `RSA-OAEP-256` key management, `A256GCM` content encryption, and the
37
+ * `kid` in the protected header. Older keys stay listed so values sealed to
38
+ * them remain openable.
39
+ *
40
+ * The organization behind the API key must have an ACTIVE customer keyring
41
+ * instance; otherwise the API answers 404.
42
+ *
43
+ * @returns {Promise<KeyringTransferKeysResponse>} The active key ID and every accepted public JWK, newest first
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * import { CompactEncrypt, importJWK } from 'jose';
48
+ *
49
+ * const { activeKid, keys } = await composio.keyring.listTransferKeys();
50
+ * const jwk = keys.find(key => key.kid === activeKid)!;
51
+ * const sealed = await new CompactEncrypt(new TextEncoder().encode(secret))
52
+ * .setProtectedHeader({ alg: 'RSA-OAEP-256', enc: 'A256GCM', kid: activeKid })
53
+ * .encrypt(await importJWK(jwk, 'RSA-OAEP-256'));
54
+ * ```
55
+ */
56
+ async listTransferKeys(
57
+ requestOptions?: ComposioRequestOptions
58
+ ): Promise<KeyringTransferKeysResponse> {
59
+ const result = await withCancellation(
60
+ () => this.client.keyring.listTransferKeys(requestOptions),
61
+ requestOptions?.signal
62
+ );
63
+ return transformKeyringTransferKeysResponse(result);
64
+ }
65
+ }
@@ -0,0 +1,101 @@
1
+ /**
2
+ * @fileoverview The `composio.logs` namespace: search and inspect
3
+ * tool-execution logs for the project.
4
+ *
5
+ * @module Logs
6
+ */
7
+ import ComposioClient from '@composio/client';
8
+ import {
9
+ LogSearchParams,
10
+ LogSearchParamsSchema,
11
+ LogSearchResponse,
12
+ ToolExecutionLogDetail,
13
+ } from '../types/logs.types';
14
+ import { ComposioRequestOptions } from '../types/requestOptions.types';
15
+ import { ValidationError } from '../errors/ValidationErrors';
16
+ import { telemetry } from '../telemetry/Telemetry';
17
+ import { withCancellation } from '../utils/cancellation';
18
+ import {
19
+ transformLogSearchParams,
20
+ transformLogSearchResponse,
21
+ transformToolExecutionLogDetail,
22
+ } from '../utils/transformers/logs';
23
+
24
+ /**
25
+ * `composio.logs` — tool-execution logs.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * const { logs, nextCursor } = await composio.logs.search({
30
+ * filters: [{ field: 'toolkit_slug', operator: '==', value: 'github' }],
31
+ * limit: 20,
32
+ * });
33
+ * const detail = await composio.logs.get(logs[0].id);
34
+ * ```
35
+ */
36
+ export class Logs {
37
+ private client: ComposioClient;
38
+
39
+ constructor(client: ComposioClient) {
40
+ this.client = client;
41
+ telemetry.instrument(this, 'Logs');
42
+ }
43
+
44
+ /**
45
+ * Search tool-execution logs with filters, a time range and cursor
46
+ * pagination.
47
+ *
48
+ * @param {LogSearchParams} [params] - Filters, `timeRange`, `limit` and `cursor`
49
+ * @returns {Promise<LogSearchResponse>} Matching logs and the next cursor
50
+ * @throws {ValidationError} If the params fail validation
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * const { logs } = await composio.logs.search({
55
+ * filters: [
56
+ * { field: 'status', operator: '==', value: 'failed' },
57
+ * { field: 'user_id', operator: '==', value: 'user_123' },
58
+ * ],
59
+ * timeRange: { from: Date.now() - 24 * 60 * 60 * 1000, to: Date.now() },
60
+ * });
61
+ * ```
62
+ */
63
+ async search(
64
+ params?: LogSearchParams,
65
+ requestOptions?: ComposioRequestOptions
66
+ ): Promise<LogSearchResponse> {
67
+ const parsedParams = LogSearchParamsSchema.safeParse(params ?? {});
68
+ if (!parsedParams.success) {
69
+ throw new ValidationError('Failed to parse log search params', {
70
+ cause: parsedParams.error,
71
+ });
72
+ }
73
+ const body = transformLogSearchParams(parsedParams.data);
74
+ const result = await withCancellation(
75
+ () => this.client.logs.createToolExecution(body, requestOptions),
76
+ requestOptions?.signal
77
+ );
78
+ return transformLogSearchResponse(result);
79
+ }
80
+
81
+ /**
82
+ * Retrieve one tool-execution log with its full detail (timings, context,
83
+ * source and raw `data`).
84
+ *
85
+ * @param {string} id - The log id
86
+ * @returns {Promise<ToolExecutionLogDetail>} The log detail
87
+ *
88
+ * @example
89
+ * ```typescript
90
+ * const log = await composio.logs.get('log_abc123');
91
+ * console.log(log.status, log.timings?.endTime);
92
+ * ```
93
+ */
94
+ async get(id: string, requestOptions?: ComposioRequestOptions): Promise<ToolExecutionLogDetail> {
95
+ const result = await withCancellation(
96
+ () => this.client.logs.retrieveToolExecution(id, requestOptions),
97
+ requestOptions?.signal
98
+ );
99
+ return transformToolExecutionLogDetail(result);
100
+ }
101
+ }
package/src/models/MCP.ts CHANGED
@@ -99,16 +99,19 @@ export class MCP {
99
99
 
100
100
  const toolkits: string[] = [];
101
101
  const auth_config_ids: string[] = [];
102
- const custom_tools: string[] = config.data.allowedTools ?? [];
102
+ const allowed_tools: string[] = config.data.allowedTools ?? [];
103
103
 
104
104
  // extract all the toolkits, authconfigs, and allowed tools to separate slugs
105
105
  config.data.toolkits.forEach(toolkit => {
106
106
  if (typeof toolkit === 'string') {
107
107
  toolkits.push(toolkit);
108
- } else if (toolkit.toolkit) {
109
- toolkits.push(toolkit.toolkit);
110
- } else if (toolkit.authConfigId) {
111
- auth_config_ids.push(toolkit.authConfigId);
108
+ } else {
109
+ if (toolkit.toolkit) {
110
+ toolkits.push(toolkit.toolkit);
111
+ }
112
+ if (toolkit.authConfigId) {
113
+ auth_config_ids.push(toolkit.authConfigId);
114
+ }
112
115
  }
113
116
  });
114
117
 
@@ -116,7 +119,7 @@ export class MCP {
116
119
  name,
117
120
  toolkits,
118
121
  auth_config_ids,
119
- custom_tools,
122
+ allowed_tools,
120
123
  // if manually manage account is set to true, disable composio account management tools
121
124
  managed_auth_via_composio: config.data.manuallyManageConnections ? false : true,
122
125
  };
@@ -380,28 +383,39 @@ export class MCP {
380
383
 
381
384
  const toolkits: string[] = [];
382
385
  const auth_config_ids: string[] = [];
383
- const custom_tools: string[] | undefined = params.allowedTools ?? undefined;
384
386
 
385
387
  // extract all the toolkits, authconfigs, and allowed tools to separate slugs
386
388
  params.toolkits?.forEach(toolkit => {
387
389
  if (typeof toolkit === 'string') {
388
390
  toolkits.push(toolkit);
389
- } else if (toolkit.toolkit) {
390
- toolkits.push(toolkit.toolkit);
391
- } else if (toolkit.authConfigId) {
392
- auth_config_ids.push(toolkit.authConfigId);
391
+ } else {
392
+ if (toolkit.toolkit) {
393
+ toolkits.push(toolkit.toolkit);
394
+ }
395
+ if (toolkit.authConfigId) {
396
+ auth_config_ids.push(toolkit.authConfigId);
397
+ }
393
398
  }
394
399
  });
400
+
401
+ // Build a sparse PATCH body: only fields the caller provided are sent, so omitted
402
+ // fields keep their current server-side values. `allowed_tools` is sent whenever it
403
+ // is provided, independently of `toolkits` (tool-only updates are valid), and must
404
+ // use the API field `allowed_tools` — the update endpoint does not read the
405
+ // deprecated create-only alias `custom_tools`. `manuallyManageConnections` is
406
+ // inverted into `managed_auth_via_composio`, matching create() and generate().
395
407
  const updateBody = {
396
- ...{ name: params.name ?? undefined },
397
- ...(params.toolkits
408
+ ...(params.name !== undefined ? { name: params.name } : {}),
409
+ ...(params.toolkits !== undefined
398
410
  ? {
399
- custom_tools: custom_tools,
400
411
  toolkits: toolkits,
401
412
  auth_config_ids: auth_config_ids,
402
413
  }
403
414
  : {}),
404
- ...{ managed_auth_via_composio: params.manuallyManageConnections ?? undefined },
415
+ ...(params.allowedTools !== undefined ? { allowed_tools: params.allowedTools } : {}),
416
+ ...(params.manuallyManageConnections !== undefined
417
+ ? { managed_auth_via_composio: !params.manuallyManageConnections }
418
+ : {}),
405
419
  };
406
420
  const response = await withCancellation(
407
421
  () => this.client.mcp.update(serverId, updateBody, requestOptions),
@@ -53,6 +53,7 @@ import {
53
53
  resolveToolRouterSandboxConfig,
54
54
  } from '../lib/toolRouterParams';
55
55
  import { PRELOAD_TOOLS_ALL } from '../lib/toolRouterConstants';
56
+ import { buildMCPServerConfig } from '../lib/toolRouterMcp';
56
57
  import { ToolRouterSession } from './ToolRouterSession';
57
58
  import { ComposioRequestOptions } from '../types/requestOptions.types';
58
59
  import { withCancellation } from '../utils/cancellation';
@@ -71,6 +72,7 @@ function getSessionMetadata(
71
72
  session: SessionCreateResponse | SessionRetrieveResponse | SessionAttachResponse
72
73
  ) {
73
74
  const metadata: ToolRouterSessionMetadata = {
75
+ config: session.config,
74
76
  preload: session.config.preload,
75
77
  workbench: session.config.workbench,
76
78
  configVersion: session.config_version,
@@ -130,20 +132,30 @@ export class ToolRouter<
130
132
  telemetry.instrument(this, 'ToolRouter');
131
133
  }
132
134
 
133
- private createMCPServerConfig({
134
- type,
135
- url,
136
- }: {
137
- type: MCPServerType;
138
- url: string;
139
- }): ToolRouterMCPServerConfig {
140
- return {
135
+ /**
136
+ * Derives the MCP config for a session from the auth context the session
137
+ * request was made with: the project key when one is configured, otherwise
138
+ * the resolved user API key, plus the org/project scope when configured.
139
+ * Headers are only attached when the MCP URL shares the client's API
140
+ * origin. Any other destination throws when the caller passed `mcp: true`
141
+ * and otherwise yields empty headers plus a warning; see
142
+ * `buildMCPServerConfig`.
143
+ */
144
+ private createMCPServerConfig(
145
+ { type, url }: { type: MCPServerType; url: string },
146
+ mcpRequested: boolean
147
+ ): ToolRouterMCPServerConfig {
148
+ return buildMCPServerConfig({
141
149
  type,
142
150
  url,
143
- headers: {
144
- ...(this.config?.apiKey ? { 'x-api-key': this.config.apiKey } : {}),
145
- },
146
- };
151
+ apiBaseURL: this.client.baseURL,
152
+ apiKey: this.config?.apiKey,
153
+ userApiKey: this.config?.userApiKey,
154
+ defaultHeaders: this.config?.defaultHeaders,
155
+ orgId: this.config?.orgId,
156
+ projectId: this.config?.projectId,
157
+ mcpRequested,
158
+ });
147
159
  }
148
160
 
149
161
  /**
@@ -151,9 +163,17 @@ export class ToolRouter<
151
163
  * Use `sessionPreset: SessionPreset.DIRECT_TOOLS` when all needed tools
152
164
  * should be exposed directly; see `ToolRouterCreateSessionConfig`.
153
165
  *
166
+ * The session's MCP config carries the session credential only when the
167
+ * MCP URL shares the origin of the configured API base URL. When it does
168
+ * not, `mcp: true` makes the call throw `ComposioMCPDestinationError`
169
+ * (naming both origins, never a key); without `mcp: true` the session is
170
+ * returned with `session.mcp.headers` empty and a warning naming both
171
+ * origins is logged, so native tools keep working.
172
+ *
154
173
  * @param userId {string} The user id to create the session for
155
174
  * @param config {ToolRouterCreateSessionConfig} The config for the tool router session
156
175
  * @returns {Promise<Session<TToolCollection, TTool, TProvider>>} The tool router session
176
+ * @throws {ComposioMCPDestinationError} When `mcp: true` is passed and the MCP URL is not on the API origin
157
177
  *
158
178
  * @example
159
179
  * ```typescript
@@ -281,7 +301,7 @@ export class ToolRouter<
281
301
  this.client,
282
302
  this.config,
283
303
  session.session_id,
284
- this.createMCPServerConfig(session.mcp),
304
+ this.createMCPServerConfig(session.mcp, routerConfig.mcp === true),
285
305
  { assistivePrompt },
286
306
  customToolsMap,
287
307
  userId,
@@ -291,8 +311,17 @@ export class ToolRouter<
291
311
 
292
312
  /**
293
313
  * Use an existing session
314
+ *
315
+ * The session's MCP config carries the session credential only when the
316
+ * MCP URL shares the origin of the configured API base URL. When it does
317
+ * not, `mcp: true` makes the call throw `ComposioMCPDestinationError`
318
+ * (naming both origins, never a key); without `mcp: true` the session is
319
+ * returned with `session.mcp.headers` empty and a warning naming both
320
+ * origins is logged, so native tools keep working.
321
+ *
294
322
  * @param id {string} The id of the session to use
295
323
  * @returns {Promise<Session<TToolCollection, TTool, TProvider>>} The tool router session
324
+ * @throws {ComposioMCPDestinationError} When `mcp: true` is passed and the MCP URL is not on the API origin
296
325
  *
297
326
  * @example
298
327
  * ```typescript
@@ -383,7 +412,7 @@ export class ToolRouter<
383
412
  this.client,
384
413
  this.config,
385
414
  session.session_id,
386
- this.createMCPServerConfig(session.mcp),
415
+ this.createMCPServerConfig(session.mcp, options?.mcp === true),
387
416
  undefined,
388
417
  customToolsMap,
389
418
  userId,