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 23, 00:30 UTC
feat: create script to add opengraph images. (#1626)
Siddharth Balyan committed
Jun 12, 2025 at 10:21 UTC
4921ddfe08866cd4883e68fbc7ab1a8d513f9ab0
30 files changed
+252
-31
fern/pages/authentication/custom-auth-configs.mdx
+1
-1
@@ -1,6 +1,6 @@
1
---
2
title: Custom Auth Configs
3
-image: "" # image for socials
3
+image: "https://og.composio.dev/api/og?title=Custom%20Auth%20Configs" # image for socials
4
subtitle: "Guide to using customising auth configs for a toolkit "
5
keywords: ""
6
hide-nav-links: true
fern/pages/authentication/custom-auth-params.mdx
+1
-1
@@ -1,6 +1,6 @@
1
---
2
title: Custom Auth Parameters
3
-image: "" # image for socials
3
+image: "https://og.composio.dev/api/og?title=Custom%20Auth%20Parameters" # image for socials
4
subtitle: "Guide to injecting custom credentials in headers or parameters for a toolkit"
5
keywords: ""
6
hide-nav-links: true
fern/pages/authentication/programmatic-auth-configs.mdx
+1
-1
@@ -1,6 +1,6 @@
1
---
2
title: Programmatic Auth Configs
3
-image: "" # image for socials
3
+image: "https://og.composio.dev/api/og?title=Programmatic%20Auth%20Configs" # image for socials
4
subtitle: "Guide to creating auth configs programmatically"
5
keywords: ""
6
hide-nav-links: true
fern/pages/examples/src/hello-world.mdx
+1
-1
@@ -1,6 +1,6 @@
1
---
2
title: Hello World!
3
-image: "" # image for socials
3
+image: "https://og.composio.dev/api/og?title=Hello%20World%21" # image for socials
4
description: "A simple example of how to use the Composio SDK to call tools."
5
keywords: "hello world, composio, sdk, tool calling"
6
subtitle: ""
fern/pages/examples/src/sample-script/sample-script.mdx
+1
-1
@@ -1,6 +1,6 @@
1
---
2
title: Sample Script
3
-image: "" # image for socials
3
+image: "https://og.composio.dev/api/og?title=Sample%20Script" # image for socials
4
description: "A simple example of python script that uses the Composio SDK to call tools."
5
keywords: "hello world python, composio, sdk, tool calling"
6
subtitle: ""
fern/pages/examples/src/sample-webserver/sample-webserver.mdx
+1
-1
@@ -1,6 +1,6 @@
1
---
2
title: A basic web server
3
-image: "" # image for socials
3
+image: "https://og.composio.dev/api/og?title=A%20basic%20web%20server" # image for socials
4
description: "A simple example of a web server that uses the Composio SDK to call tools."
5
keywords: "web server, composio, sdk, tool calling"
6
subtitle: ""
fern/pages/examples/src/vercel-composio.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: Fully featured AI chatbot with Composio
3
slug: /examples/vercel
4
-image: ""
4
+image: "https://og.composio.dev/api/og?title=Fully%20featured%20AI%20chatbot%20with%20Composio" # image for socials
5
keywords: ""
6
hide-nav-links: false
7
---
fern/pages/get-started/dev-setup.mdx
+1
-1
@@ -2,7 +2,7 @@
2
title: IDE and Agent Setup
3
subtitle: "Setup your AI IDE and agent to help you ship faster with Composio"
4
slug: /docs/dev-setup
5
-image: "" # image for socials
5
+image: "https://og.composio.dev/api/og?title=IDE%20and%20Agent%20Setup" # image for socials
6
keywords: ""
7
hide-nav-links: false
8
---
fern/pages/get-started/providers.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: Providers
3
slug: /docs/toolsets
4
-image: "" # image for socials
4
+image: "https://og.composio.dev/api/og?title=Providers" # image for socials
5
keywords: ""
6
hide-nav-links: false
7
---
fern/pages/get-started/quickstart.mdx
+3
-3
@@ -1,6 +1,6 @@
1
---
2
title: Quickstart
3
-image: "" # image for socials
3
+image: "https://og.composio.dev/api/og?title=Quickstart" # image for socials
4
description: "Add authenticated tool-calling to any LLM agent in three steps."
5
keywords: ""
6
subtitle: ""
@@ -90,7 +90,7 @@ print(result)
90
```
91
</Tab>
92
<Tab title="Anthropic (Typescript)">
93
-You may install the Anthropic SDK as well!
93
+You may install the Anthropic provider as well!
94
95
**Installation**
96
```bash
@@ -135,7 +135,7 @@ console.log("✅ Tool results:", result);
135
```
136
</Tab>
137
<Tab title="Vercel AI SDK (Typescript)">
138
-You may install the Vercel AI SDK as well!
138
+You may install the Vercel AI provider as well!
139
140
**Installation**
141
```bash
fern/pages/get-started/welcome.mdx
+1
-1
@@ -1,6 +1,6 @@
1
---
2
title: Welcome to Composio
3
-image: "" # image for socials
3
+image: "https://og.composio.dev/api/og?title=Welcome%20to%20Composio" # image for socials
4
keywords: ""
5
subtitle: "Our API and SDKs enable developers to build AI applications and experiences that are a step above the rest."
6
hide-nav-links: false
fern/pages/mcp/introduction.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: Composio MCP Servers
3
subtitle: "Guide to working with Composio MCP servers"
4
-image: "" # image for socials
4
+image: "https://og.composio.dev/api/og?title=Composio%20MCP%20Servers" # image for socials
5
keywords: ""
6
hide-nav-links: true
7
---
fern/pages/providers/anthropic.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: Anthropic Provider
3
slug: /providers/anthropic
4
-image: "" # image for socials
4
+image: "https://og.composio.dev/api/og?title=Anthropic%20Provider" # image for socials
5
keywords: ""
6
hide-nav-links: false
7
---
fern/pages/providers/crewai.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: CrewAI Provider
3
slug: /providers/crewai
4
-image: "" # image for socials
4
+image: "https://og.composio.dev/api/og?title=CrewAI%20Provider" # image for socials
5
keywords: ""
6
hide-nav-links: false
7
---
fern/pages/providers/custom.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: Custom Providers
3
slug: /toolsets/custom
4
-image: "" # image for socials
4
+image: "https://og.composio.dev/api/og?title=Custom%20Providers" # image for socials
5
keywords: ""
6
hide-nav-links: false
7
---
fern/pages/providers/google-adk.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: Google ADK Provider
3
slug: /providers/google-adk
4
-image: "" # image for socials
4
+image: "https://og.composio.dev/api/og?title=Google%20ADK%20Provider" # image for socials
5
keywords: ""
6
hide-nav-links: false
7
---
fern/pages/providers/langgraph.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: LangGraph Provider
3
slug: /providers/langgraph
4
-image: "" # image for socials
4
+image: "https://og.composio.dev/api/og?title=LangGraph%20Provider" # image for socials
5
keywords: ""
6
hide-nav-links: false
7
---
fern/pages/providers/mastra.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: Mastra Provider
3
slug: /providers/mastra
4
-image: "" # image for socials
4
+image: "https://og.composio.dev/api/og?title=Mastra%20Provider" # image for socials
5
keywords: ""
6
hide-nav-links: false
7
---
fern/pages/providers/openai-agents.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: OpenAI Agents Provider
3
slug: /providers/openai-agents
4
-image: "" # image for socials
4
+image: "https://og.composio.dev/api/og?title=OpenAI%20Agents%20Provider" # image for socials
5
keywords: ""
6
hide-nav-links: false
7
---
fern/pages/providers/openai.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: OpenAI Providers
3
slug: /providers/openai
4
-image: "" # image for socials
4
+image: "https://og.composio.dev/api/og?title=OpenAI%20Providers" # image for socials
5
keywords: ""
6
hide-nav-links: false
7
---
fern/pages/providers/vercel.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: Vercel AI SDK Provider
3
slug: /providers/vercel
4
-image: "" # image for socials
4
+image: "https://og.composio.dev/api/og?title=Vercel%20AI%20SDK%20Provider" # image for socials
5
keywords: ""
6
hide-nav-links: false
7
---
fern/pages/tool-calling/after-execution-modifiers.mdx
+1
-1
@@ -1,6 +1,6 @@
1
---
2
title: After Execution Modifiers
3
-image: "" # image for socials
3
+image: "https://og.composio.dev/api/og?title=After%20Execution%20Modifiers" # image for socials
4
keywords: ""
5
subtitle: "Learn how to use after execution modifiers to transform tool results after execution."
6
hide-nav-links: false
fern/pages/tool-calling/authenticating-tools.mdx
+1
-1
@@ -1,6 +1,6 @@
1
---
2
title: Authenticating Tools
3
-image: "" # image for socials
3
+image: "https://og.composio.dev/api/og?title=Authenticating%20Tools" # image for socials
4
keywords: ""
5
subtitle: "Learn how to authenticate tools"
6
hide-nav-links: false
fern/pages/tool-calling/before-execution-modifiers.mdx
+1
-1
@@ -1,6 +1,6 @@
1
---
2
title: Before Execution Modifiers
3
-image: "" # image for socials
3
+image: "https://og.composio.dev/api/og?title=Before%20Execution%20Modifiers" # image for socials
4
keywords: ""
5
subtitle: "Learn how to use before execution modifiers to modify tool arguments before execution."
6
hide-nav-links: false
fern/pages/tool-calling/custom-tools.mdx
+1
-1
@@ -1,6 +1,6 @@
1
---
2
title: Creating custom tools
3
-image: "" # image for socials
3
+image: "https://og.composio.dev/api/og?title=Creating%20custom%20tools" # image for socials
4
keywords: ""
5
subtitle: "Learn how to extend Composio's toolkits with your own tools"
6
hide-nav-links: false
fern/pages/tool-calling/executing-tools.mdx
+1
-1
@@ -1,6 +1,6 @@
1
---
2
title: Executing Tools
3
-image: "" # image for socials
3
+image: "https://og.composio.dev/api/og?title=Executing%20Tools" # image for socials
4
keywords: ""
5
subtitle: "Learn how to execute Composio's tools with different providers and frameworks"
6
hide-nav-links: false
fern/pages/tool-calling/fetching-tools.mdx
+1
-1
@@ -1,6 +1,6 @@
1
---
2
title: Fetching and Filtering Tools
3
-image: "" # image for socials
3
+image: "https://og.composio.dev/api/og?title=Fetching%20and%20Filtering%20Tools" # image for socials
4
keywords: ""
5
subtitle: "Learn how to fetch and filter Composio's tools and toolsets"
6
hide-nav-links: false
fern/pages/tool-calling/schema-modifiers.mdx
+1
-1
@@ -1,6 +1,6 @@
1
---
2
title: Schema Modifiers
3
-image: "" # image for socials
3
+image: "https://og.composio.dev/api/og?title=Schema%20Modifiers" # image for socials
4
keywords: ""
5
subtitle: "Learn how to use schema modifiers to transform tool schemas before they are seen by agents."
6
hide-nav-links: false
fern/pages/triggers/using-triggers.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: Using Triggers
3
subtitle: Send payloads to your system based on external events
4
-image: "" # image for socials
4
+image: "https://og.composio.dev/api/og?title=Using%20Triggers" # image for socials
5
keywords: ""
6
hide-nav-links: true
7
---
fern/scripts/add_og_imgs.py
new
+221
@@ -0,0 +1,221 @@
1
+#!/usr/bin/env python3
2
+"""
3
+Script to update image properties in MDX frontmatter for social media previews.
4
+
5
+This script processes all MDX files in the fern/pages directory and adds or updates
6
+the 'image' property in the frontmatter with a URL that generates social media
7
+preview images based on the page title.
8
+
9
+Usage:
10
+ python scripts/update_mdx_images.py [--dry-run] [--verbose]
11
+
12
+Options:
13
+ --dry-run Show what would be changed without making actual changes
14
+ --verbose Show detailed output for all processed files
15
+"""
16
+
17
+import argparse
18
+import os
19
+import re
20
+import sys
21
+from pathlib import Path
22
+from urllib.parse import quote
23
+
24
+
25
+def extract_title_from_frontmatter(frontmatter):
26
+ """Extract the title from frontmatter string."""
27
+ # Handle different title formats:
28
+ # title: Simple Title
29
+ # title: "Quoted Title"
30
+ # title: 'Single Quoted Title'
31
+ title_patterns = [
32
+ r"^title:\s*[\"']([^\"']+)[\"']\s*$", # Quoted titles
33
+ r"^title:\s*([^#\n]+?)(?:\s*#.*)?$", # Unquoted titles (with optional comments)
34
+ ]
35
+
36
+ for pattern in title_patterns:
37
+ match = re.search(pattern, frontmatter, re.MULTILINE)
38
+ if match:
39
+ return match.group(1).strip()
40
+
41
+ return None
42
+
43
+
44
+def has_frontmatter(content):
45
+ """Check if content has valid frontmatter."""
46
+ return content.startswith("---") and content.count("---") >= 2
47
+
48
+
49
+def update_mdx_image(file_path, dry_run=False, verbose=False):
50
+ """
51
+ Update the image property in MDX frontmatter based on the title.
52
+
53
+ Args:
54
+ file_path: Path to the MDX file
55
+ dry_run: If True, don't actually modify files
56
+ verbose: If True, show detailed output
57
+
58
+ Returns:
59
+ dict: Result information with keys 'updated', 'message', 'title'
60
+ """
61
+ try:
62
+ with open(file_path, "r", encoding="utf-8") as f:
63
+ content = f.read()
64
+ except Exception as e:
65
+ return {"updated": False, "message": f"Error reading file: {e}", "title": None}
66
+
67
+ # Check if file has frontmatter
68
+ if not has_frontmatter(content):
69
+ return {"updated": False, "message": "No frontmatter found", "title": None}
70
+
71
+ # Split frontmatter and content
72
+ parts = content.split("---", 2)
73
+ if len(parts) < 3:
74
+ return {"updated": False, "message": "Invalid frontmatter format", "title": None}
75
+
76
+ frontmatter = parts[1]
77
+ body = parts[2]
78
+
79
+ # Extract title from frontmatter
80
+ title = extract_title_from_frontmatter(frontmatter)
81
+ if not title:
82
+ return {"updated": False, "message": "No title found in frontmatter", "title": None}
83
+
84
+ # Create the image URL
85
+ encoded_title = quote(title)
86
+ image_url = f'"https://og.composio.dev/api/og?title={encoded_title}"'
87
+
88
+ # Check if image property already exists
89
+ image_pattern = r"^image:\s*.*$"
90
+ image_match = re.search(image_pattern, frontmatter, re.MULTILINE)
91
+
92
+ if image_match:
93
+ # Check if it's already the correct URL
94
+ current_image_line = image_match.group(0)
95
+ if image_url in current_image_line:
96
+ return {"updated": False, "message": "Image URL already up to date", "title": title}
97
+
98
+ # Update existing image property
99
+ new_frontmatter = re.sub(
100
+ image_pattern,
101
+ f"image: {image_url} # image for socials",
102
+ frontmatter,
103
+ flags=re.MULTILINE,
104
+ )
105
+ action = "Updated existing"
106
+ else:
107
+ # Add image property after title
108
+ title_pattern = r"^title:\s*.*$"
109
+ title_match = re.search(title_pattern, frontmatter, re.MULTILINE)
110
+
111
+ if not title_match:
112
+ return {
113
+ "updated": False,
114
+ "message": "Could not find title line to insert image after",
115
+ "title": title,
116
+ }
117
+
118
+ title_line = title_match.group(0)
119
+ new_image_line = f"image: {image_url} # image for socials"
120
+ new_frontmatter = frontmatter.replace(title_line, f"{title_line}\n{new_image_line}")
121
+ action = "Added new"
122
+
123
+ # Don't write if dry run
124
+ if dry_run:
125
+ return {"updated": True, "message": f"{action} image property (DRY RUN)", "title": title}
126
+
127
+ # Reconstruct the file content
128
+ new_content = f"---{new_frontmatter}---{body}"
129
+
130
+ # Write back to file
131
+ try:
132
+ with open(file_path, "w", encoding="utf-8") as f:
133
+ f.write(new_content)
134
+
135
+ return {"updated": True, "message": f"{action} image property", "title": title}
136
+ except Exception as e:
137
+ return {"updated": False, "message": f"Error writing file: {e}", "title": title}
138
+
139
+
140
+def main():
141
+ """Process all MDX files in fern/pages directory."""
142
+ parser = argparse.ArgumentParser(
143
+ description="Update image properties in MDX frontmatter for social media previews"
144
+ )
145
+ parser.add_argument(
146
+ "--dry-run",
147
+ action="store_true",
148
+ help="Show what would be changed without making actual changes",
149
+ )
150
+ parser.add_argument(
151
+ "--verbose", action="store_true", help="Show detailed output for all processed files"
152
+ )
153
+
154
+ args = parser.parse_args()
155
+
156
+ # Determine the pages directory relative to script location
157
+ script_dir = Path(__file__).parent
158
+ pages_dir = script_dir.parent / "pages"
159
+
160
+ if not pages_dir.exists():
161
+ print(f"Error: Pages directory not found at {pages_dir}")
162
+ print("Make sure to run this script from the fern directory")
163
+ sys.exit(1)
164
+
165
+ # Find all MDX files
166
+ mdx_files = list(pages_dir.rglob("*.mdx"))
167
+
168
+ if not mdx_files:
169
+ print("No MDX files found in pages directory")
170
+ return
171
+
172
+ print(f"Found {len(mdx_files)} MDX files")
173
+ if args.dry_run:
174
+ print("🔍 DRY RUN MODE - No files will be modified")
175
+ print()
176
+
177
+ # Process files
178
+ updated_count = 0
179
+ skipped_count = 0
180
+ error_count = 0
181
+
182
+ for mdx_file in sorted(mdx_files):
183
+ rel_path = mdx_file.relative_to(pages_dir)
184
+
185
+ try:
186
+ result = update_mdx_image(mdx_file, dry_run=args.dry_run, verbose=args.verbose)
187
+
188
+ if result["updated"]:
189
+ updated_count += 1
190
+ status = "✅" if not args.dry_run else "🔄"
191
+ print(f"{status} {rel_path}")
192
+ if args.verbose or args.dry_run:
193
+ print(f" Title: {result['title']}")
194
+ print(f" Action: {result['message']}")
195
+ else:
196
+ skipped_count += 1
197
+ if args.verbose:
198
+ print(f"⏭️ {rel_path}")
199
+ print(f" Reason: {result['message']}")
200
+ if result["title"]:
201
+ print(f" Title: {result['title']}")
202
+
203
+ except Exception as e:
204
+ error_count += 1
205
+ print(f"❌ {rel_path}")
206
+ print(f" Error: {e}")
207
+
208
+ # Summary
209
+ print(f"\n📊 Summary:")
210
+ print(f" Total files: {len(mdx_files)}")
211
+ print(f" Updated: {updated_count}")
212
+ print(f" Skipped: {skipped_count}")
213
+ if error_count > 0:
214
+ print(f" Errors: {error_count}")
215
+
216
+ if args.dry_run and updated_count > 0:
217
+ print(f"\n💡 Run without --dry-run to apply {updated_count} changes")
218
+
219
+
220
+if __name__ == "__main__":
221
+ main()