Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
test(ts/e2e): fix potential mcp connection leak
jkomyno07e3cf5a0f6a
diff --git a/ts/e2e-tests/runtimes/cloudflare/cf-workers-tool-router-ai/src/index.ts b/ts/e2e-tests/runtimes/cloudflare/cf-workers-tool-router-ai/src/index.tsindex a23b887fd..2467cf439 100644--- a/ts/e2e-tests/runtimes/cloudflare/cf-workers-tool-router-ai/src/index.ts+++ b/ts/e2e-tests/runtimes/cloudflare/cf-workers-tool-router-ai/src/index.ts@@ -101,34 +101,36 @@ app.get('/test/agent', async c => {},});- const tools = await mcpClient.tools();- const openai = createOpenAI({ apiKey: c.env.OPENAI_API_KEY });-- const result = await generateText({- model: openai('gpt-5.1-codex'),- prompt: `Look up the HackerNews user "pg", and tell me their karma score.`,- output: Output.object({- schema: z.object({- karma: z.number(),+ try {+ const tools = await mcpClient.tools();+ const openai = createOpenAI({ apiKey: c.env.OPENAI_API_KEY });++ const result = await generateText({+ model: openai('gpt-5.1-codex'),+ prompt: `Look up the HackerNews user "pg", and tell me their karma score.`,+ output: Output.object({+ schema: z.object({+ karma: z.number(),+ }),}),- }),- stopWhen: stepCountIs(10),- tools,- });-- const toolCalls = result.steps.flatMap(step =>- step.toolCalls.map(tc => ({ toolName: tc.toolName }))- );-- c.executionCtx.waitUntil(mcpClient.close());-- return c.json({- message: 'Agent executed successfully',- sessionId,- toolCount: Object.keys(tools).length,- toolCalls,- response: result.output,- });+ stopWhen: stepCountIs(10),+ tools,+ });++ const toolCalls = result.steps.flatMap(step =>+ step.toolCalls.map(tc => ({ toolName: tc.toolName }))+ );++ return c.json({+ message: 'Agent executed successfully',+ sessionId,+ toolCount: Object.keys(tools).length,+ toolCalls,+ response: result.output,+ });+ } finally {+ c.executionCtx.waitUntil(mcpClient.close());+ }});export default app;