Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | import { Composio } from '@composio/core'; |
| 2 | import { Agent, hostedMcpTool, run, type AgentInputItem } from '@openai/agents'; |
| 3 | import { createInterface } from 'node:readline/promises'; |
| 4 | |
| 5 | const composio = new Composio(); |
| 6 | const { mcp } = await composio.create('default', { mcp: true }); |
| 7 | |
| 8 | const agent = new Agent({ |
| 9 | name: 'Personal Assistant', |
| 10 | model: 'gpt-5.1', |
| 11 | instructions: 'You are a helpful personal assistant. Use Composio tools to execute tasks.', |
| 12 | tools: [ |
| 13 | hostedMcpTool({ |
| 14 | serverLabel: 'composio', |
| 15 | serverUrl: mcp.url, |
| 16 | headers: { |
| 17 | 'x-api-key': process.env.COMPOSIO_API_KEY!, |
| 18 | }, |
| 19 | }), |
| 20 | ], |
| 21 | }); |
| 22 | |
| 23 | const rl = createInterface({ input: process.stdin, output: process.stdout }); |
| 24 | |
| 25 | for (let input: string | AgentInputItem[] = await rl.question('You: '); input !== 'exit';) { |
| 26 | const result = await run(agent, input); |
| 27 | console.log(`Agent: ${result.finalOutput}\n`); |
| 28 | input = [ |
| 29 | ...result.history, |
| 30 | { role: 'user' as const, content: await rl.question('You: ') }, |
| 31 | ] as AgentInputItem[]; |
| 32 | } |
| 33 | |
| 34 | rl.close(); |