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
docs: update tool docs to add auth snippets as well as tool call snippets
[email protected]b304cb0f5d53
diff --git a/fern/generators/tool_doc_generator/main.py b/fern/generators/tool_doc_generator/main.pyindex d51eefd3a..8d510b2ae 100644--- a/fern/generators/tool_doc_generator/main.py+++ b/fern/generators/tool_doc_generator/main.py@@ -49,8 +49,6 @@ IMPORTANT_TOOL_SLUGS = []--try:from ruamel.yaml import YAML@@ -66,15 +64,13 @@ except ImportError:)--# Configure logginglogger = logging.getLogger(__name__)class TelemetryFilter(logging.Filter):"""Filter out telemetry-related log messages"""-+def filter(self, record):# Filter out telemetry-related messagesmessage = record.getMessage()@@ -83,18 +79,18 @@ class TelemetryFilter(logging.Filter):"telemetry","TELEMETRY","metrics/invocations",- "errors"+ "errors",]-+# Also filter by logger nameif "telemetry" in record.name.lower():return False-+# Filter by message contentfor keyword in telemetry_keywords:if keyword in message:return False-+return True@@ -204,7 +200,7 @@ class DocumentContent:self._blocks.extend(["## Overview",- f"### SLUG\n`{app_id.upper()}`",+ f"**SLUG**: `{app_id.upper()}`",f"### Description\n{sanitize_html(description)}",])@@ -221,81 +217,192 @@ class DocumentContent:return self- def _add_auth_schemes(self, auth_schemes: t.List[toolkit_retrieve_response.AuthConfigDetail]) -> None:+ def add_connection_section(+ self,+ app_name: str,+ app_slug: str,+ auth_schemes: t.Optional[t.List[toolkit_retrieve_response.AuthConfigDetail]] = None,+ ) -> None:+ schemes = ", ".join(+ self._get_auth_type(s) for s in (auth_schemes or []) if self._extract_auth_fields(s)+ )+ self._blocks.extend(+ [+ f"""## Connecting to {app_name}+### Create an auth config+Use the dashboard to create an auth config for the {app_name} toolkit. This allows you to connect multiple {app_name} accounts to Composio for agents to use.++<Steps>+ <Step title="Select App">+ Navigate to the [{app_name} toolkit page](https://app.composio.dev/apps/{app_name}) and click **"Setup Integration"**.+ </Step>+ <Step title="Configure Auth Config Settings">+ Select among the supported auth schemes of and configure them here.+ </Step>+ <Step title="Create and Get auth config ID">+ Click **"Create Integration"**. After creation, **copy the displayed ID starting with `ac_`**. This is your auth config ID. This is _not_ a sensitive ID -- you can save it in environment variables or a database.+ **This ID will be used to create connections to the toolkit for a given user.**+ </Step>+</Steps>+"""+ ],+ )++ # Add auth code snippets+ self._add_auth_section(app_name, app_slug, auth_schemes)++ def _add_auth_section(+ self,+ app_name: str,+ app_slug: str,+ auth_schemes: t.List[toolkit_retrieve_response.AuthConfigDetail] = None,+ ) -> None:+ """Add code snippets for each auth scheme using direct template processing"""+ if not auth_schemes:+ return++ self._blocks.append("### Connect Your Account")++ # Group auth schemes by type to avoid duplicates+ seen_auth_types = set()++ for scheme in auth_schemes:+ # Get normalized auth type+ auth_type_display = self._get_auth_type(scheme)+ auth_type_key = auth_type_display.lower().replace(" ", "_")++ # Skip if we've already shown this auth type or if it's no_auth+ if auth_type_key in seen_auth_types or auth_type_key == "no_auth":+ continue+ seen_auth_types.add(auth_type_key)++ # Add section for this auth type+ self._blocks.append(f"#### Using {auth_type_display}")++ # Prepare variables for template replacement+ template_vars = {+ "toolkit_name": app_name,+ "toolkit_slug": app_slug.lower(),+ "auth_config_id": f"ac_YOUR_{app_slug.upper()}_CONFIG_ID",+ "user_id": "[email protected]",+ "api_key_placeholder": f"your_{app_slug.lower()}_api_key",+ "username_placeholder": f"your_{app_slug.lower()}_username",+ "password_placeholder": f"your_{app_slug.lower()}_password",+ "bearer_token_placeholder": f"your_{app_slug.lower()}_bearer_token"+ }++ try:+ # Create code blocks using the new template method+ python_block = MDX.as_code_block_from_template(+ f"templates/python/{auth_type_key}.py",+ template_vars=template_vars,+ title="Python",+ max_lines=40,+ word_wrap=True+ )++ typescript_block = MDX.as_code_block_from_template(+ f"templates/typescript/{auth_type_key}.ts",+ template_vars=template_vars,+ title="TypeScript",+ max_lines=40,+ word_wrap=True+ )++ # Add code blocks wrapped in CodeGroup+ self._blocks.append(MDX.as_code_group(python_block, typescript_block))++ except Exception as e:+ logger.warning(f"Failed to process auth template for {auth_type_key}: {e}")+ # Fallback to a simple message if template processing fails+ self._blocks.append(f"*Authentication template for {auth_type_display} coming soon*")++ def _add_auth_schemes(+ self, auth_schemes: t.List[toolkit_retrieve_response.AuthConfigDetail]+ ) -> None:"""Add authentication schemes section."""self._blocks.append("### Authentication Details")-+for scheme in auth_schemes:fields = self._extract_auth_fields(scheme)if fields:auth_type = self._get_auth_type(scheme)self._blocks.append(MDX.as_accordion(auth_type, "\n".join(fields)))- def _extract_auth_fields(self, scheme: toolkit_retrieve_response.AuthConfigDetail) -> t.List[str]:+ def _extract_auth_fields(+ self, scheme: toolkit_retrieve_response.AuthConfigDetail+ ) -> t.List[str]:"""Extract authentication fields from scheme."""fields = []-- if hasattr(scheme, 'fields') and scheme.fields:++ if hasattr(scheme, "fields") and scheme.fields:for field in scheme.fields:fields.extend(self._process_tuple_field(field))--+return fieldsdef _process_tuple_field(self, field: tuple) -> t.List[str]:"""Process tuple-style authentication field."""fields = []_, field_config = field-- for field_list, required in [(getattr(field_config, 'required', []), True),- (getattr(field_config, 'optional', []), False)]:++ for field_list, required in [+ (getattr(field_config, "required", []), True),+ (getattr(field_config, "optional", []), False),+ ]:for f in field_list:- if hasattr(f, 'name'):+ if hasattr(f, "name"):fields.append(self._create_param_from_field(f, required))-+return fields- def _create_param_from_field(self, field: toolkit_retrieve_response.AuthConfigDetail, required: t.Optional[bool] = None) -> str:+ def _create_param_from_field(+ self, field: toolkit_retrieve_response.AuthConfigDetail, required: t.Optional[bool] = None+ ) -> str:"""Create parameter string from field object."""return MDX.as_param(name=str(field.name).replace('"', '\\"'),- required=required if required is not None else getattr(field, 'required', False),- typ=str(getattr(field, 'type', '')).replace('"', '\\"'),- default=str(getattr(field, 'default', '')).replace('"', '\\"') if getattr(field, 'default', None) else "",- doc=str(getattr(field, 'description', '')).replace('"', '\\"')+ required=required if required is not None else getattr(field, "required", False),+ typ=str(getattr(field, "type", "")).replace('"', '\\"'),+ default=str(getattr(field, "default", "")).replace('"', '\\"')+ if getattr(field, "default", None)+ else "",+ doc=str(getattr(field, "description", "")).replace('"', '\\"'),)def _get_auth_type(self, scheme: toolkit_retrieve_response.AuthConfigDetail) -> str:"""Get authentication type from scheme."""auth_type = (- getattr(scheme, 'mode', None) or- getattr(scheme, 'type', None) or- getattr(scheme, 'auth_type', None) or- getattr(scheme, 'auth_mode', None) or- 'Authentication'+ getattr(scheme, "mode", None)+ or getattr(scheme, "type", None)+ or getattr(scheme, "auth_type", None)+ or getattr(scheme, "auth_mode", None)+ or "Authentication")-+auth_type_mapping = {- 'oauth2': 'OAuth2',- 'OAUTH2': 'OAuth2',- 'api_key': 'API Key',- 'API_KEY': 'API Key',- 'bearer_token': 'Bearer Token',- 'BEARER_TOKEN': 'Bearer Token',- 'basic': 'Basic Auth',- 'BASIC': 'Basic Auth',- 'no_auth': 'No Authentication',- 'NO_AUTH': 'No Authentication'+ "oauth2": "OAuth2",+ "OAUTH2": "OAuth2",+ "api_key": "API Key",+ "API_KEY": "API Key",+ "bearer_token": "Bearer Token",+ "BEARER_TOKEN": "Bearer Token",+ "basic": "Basic Auth",+ "BASIC": "Basic Auth",+ "no_auth": "No Authentication",+ "NO_AUTH": "No Authentication",}-- return auth_type_mapping.get(auth_type, auth_type.replace('_', ' ').title())- def add_actions(self, actions: t.List[Tool]) -> "DocumentContent":+ return auth_type_mapping.get(auth_type, auth_type.replace("_", " ").title())++ def add_actions(self, actions: t.List[Tool], app_name: str, app_slug: str) -> "DocumentContent":"""Add actions section to the document.Args:actions: List of tool models to document+ app_name: The name of the application+ app_slug: The application slugReturns:Self reference for method chaining@@ -303,6 +410,66 @@ class DocumentContent:# If this is the first action, add the Actions headerif not any("## Tools" in block for block in self._blocks):self._blocks.append("## Tools")+ self._blocks.append("### Executing tools")++ # Prepare template variables+ template_vars = {+ "toolkit_name": app_name,+ "toolkit_slug": app_slug.lower(),+ "user_id": "[email protected]"+ }++ # Generate code blocks from templates+ openai_block = MDX.as_code_block_from_template(+ "templates/python/openai_tools.py",+ template_vars=template_vars,+ title="Python",+ max_lines=40,+ word_wrap=True+ )++ anthropic_block = MDX.as_code_block_from_template(+ "templates/typescript/anthropic_tools.ts",+ template_vars=template_vars,+ title="TypeScript",+ max_lines=40,+ word_wrap=True+ )++ google_block = MDX.as_code_block_from_template(+ "templates/python/google_tools.py",+ template_vars=template_vars,+ title="Python",+ max_lines=40,+ word_wrap=True+ )++ vercel_block = MDX.as_code_block_from_template(+ "templates/typescript/vercel_tools.ts",+ template_vars=template_vars,+ title="TypeScript",+ max_lines=40,+ word_wrap=True+ )++ # Build the tabs with populated code blocks+ self._blocks.append(+ f"""<Tabs>+<Tab title="OpenAI (Python)">+{openai_block}+</Tab>+<Tab title="Anthropic (TypeScript)">+{anthropic_block}+</Tab>+<Tab title="Google (Python)">+{google_block}+</Tab>+<Tab title="Vercel (TypeScript)">+{vercel_block}+</Tab>+</Tabs>"""+ )+ self._blocks.append("### Tool List")action_contents = []@@ -325,66 +492,70 @@ class DocumentContent:def _process_tool(self, tool: Tool) -> t.Optional[str]:"""Process a single tool and return accordion content."""tool_data = self._extract_tool_data(tool)- if not tool_data['name']:+ if not tool_data["name"]:return None-+content = [- f"**SLUG:** `{tool_data['slug']}`\n",- MDX.as_code_block(tool_data['description'], "text")+ f"**Tool Name:** {self._sanitize_action_name(tool_data['name'])}\n\n**Description**\n",+ MDX.as_code_block(tool_data["description"], "text"),]-+# Add parameterscontent.append("\n**Action Parameters**\n")- content.append("\n".join(self._process_parameters(tool_data['params'])))-+ content.append("\n".join(self._process_parameters(tool_data["params"])))+# Add responsescontent.append("\n**Action Response**\n")- content.append("\n".join(self._process_parameters(tool_data['response'])))-- safe_name = self._sanitize_action_name(tool_data['name'])- return MDX.as_accordion(safe_name, "\n".join(content))+ content.append("\n".join(self._process_parameters(tool_data["response"])))++ # safe_name = self._sanitize_action_name(tool_data['name'])+ return MDX.as_accordion(tool_data["slug"], "\n".join(content))def _extract_tool_data(self, tool: Tool) -> t.Dict[str, t.Any]:"""Extract data from tool object or dict."""return {- 'name': tool.name or tool.slug,- 'description': tool.description,+ "name": tool.name or tool.slug,+ "description": tool.description,"slug": tool.slug,- 'params': tool.input_parameters,- 'response': tool.output_parameters+ "params": tool.input_parameters,+ "response": tool.output_parameters,}def _process_parameters(self, params: t.Any) -> t.List[str]:"""Process parameters from various formats."""if not params or not isinstance(params, dict):return []-+param_list = []-- if 'properties' in params:- properties = params.get('properties', {})- required = params.get('required', [])-++ if "properties" in params:+ properties = params.get("properties", {})+ required = params.get("required", [])+for name, schema in properties.items():- param_list.append(MDX.as_param(- name=name,- typ=str(schema.get("type", "")),- doc=sanitize_html(schema.get("description", "")),- default=schema.get("default", ""),- required=name in required- ))- else:- for name, schema in params.items():- if isinstance(schema, dict):- param_list.append(MDX.as_param(+ param_list.append(+ MDX.as_param(name=name,typ=str(schema.get("type", "")),doc=sanitize_html(schema.get("description", "")),default=schema.get("default", ""),- required=schema.get("required", False)- ))-+ required=name in required,+ )+ )+ else:+ for name, schema in params.items():+ if isinstance(schema, dict):+ param_list.append(+ MDX.as_param(+ name=name,+ typ=str(schema.get("type", "")),+ doc=sanitize_html(schema.get("description", "")),+ default=schema.get("default", ""),+ required=schema.get("required", False),+ )+ )+return param_listdef _sanitize_action_name(self, name: str) -> str:@@ -394,12 +565,12 @@ class DocumentContent:(r"<(\d+)", r"less than \1"),(r">(\d+)", r"greater than \1"),(r"<=(\d+)", r"less than or equal to \1"),- (r">=(\d+)", r"greater than or equal to \1")+ (r">=(\d+)", r"greater than or equal to \1"),]for pattern, replacement in replacements:name = re.sub(pattern, replacement, name)name = name.replace("<", "<").replace(">", ">")-+return namedef __str__(self) -> str:@@ -432,7 +603,9 @@ class ToolDocGenerator:self.generated_tools = []self.problematic_actions = []- def generate_docs(self, output_path: Path, max_workers: int | None = None, limit: int | None = None) -> None:+ def generate_docs(+ self, output_path: Path, max_workers: int | None = None, limit: int | None = None+ ) -> None:"""Generate documentation for all apps in parallel.@@ -446,12 +619,12 @@ class ToolDocGenerator:# Get all appstoolkits = self.composio.toolkits.get()-+# Apply limit if specifiedif limit is not None:toolkits = toolkits[:limit]logger.info(f"Limited to first {limit} toolkits")-+logger.info(f"Starting documentation generation for {len(toolkits)} toolkits")# Track failures with a synchronized list@@ -501,7 +674,9 @@ class ToolDocGenerator:else:logger.info(f"\nSuccessfully generated docs for all {len(toolkits)} toolkits!")- logger.info(f"Generated {success_count} toolkit docs in parallel using {max_workers} workers")+ logger.info(+ f"Generated {success_count} toolkit docs in parallel using {max_workers} workers"+ )# Update docs.yml with the generated toolsself.update_docs_yml(output_path.parent / "docs.yml")@@ -518,12 +693,11 @@ class ToolDocGenerator:toolkit_model = self.composio.toolkits.get(slug=toolkit.slug)tools = self.composio.tools.get_raw_composio_tools(toolkits=[toolkit.slug], limit=99999)logger.info(f"Toolkit tools: {toolkit}")--+logger.info(f"Retrieved {len(tools)} tools for {toolkit.name}")if tools:logger.debug(f"First tool type: {type(tools[0])}")- if hasattr(tools[0], '__dict__'):+ if hasattr(tools[0], "__dict__"):logger.debug(f"First tool attributes: {list(tools[0].__dict__.keys())}")elif isinstance(tools[0], dict):logger.debug(f"First tool dict keys: {list(tools[0].keys())}")@@ -536,10 +710,14 @@ class ToolDocGenerator:category = Noneif toolkit_model.meta.categories:# Use the first category if multiple exist- category = toolkit_model.meta.categories[0].get('name') if isinstance(toolkit_model.meta.categories[0], dict) else getattr(toolkit_model.meta.categories[0], 'name', None)-+ category = (+ toolkit_model.meta.categories[0].get("name")+ if isinstance(toolkit_model.meta.categories[0], dict)+ else getattr(toolkit_model.meta.categories[0], "name", None)+ )+# Add frontmatter- content.add_frontmatter(titleize(toolkit.name), category)+ content.add_frontmatter(toolkit.name, category)# Handle auth schemes safelyauth_schemes = None@@ -549,42 +727,46 @@ class ToolDocGenerator:logger.info(f"Could not process auth schemes for {toolkit.name}: {e}")# Continue without auth schemes-no_auth = "NO_AUTH" in (toolkit.auth_schemes or [])logger.info(f"No auth: {no_auth}")--# Add overview section+ # For no-auth tools, don't pass auth_schemes to avoid showing authentication detailscontent.add_overview_section(app_name=toolkit.name,app_id=toolkit.slug,description=toolkit.meta.description,- auth_schemes=auth_schemes,+ auth_schemes=None if no_auth else auth_schemes,)+ # Only add connection section if authentication is required+ if not no_auth:+ content.add_connection_section(+ app_name=toolkit.name, app_slug=toolkit.slug, auth_schemes=auth_schemes+ )+# Filter out problematic actionsfiltered_tools = []for tool in tools:# Extract tool slug for filteringif isinstance(tool, dict):- if 'function' in tool:- tool_slug = tool['function'].get('name', '')+ if "function" in tool:+ tool_slug = tool["function"].get("name", "")else:- tool_slug = tool.get('slug', '')+ tool_slug = tool.get("slug", "")else:- tool_slug = getattr(tool, 'slug', '')-+ tool_slug = getattr(tool, "slug", "")+if tool_slug not in self.problematic_actions:filtered_tools.append(tool)else:logger.info(f"Filtered out problematic tool: {tool_slug}")-+logger.info(f"After filtering: {len(filtered_tools)} tools remaining out of {len(tools)}")-+# Add actions section (only the filtered ones)- content.add_actions(filtered_tools)+ content.add_actions(filtered_tools, app_name=toolkit.name, app_slug=toolkit.slug)# Write to filefilename = f"{toolkit.slug.lower()}.mdx"@@ -630,10 +812,13 @@ class ToolDocGenerator:proxy_apps = []no_auth_tools = []categories: dict[str, list] = {}-for tool in sorted_tools:- entry = {"page": tool["display_name"], "slug": "tools/" + tool["name"], "path": tool["path"]}+ entry = {+ "page": tool["display_name"],+ "slug": "tools/" + tool["name"],+ "path": tool["path"],+ }name = tool["name"]category = tool.get("category", "").strip()@@ -659,14 +844,12 @@ class ToolDocGenerator:# Sort categories by number of elements (descending), then by namesorted_categories = sorted(- categories.items(),- key=lambda item: (-len(item[1]), item[0])+ categories.items(), key=lambda item: (-len(item[1]), item[0]))logger.info(f"Category keys: {list(categories.keys())}")logger.info(f"Sorted categories keys: {[cat for cat, _ in sorted_categories]}")-# Find the "tools" tab section in the navigation structurefor tab_section in docs_data.get("navigation", []):if tab_section.get("tab") == "tools":@@ -678,21 +861,44 @@ class ToolDocGenerator:# Add Important section if presentif important_tools:- new_layout.append({"section": "Important", "skip-slug": True, "contents": important_tools, })-+ new_layout.append(+ {+ "section": "Important",+ "skip-slug": True,+ "contents": important_tools,+ }+ )# Add each category as its own sectionfor cat, tools_list in sorted_categories:if tools_list:- new_layout.append({"section": titleize(cat), "skip-slug": True, "contents": tools_list, })+ new_layout.append(+ {+ "section": titleize(cat),+ "skip-slug": True,+ "contents": tools_list,+ }+ )# Add Proxy Apps section if presentif proxy_apps:- new_layout.append({"section": "Proxy Apps", "skip-slug": True, "contents": proxy_apps, })+ new_layout.append(+ {+ "section": "Proxy Apps",+ "skip-slug": True,+ "contents": proxy_apps,+ }+ )# Add No Auth section if presentif no_auth_tools:- new_layout.append({"section": "No Auth", "skip-slug": True, "contents": no_auth_tools, })+ new_layout.append(+ {+ "section": "No Auth",+ "skip-slug": True,+ "contents": no_auth_tools,+ }+ )logger.info("new_layout: %s", new_layout)tab_section["layout"] = new_layout@@ -726,11 +932,11 @@ def configure_logging(log_level: str) -> None:format="%(asctime)s - %(levelname)s - %(message)s",datefmt="%Y-%m-%d %H:%M:%S",)-+# Add telemetry filter to root logger to filter out telemetry requeststelemetry_filter = TelemetryFilter()logging.getLogger().addFilter(telemetry_filter)-+# Also add filter to specific loggers that might handle HTTP requestsfor logger_name in ["httpx", "urllib3", "requests"]:logging.getLogger(logger_name).addFilter(telemetry_filter)@@ -814,42 +1020,5 @@ def cli_main() -> int:return 1-def generate_tool_docs(- output_dir,- config=None,- include_local=False,- log_level="info",- workers=None,- lint_only=False,- no_lint=False,- limit=None-):- """- Generate tool documentation-- Args:- output_dir: Path to output directory- config: Optional path to config file- include_local: Whether to include local development tools- log_level: Logging level (debug, info, warning, error, critical)- workers: Number of parallel worker threads- lint_only: Only lint existing MDX files without generating new ones- no_lint: Skip the linting step when generating documentation- limit: Limit processing to first N toolkits (for debugging)- """- # Configure logging- configure_logging(log_level)-- # Create generator- generator = ToolDocGenerator(include_local=include_local)-- # Generate docs with specified number of workers- generator.generate_docs(output_dir, max_workers=workers, limit=limit)-- # Force exit immediately without waiting for background telemetry- logger.info("Documentation generation complete. Exiting immediately.")- os._exit(0)--if __name__ == "__main__":sys.exit(cli_main())diff --git a/fern/generators/tool_doc_generator/mdx_formatter.py b/fern/generators/tool_doc_generator/mdx_formatter.pyindex da84c307f..e061bc36e 100644--- a/fern/generators/tool_doc_generator/mdx_formatter.py+++ b/fern/generators/tool_doc_generator/mdx_formatter.py@@ -7,6 +7,10 @@ This module provides utilities for formatting MDX content for Composio tool docuimport reimport typing as tfrom dataclasses import dataclass+from pathlib import Path+import logging++logger = logging.getLogger(__name__)class MDX:@@ -34,6 +38,7 @@ class MDX:frontmatter += f'\nsubtitle: "Learn how to use {app_name} with Composio"'if category is not None:frontmatter += f'\ncategory: "{category}"'+ frontmatter += f'\nimage: "https://og.composio.dev/api/og?title=Using%20{app_name}%20with%20Composio"'return "---\n" + frontmatter + "\n---\n"@staticmethod@@ -201,18 +206,236 @@ class MDX:return f'<AccordionGroup>\n{content}\n</AccordionGroup>\n'@staticmethod- def as_code_block(content: str, language: str = "python") -> str:+ def as_code_block(+ content: str,+ language: str = "python",+ display_name: str = None,+ highlight_lines: str = None, # e.g., "25-30" or "5"+ title: str = None,+ max_lines: int = None,+ word_wrap: bool = True+ ) -> str:"""- Format content as a code block using backticks.+ Format content as a code block using backticks with full formatting support.Args:content: The code to be displayed- language: The programming language for syntax highlighting+ language: The programming language for syntax highlighting (e.g., "python", "typescript")+ display_name: Display name for the language tab (deprecated - use title instead)+ highlight_lines: Lines to highlight (e.g., "25-30" or "5")+ title: Title for the code block (e.g., "Python", "TypeScript")+ max_lines: Maximum number of lines to display+ word_wrap: Whether to wrap long lines++ Returns:+ Formatted code block MDX string with all attributes+ """+ # Build the code fence header+ header_parts = [language]++ # Add line highlighting if provided+ if highlight_lines:+ header_parts.append(f"{{{highlight_lines}}}")++ # Add title if provided (use display_name as fallback)+ title_to_use = title or display_name+ if title_to_use:+ # Escape quotes in title+ safe_title = title_to_use.replace('"', '\\"')+ header_parts.append(f'title="{safe_title}"')++ # Add max lines if provided+ if max_lines:+ header_parts.append(f"maxLines={max_lines}")++ # Add word wrap if enabled (default is True)+ if word_wrap:+ header_parts.append("wordWrap")++ # Join all parts with spaces+ header = " ".join(header_parts)++ return f"```{header}\n{content}\n```\n"++ @staticmethod+ def as_code_group(*code_blocks: str) -> str:+ """+ Wrap multiple code blocks in a CodeGroup component.++ Args:+ *code_blocks: Variable number of code block strings++ Returns:+ Formatted CodeGroup MDX string containing all code blocks+ """+ return f"<CodeGroup>\n{''.join(code_blocks)}</CodeGroup>\n"++ @staticmethod+ def _replace_template_variables(content: str, variables: dict) -> str:+ """+ Replace {{variable}} patterns with their values, supporting transformations.++ Supports patterns like:+ - {{variable}}+ - {{variable|upper}}+ - {{variable|lower}}+ - {{variable|title}}+ - {{variable|default:'fallback value'}}++ Args:+ content: Template content with {{variable}} placeholders+ variables: Dictionary of variable names to values++ Returns:+ Content with variables replaced+ """+ def replace_var(match):+ var_name = match.group(1)+ transform = match.group(2)+ default = match.group(3)++ # Get the value or use default+ value = variables.get(var_name)+ if value is None:+ value = default.strip("'\"") if default else match.group(0)+ else:+ value = str(value)++ # Apply transformation if specified+ if transform:+ if transform == 'upper':+ value = value.upper()+ elif transform == 'lower':+ value = value.lower()+ elif transform == 'title':+ value = value.capitalize()++ return value++ # Pattern matches: {{var_name|transform|default:'value'}}+ pattern = r'\{\{(\w+)(?:\|(\w+))?(?:\|default:[\'"]([^\'"]*)[\'"])?\}\}'+ return re.sub(pattern, replace_var, content)++ @staticmethod+ def _read_template_file(template_path: str, base_path: t.Optional[Path] = None) -> str:+ """+ Read a template file.++ Args:+ template_path: Path to template file (can be relative)+ base_path: Base path to resolve relative paths from (defaults to current file's parent)++ Returns:+ Template content as string+ """+ if base_path is None:+ # Default to the directory containing this file's parent (tool_doc_generator)+ base_path = Path(__file__).parent++ # Resolve the full path+ if Path(template_path).is_absolute():+ full_path = Path(template_path)+ else:+ full_path = base_path / template_path++ try:+ with open(full_path, 'r', encoding='utf-8') as f:+ return f.read()+ except FileNotFoundError:+ logger.warning(f"Template not found: {full_path}")+ return f"# Template not found: {template_path}"++ @staticmethod+ def _detect_language_from_path(file_path: str) -> str:+ """+ Detect programming language from file extension.++ Args:+ file_path: Path to the file++ Returns:+ Language identifier for syntax highlighting+ """+ extension_map = {+ '.py': 'python',+ '.js': 'javascript',+ '.ts': 'typescript',+ '.tsx': 'typescript',+ '.jsx': 'javascript',+ '.java': 'java',+ '.cpp': 'cpp',+ '.c': 'c',+ '.go': 'go',+ '.rs': 'rust',+ '.php': 'php',+ '.rb': 'ruby',+ '.swift': 'swift',+ '.kt': 'kotlin',+ '.scala': 'scala',+ '.sh': 'bash',+ '.yml': 'yaml',+ '.yaml': 'yaml',+ '.json': 'json',+ '.xml': 'xml',+ '.html': 'html',+ '.css': 'css',+ '.scss': 'scss',+ '.sql': 'sql',+ }++ suffix = Path(file_path).suffix.lower()+ return extension_map.get(suffix, 'text')++ @staticmethod+ def as_code_block_from_template(+ template_path: str,+ template_vars: dict = None,+ language: str = None,+ display_name: str = None,+ highlight_lines: str = None,+ title: str = None,+ max_lines: int = None,+ word_wrap: bool = True,+ base_path: t.Optional[Path] = None+ ) -> str:+ """+ Create a code block from a template file with variable replacement.++ Args:+ template_path: Path to template file (relative to base_path)+ template_vars: Dictionary of variables to replace in template+ language: Override auto-detected language (e.g., "python", "typescript")+ display_name: Display name for the language tab (deprecated - use title instead)+ highlight_lines: Lines to highlight (e.g., "25-30" or "5")+ title: Title for the code block (e.g., "Python", "TypeScript")+ max_lines: Maximum number of lines to display+ word_wrap: Whether to wrap long lines+ base_path: Base path for resolving template_pathReturns:Formatted code block MDX string"""- return f"```{language} wordWrap\n{content}\n```\n"+ # Read template file+ content = MDX._read_template_file(template_path, base_path)++ # Replace variables if provided+ if template_vars:+ content = MDX._replace_template_variables(content, template_vars)++ # Auto-detect language from file extension if not provided+ if not language:+ language = MDX._detect_language_from_path(template_path)++ # Use existing as_code_block with all formatting+ return MDX.as_code_block(+ content=content,+ language=language,+ display_name=display_name,+ highlight_lines=highlight_lines,+ title=title,+ max_lines=max_lines,+ word_wrap=word_wrap+ )@staticmethoddef as_markdown_table(headers: list, rows: list) -> str:diff --git a/fern/generators/tool_doc_generator/templates/python/api_key.py b/fern/generators/tool_doc_generator/templates/python/api_key.pynew file mode 100644index 000000000..926f666da--- /dev/null+++ b/fern/generators/tool_doc_generator/templates/python/api_key.py@@ -0,0 +1,32 @@+from composio import Composio+from composio.types import auth_scheme++# Replace these with your actual values+{{toolkit_slug}}_auth_config_id = "{{auth_config_id|default:'ac_YOUR_AUTH_CONFIG_ID'}}" # Auth config ID created above+user_id = "0000-0000-0000" # UUID from database/app++composio = Composio()++def authenticate_toolkit(user_id: str, auth_config_id: str):+ # Replace this with a method to retrieve an API key from the user.+ # Or supply your own.+ user_api_key = input("[!] Enter API key")++ connection_request = composio.connected_accounts.initiate(+ user_id=user_id,+ auth_config_id=auth_config_id,+ config={"auth_scheme": "API_KEY", "val": user_api_key}+ )++ # API Key authentication is immediate - no redirect needed+ print(f"Successfully connected {{toolkit_name}} for user {user_id}")+ print(f"Connection status: {connection_request.status}")++ return connection_request.id+++connection_id = authenticate_toolkit(user_id, {{toolkit_slug}}_auth_config_id)++# You can verify the connection using:+connected_account = composio.connected_accounts.get(connection_id)+print(f"Connected account: {connected_account}")\ No newline at end of filediff --git a/fern/generators/tool_doc_generator/templates/python/basic_auth.py b/fern/generators/tool_doc_generator/templates/python/basic_auth.pynew file mode 100644index 000000000..e918ad162--- /dev/null+++ b/fern/generators/tool_doc_generator/templates/python/basic_auth.py@@ -0,0 +1,26 @@+from composio import Composio+from composio.types import auth_scheme++# Replace these with your actual values+{{toolkit_slug}}_auth_config_id = "{{auth_config_id|default:'ac_YOUR_AUTH_CONFIG_ID'}}"+user_id = "{{user_id|default:'[email protected]'}}"+username = "{{username_placeholder|default:'your_username'}}"+password = "{{password_placeholder|default:'your_password'}}"++composio = Composio()++# Create a new connected account for {{toolkit_name}} using Basic Auth+connection_request = composio.connected_accounts.initiate(+ user_id=user_id,+ auth_config_id={{toolkit_slug}}_auth_config_id,+ config=auth_scheme.basic_auth(+ username=username,+ password=password+ )+)++# Basic authentication is immediate - no redirect needed+print(f"Successfully connected {{toolkit_name}} for user {user_id}")++# You can verify the connection using:+# connected_account = composio.connected_accounts.get(user_id=user_id, app_id="{{toolkit_slug|upper}}")\ No newline at end of filediff --git a/fern/generators/tool_doc_generator/templates/python/bearer_token.py b/fern/generators/tool_doc_generator/templates/python/bearer_token.pynew file mode 100644index 000000000..9c8a406d9--- /dev/null+++ b/fern/generators/tool_doc_generator/templates/python/bearer_token.py@@ -0,0 +1,31 @@+from composio import Composio+from composio.types import auth_scheme++# Auth config ID created above+{{toolkit_slug}}_auth_config_id = "{{auth_config_id|default:'ac_YOUR_AUTH_CONFIG_ID'}}"++# UUID from database/application+user_id = "0000-0000-0000"++composio = Composio()+++def authenticate_toolkit(user_id: str, auth_config_id: str):+ # Replace this with a method to retrieve the Bearer Token from the user.+ bearer_token = input("[!] Enter bearer token")+ connection_request = composio.connected_accounts.initiate(+ user_id=user_id,+ auth_config_id=auth_config_id,+ config={"auth_scheme": "BEARER_TOKEN", "val": bearer_token}+ )+ print(f"Successfully connected {{toolkit_name}} for user {user_id}")+ print(f"Connection status: {connection_request.status}")++ return connection_request.id+++connection_id = authenticate_toolkit(user_id, {{toolkit_slug}}_auth_config_id)++# You can verify the connection using:+connected_account = composio.connected_accounts.get(connection_id)+print(f"Connected account: {connected_account}")\ No newline at end of filediff --git a/fern/generators/tool_doc_generator/templates/python/google_tools.py b/fern/generators/tool_doc_generator/templates/python/google_tools.pynew file mode 100644index 000000000..d71c2c9be--- /dev/null+++ b/fern/generators/tool_doc_generator/templates/python/google_tools.py@@ -0,0 +1,25 @@+from composio import Composio+from composio_google import GoogleProvider+from google import genai+from google.genai import types++# Create composio client+composio = Composio(provider=GoogleProvider())+# Create google client+client = genai.Client()++# User ID must be a valid UUID format+user_id = "0000-0000-0000" # Replace with actual user UUID from your database++# Get tools for {{toolkit_name}}+tools = composio.tools.get(user_id, toolkits=["{{toolkit_slug|upper}}"])++print("[!] Tools:", tools)++# Create genai client config+config = types.GenerateContentConfig(tools=tools)++# Use the chat interface+chat = client.chats.create(model="gemini-2.0-flash", config=config)+response = chat.send_message("What can you do with {{toolkit_name}}?")+print("[!] Response:", response.text)\ No newline at end of filediff --git a/fern/generators/tool_doc_generator/templates/python/oauth2.py b/fern/generators/tool_doc_generator/templates/python/oauth2.pynew file mode 100644index 000000000..6a3503d96--- /dev/null+++ b/fern/generators/tool_doc_generator/templates/python/oauth2.py@@ -0,0 +1,30 @@+from composio import Composio+from composio.types import auth_scheme++# Replace these with your actual values+{{toolkit_slug}}_auth_config_id = "{{auth_config_id|default:'ac_YOUR_AUTH_CONFIG_ID'}}" # Auth config ID created above+user_id = "0000-0000-0000" # UUID from database/application++composio = Composio()+++def authenticate_toolkit(user_id: str, auth_config_id: str):+ connection_request = composio.connected_accounts.initiate(+ user_id=user_id,+ auth_config_id=auth_config_id,+ )++ print(+ f"Visit this URL to authenticate {{toolkit_name}}: {connection_request.redirect_url}"+ )++ # This will wait for the auth flow to be completed+ connection_request.wait_for_connection(timeout=15)+ return connection_request.id+++connection_id = authenticate_toolkit(user_id, {{toolkit_slug}}_auth_config_id)++# You can also verify the connection status using:+connected_account = composio.connected_accounts.get(connection_id)+print(f"Connected account: {connected_account}")\ No newline at end of filediff --git a/fern/generators/tool_doc_generator/templates/python/openai_tools.py b/fern/generators/tool_doc_generator/templates/python/openai_tools.pynew file mode 100644index 000000000..d8699fa8c--- /dev/null+++ b/fern/generators/tool_doc_generator/templates/python/openai_tools.py@@ -0,0 +1,33 @@+from composio import Composio+from openai import OpenAI+import json++openai = OpenAI()+composio = Composio()++# User ID must be a valid UUID format+user_id = "0000-0000-0000" # Replace with actual user UUID from your database++tools = composio.tools.get(user_id=user_id, toolkits=["{{toolkit_slug|upper}}"])++print("[!] Tools:")+print(json.dumps(tools))++def invoke_llm(task = "What can you do?"):+ completion = openai.chat.completions.create(+ model="gpt-4o",+ messages=[+ {+ "role": "user",+ "content": task, # Your task here!+ },+ ],+ tools=tools,+ )++ # Handle Result from tool call+ result = composio.provider.handle_tool_calls(user_id=user_id, response=completion)+ print(f"[!] Completion: {completion}")+ print(f"[!] Tool call result: {result}")++invoke_llm()\ No newline at end of filediff --git a/fern/generators/tool_doc_generator/templates/typescript/anthropic_tools.ts b/fern/generators/tool_doc_generator/templates/typescript/anthropic_tools.tsnew file mode 100644index 000000000..cf7256470--- /dev/null+++ b/fern/generators/tool_doc_generator/templates/typescript/anthropic_tools.ts@@ -0,0 +1,38 @@+import { Composio } from '@composio/core';+import { AnthropicProvider } from '@composio/anthropic';+import { Anthropic } from '@anthropic-ai/sdk';++const composio = new Composio({+ provider: new AnthropicProvider({+ cacheTools: false, // default+ }),+});++const anthropic = new Anthropic();++// User ID must be a valid UUID format+const userId = "0000-0000-0000"; // Replace with actual user UUID from your database++// Get tools for {{toolkit_name}}+const tools = await composio.tools.get(userId, {+ toolkits: ["{{toolkit_slug|upper}}"],+});++console.log("[!] Tools:", tools);++// Create a message with the tools+const msg = await anthropic.messages.create({+ model: 'claude-3-5-sonnet-20240620',+ messages: [+ {+ role: 'user',+ content: 'What can you do with {{toolkit_name}}?', // Your task here!+ },+ ],+ tools: tools,+ max_tokens: 1000,+});++// Handle tool calls if any+const result = await composio.provider.handleToolCalls(userId, msg);+console.log("[!] Result:", result);\ No newline at end of filediff --git a/fern/generators/tool_doc_generator/templates/typescript/api_key.ts b/fern/generators/tool_doc_generator/templates/typescript/api_key.tsnew file mode 100644index 000000000..057f79aa5--- /dev/null+++ b/fern/generators/tool_doc_generator/templates/typescript/api_key.ts@@ -0,0 +1,38 @@+import { Composio } from '@composio/core';++// Replace these with your actual values+const {{toolkit_slug}}_auth_config_id = "{{auth_config_id|default:'ac_YOUR_AUTH_CONFIG_ID'}}"; // Auth config ID created above+const userId = "{{user_id|default:'[email protected]'}}"; // User ID from database/application++const composio = new Composio();++async function authenticateToolkit(userId: string, authConfigId: string) {+ // TODO: Replace this with a method to retrieve the API key from the user.+ // In production, this should be securely retrieved from your database or user input.+ // For example: const userApiKey = await getUserApiKey(userId);+ const userApiKey = "{{api_key_placeholder|default:'your_api_key_here'}}"; // Replace with actual API key++ const connectionRequest = await composio.connectedAccounts.initiate({+ userId: userId,+ authConfigId: authConfigId,+ config: {+ authScheme: "API_KEY",+ config: {+ api_key: userApiKey+ }+ }+ });++ // API Key authentication is immediate - no redirect needed+ console.log(`Successfully connected {{toolkit_name}} for user ${userId}`);+ console.log(`Connection status: ${connectionRequest.status}`);++ return connectionRequest.id;+}++// Authenticate the toolkit+const connectionId = await authenticateToolkit(userId, {{toolkit_slug}}_auth_config_id);++// You can verify the connection using:+const connectedAccount = await composio.connectedAccounts.get(connectionId);+console.log("Connected account:", connectedAccount);\ No newline at end of filediff --git a/fern/generators/tool_doc_generator/templates/typescript/basic_auth.ts b/fern/generators/tool_doc_generator/templates/typescript/basic_auth.tsnew file mode 100644index 000000000..347076b7a--- /dev/null+++ b/fern/generators/tool_doc_generator/templates/typescript/basic_auth.ts@@ -0,0 +1,40 @@+import { Composio } from '@composio/core';++// Replace these with your actual values+const {{toolkit_slug}}_auth_config_id = "{{auth_config_id|default:'ac_YOUR_AUTH_CONFIG_ID'}}"; // Auth config ID created above+const userId = "{{user_id|default:'[email protected]'}}"; // User ID from database/application++const composio = new Composio();++async function authenticateToolkit(userId: string, authConfigId: string) {+ // TODO: Replace these with a method to retrieve credentials from the user.+ // In production, these should be securely retrieved from your database or user input.+ // For example: const { username, password } = await getUserCredentials(userId);+ const username = "{{username_placeholder|default:'your_username'}}"; // Replace with actual username+ const password = "{{password_placeholder|default:'your_password'}}"; // Replace with actual password++ const connectionRequest = await composio.connectedAccounts.initiate({+ userId: userId,+ authConfigId: authConfigId,+ config: {+ authScheme: "BASIC",+ config: {+ username: username,+ password: password+ }+ }+ });++ // Basic authentication is immediate - no redirect needed+ console.log(`Successfully connected {{toolkit_name}} for user ${userId}`);+ console.log(`Connection status: ${connectionRequest.status}`);++ return connectionRequest.id;+}++// Authenticate the toolkit+const connectionId = await authenticateToolkit(userId, {{toolkit_slug}}_auth_config_id);++// You can verify the connection using:+const connectedAccount = await composio.connectedAccounts.get(connectionId);+console.log("Connected account:", connectedAccount);\ No newline at end of filediff --git a/fern/generators/tool_doc_generator/templates/typescript/bearer_token.ts b/fern/generators/tool_doc_generator/templates/typescript/bearer_token.tsnew file mode 100644index 000000000..a6343e218--- /dev/null+++ b/fern/generators/tool_doc_generator/templates/typescript/bearer_token.ts@@ -0,0 +1,38 @@+import { Composio } from '@composio/core';++// Replace these with your actual values+const {{toolkit_slug}}_auth_config_id = "{{auth_config_id|default:'ac_YOUR_AUTH_CONFIG_ID'}}"; // Auth config ID created above+const userId = "{{user_id|default:'[email protected]'}}"; // User ID from database/application++const composio = new Composio();++async function authenticateToolkit(userId: string, authConfigId: string) {+ // TODO: Replace this with a method to retrieve the Bearer Token from the user.+ // In production, this should be securely retrieved from your database or user input.+ // For example: const bearerToken = await getUserBearerToken(userId);+ const bearerToken = "{{bearer_token_placeholder|default:'your_bearer_token_here'}}"; // Replace with actual bearer token++ const connectionRequest = await composio.connectedAccounts.initiate({+ userId: userId,+ authConfigId: authConfigId,+ config: {+ authScheme: "BEARER_TOKEN",+ config: {+ token: bearerToken+ }+ }+ });++ // Bearer token authentication is immediate - no redirect needed+ console.log(`Successfully connected {{toolkit_name}} for user ${userId}`);+ console.log(`Connection status: ${connectionRequest.status}`);++ return connectionRequest.id;+}++// Authenticate the toolkit+const connectionId = await authenticateToolkit(userId, {{toolkit_slug}}_auth_config_id);++// You can verify the connection using:+const connectedAccount = await composio.connectedAccounts.get(connectionId);+console.log("Connected account:", connectedAccount);\ No newline at end of filediff --git a/fern/generators/tool_doc_generator/templates/typescript/oauth2.ts b/fern/generators/tool_doc_generator/templates/typescript/oauth2.tsnew file mode 100644index 000000000..bcace48a6--- /dev/null+++ b/fern/generators/tool_doc_generator/templates/typescript/oauth2.ts@@ -0,0 +1,28 @@+import { Composio } from '@composio/core';++// Replace these with your actual values+const {{toolkit_slug}}_auth_config_id = "{{auth_config_id|default:'ac_YOUR_AUTH_CONFIG_ID'}}"; // Auth config ID created above+const userId = "{{user_id|default:'[email protected]'}}"; // User ID from database/application++const composio = new Composio();++async function authenticateToolkit(userId: string, authConfigId: string) {+ const connectionRequest = await composio.connectedAccounts.initiate({+ userId: userId,+ authConfigId: authConfigId,+ });++ console.log(`Visit this URL to authenticate {{toolkit_name}}: ${connectionRequest.redirectUrl}`);++ // This will wait for the auth flow to be completed+ await connectionRequest.waitForConnection(60);++ return connectionRequest.id;+}++// Authenticate the toolkit+const connectionId = await authenticateToolkit(userId, {{toolkit_slug}}_auth_config_id);++// You can also verify the connection status using:+const connectedAccount = await composio.connectedAccounts.get(connectionId);+console.log("Connected account:", connectedAccount);\ No newline at end of filediff --git a/fern/generators/tool_doc_generator/templates/typescript/vercel_tools.ts b/fern/generators/tool_doc_generator/templates/typescript/vercel_tools.tsnew file mode 100644index 000000000..ea5e2f279--- /dev/null+++ b/fern/generators/tool_doc_generator/templates/typescript/vercel_tools.ts@@ -0,0 +1,34 @@+import { Composio } from '@composio/core';+import { generateText } from 'ai';+import { anthropic } from '@ai-sdk/anthropic';+import { VercelProvider } from '@composio/vercel';++const composio = new Composio({+ apiKey: process.env.COMPOSIO_API_KEY,+ provider: new VercelProvider(),+});++// User ID must be a valid UUID format+const userId = "0000-0000-0000"; // Replace with actual user UUID from your database++// Get tools for {{toolkit_name}}+const tools = await composio.tools.get(userId, {+ toolkits: ["{{toolkit_slug|upper}}"]+});++console.log("[!] Tools:", tools);++// Generate text with tools+const { text } = await generateText({+ model: anthropic('claude-3-7-sonnet-20250219'),+ messages: [+ {+ role: 'user',+ content: "What can you do with {{toolkit_name}}?", // Your task here!+ },+ ],+ tools,+ maxSteps: 3,+});++console.log("[!] Result:", text);\ No newline at end of filediff --git a/fern/package.json b/fern/package.jsonindex c8808fb37..6cc65dfb0 100644--- a/fern/package.json+++ b/fern/package.json@@ -18,7 +18,7 @@"snippets:dev": "bun watch scripts/build-snippets.ts --watch","add-og": "uv run scripts/add_og_imgs.py","check": "fern check",- "dev": "bun run scripts/build-snippets.ts --watch & fern docs dev",+ "dev": "fern docs dev","links": "fern docs broken-links","build": "echo 'Build orchestrated by Turbo'","preview": "fern generate --docs --preview --log-level debug",diff --git a/fern/pages/src/examples/gmail-filterer.mdx b/fern/pages/src/examples/gmail-filterer.mdxindex f67d51761..88fa4b478 100644--- a/fern/pages/src/examples/gmail-filterer.mdx+++ b/fern/pages/src/examples/gmail-filterer.mdx@@ -1,7 +1,7 @@---title: AI Gmail Labellersubtitle: "A Python app that uses your custom LLM prompt to label your Gmail!"-image: "https://og.composio.dev/api/og?title=Full%20Stack%20Chat%20App" # image for socials+image: "https://og.composio.dev/api/og?title=AI%20Gmail%20Labeller" # image for socialskeywords: ''hide-nav-links: false---diff --git a/fern/pages/src/get-started/welcome.mdx b/fern/pages/src/get-started/welcome.mdxindex 1c5400150..ace9061be 100644--- a/fern/pages/src/get-started/welcome.mdx+++ b/fern/pages/src/get-started/welcome.mdx@@ -1,6 +1,6 @@---title: Welcome to Composio-image: 'https://og.composio.dev/api/og?title=Welcome%20to%20Composio' # image for socials+image: "https://og.composio.dev/api/og?title=Welcome%20to%20Composio" # image for socialskeywords: ''# subtitle: 'Our API and SDKs enable developers to build AI applications and experiences that are a step above the rest.'hide-nav-links: falsediff --git a/fern/pages/src/mcp/developers.mdx b/fern/pages/src/mcp/developers.mdxindex f738f06be..ffbd5039c 100644--- a/fern/pages/src/mcp/developers.mdx+++ b/fern/pages/src/mcp/developers.mdx@@ -1,7 +1,7 @@---title: MCP Servers for developerssubtitle: "Guide to create and manage MCP servers"-image: "https://og.composio.dev/api/og?title=Composio%20MCP%20Servers" # image for socials+image: "https://og.composio.dev/api/og?title=MCP%20Servers%20for%20developers" # image for socialskeywords: ""hide-nav-links: true---diff --git a/fern/pages/src/providers/google.mdx b/fern/pages/src/providers/google.mdxindex 317b4e039..e28c26126 100644--- a/fern/pages/src/providers/google.mdx+++ b/fern/pages/src/providers/google.mdx@@ -1,7 +1,7 @@---title: Google Gen AI Providerslug: /providers/google-image: "https://og.composio.dev/api/og?title=Google%20Provider" # image for socials+image: "https://og.composio.dev/api/og?title=Google%20Gen%20AI%20Provider" # image for socialskeywords: ""hide-nav-links: false---diff --git a/fern/pages/src/providers/openai.mdx b/fern/pages/src/providers/openai.mdxindex a893e86f7..8fcacb907 100644--- a/fern/pages/src/providers/openai.mdx+++ b/fern/pages/src/providers/openai.mdx@@ -54,7 +54,7 @@ Chat Completion API is the industry standard for building LLM-powered applicatio<CodeGroup><SnippetCodesrc="fern/snippets/providers/python/openai-provider.py"- startLine={10}+ startLine={9}endLine={24}/><SnippetCodediff --git a/fern/pages/src/providers/py-custom.mdx b/fern/pages/src/providers/py-custom.mdxindex c734e7946..54ebf65d6 100644--- a/fern/pages/src/providers/py-custom.mdx+++ b/fern/pages/src/providers/py-custom.mdx@@ -1,6 +1,6 @@---title: Python custom provider-image: "https://og.composio.dev/api/og?title=Python%20Custom%20Provider" # image for socials+image: "https://og.composio.dev/api/og?title=Python%20custom%20provider" # image for socialskeywords: ""hide-nav-links: false---diff --git a/fern/scripts/build-snippets.ts b/fern/scripts/build-snippets.tsindex 7e0cb113e..c29c99e6d 100644--- a/fern/scripts/build-snippets.ts+++ b/fern/scripts/build-snippets.ts@@ -40,6 +40,7 @@ interface SnippetCodeProps {relativeHighlightStart?: number;relativeHighlightEnd?: number;path?: string;+ vars?: Record<string, string>;}// Parse GitHub URL and extract components@@ -142,6 +143,40 @@ function ensureDistDir() {fs.mkdirSync(PAGES_DIST_DIR, { recursive: true });}+// Replace template variables in content+function replaceTemplateVariables(content: string, vars: Record<string, string> = {}): string {+ // Replace {{variable}} patterns with their values+ return content.replace(/\{\{(\w+)(?:\|(\w+)(?::([^}]+))?)?\}\}/g, (match, varName, transform, defaultValue) => {+ let value = vars[varName];++ // Use default value if variable not found+ if (value === undefined || value === null) {+ if (defaultValue !== undefined) {+ value = defaultValue.replace(/^["']|["']$/g, ''); // Remove quotes from default value+ } else {+ return match; // Keep original placeholder if no value and no default+ }+ }++ // Apply transformations+ if (transform) {+ switch (transform.toLowerCase()) {+ case 'lower':+ value = value.toLowerCase();+ break;+ case 'upper':+ value = value.toUpperCase();+ break;+ case 'title':+ value = value.charAt(0).toUpperCase() + value.slice(1).toLowerCase();+ break;+ }+ }++ return value;+ });+}+function getLanguageFromPath(filePath: string): { syntax: string; displayName: string } {const extension = filePath.split('.').pop()?.toLowerCase();const languageMap: Record<string, { syntax: string; displayName: string }> = {@@ -185,6 +220,30 @@ function readFileLines(// If the path starts with './' or '../', resolve it relative to the context directoryif (filePath.startsWith('./') || filePath.startsWith('../')) {fullPath = path.resolve(contextDir, filePath);+ } else if (filePath.startsWith('fern/')) {+ // For paths starting with 'fern/', we need to find the actual fern directory+ // The MDX file might be in tools/, pages/dist/, etc., but we want to resolve+ // relative to the actual fern directory++ // Try multiple possible locations for the fern directory+ const possiblePaths = [+ path.resolve(PROJECT_ROOT, '..', filePath), // composio1/fern/...+ path.resolve(PROJECT_ROOT, filePath), // Already in fern/...+ path.resolve(contextDir, '..', '..', filePath), // Relative to context+ ];++ // Find the first path that exists+ for (const possiblePath of possiblePaths) {+ if (fs.existsSync(possiblePath)) {+ fullPath = possiblePath;+ break;+ }+ }++ if (!fullPath) {+ // If none found, use the most likely path+ fullPath = path.resolve(PROJECT_ROOT, '..', filePath);+ }} else {// Otherwise, resolve it relative to the project rootfullPath = path.resolve(PROJECT_ROOT, filePath);@@ -198,7 +257,7 @@ function readFileLines(return lines.slice(start, end).join('\n');} catch (error) {- console.warn(`⚠️ Failed to read file: ${filePath}`, error);+ console.warn(`⚠️ Failed to read file: ${filePath} (resolved to: ${fullPath})`, error);return `// File not found: ${filePath}`;}}@@ -285,6 +344,23 @@ async function parseSnippetCodeTags(content: string, contextDir: string): PromisrelativeHighlightEndMatch[1] || relativeHighlightEndMatch[2]);+ // Extract vars object prop+ const varsMatch = propsString.match(/vars=\{({[^}]*})\}/);+ if (varsMatch) {+ try {+ // Parse the vars object - need to handle JSX syntax+ const varsString = varsMatch[1];+ // Convert JSX object syntax to JSON+ const jsonString = varsString+ .replace(/(\w+):/g, '"$1":') // Add quotes around keys+ .replace(/:\s*"([^"]+)"/g, ':"$1"') // Ensure values are quoted+ .replace(/:\s*'([^']+)'/g, ':"$1"'); // Convert single quotes to double+ props.vars = JSON.parse(`{${jsonString}}`);+ } catch (error) {+ console.warn(`⚠️ Failed to parse vars prop: ${varsMatch[1]}`);+ }+ }+// Extract wordWrap boolean propconst wordWrapMatch = propsString.match(/wordWrap=(?:["']?(true|false)["']?|{(true|false)})/);if (wordWrapMatch) {@@ -331,6 +407,11 @@ async function parseSnippetCodeTags(content: string, contextDir: string): PromisfilePath = props.src!;langInfo = getLanguageFromPath(filePath);}++ // Apply variable replacements if vars are provided+ if (props.vars && Object.keys(props.vars).length > 0) {+ codeContent = replaceTemplateVariables(codeContent, props.vars);+ }} catch (error) {const errorMessage = error instanceof SnippetCodeError ? error.message : `Unexpected error: ${error.message}`;console.error(`❌ SnippetCode Error: ${errorMessage}`);diff --git a/fern/turbo.json b/fern/turbo.jsonindex 4be77acd7..c704dcc85 100644--- a/fern/turbo.json+++ b/fern/turbo.json@@ -8,8 +8,13 @@"cache": true},+ "dev:deps": {+ "dependsOn": ["api:pull", "add-og", "sdkdocs", "tools:generate:dev", "snippets:build"],+ "cache": false+ },+"dev": {- "dependsOn": ["api:pull", "sdkdocs", "tools:generate:dev", "snippets:build"],+ "dependsOn": ["dev:deps"],"persistent": true,"cache": false},@@ -20,7 +25,6 @@},"add-og": {- "dependsOn": ["^build"],"inputs": ["scripts/add_og_imgs.py", "pages/**/*.mdx"],"cache": false},@@ -39,13 +43,13 @@"tools:generate": {"outputs": ["tools/**"],- "inputs": ["generators/tool_doc_generator/**/*.py"],+ "inputs": ["generators/tool_doc_generator/**/*.py", "generators/tool_doc_generator/templates/**/*"],"cache": true,"env": ["COMPOSIO_API_KEY"]},"tools:generate:dev": {"cache": false,- "inputs": ["generators/tool_doc_generator/**/*.py"],+ "inputs": ["generators/tool_doc_generator/**/*.py", "generators/tool_doc_generator/templates/**/*"],"env": ["COMPOSIO_API_KEY", "LIMIT"]},diff --git a/uv.lock b/uv.lockindex 9a36472da..4a9b6338b 100644--- a/uv.lock+++ b/uv.lock@@ -467,7 +467,7 @@ wheels = [[[package]]name = "composio"-version = "1.0.0rc9"+version = "1.0.0rc10"source = { virtual = "python" }dependencies = [{ name = "composio-client" },@@ -514,7 +514,7 @@ dev = [[[package]]name = "composio-anthropic"-version = "1.0.0rc9"+version = "1.0.0rc10"source = { virtual = "python/providers/anthropic" }dependencies = [{ name = "anthropic" },@@ -546,7 +546,7 @@ wheels = [[[package]]name = "composio-crewai"-version = "1.0.0rc9"+version = "1.0.0rc10"source = { virtual = "python/providers/crewai" }dependencies = [{ name = "composio" },@@ -561,7 +561,7 @@ requires-dist = [[[package]]name = "composio-gemini"-version = "1.0.0rc9"+version = "1.0.0rc10"source = { virtual = "python/providers/gemini" }dependencies = [{ name = "composio" },@@ -576,7 +576,7 @@ requires-dist = [[[package]]name = "composio-google"-version = "1.0.0rc9"+version = "1.0.0rc10"source = { virtual = "python/providers/google" }dependencies = [{ name = "composio" },@@ -591,7 +591,7 @@ requires-dist = [[[package]]name = "composio-google-adk"-version = "1.0.0rc9"+version = "1.0.0rc10"source = { virtual = "python/providers/google_adk" }dependencies = [{ name = "composio" },@@ -606,7 +606,7 @@ requires-dist = [[[package]]name = "composio-langchain"-version = "1.0.0rc9"+version = "1.0.0rc10"source = { virtual = "python/providers/langchain" }dependencies = [{ name = "composio" },@@ -621,7 +621,7 @@ requires-dist = [[[package]]name = "composio-openai"-version = "1.0.0rc9"+version = "1.0.0rc10"source = { virtual = "python/providers/openai" }dependencies = [{ name = "composio" },@@ -636,7 +636,7 @@ requires-dist = [[[package]]name = "composio-openai-agents"-version = "1.0.0rc9"+version = "1.0.0rc10"source = { virtual = "python/providers/openai_agents" }dependencies = [{ name = "composio" },