ts/e2e-tests/runtimes/cloudflare/cf-workers-tool-router-ai/README.md
Verifies that the Tool Router AI pattern (MCP session + Vercel AI SDK) works correctly in the Cloudflare Workers runtime environment.
This test validates that the full Tool Router workflow works in Cloudflare Workers:
@ai-sdk/mcpstreamText| Test | Description |
|---|---|
| MCP Session Creation | Creates a toolrouter session with specified toolkits |
| MCP Client Connection | Connects to the MCP server URL returned from session creation |
| Tool Retrieval | Retrieves tools from the MCP client |
| Agent Execution | Executes an AI agent using the retrieved tools |
| Uses LLMs? | ✅ (OpenAI GPT) |
wrangler: Cloudflare's CLI that runs a local workerd instance@cloudflare/vitest-pool-workers: Runs Vitest tests inside the Workers runtime, not Node.jsThis combination provides true runtime isolation—tests execute in the same environment as production Workers.
.env.example to .env and add your API keys:
COMPOSIO_API_KEY: Your Composio API keyOPENAI_API_KEY: Your OpenAI API keypnpm install# Via pnpm (recommended)
pnpm test:e2e
| File | Purpose |
|---|---|
wrangler.jsonc | Worker configuration (bindings, compatibility flags) |
vitest.config.mts | Vitest setup with Workers pool and env bindings |