@devries-cameron20 / composio Mirror · read-only / commits / 52a64a6a6
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, 18:15 UTC

add back code to concpets

Sushmithamallesh committed Dec 8, 2025 at 20:31 UTC 52a64a6a6aaab92d423019fc87e9ab8e917769a6
11 files changed +1134 -316
fern/docs.yml
+6 -6
@@ -125,6 +125,9 @@ navigation:
125 - page: Quickstart
126 path: pages/dist/get-started/quickstart.mdx
127 slug: quickstart
128 + - page: Quickstart Preview
129 + path: pages/dist/get-started/quickstart-preview.mdx
130 + slug: quickstart-preview
131 - page: IDE and Agent Setup
132 path: pages/dist/get-started/dev-setup.mdx
133 slug: dev-setup
@@ -305,9 +308,6 @@ navigation:
308 icon: fa-light fa-book
309 skip-slug: true
310 contents:
308 - - page: Session Configuration
309 - path: pages/dist/tool-router/creating-sessions.mdx
310 - slug: creating-sessions
311 - page: Using In-chat Authentication
312 path: pages/dist/tool-router/using-in-chat-authentication.mdx
313 slug: using-in-chat-authentication
@@ -326,9 +326,9 @@ navigation:
326 - page: Using with MCP Clients
327 path: pages/dist/tool-router/using-with-mcp-clients.mdx
328 slug: using-with-mcp-clients
329 - - page: Using as Native Tools
330 - path: pages/dist/tool-router/using-as-native-tools.mdx
331 - slug: using-as-native-tools
329 + # - page: Using as Native Tools
330 + # path: pages/dist/tool-router/using-as-native-tools.mdx
331 + # slug: using-as-native-tools
332 - page: Handling Files
333 path: pages/dist/tool-router/file-upload-download.mdx
334 slug: file-upload-download
fern/pages/src/get-started/quickstart-preview.mdx new
+958
@@ -0,0 +1,958 @@
1 +---
2 +title: Quickstart
3 +subtitle: Connect AI agents to 500+ tools in under 5 minutes
4 +description: "Build production-ready AI agents with real-world tool access using Composio's powerful integration platform"
5 +---
6 +
7 +
8 +## Prerequisites
9 +
10 +Before you begin, ensure you have:
11 +- **Composio account**: [Sign up free](https://platform.composio.dev) (no credit card required)
12 +- **API key**: Get it from [your dashboard](https://platform.composio.dev?next_page=/settings)
13 +- **Development environment**: Python 3.10+ or Node.js 18+
14 +- **AI provider API key**: OpenAI, Anthropic, or other supported provider
15 +
16 +
17 +## Execute your first tool
18 +
19 +Composio offers three ways to connect AI agents to tools:
20 +
21 +<Tabs>
22 +<Tab title="Tool Router">
23 +Single MCP server and Tool that can search, authenticate, and execute across all Composio tools.
24 +
25 +<Steps>
26 +<Step title="Install SDK">
27 +<CodeGroup>
28 +```bash Python
29 +pip install composio
30 +```
31 +```bash TypeScript
32 +npm install @composio/core
33 +```
34 +</CodeGroup>
35 +</Step>
36 +
37 +<Step title="Create a session">
38 +Initialize Tool Router with your toolkits:
39 +
40 +<CodeGroup>
41 +```python Python
42 +from composio import Composio
43 +
44 +composio = Composio()
45 +
46 +session = composio.tool_router.create(
47 + user_id='user-123',
48 + toolkits=['gmail', 'calendar', 'slack', 'notion']
49 +)
50 +
51 +print(f'Session created: {session.id}')
52 +```
53 +```typescript TypeScript
54 +import { Composio } from '@composio/core';
55 +
56 +const composio = new Composio();
57 +
58 +const session = await composio.toolRouter.create({
59 + userId: 'user-123',
60 + toolkits: ['gmail', 'calendar', 'slack', 'notion']
61 +});
62 +
63 +console.log('Session created:', session.id);
64 +```
65 +</CodeGroup>
66 +</Step>
67 +
68 +<Step title="Get tools and execute">
69 +Use the session to get tools for any AI framework:
70 +
71 +<CodeGroup>
72 +```python Python
73 +from openai import OpenAI
74 +
75 +client = OpenAI()
76 +
77 +tools = session.get_tools()
78 +
79 +response = client.chat.completions.create(
80 + model="gpt-4",
81 + messages=[{
82 + "role": "user",
83 + "content": "Send an email to john@example.com about the meeting"
84 + }],
85 + tools=tools,
86 + tool_choice="auto"
87 +)
88 +
89 +result = session.handle_tool_call(response)
90 +print(f"Result: {result}")
91 +```
92 +```typescript TypeScript
93 +import OpenAI from 'openai';
94 +
95 +const client = new OpenAI();
96 +
97 +const tools = await session.getTools();
98 +
99 +const response = await client.chat.completions.create({
100 + model: 'gpt-4',
101 + messages: [{
102 + role: 'user',
103 + content: 'Send an email to john@example.com about the meeting'
104 + }],
105 + tools: tools,
106 + tool_choice: 'auto'
107 +});
108 +
109 +const result = await session.handleToolCall(response);
110 +console.log('Result:', result);
111 +```
112 +</CodeGroup>
113 +</Step>
114 +</Steps>
115 +
116 +<CardGroup cols={2}>
117 +<Card title="Tool Router Overview" icon="fa-light fa-sparkles" href="/tool-router/overview">
118 +Learn about Tool Router capabilities
119 +</Card>
120 +<Card title="Tool Router Quickstart" icon="fa-light fa-rocket" href="/tool-router/quickstart">
121 +Complete quickstart guide
122 +</Card>
123 +</CardGroup>
124 +
125 +</Tab>
126 +
127 +<Tab title="Composio Tools">
128 +Use Composio SDK to integrate tools directly with your favorite AI frameworks.
129 +
130 +<Tabs>
131 +<Tab title="OpenAI">
132 +<Steps>
133 +<Step title="Install Composio SDK and Authenticate your Users">
134 +Install the toolkit to get started
135 +
136 +<CodeGroup>
137 +```bash Python
138 +pip install composio composio-openai
139 +```
140 +```bash TypeScript
141 +npm install @composio/core @composio/openai
142 +```
143 +</CodeGroup>
144 +
145 +**Create an Auth Config for Gmail**
146 +
147 +Auth Configs help you define how users should be authenticated.
148 +
149 +<CodeGroup>
150 +```python Python
151 +from composio import Composio
152 +
153 +composio = Composio()
154 +
155 +# Create auth config for Gmail
156 +auth_config = composio.auth_configs.create(
157 + toolkit="gmail",
158 + config={
159 + "client_id": "your_gmail_client_id",
160 + "client_secret": "your_gmail_client_secret",
161 + "scopes": ["https://www.googleapis.com/auth/gmail.send"]
162 + }
163 +)
164 +
165 +print(f"Auth Config ID: {auth_config.id}")
166 +```
167 +```typescript TypeScript
168 +import { Composio } from '@composio/core';
169 +
170 +const composio = new Composio();
171 +
172 +// Create auth config for Gmail
173 +const authConfig = await composio.authConfigs.create({
174 + toolkit: 'gmail',
175 + config: {
176 + clientId: 'your_gmail_client_id',
177 + clientSecret: 'your_gmail_client_secret',
178 + scopes: ['https://www.googleapis.com/auth/gmail.send']
179 + }
180 +});
181 +
182 +console.log(`Auth Config ID: ${authConfig.id}`);
183 +```
184 +</CodeGroup>
185 +
186 +**Connect your users via the auth config**
187 +
188 +Use composio auth links to let your users authenticate their accounts.
189 +
190 +<CodeGroup>
191 +```python Python
192 +# Generate connection request for a user
193 +connection_request = composio.connected_accounts.link(
194 + user_id="user-123",
195 + auth_config_id=auth_config.id
196 +)
197 +
198 +# Redirect user to this URL for authentication
199 +print(f"Please authorize at: {connection_request.redirect_url}")
200 +
201 +# Wait for connection to be established
202 +connection = connection_request.wait_for_connection()
203 +print(f"Connected: {connection.id}")
204 +```
205 +```typescript TypeScript
206 +// Generate connection request for a user
207 +const connectionRequest = await composio.connectedAccounts.link({
208 + userId: 'user-123',
209 + authConfigId: authConfig.id
210 +});
211 +
212 +// Redirect user to this URL for authentication
213 +console.log(`Please authorize at: ${connectionRequest.redirectUrl}`);
214 +
215 +// Wait for connection to be established
216 +const connection = await connectionRequest.waitForConnection();
217 +console.log(`Connected: ${connection.id}`);
218 +```
219 +</CodeGroup>
220 +</Step>
221 +
222 +<Step title="Fetch tools and execute">
223 +Get the tool your agent needs from composio and execute it.
224 +
225 +<CodeGroup>
226 +```python Python
227 +from composio_openai import ComposioToolSet
228 +import openai
229 +
230 +# Initialize
231 +openai_client = openai.Client()
232 +toolset = ComposioToolSet()
233 +
234 +# Fetch tools for the user
235 +tools = toolset.get_tools(
236 + actions=["GMAIL_SEND_EMAIL"],
237 + entity_id="user-123"
238 +)
239 +
240 +# Use with OpenAI
241 +response = openai_client.chat.completions.create(
242 + model="gpt-4",
243 + messages=[{
244 + "role": "user",
245 + "content": "Send an email to john@example.com saying 'Meeting confirmed for 3pm tomorrow'"
246 + }],
247 + tools=tools,
248 + tool_choice="auto"
249 +)
250 +
251 +# Execute the tool call
252 +result = toolset.handle_tool_call(response, entity_id="user-123")
253 +print(f"Email sent successfully: {result}")
254 +```
255 +```typescript TypeScript
256 +import { OpenAIToolSet } from '@composio/openai';
257 +import OpenAI from 'openai';
258 +
259 +// Initialize
260 +const openai = new OpenAI();
261 +const toolset = new OpenAIToolSet({
262 + apiKey: process.env.COMPOSIO_API_KEY
263 +});
264 +
265 +// Fetch tools for the user
266 +const tools = await toolset.getTools({
267 + actions: ['GMAIL_SEND_EMAIL'],
268 + entityId: 'user-123'
269 +});
270 +
271 +// Use with OpenAI
272 +const response = await openai.chat.completions.create({
273 + model: 'gpt-4',
274 + messages: [{
275 + role: 'user',
276 + content: "Send an email to john@example.com saying 'Meeting confirmed for 3pm tomorrow'"
277 + }],
278 + tools: tools,
279 + tool_choice: 'auto'
280 +});
281 +
282 +// Execute the tool call
283 +const result = await toolset.handleToolCall(response, {
284 + entityId: 'user-123'
285 +});
286 +console.log('Email sent successfully:', result);
287 +```
288 +</CodeGroup>
289 +</Step>
290 +
291 +<Step title="Create triggers and listen to events">
292 +Setup triggers to run agents when specific events occur.
293 +
294 +<CodeGroup>
295 +```python Python
296 +# Create a trigger for new Gmail messages
297 +trigger = composio.triggers.create(
298 + user_id="user-123",
299 + toolkit="gmail",
300 + trigger_name="GMAIL_NEW_MESSAGE",
301 + config={
302 + "label_ids": ["INBOX"],
303 + "poll_interval": 60 # Check every 60 seconds
304 + }
305 +)
306 +
307 +print(f"Trigger created: {trigger.id}")
308 +
309 +# Subscribe to trigger events
310 +@composio.triggers.on("GMAIL_NEW_MESSAGE")
311 +def handle_new_email(event):
312 + print(f"New email from: {event['from']}")
313 + print(f"Subject: {event['subject']}")
314 +
315 + # Process with AI
316 + response = openai_client.chat.completions.create(
317 + model="gpt-4",
318 + messages=[{
319 + "role": "user",
320 + "content": f"Summarize this email: {event['body']}"
321 + }]
322 + )
323 +
324 + print(f"Summary: {response.choices[0].message.content}")
325 +
326 +# Start listening for events
327 +composio.triggers.start_listening()
328 +```
329 +```typescript TypeScript
330 +// Create a trigger for new Gmail messages
331 +const trigger = await composio.triggers.create({
332 + userId: 'user-123',
333 + toolkit: 'gmail',
334 + triggerName: 'GMAIL_NEW_MESSAGE',
335 + config: {
336 + labelIds: ['INBOX'],
337 + pollInterval: 60 // Check every 60 seconds
338 + }
339 +});
340 +
341 +console.log(`Trigger created: ${trigger.id}`);
342 +
343 +// Subscribe to trigger events
344 +composio.triggers.subscribe('GMAIL_NEW_MESSAGE', async (event) => {
345 + console.log(`New email from: ${event.from}`);
346 + console.log(`Subject: ${event.subject}`);
347 +
348 + // Process with AI
349 + const response = await openai.chat.completions.create({
350 + model: 'gpt-4',
351 + messages: [{
352 + role: 'user',
353 + content: `Summarize this email: ${event.body}`
354 + }]
355 + });
356 +
357 + console.log(`Summary: ${response.choices[0].message.content}`);
358 +});
359 +
360 +// Start listening for events
361 +await composio.triggers.startListening();
362 +```
363 +</CodeGroup>
364 +
365 +<Note>
366 +For production use, consider using webhooks instead of polling for better performance. See [Triggers documentation](/docs/using-triggers) for more details.
367 +</Note>
368 +</Step>
369 +</Steps>
370 +</Tab>
371 +
372 +<Tab title="Anthropic">
373 +<Steps>
374 +<Step title="Install SDK">
375 +<CodeGroup>
376 +```bash Python
377 +pip install composio composio-anthropic
378 +```
379 +```bash TypeScript
380 +npm install @composio/core @composio/anthropic
381 +```
382 +</CodeGroup>
383 +</Step>
384 +
385 +<Step title="Initialize and authenticate">
386 +<CodeGroup>
387 +```python Python
388 +from composio import Composio
389 +from composio_anthropic import ComposioToolSet
390 +import anthropic
391 +
392 +# Initialize
393 +composio = Composio()
394 +client = anthropic.Anthropic()
395 +toolset = ComposioToolSet()
396 +
397 +# Create auth config for Slack
398 +auth_config = composio.auth_configs.create(
399 + toolkit="slack",
400 + config={"client_id": "your_id", "client_secret": "your_secret"}
401 +)
402 +
403 +# Connect user account
404 +connection = composio.connected_accounts.link(
405 + user_id="user-123",
406 + auth_config_id=auth_config.id
407 +)
408 +print(f"Authorize at: {connection.redirect_url}")
409 +```
410 +```typescript TypeScript
411 +import { Composio } from '@composio/core';
412 +import { AnthropicToolSet } from '@composio/anthropic';
413 +import Anthropic from '@anthropic-ai/sdk';
414 +
415 +// Initialize
416 +const composio = new Composio();
417 +const client = new Anthropic();
418 +const toolset = new AnthropicToolSet({ composio });
419 +
420 +// Create auth config for Slack
421 +const authConfig = await composio.authConfigs.create({
422 + toolkit: 'slack',
423 + config: { clientId: 'your_id', clientSecret: 'your_secret' }
424 +});
425 +
426 +// Connect user account
427 +const connection = await composio.connectedAccounts.link({
428 + userId: 'user-123',
429 + authConfigId: authConfig.id
430 +});
431 +console.log(`Authorize at: ${connection.redirectUrl}`);
432 +```
433 +</CodeGroup>
434 +</Step>
435 +
436 +<Step title="Execute tools">
437 +<CodeGroup>
438 +```python Python
439 +# Get tools for the user
440 +tools = toolset.get_tools(actions=["SLACK_SEND_MESSAGE"])
441 +
442 +# Use with Claude
443 +response = client.messages.create(
444 + model="claude-3-sonnet-20240229",
445 + max_tokens=1024,
446 + messages=[
447 + {"role": "user", "content": "Send a message to #general channel about the standup"}
448 + ],
449 + tools=tools
450 +)
451 +
452 +# Execute the tool call
453 +result = toolset.handle_tool_call(response, entity_id="user-123")
454 +print(f"Message sent: {result}")
455 +```
456 +```typescript TypeScript
457 +// Get tools for the user
458 +const tools = await toolset.getTools({ actions: ['SLACK_SEND_MESSAGE'] });
459 +
460 +// Use with Claude
461 +const response = await client.messages.create({
462 + model: 'claude-3-sonnet-20240229',
463 + max_tokens: 1024,
464 + messages: [
465 + { role: 'user', content: 'Send a message to #general channel about the standup' }
466 + ],
467 + tools: tools
468 +});
469 +
470 +// Execute the tool call
471 +const result = await toolset.handleToolCall(response, { entityId: 'user-123' });
472 +console.log('Message sent:', result);
473 +```
474 +</CodeGroup>
475 +</Step>
476 +</Steps>
477 +</Tab>
478 +
479 +<Tab title="LangChain">
480 +<Steps>
481 +<Step title="Install SDK">
482 +```bash
483 +pip install composio-langchain langchain langchain-openai
484 +```
485 +</Step>
486 +
487 +<Step title="Initialize and authenticate">
488 +```python
489 +from composio_langchain import ComposioToolSet
490 +from langchain.agents import create_openai_functions_agent
491 +from langchain_openai import ChatOpenAI
492 +from langchain.prompts import ChatPromptTemplate
493 +
494 +# Initialize
495 +toolset = ComposioToolSet()
496 +llm = ChatOpenAI(model="gpt-4")
497 +
498 +# Create auth config for GitHub
499 +auth_config = toolset.client.auth_configs.create(
500 + toolkit="github",
501 + config={"client_id": "your_id", "client_secret": "your_secret"}
502 +)
503 +
504 +# Connect user account
505 +connection = toolset.client.connected_accounts.link(
506 + user_id="user-123",
507 + auth_config_id=auth_config.id
508 +)
509 +print(f"Authorize at: {connection.redirect_url}")
510 +```
511 +</Step>
512 +
513 +<Step title="Execute tools">
514 +```python
515 +# Get tools for the user
516 +tools = toolset.get_tools(actions=["GITHUB_CREATE_ISSUE"])
517 +
518 +# Create agent
519 +prompt = ChatPromptTemplate.from_messages([
520 + ("system", "You are a helpful assistant that can interact with GitHub."),
521 + ("human", "{input}"),
522 + ("placeholder", "{agent_scratchpad}")
523 +])
524 +
525 +agent = create_openai_functions_agent(llm, tools, prompt)
526 +from langchain.agents import AgentExecutor
527 +agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
528 +
529 +# Execute
530 +result = agent_executor.invoke({
531 + "input": "Create a new issue in the main repo about the bug we found"
532 +}, config={"metadata": {"entity_id": "user-123"}})
533 +
534 +print(f"Issue created: {result['output']}")
535 +```
536 +</Step>
537 +</Steps>
538 +</Tab>
539 +
540 +<Tab title="Vercel AI SDK">
541 +<Steps>
542 +<Step title="Install SDK">
543 +```bash
544 +npm install @composio/vercel ai
545 +```
546 +</Step>
547 +
548 +<Step title="Initialize and authenticate">
549 +```typescript
550 +import { Composio } from '@composio/core';
551 +import { VercelAIToolSet } from '@composio/vercel';
552 +import { openai } from '@ai-sdk/openai';
553 +
554 +// Initialize
555 +const composio = new Composio();
556 +const toolset = new VercelAIToolSet({ composio });
557 +
558 +// Create auth config for Notion
559 +const authConfig = await composio.authConfigs.create({
560 + toolkit: 'notion',
561 + config: { clientId: 'your_id', clientSecret: 'your_secret' }
562 +});
563 +
564 +// Connect user account
565 +const connection = await composio.connectedAccounts.link({
566 + userId: 'user-123',
567 + authConfigId: authConfig.id
568 +});
569 +console.log(`Authorize at: ${connection.redirectUrl}`);
570 +```
571 +</Step>
572 +
573 +<Step title="Execute tools">
574 +```typescript
575 +import { generateText } from 'ai';
576 +
577 +// Get tools for the user
578 +const tools = await toolset.getTools({
579 + actions: ['NOTION_CREATE_PAGE'],
580 + entityId: 'user-123'
581 +});
582 +
583 +// Use with Vercel AI SDK
584 +const { text } = await generateText({
585 + model: openai('gpt-4'),
586 + prompt: 'Create a new Notion page for the Q4 planning',
587 + tools: tools,
588 +});
589 +
590 +console.log('Page created:', text);
591 +```
592 +</Step>
593 +</Steps>
594 +</Tab>
595 +</Tabs>
596 +
597 +<AccordionGroup>
598 +<Accordion title="Supported frameworks">
599 +- OpenAI (GPT-4, GPT-3.5)
600 +- Anthropic (Claude 3.5)
601 +- Google (Gemini)
602 +- Vercel AI SDK
603 +- LangChain
604 +- LlamaIndex
605 +- CrewAI
606 +- Autogen
607 +</Accordion>
608 +
609 +<Accordion title="Advanced features">
610 +- Custom tool creation
611 +- Response modifiers
612 +- Error handling
613 +- Rate limiting
614 +- Webhook triggers
615 +</Accordion>
616 +</AccordionGroup>
617 +
618 +</Tab>
619 +
620 +<Tab title="MCP Server">
621 +Use Model Context Protocol to connect tools with any MCP-compatible AI client.
622 +
623 +<Tabs>
624 +<Tab title="Anthropic">
625 +<Steps>
626 +<Step title="Install SDK and create MCP server">
627 +<CodeGroup>
628 +```bash Python
629 +pip install composio anthropic
630 +```
631 +```bash TypeScript
632 +npm install @composio/core @anthropic-ai/sdk
633 +```
634 +</CodeGroup>
635 +
636 +Set up MCP server with your tools:
637 +
638 +<CodeGroup>
639 +```python Python
640 +from composio import Composio
641 +from anthropic import Anthropic
642 +
643 +# Initialize clients
644 +composio = Composio()
645 +anthropic = Anthropic()
646 +
647 +# Create MCP server config
648 +mcp_config = composio.mcp.create(
649 + name="dev-workflow-server",
650 + toolkits=[
651 + {"toolkit": "github", "auth_config": "ac_github_123"},
652 + {"toolkit": "linear", "auth_config": "ac_linear_456"}
653 + ],
654 + allowed_tools=["GITHUB_LIST_PRS", "GITHUB_CREATE_COMMENT", "LINEAR_CREATE_ISSUE"]
655 +)
656 +
657 +print(f"MCP Config created: {mcp_config.id}")
658 +```
659 +```typescript TypeScript
660 +import { Composio } from '@composio/core';
661 +import Anthropic from '@anthropic-ai/sdk';
662 +
663 +// Initialize clients
664 +const composio = new Composio();
665 +const anthropic = new Anthropic();
666 +
667 +// Create MCP server config
668 +const mcpConfig = await composio.mcp.create({
669 + name: 'dev-workflow-server',
670 + toolkits: [
671 + { toolkit: 'github', authConfig: 'ac_github_123' },
672 + { toolkit: 'linear', authConfig: 'ac_linear_456' }
673 + ],
674 + allowedTools: ['GITHUB_LIST_PRS', 'GITHUB_CREATE_COMMENT', 'LINEAR_CREATE_ISSUE']
675 +});
676 +
677 +console.log(`MCP Config created: ${mcpConfig.id}`);
678 +```
679 +</CodeGroup>
680 +</Step>
681 +
682 +<Step title="Generate user URL and use with Anthropic">
683 +Get user-specific URL and connect to Claude:
684 +
685 +<CodeGroup>
686 +```python Python
687 +# Generate MCP instance for user
688 +instance = mcp_config.generate("user-123")
689 +
690 +# Use MCP with Anthropic to manage development workflow
691 +response = anthropic.beta.messages.create(
692 + model="claude-3-5-sonnet-20241022",
693 + system="You are a helpful assistant with access to GitHub and Linear tools.",
694 + max_tokens=1000,
695 + messages=[{
696 + "role": "user",
697 + "content": "Check my GitHub PRs for review comments and create Linear tasks for any requested changes"
698 + }],
699 + mcp_servers=[{
700 + "type": "url",
701 + "url": instance['url'],
702 + "name": "composio-mcp-server"
703 + }],
704 + betas=["mcp-client-2025-04-04"] # Enable MCP beta
705 +)
706 +
707 +print(response.content)
708 +```
709 +```typescript TypeScript
710 +// Generate MCP instance for user
711 +const instance = await mcpConfig.generate('user-123');
712 +
713 +// Use MCP with Anthropic to manage development workflow
714 +const response = await anthropic.beta.messages.create({
715 + model: 'claude-3-5-sonnet-20241022',
716 + system: 'You are a helpful assistant with access to GitHub and Linear tools.',
717 + maxTokens: 1000,
718 + messages: [{
719 + role: 'user',
720 + content: 'Check my GitHub PRs for review comments and create Linear tasks for any requested changes'
721 + }],
722 + mcpServers: [{
723 + type: 'url',
724 + url: instance.url,
725 + name: 'composio-mcp-server'
726 + }],
727 + betas: ['mcp-client-2025-04-04'] // Enable MCP beta
728 +});
729 +
730 +console.log(response.content);
731 +```
732 +</CodeGroup>
733 +</Step>
734 +</Steps>
735 +</Tab>
736 +
737 +<Tab title="OpenAI">
738 +<Steps>
739 +<Step title="Install SDK and create MCP server">
740 +<CodeGroup>
741 +```bash Python
742 +pip install composio openai
743 +```
744 +```bash TypeScript
745 +npm install @composio/core openai
746 +```
747 +</CodeGroup>
748 +
749 +Set up MCP server with your tools:
750 +
751 +<CodeGroup>
752 +```python Python
753 +from composio import Composio
754 +from openai import OpenAI
755 +
756 +# Initialize clients
757 +composio = Composio()
758 +openai = OpenAI()
759 +
760 +# Create MCP server config
761 +mcp_config = composio.mcp.create(
762 + name="data-docs-server",
763 + toolkits=[
764 + {"toolkit": "googlesheets", "auth_config": "ac_sheets_123"},
765 + {"toolkit": "notion", "auth_config": "ac_notion_456"}
766 + ],
767 + allowed_tools=["GOOGLESHEETS_GET_DATA", "GOOGLESHEETS_UPDATE_DATA", "NOTION_CREATE_PAGE"]
768 +)
769 +
770 +print(f"MCP Config created: {mcp_config.id}")
771 +```
772 +```typescript TypeScript
773 +import { Composio } from '@composio/core';
774 +import OpenAI from 'openai';
775 +
776 +// Initialize clients
777 +const composio = new Composio();
778 +const openai = new OpenAI();
779 +
780 +// Create MCP server config
781 +const mcpConfig = await composio.mcp.create({
782 + name: 'data-docs-server',
783 + toolkits: [
784 + { toolkit: 'googlesheets', authConfig: 'ac_sheets_123' },
785 + { toolkit: 'notion', authConfig: 'ac_notion_456' }
786 + ],
787 + allowedTools: ['GOOGLESHEETS_GET_DATA', 'GOOGLESHEETS_UPDATE_DATA', 'NOTION_CREATE_PAGE']
788 +});
789 +
790 +console.log(`MCP Config created: ${mcpConfig.id}`);
791 +```
792 +</CodeGroup>
793 +</Step>
794 +
795 +<Step title="Generate user URL and use with OpenAI">
796 +Get user-specific URL and use with GPT:
797 +
798 +<CodeGroup>
799 +```python Python
800 +# Generate MCP instance for user
801 +instance = mcp_config.generate("user-123")
802 +
803 +# Use MCP with OpenAI for data management
804 +response = openai.responses.create(
805 + model="gpt-4",
806 + tools=[{
807 + "type": "mcp",
808 + "server_label": "composio-server",
809 + "server_description": "Composio MCP server with Google Sheets and Notion integrations",
810 + "server_url": instance['url'],
811 + "require_approval": "never",
812 + }],
813 + input="Export the Q4 metrics from Google Sheets and create a comprehensive Notion page with analysis"
814 +)
815 +
816 +print("Response:", response.output_text)
817 +```
818 +```typescript TypeScript
819 +// Generate MCP instance for user
820 +const instance = await mcpConfig.generate('user-123');
821 +
822 +// Use MCP with OpenAI for data management
823 +const response = await openai.responses.create({
824 + model: 'gpt-4',
825 + tools: [{
826 + type: 'mcp',
827 + serverLabel: 'composio-server',
828 + serverDescription: 'Composio MCP server with Google Sheets and Notion integrations',
829 + serverUrl: instance.url,
830 + requireApproval: 'never'
831 + }],
832 + input: 'Export the Q4 metrics from Google Sheets and create a comprehensive Notion page with analysis'
833 +});
834 +
835 +console.log('Response:', response.outputText);
836 +```
837 +</CodeGroup>
838 +</Step>
839 +</Steps>
840 +</Tab>
841 +
842 +<Tab title="Mastra">
843 +<Steps>
844 +<Step title="Install SDK and create MCP server">
845 +```bash
846 +npm install @composio/core @mastra/core
847 +```
848 +
849 +Set up MCP server with your tools:
850 +
851 +```typescript
852 +import { Composio } from '@composio/core';
853 +import { Mastra } from '@mastra/core';
854 +
855 +// Initialize clients
856 +const composio = new Composio();
857 +
858 +// Create MCP server config
859 +const mcpConfig = await composio.mcp.create({
860 + name: 'automation-server',
861 + toolkits: [
862 + { toolkit: 'slack', authConfig: 'ac_slack_123' },
863 + { toolkit: 'jira', authConfig: 'ac_jira_456' }
864 + ]
865 +});
866 +
867 +console.log(`MCP Config created: ${mcpConfig.id}`);
868 +```
869 +</Step>
870 +
871 +<Step title="Use with Mastra framework">
872 +```typescript
873 +// Generate MCP instance for user
874 +const instance = await mcpConfig.generate('user-123');
875 +
876 +// Configure Mastra with MCP
877 +const mastra = new Mastra({
878 + mcp: {
879 + servers: [{
880 + name: 'composio-mcp',
881 + url: instance.url
882 + }]
883 + }
884 +});
885 +
886 +// Use in Mastra workflow
887 +const workflow = mastra.createWorkflow({
888 + id: 'issue-tracker',
889 + execute: async (context) => {
890 + const tools = await context.mcp.getTools('composio-mcp');
891 +
892 + // Use Slack and Jira tools
893 + const result = await tools.execute('SLACK_SEND_MESSAGE', {
894 + channel: '#dev-team',
895 + text: 'New Jira ticket created'
896 + });
897 +
898 + return result;
899 + }
900 +});
901 +
902 +await workflow.run();
903 +```
904 +</Step>
905 +</Steps>
906 +</Tab>
907 +</Tabs>
908 +
909 +</Tab>
910 +</Tabs>
911 +
912 +## Real-world examples
913 +
914 +See Composio in action with these practical examples:
915 +
916 +<CardGroup cols={3}>
917 +<Card title="AI Research Assistant" icon="magnifying-glass">
918 +Perplexity + Notion + Gmail
919 +
920 +Researches topics and organizes findings
921 +</Card>
922 +
923 +<Card title="DevOps Agent" icon="code-branch">
924 +GitHub + Slack + PagerDuty
925 +
926 +Manages deployments and incidents
927 +</Card>
928 +
929 +<Card title="Sales Automation" icon="chart-line">
930 +Salesforce + Calendar + Email
931 +
932 +Automates CRM and follow-ups
933 +</Card>
934 +</CardGroup>
935 +
936 +## Next steps
937 +
938 +<CardGroup cols={2}>
939 +<Card title="Explore providers" icon="plug" href="/providers">
940 +Deep dive into framework-specific integrations
941 +</Card>
942 +
943 +<Card title="Browse tools" icon="toolbox" href="/tools">
944 +Discover all 500+ available integrations
945 +</Card>
946 +
947 +<Card title="Authentication guide" icon="key" href="/docs/authenticating-tools">
948 +Master user authentication flows
949 +</Card>
950 +
951 +<Card title="Build custom tools" icon="hammer" href="/docs/custom-tools">
952 +Create your own tool integrations
953 +</Card>
954 +</CardGroup>
955 +
956 +<Tip>
957 +**Need help?** Join our [Discord community](https://discord.com/invite/composio)
958 +</Tip>
\ No newline at end of file
fern/pages/src/tool-router/configuring-custom-auth-configs.mdx
+2 -2
@@ -33,14 +33,14 @@ Pass your auth config ID when creating a session:
33 <CodeGroup>
34 ```python
35 session = composio.create(
36 - user_id="pg-user-550e8400-e29b-41d4",
36 + user_id="user_123",
37 auth_configs={
38 "posthog": "ac_your_posthog_config"
39 }
40 )
41 ```
42 ```typescript
43 -const session = await composio.create("pg-user-550e8400-e29b-41d4", {
43 +const session = await composio.create("user_123", {
44 authConfigs: {
45 posthog: "ac_your_posthog_config",
46 },
fern/pages/src/tool-router/creating-sessions.mdx deleted
-266
@@ -1,266 +0,0 @@
1 ----
2 -title: Session configuration
3 -image: "https://og.composio.dev/api/og?title=Session%20Configuration"
4 -description: "Configure toolkits, authentication, and connections for a session"
5 -keywords: "sessions, create session, tool router, configuration, configuring toolkits"
6 -hide-nav-links: false
7 ----
8 -
9 -Sessions are ephemeral, user-scoped containers that manage which tools are available and how authentication works.
10 -
11 -## Creating a session
12 -
13 -<CodeGroup>
14 -```python
15 -from composio import Composio
16 -
17 -composio = Composio(api_key="your-api-key")
18 -session = composio.create(user_id="pg-user-550e8400-e29b-41d4")
19 -```
20 -
21 -```typescript
22 -import { Composio } from "@composio/core";
23 -
24 -const composio = new Composio({ apiKey: "your-api-key" });
25 -const session = await composio.create("pg-user-550e8400-e29b-41d4");
26 -```
27 -</CodeGroup>
28 -
29 -By default, all toolkits are available and in-chat authentication is enabled.
30 -
31 -## Toolkit access
32 -
33 -### Allow specific toolkits
34 -
35 -<CodeGroup>
36 -```python
37 -session = composio.create(
38 - user_id="pg-user-550e8400-e29b-41d4",
39 - toolkits=["github", "gmail", "slack"]
40 -)
41 -```
42 -
43 -```typescript
44 -const session = await composio.create("pg-user-550e8400-e29b-41d4", {
45 - toolkits: ["github", "gmail", "slack"],
46 -});
47 -```
48 -</CodeGroup>
49 -
50 -### Disable specific toolkits
51 -
52 -<CodeGroup>
53 -```python
54 -session = composio.create(
55 - user_id="pg-user-550e8400-e29b-41d4",
56 - toolkits={"disable": ["exa", "firecrawl"]}
57 -)
58 -```
59 -
60 -```typescript
61 -const session = await composio.create("pg-user-550e8400-e29b-41d4", {
62 - toolkits: { disable: ["exa", "firecrawl"] },
63 -});
64 -```
65 -</CodeGroup>
66 -
67 -## Authentication
68 -
69 -### Custom OAuth apps
70 -
71 -Use your own OAuth credentials instead of Composio's defaults. See [White-labeling authentication](/tool-router/white-labeling-authentication) for branding, or [Configuring custom auth configs](/tool-router/configuring-custom-auth-configs) for toolkits that require your own credentials.
72 -
73 -<CodeGroup>
74 -```python
75 -session = composio.create(
76 - user_id="pg-user-550e8400-e29b-41d4",
77 - auth_configs={
78 - "github": "ac_your_github_config",
79 - "slack": "ac_your_slack_config"
80 - }
81 -)
82 -```
83 -
84 -```typescript
85 -const session = await composio.create("pg-user-550e8400-e29b-41d4", {
86 - authConfigs: {
87 - github: "ac_your_github_config",
88 - slack: "ac_your_slack_config",
89 - },
90 -});
91 -```
92 -</CodeGroup>
93 -
94 -### Account selection
95 -
96 -Specify which connected account to use when a user has multiple accounts for the same toolkit.
97 -
98 -<CodeGroup>
99 -```python
100 -session = composio.create(
101 - user_id="pg-user-550e8400-e29b-41d4",
102 - connected_accounts={
103 - "gmail": "ca_work_gmail",
104 - "github": "ca_personal_github"
105 - }
106 -)
107 -```
108 -
109 -```typescript
110 -const session = await composio.create("pg-user-550e8400-e29b-41d4", {
111 - connectedAccounts: {
112 - gmail: "ca_work_gmail",
113 - github: "ca_personal_github",
114 - },
115 -});
116 -```
117 -</CodeGroup>
118 -
119 -### In-chat prompts
120 -
121 -Control whether the agent can prompt users to connect accounts during chat.
122 -
123 -**Disable in-chat authentication:**
124 -
125 -<CodeGroup>
126 -```python
127 -session = composio.create(
128 - user_id="pg-user-550e8400-e29b-41d4",
129 - manage_connections=False
130 -)
131 -```
132 -
133 -```typescript
134 -const session = await composio.create("pg-user-550e8400-e29b-41d4", {
135 - manageConnections: false,
136 -});
137 -```
138 -</CodeGroup>
139 -
140 -**Custom callback URL:**
141 -
142 -<CodeGroup>
143 -```python
144 -session = composio.create(
145 - user_id="pg-user-550e8400-e29b-41d4",
146 - manage_connections={"callback_url": "https://myapp.com/callback"}
147 -)
148 -```
149 -
150 -```typescript
151 -const session = await composio.create("pg-user-550e8400-e29b-41d4", {
152 - manageConnections: { callbackUrl: "https://myapp.com/callback" },
153 -});
154 -```
155 -</CodeGroup>
156 -
157 -For more details, see [Using in-chat authentication](/tool-router/using-in-chat-authentication) and [Manually authenticating users](/tool-router/manually-authenticating-users).
158 -
159 -## Session methods
160 -
161 -{/* ### tools()
162 -
163 -Get meta-tools to pass to your agent framework.
164 -
165 -<CodeGroup>
166 -```python
167 -tools = session.tools()
168 -
169 -agent = Agent(
170 - name="Assistant",
171 - instructions="You are a helpful assistant.",
172 - tools=tools
173 -)
174 -```
175 -
176 -```typescript
177 -const tools = await session.tools();
178 -
179 -const agent = new Agent({
180 - name: "Assistant",
181 - instructions: "You are a helpful assistant.",
182 - tools: tools,
183 -});
184 -```
185 -</CodeGroup>
186 -
187 -For framework-specific examples, see [Using as native tools](/tool-router/using-as-native-tools). */}
188 -
189 -### mcp
190 -
191 -Get the MCP server URL to use with any MCP-compatible client.
192 -
193 -<CodeGroup>
194 -```python
195 -mcp_url = session.mcp.url
196 -```
197 -
198 -```typescript
199 -const { mcp } = session;
200 -console.log(mcp.url);
201 -```
202 -</CodeGroup>
203 -
204 -For framework examples, see [Using with MCP clients](/tool-router/using-with-mcp-clients).
205 -
206 -### authorize()
207 -
208 -Manually authenticate a user to a toolkit outside of the chat flow.
209 -
210 -<CodeGroup>
211 -```python
212 -connection_request = session.authorize(
213 - "github",
214 - callback_url="https://myapp.com/callback"
215 -)
216 -
217 -print(connection_request.redirect_url)
218 -
219 -connected_account = connection_request.wait_for_connection()
220 -```
221 -
222 -```typescript
223 -const connectionRequest = await session.authorize("github", {
224 - callbackUrl: "https://myapp.com/callback",
225 -});
226 -
227 -console.log(connectionRequest.redirectUrl);
228 -
229 -const connectedAccount = await connectionRequest.waitForConnection();
230 -```
231 -</CodeGroup>
232 -
233 -For more details, see [Manually authenticating users](/tool-router/manually-authenticating-users).
234 -
235 -### toolkits()
236 -
237 -List available toolkits and their connection status. Use this to build a UI showing which apps are connected.
238 -
239 -<CodeGroup>
240 -```python
241 -toolkits = session.toolkits(
242 - order_by="popularity",
243 - is_connected=True
244 -)
245 -
246 -for toolkit in toolkits:
247 - status = toolkit.connected_account.id if toolkit.connected_account else "Not connected"
248 - print(f"{toolkit.name}: {status}")
249 -```
250 -
251 -```typescript
252 -const toolkits = await session.toolkits({
253 - orderBy: "popularity",
254 - isConnected: true,
255 -});
256 -
257 -toolkits.forEach((toolkit) => {
258 - console.log(`${toolkit.name}: ${toolkit.connectedAccount?.id ?? "Not connected"}`);
259 -});
260 -```
261 -</CodeGroup>
262 -
263 -**Filter options:**
264 -- `orderBy`: `"popularity"`, `"name"`, or `"connected_at"`
265 -- `isConnected`: `true` to show only connected toolkits
266 -- `category`: Filter by category (e.g., `"productivity"`, `"communication"`)
fern/pages/src/tool-router/manually-authenticating-users.mdx
+2 -2
@@ -16,12 +16,12 @@ Disable the `COMPOSIO_MANAGE_CONNECTIONS` meta-tool so the agent doesn't prompt
16 <CodeGroup>
17 ```python
18 session = await composio.create(
19 - user="pg-user-550e8400-e29b-41d4",
19 + user="user_123",
20 manage_connections=False,
21 )
22 ```
23 ```typescript
24 -const session = await composio.create("pg-user-550e8400-e29b-41d4", {
24 +const session = await composio.create("user_123", {
25 manageConnections: false,
26 });
27 ```
fern/pages/src/tool-router/tools-and-toolkits.mdx
+4 -4
@@ -5,7 +5,7 @@ description: "Access 800+ integrations through Tool Router"
5 keywords: "tool router, tools, toolkits, integrations, composio"
6 ---
7
8 -Tool Router gives your agent access to most Composio toolkits by default. For details on configuring which toolkits and tools are available in a session, see [Session configuration](/tool-router/creating-sessions).
8 +Tool Router gives your agent access to most Composio toolkits by default. For details on configuring which toolkits are available in a session, see [Users and sessions](/tool-router/users-and-sessions#enabling-toolkits).
9
10 ## Toolkits and tools
11
@@ -32,14 +32,14 @@ When you create a session, all toolkits are available:
32
33 <CodeGroup>
34 ```python
35 -session = composio.create(user_id="pg-user-550e8400-e29b-41d4")
35 +session = composio.create(user_id="user_123")
36 ```
37 ```typescript
38 -const session = await composio.create("pg-user-550e8400-e29b-41d4");
38 +const session = await composio.create("user_123");
39 ```
40 </CodeGroup>
41
42 -Your agent can search and use tools from any toolkit. To restrict or configure which toolkits are available, see [Session configuration](/docs/tool-router/creating-sessions).
42 +Your agent can search and use tools from any toolkit. To restrict or configure which toolkits are available, see [Users and sessions](/tool-router/users-and-sessions#enabling-toolkits).
43
44 <Tip>
45 Triggers can be used alongside Tool Router to respond to events in connected apps. See [Using triggers](/docs/tools-and-triggers/using-triggers) for setup instructions.
fern/pages/src/tool-router/users-and-sessions.mdx
+150 -24
@@ -6,67 +6,122 @@ keywords: "sessions, users, tool router, configuration"
6 hide-nav-links: false
7 ---
8
9 -Sessions are ephemeral, user-scoped configurations that define what tools are available and how authentication works.
9 +A **user ID** is an identifier from your system (database ID, UUID, or any unique string) that scopes connected accounts and tool access to a specific user. User IDs can represent individuals, teams, or organizations. See [User Management](/docs/user-management) for patterns.
10
11 -## Users
11 +A **session** is an ephemeral configuration that combines:
12 +- Which user's connected accounts to use
13 +- Which toolkits are available
14 +- Which auth configs to use
15
13 -A user ID is an identifier from your system (database UUID, primary key) that Composio uses to scope connected accounts and tool access.
16 +Tool Router's meta-tools are the same for everyone. The session determines the context they operate within.
17 +
18 +## Creating a session
19
20 <CodeGroup>
21 ```python Python
17 -session = composio.create(user_id="pg-user-550e8400-e29b-41d4")
22 +session = composio.create(user_id="user_123")
23 ```
24
25 ```typescript TypeScript
21 -const session = await composio.create("pg-user-550e8400-e29b-41d4");
26 +const session = await composio.create("user_123");
27 ```
28 </CodeGroup>
29
25 -User IDs can represent individuals, teams, or organizations depending on your application. For detailed patterns, see [User Management](/docs/user-management).
30 +### Enabling toolkits
31
27 -## Sessions
32 +Restrict the session to specific toolkits:
33
29 -A session defines the execution context for Tool Router's meta-tools. It combines:
30 -- Which user's connected accounts to use
31 -- Which toolkits are available
32 -- Which auth configs to use
34 +<CodeGroup>
35 +```python Python
36 +session = composio.create(
37 + user_id="user_123",
38 + toolkits=["github", "gmail", "slack"]
39 +)
40 +```
41 +
42 +```typescript TypeScript
43 +const session = await composio.create("user_123", {
44 + toolkits: ["github", "gmail", "slack"],
45 +});
46 +```
47 +</CodeGroup>
48 +
49 +### Disabling toolkits
50 +
51 +Keep all toolkits enabled except specific ones:
52 +
53 +<CodeGroup>
54 +```python Python
55 +session = composio.create(
56 + user_id="user_123",
57 + toolkits={"disable": ["exa", "firecrawl"]}
58 +)
59 +```
60
34 -Tool Router's meta-tools (search, execute, workbench, manage connections) are the same for everyone. The session determines the context they operate within - when the agent searches for tools, it searches within the session's allowed toolkits. When it executes a tool, it uses the session user's connected accounts.
61 +```typescript TypeScript
62 +const session = await composio.create("user_123", {
63 + toolkits: { disable: ["exa", "firecrawl"] },
64 +});
65 +```
66 +</CodeGroup>
67
36 -### Creating a session
68 +### Custom auth configs
69
38 -A session pulls together your user's auth state with your toolkit configuration. All options are optional - by default, all toolkits with Composio managed auth are enabled.
70 +Use your own OAuth credentials instead of Composio's defaults:
71
72 <CodeGroup>
73 ```python Python
74 session = composio.create(
43 - user_id="pg-user-550e8400-e29b-41d4",
44 - toolkits=["github", "gmail", "slack"],
75 + user_id="user_123",
76 auth_configs={
46 - "github": "ac_your_github_config"
77 + "github": "ac_your_github_config",
78 + "slack": "ac_your_slack_config"
79 }
80 )
81 ```
82
83 ```typescript TypeScript
52 -const session = await composio.create("pg-user-550e8400-e29b-41d4", {
53 - toolkits: ["github", "gmail", "slack"],
84 +const session = await composio.create("user_123", {
85 authConfigs: {
86 github: "ac_your_github_config",
87 + slack: "ac_your_slack_config",
88 },
89 });
90 ```
91 </CodeGroup>
92
61 -For all configuration options, see [Creating sessions](/tool-router/creating-sessions).
93 +See [White-labeling authentication](/tool-router/white-labeling-authentication) for branding, or [Configuring custom auth configs](/tool-router/configuring-custom-auth-configs) for toolkits that require your own credentials.
94 +
95 +## Connected accounts
96 +
97 +Connected accounts are stored in Composio and persist across sessions. When a user connects their GitHub account in one session, it remains available in future sessions. Sessions configure *which* connections to use, but don't own the connections themselves.
98
63 -### Connections persist
99 +### Account selection
100
65 -Connected accounts are stored in Composio and persist across sessions. When a user connects their GitHub account in one session, it remains available in future sessions.
101 +If a user has multiple connected accounts for the same toolkit, you can specify which one to use:
102
67 -Sessions configure *which* connections to use, but don't own the connections themselves.
103 +<CodeGroup>
104 +```python Python
105 +session = composio.create(
106 + user_id="user_123",
107 + connected_accounts={
108 + "gmail": "ca_work_gmail",
109 + "github": "ca_personal_github"
110 + }
111 +)
112 +```
113
69 -## Connected account precedence
114 +```typescript TypeScript
115 +const session = await composio.create("user_123", {
116 + connectedAccounts: {
117 + gmail: "ca_work_gmail",
118 + github: "ca_personal_github",
119 + },
120 +});
121 +```
122 +</CodeGroup>
123 +
124 +### Precedence
125
126 When executing a tool, Tool Router selects the connected account in this order:
127
@@ -78,3 +133,74 @@ When executing a tool, Tool Router selects the connected account in this order:
133
134 If a user has multiple connected accounts for a toolkit, the most recently connected one is used.
135
136 +## Session methods
137 +
138 +### mcp
139 +
140 +Get the MCP server URL to use with any MCP-compatible client.
141 +
142 +<CodeGroup>
143 +```python Python
144 +mcp_url = session.mcp.url
145 +```
146 +
147 +```typescript TypeScript
148 +const { mcp } = session;
149 +console.log(mcp.url);
150 +```
151 +</CodeGroup>
152 +
153 +For framework examples, see [Using with MCP clients](/tool-router/using-with-mcp-clients).
154 +
155 +### authorize()
156 +
157 +Manually authenticate a user to a toolkit outside of the chat flow.
158 +
159 +<CodeGroup>
160 +```python Python
161 +connection_request = session.authorize(
162 + "github",
163 + callback_url="https://myapp.com/callback"
164 +)
165 +
166 +print(connection_request.redirect_url)
167 +
168 +connected_account = connection_request.wait_for_connection()
169 +```
170 +
171 +```typescript TypeScript
172 +const connectionRequest = await session.authorize("github", {
173 + callbackUrl: "https://myapp.com/callback",
174 +});
175 +
176 +console.log(connectionRequest.redirectUrl);
177 +
178 +const connectedAccount = await connectionRequest.waitForConnection();
179 +```
180 +</CodeGroup>
181 +
182 +For more details, see [Manually authenticating users](/tool-router/manually-authenticating-users).
183 +
184 +### toolkits()
185 +
186 +List available toolkits and their connection status. You can use this to build a UI showing which apps are connected.
187 +
188 +<CodeGroup>
189 +```python Python
190 +toolkits = session.toolkits()
191 +
192 +for toolkit in toolkits:
193 + status = toolkit.connected_account.id if toolkit.connected_account else "Not connected"
194 + print(f"{toolkit.name}: {status}")
195 +```
196 +
197 +```typescript TypeScript
198 +const toolkits = await session.toolkits();
199 +
200 +toolkits.items.forEach((toolkit) => {
201 + console.log(`${toolkit.name}: ${toolkit.connection.connectedAccount?.id ?? "Not connected"}`);
202 +});
203 +```
204 +</CodeGroup>
205 +
206 +Returns the first 20 toolkits by default.
fern/pages/src/tool-router/using-in-chat-authentication.mdx
+6 -6
@@ -20,11 +20,11 @@ In-chat auth is enabled by default. The `COMPOSIO_MANAGE_CONNECTIONS` meta-tool
20 <CodeGroup>
21 ```python
22 session = await composio.create(
23 - user="pg-user-550e8400-e29b-41d4",
23 + user="user_123",
24 )
25 ```
26 ```typescript
27 -const { mcp } = await composio.create("pg-user-550e8400-e29b-41d4");
27 +const { mcp } = await composio.create("user_123");
28 ```
29 </CodeGroup>
30
@@ -35,14 +35,14 @@ Redirect users to a specific page after authentication:
35 <CodeGroup>
36 ```python
37 session = await composio.create(
38 - user="pg-user-550e8400-e29b-41d4",
38 + user="user_123",
39 manage_connections={
40 "callback_url": "https://yourapp.com/chat"
41 },
42 )
43 ```
44 ```typescript
45 -const { mcp } = await composio.create("pg-user-550e8400-e29b-41d4", {
45 +const { mcp } = await composio.create("user_123", {
46 manageConnections: {
47 callbackUrl: "https://yourapp.com/chat",
48 },
@@ -57,12 +57,12 @@ To manage authentication outside of chat, disable the `COMPOSIO_MANAGE_CONNECTIO
57 <CodeGroup>
58 ```python
59 session = await composio.create(
60 - user="pg-user-550e8400-e29b-41d4",
60 + user="user_123",
61 manage_connections=False,
62 )
63 ```
64 ```typescript
65 -const { mcp } = await composio.create("pg-user-550e8400-e29b-41d4", {
65 +const { mcp } = await composio.create("user_123", {
66 manageConnections: false,
67 });
68 ```
fern/pages/src/tool-router/white-labeling-authentication.mdx
+4 -4
@@ -49,14 +49,14 @@ Pass your auth config ID in the session:
49 <CodeGroup>
50 ```python
51 session = await composio.create(
52 - user="pg-user-550e8400-e29b-41d4",
52 + user="user_123",
53 auth_configs={
54 "github": "ac_your_github_config"
55 },
56 )
57 ```
58 ```typescript
59 -const session = await composio.create("pg-user-550e8400-e29b-41d4", {
59 +const session = await composio.create("user_123", {
60 authConfigs: {
61 github: "ac_your_github_config",
62 },
@@ -75,7 +75,7 @@ You can white-label some toolkits while using Composio's default credentials for
75 <CodeGroup>
76 ```python
77 session = await composio.create(
78 - user="pg-user-550e8400-e29b-41d4",
78 + user="user_123",
79 auth_configs={
80 "github": "ac_your_github_config",
81 "slack": "ac_your_slack_config",
@@ -84,7 +84,7 @@ session = await composio.create(
84 )
85 ```
86 ```typescript
87 -const session = await composio.create("pg-user-550e8400-e29b-41d4", {
87 +const session = await composio.create("user_123", {
88 authConfigs: {
89 github: "ac_your_github_config",
90 slack: "ac_your_slack_config",
fern/snippets/tool-router/typescript/quickstart-openai.ts
+1 -1
@@ -3,7 +3,7 @@ import { Agent, run, hostedMcpTool } from "@openai/agents";
3 import { createInterface } from "readline/promises";
4
5 const composioApiKey = process.env.COMPOSIO_API_KEY;
6 -const userId = "550e8400-e29b-41d4-a716-446655440000"; // Your user's unique identifier
6 +const userId = "user-1234"; // Your user's unique identifier
7
8 const composio = new Composio({ apiKey: composioApiKey });
9 const { mcp } = await composio.create(userId);
fern/snippets/tool-router/typescript/quickstart-vercel.ts
+1 -1
@@ -3,7 +3,7 @@ import { experimental_createMCPClient as createMCPClient } from "@ai-sdk/mcp";
3 import { Composio } from "@composio/core";
4 import { stepCountIs, streamText } from "ai";
5 const composioApiKey = process.env.COMPOSIO_API_KEY;
6 -const userId = "550e8400-e29b-41d4-a716-446655440000"; // Your user's unique identifier
6 +const userId = "user-1234"; // Your user's unique identifier
7
8 const composio = new Composio({ apiKey: composioApiKey });
9