get-studio-templates
Retrieve available studio templates for generating images using your Orshot API key. Access pre-designed templates to create images from prompts in Claude, Cursor, or other MCP-supported applications.
Instructions
Get all available studio templates for the user using their API key
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apiKey | No | Orshot API key for authentication (optional if set in environment) |
Implementation Reference
- src/index.ts:1164-1255 (registration)Registration of the 'get-studio-templates' tool using server.tool(), including inline schema and handler function."get-studio-templates", "Get all available studio templates for the user using their API key", { apiKey: z.string().optional().describe("Orshot API key for authentication (optional if set in environment)"), }, async (args) => { const { apiKey } = args; const actualApiKey = apiKey || DEFAULT_API_KEY; if (!actualApiKey) { return { content: [ { type: "text", text: "No API key provided. Please provide an API key parameter or set ORSHOT_API_KEY environment variable.", }, ], }; } try { const response = await fetch(`${ORSHOT_API_BASE}/v1/studio/templates`, { method: "GET", headers: { "Authorization": `Bearer ${actualApiKey}`, "Content-Type": "application/json", }, }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const studioTemplates = await response.json(); const templatesArray = Array.isArray(studioTemplates) ? studioTemplates : []; if (templatesArray.length === 0) { return { content: [ { type: "text", text: "No studio templates found for your account. You may need to create templates in Orshot Studio first.", }, ], }; } const templateList = templatesArray.map((template: any, index: number) => { const modifications = template.modifications || []; const modificationsList = modifications.length > 0 ? modifications.map((mod: any) => ` - ${mod.key || mod.id}: ${mod.helpText || 'No description'} ${mod.example ? `(e.g., "${mod.example}")` : ''}`).join('\n') : ' - No modifications available'; const dimensions = template.canvas_width && template.canvas_height ? `${template.canvas_width}Ć${template.canvas_height}px` : 'Unknown'; return `${index + 1}. **${template.name || 'Untitled'}** ID: ${template.id} Description: ${template.description || 'No description'} Dimensions: ${dimensions} ${template.created_at ? `Created: ${new Date(template.created_at).toLocaleDateString()}` : ''} ${template.updated_at ? `Updated: ${new Date(template.updated_at).toLocaleDateString()}` : ''} ${template.thumbnail_url ? `Thumbnail: ${template.thumbnail_url}` : ''} Available Modifications: ${modificationsList}`; }).join('\n\n'); return { content: [ { type: "text", text: `Found ${templatesArray.length} studio template(s):\n\n${templateList} š” **Tip**: You can now use either the template ID (${templatesArray[0]?.id}) or name ("${templatesArray[0]?.name}") when generating images!`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Failed to fetch studio templates: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], }; } } );
- src/index.ts:1167-1169 (schema)Input schema for the tool using Zod: optional apiKey string.apiKey: z.string().optional().describe("Orshot API key for authentication (optional if set in environment)"), }, async (args) => {
- src/index.ts:1170-1254 (handler)Handler function that fetches studio templates from Orshot API (/v1/studio/templates), processes the list, formats a detailed markdown list with template details (ID, name, description, dimensions, created/updated dates, thumbnail, modifications), handles API key validation, errors, and empty results.const { apiKey } = args; const actualApiKey = apiKey || DEFAULT_API_KEY; if (!actualApiKey) { return { content: [ { type: "text", text: "No API key provided. Please provide an API key parameter or set ORSHOT_API_KEY environment variable.", }, ], }; } try { const response = await fetch(`${ORSHOT_API_BASE}/v1/studio/templates`, { method: "GET", headers: { "Authorization": `Bearer ${actualApiKey}`, "Content-Type": "application/json", }, }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const studioTemplates = await response.json(); const templatesArray = Array.isArray(studioTemplates) ? studioTemplates : []; if (templatesArray.length === 0) { return { content: [ { type: "text", text: "No studio templates found for your account. You may need to create templates in Orshot Studio first.", }, ], }; } const templateList = templatesArray.map((template: any, index: number) => { const modifications = template.modifications || []; const modificationsList = modifications.length > 0 ? modifications.map((mod: any) => ` - ${mod.key || mod.id}: ${mod.helpText || 'No description'} ${mod.example ? `(e.g., "${mod.example}")` : ''}`).join('\n') : ' - No modifications available'; const dimensions = template.canvas_width && template.canvas_height ? `${template.canvas_width}Ć${template.canvas_height}px` : 'Unknown'; return `${index + 1}. **${template.name || 'Untitled'}** ID: ${template.id} Description: ${template.description || 'No description'} Dimensions: ${dimensions} ${template.created_at ? `Created: ${new Date(template.created_at).toLocaleDateString()}` : ''} ${template.updated_at ? `Updated: ${new Date(template.updated_at).toLocaleDateString()}` : ''} ${template.thumbnail_url ? `Thumbnail: ${template.thumbnail_url}` : ''} Available Modifications: ${modificationsList}`; }).join('\n\n'); return { content: [ { type: "text", text: `Found ${templatesArray.length} studio template(s):\n\n${templateList} š” **Tip**: You can now use either the template ID (${templatesArray[0]?.id}) or name ("${templatesArray[0]?.name}") when generating images!`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Failed to fetch studio templates: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], }; } } );