@devries-cameron20 / composio Mirror · read-only / commits / 00beaedb0
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 13:15 UTC

feat(ts/e2e): add e2e tests for @composio/mastra + tool router + zod (v3, v4)

jkomyno committed Jan 27, 2026 at 04:51 UTC 00beaedb0e8dea612109153833a31167e627da2b
10 files changed +496 -7
pnpm-lock.yaml
+169 -7
@@ -6,6 +6,9 @@ settings:
6
7 catalogs:
8 default:
9 + '@ai-sdk/openai':
10 + specifier: ^3.0.19
11 + version: 3.0.19
12 '@arethetypeswrong/cli':
13 specifier: ^0.18.2
14 version: 0.18.2
@@ -214,7 +217,7 @@ importers:
217 version: 6.0.49(zod@4.3.6)
218 composio-core:
219 specifier: ^0.5.39
217 - version: 0.5.39(3053e361571666380203a2990eacf306)
220 + version: 0.5.39(9958f69effac5ea0e6101081f492dcab)
221 hono:
222 specifier: 'catalog:'
223 version: 4.11.5
@@ -422,6 +425,62 @@ importers:
425 specifier: workspace:*
426 version: link:../../../_utils
427
428 + ts/e2e-tests/runtimes/node/mastra-tool-router-zod-v3:
429 + dependencies:
430 + '@ai-sdk/openai':
431 + specifier: 'catalog:'
432 + version: 3.0.19(zod@3.25.76)
433 + '@composio/core':
434 + specifier: workspace:*
435 + version: link:../../../../packages/core
436 + '@composio/mastra':
437 + specifier: workspace:*
438 + version: link:../../../../packages/providers/mastra
439 + '@mastra/core':
440 + specifier: 'catalog:'
441 + version: 1.0.4(@cfworker/json-schema@4.1.1)(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(effect@3.19.15)(quansync@1.0.0)(zod-to-json-schema@3.25.1(zod@3.25.76))(zod@3.25.76))(@standard-community/standard-openapi@0.2.9(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(effect@3.19.15)(quansync@1.0.0)(zod-to-json-schema@3.25.1(zod@3.25.76))(zod@3.25.76))(@standard-schema/spec@1.1.0)(effect@3.19.15)(openapi-types@12.1.3)(zod@3.25.76))(@types/json-schema@7.0.15)(openapi-types@12.1.3)(zod@3.25.76)
442 + '@mastra/mcp':
443 + specifier: ^1.0.0
444 + version: 1.0.0(@cfworker/json-schema@4.1.1)(@mastra/core@1.0.4(@cfworker/json-schema@4.1.1)(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(effect@3.19.15)(quansync@1.0.0)(zod-to-json-schema@3.25.1(zod@3.25.76))(zod@3.25.76))(@standard-community/standard-openapi@0.2.9(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(effect@3.19.15)(quansync@1.0.0)(zod-to-json-schema@3.25.1(zod@3.25.76))(zod@3.25.76))(@standard-schema/spec@1.1.0)(effect@3.19.15)(openapi-types@12.1.3)(zod@3.25.76))(@types/json-schema@7.0.15)(openapi-types@12.1.3)(zod@3.25.76))(@types/json-schema@7.0.15)(hono@4.11.5)(zod@3.25.76)
445 + ai:
446 + specifier: 'catalog:'
447 + version: 6.0.49(zod@3.25.76)
448 + zod:
449 + specifier: 3.25.76
450 + version: 3.25.76
451 + devDependencies:
452 + '@e2e-tests/utils':
453 + specifier: workspace:*
454 + version: link:../../../_utils
455 +
456 + ts/e2e-tests/runtimes/node/mastra-tool-router-zod-v4:
457 + dependencies:
458 + '@ai-sdk/openai':
459 + specifier: 'catalog:'
460 + version: 3.0.19(zod@4.3.6)
461 + '@composio/core':
462 + specifier: workspace:*
463 + version: link:../../../../packages/core
464 + '@composio/mastra':
465 + specifier: workspace:*
466 + version: link:../../../../packages/providers/mastra
467 + '@mastra/core':
468 + specifier: 'catalog:'
469 + version: 1.0.4(@cfworker/json-schema@4.1.1)(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(effect@3.19.15)(quansync@1.0.0)(zod-to-json-schema@3.25.1(zod@4.3.6))(zod@4.3.6))(@standard-community/standard-openapi@0.2.9(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(effect@3.19.15)(quansync@1.0.0)(zod-to-json-schema@3.25.1(zod@4.3.6))(zod@4.3.6))(@standard-schema/spec@1.1.0)(effect@3.19.15)(openapi-types@12.1.3)(zod@4.3.6))(@types/json-schema@7.0.15)(openapi-types@12.1.3)(zod@4.3.6)
470 + '@mastra/mcp':
471 + specifier: ^1.0.0
472 + version: 1.0.0(@cfworker/json-schema@4.1.1)(@mastra/core@1.0.4(@cfworker/json-schema@4.1.1)(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(effect@3.19.15)(quansync@1.0.0)(zod-to-json-schema@3.25.1(zod@4.3.6))(zod@4.3.6))(@standard-community/standard-openapi@0.2.9(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(effect@3.19.15)(quansync@1.0.0)(zod-to-json-schema@3.25.1(zod@4.3.6))(zod@4.3.6))(@standard-schema/spec@1.1.0)(effect@3.19.15)(openapi-types@12.1.3)(zod@4.3.6))(@types/json-schema@7.0.15)(openapi-types@12.1.3)(zod@4.3.6))(@types/json-schema@7.0.15)(zod@4.3.6)
473 + ai:
474 + specifier: 'catalog:'
475 + version: 6.0.49(zod@4.3.6)
476 + zod:
477 + specifier: ^4.1.0
478 + version: 4.3.6
479 + devDependencies:
480 + '@e2e-tests/utils':
481 + specifier: workspace:*
482 + version: link:../../../_utils
483 +
484 ts/e2e-tests/runtimes/node/openai-zod4-compat:
485 devDependencies:
486 '@e2e-tests/utils':
@@ -1447,6 +1506,12 @@ packages:
1506 peerDependencies:
1507 zod: ^3.25.76 || ^4.1.8
1508
1509 + '@ai-sdk/openai@3.0.19':
1510 + resolution: {integrity: sha512-qpMGKV6eYfW8IzErk/OppchQwVui3GPc4BEfg/sQGRzR89vf2Sa8qvSavXeZi5w/oUF56d+VtobwSH0FRooFCQ==}
1511 + engines: {node: '>=18'}
1512 + peerDependencies:
1513 + zod: ^3.25.76 || ^4.1.8
1514 +
1515 '@ai-sdk/provider-utils@2.2.8':
1516 resolution: {integrity: sha512-fqhG+4sCVv8x7nFzYnFo19ryhAa3w096Kmc3hWxMQfW/TubPOmt3A6tYZhl4mUfQWWQMsuSkLrtjlWuXBVSGQA==}
1517 engines: {node: '>=18'}
@@ -2985,6 +3050,13 @@ packages:
3050 '@mastra/core': '>=0.20.1-0 <0.25.0-0'
3051 zod: ^3.25.0 || ^4.0.0
3052
3053 + '@mastra/mcp@1.0.0':
3054 + resolution: {integrity: sha512-g+N3L61Sq4dQGLjMlQmVAnAPVOi1fJHmSe+gJxamxTGJ/r8Tdl6Za0gOj4faSeDUAn2sim0dCz2FEDjXDvoDsQ==}
3055 + engines: {node: '>=22.13.0'}
3056 + peerDependencies:
3057 + '@mastra/core': '>=1.0.0-0 <2.0.0-0'
3058 + zod: ^3.25.0 || ^4.0.0
3059 +
3060 '@mastra/schema-compat@1.0.0':
3061 resolution: {integrity: sha512-jR5QsibhCO3lh2Vv3hNifd5XaKFnOV7ecduZyNxNg21Fw1+59ozpHkNtUAmDQW88uwvx/qHu1dKN/XtOhwWeyw==}
3062 engines: {node: '>=22.13.0'}
@@ -4838,6 +4910,10 @@ packages:
4910 resolution: {integrity: sha512-Fqs7ChZm72y40wKjOFXBKg7nJZvQJmewP5/7LtePDdnah/+FH9Hp5sgMujSCMPXlxOAW2//1jrW9pnsY7o20vQ==}
4911 engines: {node: '>=18'}
4912
4913 + exit-hook@5.0.1:
4914 + resolution: {integrity: sha512-LHebYV6wSOObiWC894M36qqoWbGWFDZFJnCAch+JUYTyI5EJAlF3Lhv9sqLKoUDjTj3X6SsIxwy41mw2AqFfdA==}
4915 + engines: {node: '>=20'}
4916 +
4917 expect-type@1.3.0:
4918 resolution: {integrity: sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==}
4919 engines: {node: '>=12.0.0'}
@@ -7230,6 +7306,13 @@ snapshots:
7306 '@ai-sdk/provider-utils': 2.2.8(zod@4.3.6)
7307 zod: 4.3.6
7308
7309 + '@ai-sdk/gateway@3.0.22(zod@3.25.76)':
7310 + dependencies:
7311 + '@ai-sdk/provider': 3.0.5
7312 + '@ai-sdk/provider-utils': 4.0.9(zod@3.25.76)
7313 + '@vercel/oidc': 3.1.0
7314 + zod: 3.25.76
7315 +
7316 '@ai-sdk/gateway@3.0.22(zod@4.3.6)':
7317 dependencies:
7318 '@ai-sdk/provider': 3.0.5
@@ -7269,6 +7352,18 @@ snapshots:
7352 '@ai-sdk/provider-utils': 4.0.9(zod@4.3.6)
7353 zod: 4.3.6
7354
7355 + '@ai-sdk/openai@3.0.19(zod@3.25.76)':
7356 + dependencies:
7357 + '@ai-sdk/provider': 3.0.5
7358 + '@ai-sdk/provider-utils': 4.0.9(zod@3.25.76)
7359 + zod: 3.25.76
7360 +
7361 + '@ai-sdk/openai@3.0.19(zod@4.3.6)':
7362 + dependencies:
7363 + '@ai-sdk/provider': 3.0.5
7364 + '@ai-sdk/provider-utils': 4.0.9(zod@4.3.6)
7365 + zod: 4.3.6
7366 +
7367 '@ai-sdk/provider-utils@2.2.8(zod@3.25.76)':
7368 dependencies:
7369 '@ai-sdk/provider': 1.1.3
@@ -7325,6 +7420,13 @@ snapshots:
7420 eventsource-parser: 3.0.6
7421 zod: 4.3.6
7422
7423 + '@ai-sdk/provider-utils@4.0.9(zod@3.25.76)':
7424 + dependencies:
7425 + '@ai-sdk/provider': 3.0.5
7426 + '@standard-schema/spec': 1.1.0
7427 + eventsource-parser: 3.0.6
7428 + zod: 3.25.76
7429 +
7430 '@ai-sdk/provider-utils@4.0.9(zod@4.3.6)':
7431 dependencies:
7432 '@ai-sdk/provider': 3.0.5
@@ -8830,6 +8932,40 @@ snapshots:
8932 - hono
8933 - supports-color
8934
8935 + '@mastra/mcp@1.0.0(@cfworker/json-schema@4.1.1)(@mastra/core@1.0.4(@cfworker/json-schema@4.1.1)(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(effect@3.19.15)(quansync@1.0.0)(zod-to-json-schema@3.25.1(zod@3.25.76))(zod@3.25.76))(@standard-community/standard-openapi@0.2.9(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(effect@3.19.15)(quansync@1.0.0)(zod-to-json-schema@3.25.1(zod@3.25.76))(zod@3.25.76))(@standard-schema/spec@1.1.0)(effect@3.19.15)(openapi-types@12.1.3)(zod@3.25.76))(@types/json-schema@7.0.15)(openapi-types@12.1.3)(zod@3.25.76))(@types/json-schema@7.0.15)(hono@4.11.5)(zod@3.25.76)':
8936 + dependencies:
8937 + '@apidevtools/json-schema-ref-parser': 14.2.1(@types/json-schema@7.0.15)
8938 + '@mastra/core': 1.0.4(@cfworker/json-schema@4.1.1)(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(effect@3.19.15)(quansync@1.0.0)(zod-to-json-schema@3.25.1(zod@3.25.76))(zod@3.25.76))(@standard-community/standard-openapi@0.2.9(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(effect@3.19.15)(quansync@1.0.0)(zod-to-json-schema@3.25.1(zod@3.25.76))(zod@3.25.76))(@standard-schema/spec@1.1.0)(effect@3.19.15)(openapi-types@12.1.3)(zod@3.25.76))(@types/json-schema@7.0.15)(openapi-types@12.1.3)(zod@3.25.76)
8939 + '@modelcontextprotocol/sdk': 1.25.3(@cfworker/json-schema@4.1.1)(hono@4.11.5)(zod@3.25.76)
8940 + exit-hook: 5.0.1
8941 + fast-deep-equal: 3.1.3
8942 + uuid: 13.0.0
8943 + zod: 3.25.76
8944 + zod-from-json-schema: 0.5.2
8945 + zod-from-json-schema-v3: zod-from-json-schema@0.0.5
8946 + transitivePeerDependencies:
8947 + - '@cfworker/json-schema'
8948 + - '@types/json-schema'
8949 + - hono
8950 + - supports-color
8951 +
8952 + '@mastra/mcp@1.0.0(@cfworker/json-schema@4.1.1)(@mastra/core@1.0.4(@cfworker/json-schema@4.1.1)(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(effect@3.19.15)(quansync@1.0.0)(zod-to-json-schema@3.25.1(zod@4.3.6))(zod@4.3.6))(@standard-community/standard-openapi@0.2.9(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(effect@3.19.15)(quansync@1.0.0)(zod-to-json-schema@3.25.1(zod@4.3.6))(zod@4.3.6))(@standard-schema/spec@1.1.0)(effect@3.19.15)(openapi-types@12.1.3)(zod@4.3.6))(@types/json-schema@7.0.15)(openapi-types@12.1.3)(zod@4.3.6))(@types/json-schema@7.0.15)(zod@4.3.6)':
8953 + dependencies:
8954 + '@apidevtools/json-schema-ref-parser': 14.2.1(@types/json-schema@7.0.15)
8955 + '@mastra/core': 1.0.4(@cfworker/json-schema@4.1.1)(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(effect@3.19.15)(quansync@1.0.0)(zod-to-json-schema@3.25.1(zod@4.3.6))(zod@4.3.6))(@standard-community/standard-openapi@0.2.9(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(effect@3.19.15)(quansync@1.0.0)(zod-to-json-schema@3.25.1(zod@4.3.6))(zod@4.3.6))(@standard-schema/spec@1.1.0)(effect@3.19.15)(openapi-types@12.1.3)(zod@4.3.6))(@types/json-schema@7.0.15)(openapi-types@12.1.3)(zod@4.3.6)
8956 + '@modelcontextprotocol/sdk': 1.25.3(@cfworker/json-schema@4.1.1)(hono@4.11.5)(zod@4.3.6)
8957 + exit-hook: 5.0.1
8958 + fast-deep-equal: 3.1.3
8959 + uuid: 13.0.0
8960 + zod: 4.3.6
8961 + zod-from-json-schema: 0.5.2
8962 + zod-from-json-schema-v3: zod-from-json-schema@0.0.5
8963 + transitivePeerDependencies:
8964 + - '@cfworker/json-schema'
8965 + - '@types/json-schema'
8966 + - hono
8967 + - supports-color
8968 +
8969 '@mastra/schema-compat@1.0.0(zod@3.25.76)':
8970 dependencies:
8971 json-schema-to-zod: 2.7.0
@@ -9697,7 +9833,7 @@ snapshots:
9833
9834 '@types/mute-stream@0.0.4':
9835 dependencies:
9700 - '@types/node': 20.19.30
9836 + '@types/node': 24.10.9
9837
9838 '@types/node-fetch@2.6.13':
9839 dependencies:
@@ -9867,6 +10003,14 @@ snapshots:
10003 chai: 5.3.3
10004 tinyrainbow: 2.0.0
10005
10006 + '@vitest/mocker@3.2.4(vite@7.3.1(@types/node@20.19.30)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2))':
10007 + dependencies:
10008 + '@vitest/spy': 3.2.4
10009 + estree-walker: 3.0.3
10010 + magic-string: 0.30.21
10011 + optionalDependencies:
10012 + vite: 7.3.1(@types/node@20.19.30)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
10013 +
10014 '@vitest/mocker@3.2.4(vite@7.3.1(@types/node@22.19.7)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2))':
10015 dependencies:
10016 '@vitest/spy': 3.2.4
@@ -9875,6 +10019,14 @@ snapshots:
10019 optionalDependencies:
10020 vite: 7.3.1(@types/node@22.19.7)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
10021
10022 + '@vitest/mocker@3.2.4(vite@7.3.1(@types/node@24.10.9)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2))':
10023 + dependencies:
10024 + '@vitest/spy': 3.2.4
10025 + estree-walker: 3.0.3
10026 + magic-string: 0.30.21
10027 + optionalDependencies:
10028 + vite: 7.3.1(@types/node@24.10.9)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
10029 +
10030 '@vitest/pretty-format@3.2.4':
10031 dependencies:
10032 tinyrainbow: 2.0.0
@@ -9904,7 +10056,7 @@ snapshots:
10056 sirv: 3.0.2
10057 tinyglobby: 0.2.15
10058 tinyrainbow: 2.0.0
9907 - vitest: 3.2.4(@types/node@22.19.7)(@vitest/ui@3.2.4)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
10059 + vitest: 3.2.4(@types/node@20.19.30)(@vitest/ui@3.2.4)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
10060
10061 '@vitest/utils@3.2.4':
10062 dependencies:
@@ -9942,6 +10094,14 @@ snapshots:
10094 dependencies:
10095 humanize-ms: 1.2.1
10096
10097 + ai@6.0.49(zod@3.25.76):
10098 + dependencies:
10099 + '@ai-sdk/gateway': 3.0.22(zod@3.25.76)
10100 + '@ai-sdk/provider': 3.0.5
10101 + '@ai-sdk/provider-utils': 4.0.9(zod@3.25.76)
10102 + '@opentelemetry/api': 1.9.0
10103 + zod: 3.25.76
10104 +
10105 ai@6.0.49(zod@4.3.6):
10106 dependencies:
10107 '@ai-sdk/gateway': 3.0.22(zod@4.3.6)
@@ -10285,9 +10445,9 @@ snapshots:
10445 core-util-is: 1.0.3
10446 esprima: 4.0.1
10447
10288 - composio-core@0.5.39(3053e361571666380203a2990eacf306):
10448 + composio-core@0.5.39(9958f69effac5ea0e6101081f492dcab):
10449 dependencies:
10290 - '@ai-sdk/openai': 3.0.18(zod@4.3.6)
10450 + '@ai-sdk/openai': 3.0.19(zod@4.3.6)
10451 '@cloudflare/workers-types': 4.20260124.0
10452 '@composio/mcp': 1.0.3-0
10453 '@hey-api/client-axios': 0.2.12(axios@1.13.3)
@@ -10741,6 +10901,8 @@ snapshots:
10901
10902 exit-hook@4.0.0: {}
10903
10904 + exit-hook@5.0.1: {}
10905 +
10906 expect-type@1.3.0: {}
10907
10908 express-rate-limit@7.5.1(express@5.2.1):
@@ -13113,7 +13275,7 @@ snapshots:
13275 dependencies:
13276 '@types/chai': 5.2.3
13277 '@vitest/expect': 3.2.4
13116 - '@vitest/mocker': 3.2.4(vite@7.3.1(@types/node@22.19.7)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2))
13278 + '@vitest/mocker': 3.2.4(vite@7.3.1(@types/node@20.19.30)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2))
13279 '@vitest/pretty-format': 3.2.4
13280 '@vitest/runner': 3.2.4
13281 '@vitest/snapshot': 3.2.4
@@ -13197,7 +13359,7 @@ snapshots:
13359 dependencies:
13360 '@types/chai': 5.2.3
13361 '@vitest/expect': 3.2.4
13200 - '@vitest/mocker': 3.2.4(vite@7.3.1(@types/node@22.19.7)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2))
13362 + '@vitest/mocker': 3.2.4(vite@7.3.1(@types/node@24.10.9)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2))
13363 '@vitest/pretty-format': 3.2.4
13364 '@vitest/runner': 3.2.4
13365 '@vitest/snapshot': 3.2.4
pnpm-workspace.yaml
+1
@@ -15,6 +15,7 @@ packages:
15 - fern/snippets/*
16
17 catalog:
18 + '@ai-sdk/openai': ^3.0.19
19 '@arethetypeswrong/cli': ^0.18.2
20 '@cloudflare/vitest-pool-workers': ^0.9.2
21 '@cloudflare/workers-types': ^4.20250917.0
ts/e2e-tests/runtimes/node/mastra-tool-router-zod-v3/README.md new
+24
@@ -0,0 +1,24 @@
1 +# @composio/mastra + Zod v3 Tool Router Test
2 +
3 +Verifies that `@composio/mastra` works correctly with `zod@3.25.76` in a Tool Router workflow.
4 +
5 +## Why This Exists
6 +
7 +Issue [#2109](https://github.com/ComposioHQ/composio/issues/2109) tracks Mastra integration support. The `@composio/mastra` provider must work with both Zod v3 and v4. This suite ensures:
8 +
9 +- MastraProvider integrates correctly with Composio core
10 +- MCP client can connect to Composio's Tool Router endpoint
11 +- Mastra Agent can use Composio tools via MCP
12 +- Structured output with Zod v3 schemas works correctly
13 +
14 +## What It Tests
15 +
16 +| Test | Description |
17 +| -------------------- | -------------------------------------------------------- |
18 +| Tool Router workflow | Creates session, connects MCP, runs agent with Zod v3 schema |
19 +
20 +## Running
21 +
22 +```bash
23 +pnpm test:e2e
24 +```
ts/e2e-tests/runtimes/node/mastra-tool-router-zod-v3/e2e.test.ts new
+104
@@ -0,0 +1,104 @@
1 +/**
2 + * @composio/mastra + openai + zod 3
3 + *
4 + * Verifies that @composio/mastra works correctly with zod@3.
5 + *
6 + * See: https://github.com/ComposioHQ/composio/issues/2109.
7 + */
8 +
9 +import { Composio } from '@composio/core';
10 +import { MastraProvider } from '@composio/mastra';
11 +import { MCPClient } from '@mastra/mcp';
12 +import { Agent } from '@mastra/core/agent';
13 +import { e2e } from '@e2e-tests/utils';
14 +import { TIMEOUTS } from '@e2e-tests/utils/const';
15 +import { describe, it, expect } from 'bun:test';
16 +import { createOpenAI } from '@ai-sdk/openai';
17 +import { stepCountIs } from 'ai';
18 +import { z } from 'zod';
19 +
20 +declare module 'bun' {
21 + interface Env {
22 + COMPOSIO_API_KEY: string;
23 + OPENAI_API_KEY: string;
24 + }
25 +}
26 +
27 +e2e(import.meta.url, {
28 + nodeVersions: ['current'],
29 + env: {
30 + COMPOSIO_API_KEY: Bun.env.COMPOSIO_API_KEY,
31 + OPENAI_API_KEY: Bun.env.OPENAI_API_KEY,
32 + },
33 + defineTests: () => {
34 + describe('@composio/mastra + openai + zod 4', () => {
35 +
36 + const composio = new Composio({
37 + apiKey: Bun.env.COMPOSIO_API_KEY,
38 + provider: new MastraProvider(),
39 + });
40 +
41 + it('should work with Tool Router', async () => {
42 + const session = await composio.create('default', {
43 + toolkits: ['hackernews'],
44 + manageConnections: true,
45 + tools: {
46 + hackernews: {
47 + enable: ['HACKERNEWS_GET_USER'],
48 + },
49 + },
50 + });
51 +
52 + const { mcp, sessionId } = session;
53 + expect(sessionId).toBeDefined();
54 +
55 + // Create a client with an HTTP server (tries Streamable HTTP, falls back to SSE)
56 + const mcpClient = new MCPClient({
57 + servers: {
58 + myHttpClient: {
59 + url: new URL(mcp.url),
60 + requestInit: {
61 + headers: mcp.headers,
62 + },
63 + },
64 + },
65 + });
66 +
67 + const tools = await mcpClient.listTools();
68 + const openai = createOpenAI({ apiKey: Bun.env.OPENAI_API_KEY });
69 +
70 + const hackernewsAgent = new Agent({
71 + id: 'test',
72 + name: 'test',
73 + instructions: `You're a helpful Hackernews agent, able to finding information about users.`,
74 + model: openai('gpt-5.1'),
75 + tools,
76 + });
77 +
78 + const result = await hackernewsAgent.generate('Look up user "pg", and tell me their karma score.', {
79 + structuredOutput: {
80 + schema: z.object({
81 + karma: z.number(),
82 + }),
83 + },
84 + stopWhen: stepCountIs(10),
85 + });
86 +
87 + const toolCalls = result.toolCalls.flatMap(toolCall =>
88 + toolCall.payload.toolName
89 + );
90 + const toolCount = Object.keys(tools).length;
91 +
92 + expect(toolCount).toBeGreaterThan(0);
93 + expect(toolCalls).toBeDefined();
94 + expect(result.error).toBeUndefined();
95 + expect(result.object).toBeDefined();
96 + expect(result.object.karma).toBeGreaterThan(150_000);
97 +
98 + await mcpClient.disconnect();
99 + }, {
100 + timeout: TIMEOUTS.LLM_SHORT,
101 + });
102 + });
103 + }
104 +});
ts/e2e-tests/runtimes/node/mastra-tool-router-zod-v3/package.json new
+23
@@ -0,0 +1,23 @@
1 +{
2 + "name": "@e2e-tests/node-mastra-tool-router-zod-v3",
3 + "version": "0.0.0",
4 + "private": true,
5 + "type": "module",
6 + "scripts": {
7 + "typecheck": "tsc --noEmit",
8 + "test:e2e": "bun test e2e.test.ts",
9 + "test:e2e:node": "bun test e2e.test.ts"
10 + },
11 + "dependencies": {
12 + "@ai-sdk/openai": "catalog:",
13 + "@composio/core": "workspace:*",
14 + "@composio/mastra": "workspace:*",
15 + "@mastra/core": "catalog:",
16 + "@mastra/mcp": "^1.0.0",
17 + "ai": "catalog:",
18 + "zod": "3.25.76"
19 + },
20 + "devDependencies": {
21 + "@e2e-tests/utils": "workspace:*"
22 + }
23 +}
ts/e2e-tests/runtimes/node/mastra-tool-router-zod-v3/tsconfig.json new
+12
@@ -0,0 +1,12 @@
1 +{
2 + "$schema": "https://json.schemastore.org/tsconfig",
3 + "compilerOptions": {
4 + "target": "es2022",
5 + "module": "esnext",
6 + "moduleResolution": "bundler",
7 + "strict": true,
8 + "skipLibCheck": true,
9 + "noEmit": true
10 + },
11 + "include": ["e2e.test.ts"]
12 +}
ts/e2e-tests/runtimes/node/mastra-tool-router-zod-v4/README.md new
+24
@@ -0,0 +1,24 @@
1 +# @composio/mastra + Zod v4 Tool Router Test
2 +
3 +Verifies that `@composio/mastra` works correctly with `zod@4` in a Tool Router workflow.
4 +
5 +## Why This Exists
6 +
7 +Issue [#2109](https://github.com/ComposioHQ/composio/issues/2109) tracks Mastra integration support. The `@composio/mastra` provider must work with both Zod v3 and v4. This suite ensures:
8 +
9 +- MastraProvider integrates correctly with Composio core
10 +- MCP client can connect to Composio's Tool Router endpoint
11 +- Mastra Agent can use Composio tools via MCP
12 +- Structured output with Zod v4 schemas works correctly
13 +
14 +## What It Tests
15 +
16 +| Test | Description |
17 +| -------------------- | -------------------------------------------------------- |
18 +| Tool Router workflow | Creates session, connects MCP, runs agent with Zod v4 schema |
19 +
20 +## Running
21 +
22 +```bash
23 +pnpm test:e2e
24 +```
ts/e2e-tests/runtimes/node/mastra-tool-router-zod-v4/e2e.test.ts new
+104
@@ -0,0 +1,104 @@
1 +/**
2 + * @composio/mastra + openai + zod 4
3 + *
4 + * Verifies that @composio/mastra works correctly with zod@4.
5 + *
6 + * See: https://github.com/ComposioHQ/composio/issues/2109.
7 + */
8 +
9 +import { Composio } from '@composio/core';
10 +import { MastraProvider } from '@composio/mastra';
11 +import { MCPClient } from '@mastra/mcp';
12 +import { Agent } from '@mastra/core/agent';
13 +import { e2e } from '@e2e-tests/utils';
14 +import { TIMEOUTS } from '@e2e-tests/utils/const';
15 +import { describe, it, expect } from 'bun:test';
16 +import { createOpenAI } from '@ai-sdk/openai';
17 +import { stepCountIs } from 'ai';
18 +import { z } from 'zod';
19 +
20 +declare module 'bun' {
21 + interface Env {
22 + COMPOSIO_API_KEY: string;
23 + OPENAI_API_KEY: string;
24 + }
25 +}
26 +
27 +e2e(import.meta.url, {
28 + nodeVersions: ['current'],
29 + env: {
30 + COMPOSIO_API_KEY: Bun.env.COMPOSIO_API_KEY,
31 + OPENAI_API_KEY: Bun.env.OPENAI_API_KEY,
32 + },
33 + defineTests: () => {
34 + describe('@composio/mastra + openai + zod 4', () => {
35 +
36 + const composio = new Composio({
37 + apiKey: Bun.env.COMPOSIO_API_KEY,
38 + provider: new MastraProvider(),
39 + });
40 +
41 + it('should work with Tool Router', async () => {
42 + const session = await composio.create('default', {
43 + toolkits: ['hackernews'],
44 + manageConnections: true,
45 + tools: {
46 + hackernews: {
47 + enable: ['HACKERNEWS_GET_USER'],
48 + },
49 + },
50 + });
51 +
52 + const { mcp, sessionId } = session;
53 + expect(sessionId).toBeDefined();
54 +
55 + // Create a client with an HTTP server (tries Streamable HTTP, falls back to SSE)
56 + const mcpClient = new MCPClient({
57 + servers: {
58 + myHttpClient: {
59 + url: new URL(mcp.url),
60 + requestInit: {
61 + headers: mcp.headers,
62 + },
63 + },
64 + },
65 + });
66 +
67 + const tools = await mcpClient.listTools();
68 + const openai = createOpenAI({ apiKey: Bun.env.OPENAI_API_KEY });
69 +
70 + const hackernewsAgent = new Agent({
71 + id: 'test',
72 + name: 'test',
73 + instructions: `You're a helpful Hackernews agent, able to finding information about users.`,
74 + model: openai('gpt-5.1'),
75 + tools,
76 + });
77 +
78 + const result = await hackernewsAgent.generate('Look up user "pg", and tell me their karma score.', {
79 + structuredOutput: {
80 + schema: z.object({
81 + karma: z.number(),
82 + }),
83 + },
84 + stopWhen: stepCountIs(10),
85 + });
86 +
87 + const toolCalls = result.toolCalls.flatMap(toolCall =>
88 + toolCall.payload.toolName
89 + );
90 + const toolCount = Object.keys(tools).length;
91 +
92 + expect(toolCount).toBeGreaterThan(0);
93 + expect(toolCalls).toBeDefined();
94 + expect(result.error).toBeUndefined();
95 + expect(result.object).toBeDefined();
96 + expect(result.object.karma).toBeGreaterThan(150_000);
97 +
98 + await mcpClient.disconnect();
99 + }, {
100 + timeout: TIMEOUTS.LLM_SHORT,
101 + });
102 + });
103 + }
104 +});
ts/e2e-tests/runtimes/node/mastra-tool-router-zod-v4/package.json new
+23
@@ -0,0 +1,23 @@
1 +{
2 + "name": "@e2e-tests/node-mastra-tool-router-zod-v4",
3 + "version": "0.0.0",
4 + "private": true,
5 + "type": "module",
6 + "scripts": {
7 + "typecheck": "tsc --noEmit",
8 + "test:e2e": "bun test e2e.test.ts",
9 + "test:e2e:node": "bun test e2e.test.ts"
10 + },
11 + "dependencies": {
12 + "@ai-sdk/openai": "catalog:",
13 + "@composio/core": "workspace:*",
14 + "@composio/mastra": "workspace:*",
15 + "@mastra/core": "catalog:",
16 + "@mastra/mcp": "^1.0.0",
17 + "ai": "catalog:",
18 + "zod": "^4.1.0"
19 + },
20 + "devDependencies": {
21 + "@e2e-tests/utils": "workspace:*"
22 + }
23 +}
ts/e2e-tests/runtimes/node/mastra-tool-router-zod-v4/tsconfig.json new
+12
@@ -0,0 +1,12 @@
1 +{
2 + "$schema": "https://json.schemastore.org/tsconfig",
3 + "compilerOptions": {
4 + "target": "es2022",
5 + "module": "esnext",
6 + "moduleResolution": "bundler",
7 + "strict": true,
8 + "skipLibCheck": true,
9 + "noEmit": true
10 + },
11 + "include": ["e2e.test.ts"]
12 +}