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 21, 07:15 UTC
| 1 | # Tool Router AI - Cloudflare Workers E2E Test |
| 2 | |
| 3 | Verifies that the Tool Router AI pattern (MCP session + Vercel AI SDK) works correctly in the Cloudflare Workers runtime environment. |
| 4 | |
| 5 | ## Why This Exists |
| 6 | |
| 7 | This test validates that the full Tool Router workflow works in Cloudflare Workers: |
| 8 | |
| 9 | 1. Creating MCP sessions via Composio |
| 10 | 2. Connecting to MCP servers using `@ai-sdk/mcp` |
| 11 | 3. Retrieving tools from the MCP client |
| 12 | 4. Using tools with Vercel AI SDK's `streamText` |
| 13 | |
| 14 | ## What It Tests |
| 15 | |
| 16 | | Test | Description | |
| 17 | | --------------------- | --------------------------------------------------------------- | |
| 18 | | MCP Session Creation | Creates a toolrouter session with specified toolkits | |
| 19 | | MCP Client Connection | Connects to the MCP server URL returned from session creation | |
| 20 | | Tool Retrieval | Retrieves tools from the MCP client | |
| 21 | | Agent Execution | Executes an AI agent using the retrieved tools | |
| 22 | | Uses LLMs? | ✅ (OpenAI GPT) | |
| 23 | |
| 24 | ## Isolation Tool |
| 25 | |
| 26 | - `wrangler`: Cloudflare's CLI that runs a local workerd instance |
| 27 | - `@cloudflare/vitest-pool-workers`: Runs Vitest tests inside the Workers runtime, not Node.js |
| 28 | |
| 29 | This combination provides true runtime isolation—tests execute in the same environment as production Workers. |
| 30 | |
| 31 | ## Setup |
| 32 | |
| 33 | 1. Copy `.env.example` to `.env` and add your API keys: |
| 34 | - `COMPOSIO_API_KEY`: Your Composio API key |
| 35 | - `OPENAI_API_KEY`: Your OpenAI API key |
| 36 | 2. Install dependencies: `pnpm install` |
| 37 | |
| 38 | ## Running |
| 39 | |
| 40 | ```bash |
| 41 | # Via pnpm (recommended) |
| 42 | pnpm test:e2e |
| 43 | ``` |
| 44 | |
| 45 | ## Configuration |
| 46 | |
| 47 | | File | Purpose | |
| 48 | | ------------------- | ---------------------------------------------------- | |
| 49 | | `wrangler.jsonc` | Worker configuration (bindings, compatibility flags) | |
| 50 | | `vitest.config.mts` | Vitest setup with Workers pool and env bindings | |