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

next
ts 25 lines 846 Bytes
Raw
1 /**
2 * Mastra × Composio — Tool Router
3 *
4 * The v1-canonical way to give an agent tools: create a session scoped to one
5 * or more toolkits, then hand `session.tools()` to a Mastra Agent. The session
6 * exposes Composio's router meta-tools (search + multi-execute), so the agent
7 * discovers and runs the toolkit's tools dynamically.
8 *
9 * Uses the unauthenticated HACKERNEWS toolkit — no connected account needed.
10 *
11 * Prerequisites:
12 * - COMPOSIO_API_KEY (https://app.composio.dev)
13 * - OPENAI_API_KEY (or swap the model — see README)
14 *
15 * Run:
16 * bun ts/examples/mastra/src/tool-router.ts
17 */
18 import 'dotenv/config';
19
20 import { runToolRouterHackerNewsAgent } from './hackernews-agent/tool-router';
21
22 const text = await runToolRouterHackerNewsAgent(process.env);
23
24 console.log('\n🤖 Agent response:\n');
25 console.log(text);