@devries-cameron20 / composio Mirror · read-only / commits / 22b87b3c3
Fork 0

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 22, 13:15 UTC

docs: update Vercel AI quickstart examples with multi-turn conversation

Update both Native and MCP Vercel AI examples to include: - readline-based conversation loop - Message history management using CoreMessage array - Consistent multi-turn experience with other frameworks Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Sushmithamallesh committed Jan 25, 2026 at 22:37 UTC 22b87b3c348d9b247653bb01ed9c926bfdaa30a0
1 file changed +268 -102
docs/content/docs/quickstart.mdx
+268 -102
@@ -20,7 +20,7 @@ Build your first AI agent with Composio Tools.
20 <Tabs groupId="language" items={['Python', 'TypeScript']} persist>
21 <Tab value="Python">
22 ```bash
23 -pip install composio composio-openai-agents openai-agents
23 +pip install python-dotenv composio composio-openai-agents openai-agents
24 ```
25 </Tab>
26 <Tab value="TypeScript">
@@ -35,7 +35,8 @@ npm install @composio/core @composio/openai-agents @openai/agents
35 ### Configure API Keys
36
37 <Callout type="info">
38 -Set `COMPOSIO_API_KEY` from [Settings](https://platform.composio.dev/?next_page=/settings) and `OPENAI_API_KEY` from [OpenAI](https://platform.openai.com/api-keys).
38 +- Set `COMPOSIO_API_KEY` from [Settings](https://platform.composio.dev/?next_page=/settings)
39 +- Set `OPENAI_API_KEY` from [OpenAI](https://platform.openai.com/api-keys)
40 </Callout>
41
42 ```txt title=".env"
@@ -65,10 +66,10 @@ user_id = "user_123"
66 session = composio.create(user_id=user_id)
67 tools = session.tools()
68
68 -# Create agent with tools
69 +# Configure agent with Composio tools
70 agent = Agent(
71 name="Personal Assistant",
71 - instructions="You are a helpful assistant. Use tools to complete tasks.",
72 + instructions="You are a helpful personal assistant. Use Composio tools to take action.",
73 model="gpt-4.1",
74 tools=tools,
75 )
@@ -76,15 +77,26 @@ agent = Agent(
77 # Memory for multi-turn conversation
78 memory = SQLiteSession("conversation")
79
79 -print("Assistant ready! Type 'exit' to quit.")
80 +print("""
81 +What task would you like me to help you with?
82 +I can use tools like Gmail, GitHub, Linear, Notion, and more.
83 +(Type 'exit' to exit)
84 +Example tasks:
85 + - 'Summarize my emails from today'
86 + - 'List all open issues on the composio github repository'
87 +""")
88
89 while True:
90 user_input = input("You: ").strip()
91 if user_input.lower() == "exit":
92 break
93
86 - result = Runner.run_sync(starting_agent=agent, input=user_input, session=memory)
87 - print(f"Assistant: {result.final_output}\n")
94 + print("Assistant: ", end="", flush=True)
95 + try:
96 + result = Runner.run_sync(starting_agent=agent, input=user_input, session=memory)
97 + print(f"{result.final_output}\n")
98 + except Exception as e:
99 + print(f"\n[Error]: {e}")
100 ```
101 </Tab>
102 <Tab value="TypeScript">
@@ -105,24 +117,39 @@ const tools = await session.tools();
117
118 const agent = new Agent({
119 name: "Personal Assistant",
108 - instructions: "You are a helpful assistant. Use tools to complete tasks.",
120 + instructions: "You are a helpful personal assistant. Use Composio tools to take action.",
121 model: "gpt-4.1",
122 tools,
123 });
124
125 +// Memory for multi-turn conversation
126 const memory = new MemorySession();
127 const readline = createInterface({ input: process.stdin, output: process.stdout });
128
116 -console.log("Assistant ready! Type 'exit' to quit.");
129 +console.log(`
130 +What task would you like me to help you with?
131 +I can use tools like Gmail, GitHub, Linear, Notion, and more.
132 +(Type 'exit' to exit)
133 +Example tasks:
134 + - 'Summarize my emails from today'
135 + - 'List all open issues on the composio github repository and create a Google Sheet with the issues'
136 +`);
137
138 +// Multi-turn conversation with agentic tool calling
139 while (true) {
119 - const input = (await readline.question("You: ")).trim();
120 - if (input.toLowerCase() === "exit") break;
140 + const query = await readline.question("You: ");
141 + const input = query.trim();
142
122 - const result = await run(agent, input, { session: memory });
123 - console.log(`Assistant: ${result.finalOutput}\n`);
124 -}
143 + if (input.toLowerCase() === "exit") break;
144 + process.stdout.write("Assistant: ");
145
146 + try {
147 + const result = await run(agent, input, { session: memory });
148 + process.stdout.write(`${result.finalOutput}\n`);
149 + } catch (error) {
150 + console.error("\n[Error]:", error instanceof Error ? error.message : error);
151 + }
152 +}
153 readline.close();
154 ```
155 </Tab>
@@ -140,12 +167,12 @@ readline.close();
167 <Tabs groupId="language" items={['Python', 'TypeScript']} persist>
168 <Tab value="Python">
169 ```bash
143 -pip install composio openai-agents
170 +pip install python-dotenv composio openai-agents
171 ```
172 </Tab>
173 <Tab value="TypeScript">
174 ```bash
148 -npm install @composio/core @openai/agents
175 +npm install dotenv @composio/core @openai/agents zod@3
176 ```
177 </Tab>
178 </Tabs>
@@ -155,7 +182,8 @@ npm install @composio/core @openai/agents
182 ### Configure API Keys
183
184 <Callout type="info">
158 -Set `COMPOSIO_API_KEY` from [Settings](https://platform.composio.dev/?next_page=/settings) and `OPENAI_API_KEY` from [OpenAI](https://platform.openai.com/api-keys).
185 +- Set `COMPOSIO_API_KEY` from [Settings](https://platform.composio.dev/?next_page=/settings)
186 +- Set `OPENAI_API_KEY` from [OpenAI](https://platform.openai.com/api-keys)
187 </Callout>
188
189 ```txt title=".env"
@@ -186,7 +214,7 @@ session = composio.create(user_id=user_id)
214 # Configure agent with Composio MCP server
215 agent = Agent(
216 name="Personal Assistant",
189 - instructions="You are a helpful assistant. Use tools to complete tasks.",
217 + instructions="You are a helpful personal assistant. Use Composio tools to take action.",
218 model="gpt-4.1",
219 tools=[
220 HostedMCPTool(
@@ -204,15 +232,26 @@ agent = Agent(
232 # Memory for multi-turn conversation
233 memory = SQLiteSession(user_id)
234
207 -print("Assistant ready! Type 'exit' to quit.")
235 +print("""
236 +What task would you like me to help you with?
237 +I can use tools like Gmail, GitHub, Linear, Notion, and more.
238 +(Type 'exit' to exit)
239 +Example tasks:
240 + - 'Summarize my emails from today'
241 + - 'List all open issues on the composio github repository'
242 +""")
243
244 while True:
245 user_input = input("You: ").strip()
246 if user_input.lower() == "exit":
247 break
248
214 - result = Runner.run_sync(starting_agent=agent, input=user_input, session=memory)
215 - print(f"Assistant: {result.final_output}\n")
249 + print("Assistant: ", end="", flush=True)
250 + try:
251 + result = Runner.run_sync(starting_agent=agent, input=user_input, session=memory)
252 + print(f"{result.final_output}\n")
253 + except Exception as e:
254 + print(f"\n[Error]: {e}")
255 ```
256 </Tab>
257 <Tab value="TypeScript">
@@ -231,7 +270,7 @@ const session = await composio.create(userId);
270
271 const agent = new Agent({
272 name: "Personal Assistant",
234 - instructions: "You are a helpful assistant. Use tools to complete tasks.",
273 + instructions: "You are a helpful personal assistant. Use Composio tools to take action.",
274 model: "gpt-4.1",
275 tools: [
276 hostedMcpTool({
@@ -242,19 +281,33 @@ const agent = new Agent({
281 ],
282 });
283
284 +// Memory for multi-turn conversation
285 const memory = new MemorySession();
286 const readline = createInterface({ input: process.stdin, output: process.stdout });
287
248 -console.log("Assistant ready! Type 'exit' to quit.");
288 +console.log(`
289 +What task would you like me to help you with?
290 +I can use tools like Gmail, GitHub, Linear, Notion, and more.
291 +(Type 'exit' to exit)
292 +Example tasks:
293 + - 'Summarize my emails from today'
294 + - 'List all open issues on the composio github repository and create a Google Sheet with the issues'
295 +`);
296
297 +// Multi-turn conversation with agentic tool calling
298 while (true) {
299 const input = (await readline.question("You: ")).trim();
300 if (input.toLowerCase() === "exit") break;
301
254 - const result = await run(agent, input, { session: memory });
255 - console.log(`Assistant: ${result.finalOutput}\n`);
256 -}
302 + console.log("Assistant: ");
303
304 + try {
305 + const result = await run(agent, input, { session: memory });
306 + console.log(`${result.finalOutput}`);
307 + } catch (error) {
308 + console.error("\n[Error]:", error instanceof Error ? error.message : error);
309 + }
310 +}
311 readline.close();
312 ```
313 </Tab>
@@ -279,12 +332,12 @@ readline.close();
332 <Tabs groupId="language" items={['Python', 'TypeScript']} persist>
333 <Tab value="Python">
334 ```bash
282 -pip install composio composio-claude-agent-sdk claude-agent-sdk
335 +pip install python-dotenv composio composio-claude-agent-sdk claude-agent-sdk
336 ```
337 </Tab>
338 <Tab value="TypeScript">
339 ```bash
287 -npm install @composio/core @composio/claude-agent-sdk @anthropic-ai/claude-agent-sdk
340 +npm install dotenv @composio/core @composio/claude-agent-sdk @anthropic-ai/claude-agent-sdk
341 ```
342 </Tab>
343 </Tabs>
@@ -294,7 +347,8 @@ npm install @composio/core @composio/claude-agent-sdk @anthropic-ai/claude-agent
347 ### Configure API Keys
348
349 <Callout type="info">
297 -Set `COMPOSIO_API_KEY` from [Settings](https://platform.composio.dev/?next_page=/settings) and `ANTHROPIC_API_KEY` from [Anthropic](https://console.anthropic.com/settings/keys).
350 +- Set `COMPOSIO_API_KEY` from [Settings](https://platform.composio.dev/?next_page=/settings)
351 +- Set `ANTHROPIC_API_KEY` from [Anthropic](https://console.anthropic.com/settings/keys)
352 </Callout>
353
354 ```txt title=".env"
@@ -420,12 +474,12 @@ readline.close();
474 <Tabs groupId="language" items={['Python', 'TypeScript']} persist>
475 <Tab value="Python">
476 ```bash
423 -pip install composio claude-agent-sdk
477 +pip install python-dotenv composio claude-agent-sdk
478 ```
479 </Tab>
480 <Tab value="TypeScript">
481 ```bash
428 -npm install @composio/core @anthropic-ai/claude-agent-sdk
482 +npm install dotenv @composio/core @anthropic-ai/claude-agent-sdk
483 ```
484 </Tab>
485 </Tabs>
@@ -435,7 +489,8 @@ npm install @composio/core @anthropic-ai/claude-agent-sdk
489 ### Configure API Keys
490
491 <Callout type="info">
438 -Set `COMPOSIO_API_KEY` from [Settings](https://platform.composio.dev/?next_page=/settings) and `ANTHROPIC_API_KEY` from [Anthropic](https://console.anthropic.com/settings/keys).
492 +- Set `COMPOSIO_API_KEY` from [Settings](https://platform.composio.dev/?next_page=/settings)
493 +- Set `ANTHROPIC_API_KEY` from [Anthropic](https://console.anthropic.com/settings/keys)
494 </Callout>
495
496 ```txt title=".env"
@@ -453,7 +508,12 @@ ANTHROPIC_API_KEY=your_anthropic_api_key
508 import asyncio
509 from dotenv import load_dotenv
510 from claude_agent_sdk.client import ClaudeSDKClient
456 -from claude_agent_sdk.types import ClaudeAgentOptions, AssistantMessage, TextBlock, ToolUseBlock
511 +from claude_agent_sdk.types import (
512 + ClaudeAgentOptions,
513 + AssistantMessage,
514 + TextBlock,
515 + ToolUseBlock,
516 +)
517 from composio import Composio
518
519 load_dotenv()
@@ -467,7 +527,10 @@ session = composio.create(user_id=user_id)
527
528 # Configure Claude with Composio MCP server
529 options = ClaudeAgentOptions(
470 - system_prompt="You are a helpful assistant. Use tools to complete tasks.",
530 + system_prompt=(
531 + "You are a helpful assistant with access to external tools. "
532 + "Always use the available tools to complete user requests."
533 + ),
534 mcp_servers={
535 "composio": {
536 "type": "http",
@@ -478,25 +541,41 @@ options = ClaudeAgentOptions(
541 permission_mode="bypassPermissions",
542 )
543
544 +
545 async def main():
482 - async with ClaudeSDKClient(options) as client:
483 - print("Assistant ready! Type 'exit' to quit.")
546 + print("""
547 +What task would you like me to help you with?
548 +I can use tools like Gmail, GitHub, Linear, Notion, and more.
549 +(Type 'exit' to exit)
550 +Example tasks:
551 + - 'Summarize my emails from today'
552 + - 'List all open issues on the composio github repository and create a notion page with the issues'
553 +""")
554
555 + async with ClaudeSDKClient(options) as client:
556 + # Multi-turn conversation with agentic tool calling
557 while True:
558 user_input = input("You: ").strip()
559 if user_input.lower() == "exit":
560 break
561
490 - print("Claude: ", end="", flush=True)
491 - await client.query(user_input)
492 - async for msg in client.receive_response():
493 - if isinstance(msg, AssistantMessage):
494 - for block in msg.content:
495 - if isinstance(block, TextBlock):
496 - print(block.text, end="", flush=True)
497 - print()
498 -
499 -asyncio.run(main())
562 + print("\nClaude: ", end="", flush=True)
563 + try:
564 + await client.query(user_input)
565 + async for msg in client.receive_response():
566 + if isinstance(msg, AssistantMessage):
567 + for block in msg.content:
568 + if isinstance(block, ToolUseBlock):
569 + print(f"\n[Using tool: {block.name}]", end="")
570 + elif isinstance(block, TextBlock):
571 + print(block.text, end="", flush=True)
572 + print()
573 + except Exception as e:
574 + print(f"\n[Error]: {e}")
575 +
576 +
577 +if __name__ == "__main__":
578 + asyncio.run(main())
579 ```
580 </Tab>
581 <Tab value="TypeScript">
@@ -514,7 +593,8 @@ const userId = "user_123";
593 const session = await composio.create(userId);
594
595 const options: Options = {
517 - systemPrompt: "You are a helpful assistant. Use tools to complete tasks.",
596 + systemPrompt: `You are a helpful assistant with access to external tools. ` +
597 + `Always use the available tools to complete user requests.`,
598 mcpServers: {
599 composio: {
600 type: "http",
@@ -527,28 +607,46 @@ const options: Options = {
607
608 const readline = createInterface({ input: process.stdin, output: process.stdout });
609
530 -console.log("Assistant ready! Type 'exit' to quit.");
610 +console.log(`
611 +What task would you like me to help you with?
612 +I can use tools like Gmail, GitHub, Linear, Notion, and more.
613 +(Type 'exit' to exit)
614 +Example tasks:
615 + - 'Summarize my emails from today'
616 + - 'List all open issues on the composio github repository and create a Google Sheet with the issues'
617 +`);
618
619 let isFirstQuery = true;
620
621 +// Multi-turn conversation with agentic tool calling
622 while (true) {
535 - const input = (await readline.question("You: ")).trim();
623 + const answer = await readline.question('You: ');
624 + const input = answer.trim();
625 if (input.toLowerCase() === "exit") break;
626
627 process.stdout.write("Claude: ");
628 +
629 + // Use `continue: true` to maintain conversation context
630 const queryOptions = isFirstQuery ? options : { ...options, continue: true };
631 isFirstQuery = false;
632
542 - for await (const stream of query({ prompt: input, options: queryOptions })) {
543 - if (stream.type === "assistant") {
544 - for (const block of stream.message.content) {
545 - if (block.type === "text") {
546 - process.stdout.write(block.text);
633 + try {
634 + for await (const stream of query({ prompt: input, options: queryOptions })) {
635 + if (stream.type === "assistant") {
636 + const { content } = stream.message;
637 + for (const block of content) {
638 + if (block.type === "tool_use") {
639 + process.stdout.write(`\n[Using tool: ${block.name}]`);
640 + } else if (block.type === "text") {
641 + process.stdout.write(block.text);
642 + }
643 }
644 }
645 }
646 + } catch (error) {
647 + console.error("\n[Error]:", error instanceof Error ? error.message : error);
648 }
551 - console.log();
649 + process.stdout.write("\n");
650 }
651
652 readline.close();
@@ -573,7 +671,7 @@ readline.close();
671 ### Install
672
673 ```bash
576 -npm install @composio/core @composio/vercel ai @ai-sdk/openai
674 +npm install @composio/core @composio/vercel ai @ai-sdk/anthropic
675 ```
676 </Step>
677
@@ -581,12 +679,13 @@ npm install @composio/core @composio/vercel ai @ai-sdk/openai
679 ### Configure API Keys
680
681 <Callout type="info">
584 -Set `COMPOSIO_API_KEY` from [Settings](https://platform.composio.dev/?next_page=/settings) and `OPENAI_API_KEY` from [OpenAI](https://platform.openai.com/api-keys).
682 +- Set `COMPOSIO_API_KEY` from [Settings](https://platform.composio.dev/?next_page=/settings)
683 +- Set `ANTHROPIC_API_KEY` from [Anthropic](https://console.anthropic.com/settings/keys)
684 </Callout>
685
686 ```txt title=".env"
687 COMPOSIO_API_KEY=your_composio_api_key
589 -OPENAI_API_KEY=your_openai_api_key
688 +ANTHROPIC_API_KEY=your_anthropic_api_key
689 ```
690 </Step>
691
@@ -595,10 +694,11 @@ OPENAI_API_KEY=your_openai_api_key
694
695 ```typescript
696 import "dotenv/config";
598 -import { openai } from "@ai-sdk/openai";
697 +import { anthropic } from "@ai-sdk/anthropic";
698 import { Composio } from "@composio/core";
699 import { VercelProvider } from "@composio/vercel";
601 -import { stepCountIs, streamText } from "ai";
700 +import { CoreMessage, stepCountIs, streamText } from "ai";
701 +import { createInterface } from "readline/promises";
702
703 // Initialize Composio with Vercel provider
704 const composio = new Composio({ provider: new VercelProvider() });
@@ -608,24 +708,56 @@ const userId = "user_123";
708 const session = await composio.create(userId);
709 const tools = await session.tools();
710
611 -console.log("Summarizing your emails from today...\n");
711 +const readline = createInterface({ input: process.stdin, output: process.stdout });
712 +
713 +console.log(`
714 +What task would you like me to help you with?
715 +I can use tools like Gmail, GitHub, Linear, Notion, and more.
716 +(Type 'exit' to exit)
717 +Example tasks:
718 + - 'Summarize my emails from today'
719 + - 'List all open issues on the composio github repository'
720 +`);
721
613 -const stream = await streamText({
614 - model: openai("gpt-4.1"),
615 - system: "You are a helpful assistant. Use tools to complete tasks.",
616 - prompt: "Summarize my emails from today",
617 - stopWhen: stepCountIs(10),
618 - onStepFinish: (step) => {
619 - for (const toolCall of step.toolCalls) {
620 - console.log(`[Using tool: ${toolCall.toolName}]`);
722 +// Message history for multi-turn conversation
723 +const messages: CoreMessage[] = [];
724 +
725 +while (true) {
726 + const input = (await readline.question("You: ")).trim();
727 + if (input.toLowerCase() === "exit") break;
728 +
729 + messages.push({ role: "user", content: input });
730 + process.stdout.write("Assistant: ");
731 +
732 + try {
733 + const result = await streamText({
734 + system: "You are a helpful personal assistant. Use Composio tools to take action.",
735 + model: anthropic("claude-sonnet-4-5"),
736 + messages,
737 + maxSteps: 10,
738 + onStepFinish: (step) => {
739 + for (const toolCall of step.toolCalls) {
740 + process.stdout.write(`\n[Using tool: ${toolCall.toolName}]`);
741 + }
742 + },
743 + tools,
744 + });
745 +
746 + let assistantResponse = "";
747 + for await (const textPart of result.textStream) {
748 + process.stdout.write(textPart);
749 + assistantResponse += textPart;
750 }
622 - },
623 - tools,
624 -});
751 + console.log();
752
626 -for await (const textPart of stream.textStream) {
627 - process.stdout.write(textPart);
753 + // Add assistant response to history for context
754 + messages.push({ role: "assistant", content: assistantResponse });
755 + } catch (error) {
756 + console.error("\n[Error]:", error instanceof Error ? error.message : error);
757 + }
758 }
759 +
760 +readline.close();
761 ```
762 </Step>
763 </Steps>
@@ -638,7 +770,7 @@ for await (const textPart of stream.textStream) {
770 ### Install
771
772 ```bash
641 -npm install @composio/core ai @ai-sdk/anthropic @ai-sdk/mcp
773 +npm install dotenv @composio/core ai @ai-sdk/anthropic @ai-sdk/mcp
774 ```
775 </Step>
776
@@ -646,7 +778,8 @@ npm install @composio/core ai @ai-sdk/anthropic @ai-sdk/mcp
778 ### Configure API Keys
779
780 <Callout type="info">
649 -Set `COMPOSIO_API_KEY` from [Settings](https://platform.composio.dev/?next_page=/settings) and `ANTHROPIC_API_KEY` from [Anthropic](https://console.anthropic.com/settings/keys).
781 +- Set `COMPOSIO_API_KEY` from [Settings](https://platform.composio.dev/?next_page=/settings)
782 +- Set `ANTHROPIC_API_KEY` from [Anthropic](https://console.anthropic.com/settings/keys)
783 </Callout>
784
785 ```txt title=".env"
@@ -663,7 +796,8 @@ import "dotenv/config";
796 import { anthropic } from "@ai-sdk/anthropic";
797 import { experimental_createMCPClient as createMCPClient } from "@ai-sdk/mcp";
798 import { Composio } from "@composio/core";
666 -import { stepCountIs, streamText } from "ai";
799 +import { CoreMessage, stepCountIs, streamText } from "ai";
800 +import { createInterface } from "readline/promises";
801
802 // Initialize Composio
803 const composio = new Composio();
@@ -682,26 +816,56 @@ const client = await createMCPClient({
816 });
817 const tools = await client.tools();
818
685 -console.log("Summarizing your emails from today...\n");
819 +const readline = createInterface({ input: process.stdin, output: process.stdout });
820 +
821 +console.log(`
822 +What task would you like me to help you with?
823 +I can use tools like Gmail, GitHub, Linear, Notion, and more.
824 +(Type 'exit' to exit)
825 +Example tasks:
826 + - 'Summarize my emails from today'
827 + - 'List all open issues on the composio github repository'
828 +`);
829
687 -const stream = await streamText({
688 - model: anthropic("claude-sonnet-4-5"),
689 - system: "You are a helpful assistant. Use tools to complete tasks.",
690 - prompt: "Summarize my emails from today",
691 - stopWhen: stepCountIs(10),
692 - onStepFinish: (step) => {
693 - for (const toolCall of step.toolCalls) {
694 - console.log(`[Using tool: ${toolCall.toolName}]`);
830 +// Message history for multi-turn conversation
831 +const messages: CoreMessage[] = [];
832 +
833 +while (true) {
834 + const input = (await readline.question("You: ")).trim();
835 + if (input.toLowerCase() === "exit") break;
836 +
837 + messages.push({ role: "user", content: input });
838 + process.stdout.write("Assistant: ");
839 +
840 + try {
841 + const result = await streamText({
842 + system: "You are a helpful personal assistant. Use Composio tools to take action.",
843 + model: anthropic("claude-sonnet-4-5"),
844 + messages,
845 + maxSteps: 10,
846 + onStepFinish: (step) => {
847 + for (const toolCall of step.toolCalls) {
848 + process.stdout.write(`\n[Using tool: ${toolCall.toolName}]`);
849 + }
850 + },
851 + tools,
852 + });
853 +
854 + let assistantResponse = "";
855 + for await (const textPart of result.textStream) {
856 + process.stdout.write(textPart);
857 + assistantResponse += textPart;
858 }
696 - },
697 - tools,
698 -});
859 + console.log();
860
700 -for await (const textPart of stream.textStream) {
701 - process.stdout.write(textPart);
861 + // Add assistant response to history for context
862 + messages.push({ role: "assistant", content: assistantResponse });
863 + } catch (error) {
864 + console.error("\n[Error]:", error instanceof Error ? error.message : error);
865 + }
866 }
867
704 -console.log("\n\nTip: If prompted to authenticate, complete the auth flow and run again.");
868 +readline.close();
869 ```
870 </Step>
871 </Steps>
@@ -716,14 +880,16 @@ console.log("\n\nTip: If prompted to authenticate, complete the auth flow and ru
880 ## Next steps
881
882 <Cards>
719 - <Card
720 - title="Session management"
721 - href="/docs/users-and-sessions"
722 - description="Learn about users, sessions, and how they work."
723 - />
724 - <Card
725 - title="Tools and toolkits"
726 - href="/docs/tools-and-toolkits"
727 - description="Learn about tools, toolkits, and how to configure them."
728 - />
883 + <Card title="Session management" href="/docs/users-and-sessions">
884 + Learn about users, sessions, and how they work.
885 + </Card>
886 + <Card title="Tools and toolkits" href="/docs/tools-and-toolkits">
887 + Learn about tools, toolkits, and how to configure them.
888 + </Card>
889 + <Card title="Manual authentication" href="/docs/authenticating-users/manually-authenticating">
890 + Customise the authentication flow for your users.
891 + </Card>
892 + <Card title="Using MCP" href="/docs/mcp">
893 + Connect Tool Router to any MCP-compatible client.
894 + </Card>
895 </Cards>