Skip to main content
Glama

get-template-modifications

Retrieve modifications for specific templates in Orshot's MCP Server, supporting both library and studio templates. Use template ID or name to access available changes for dynamic image generation.

Instructions

Get available modifications for a specific template (works for both library and studio templates). For studio templates, you can use either ID or name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
apiKeyNoOrshot API key for authentication (optional if set in environment)
templateIdYesThe ID or name of the template to get modifications for
templateTypeNoType of template (library, studio, or auto-detect)auto

Implementation Reference

  • src/index.ts:1257-1265 (registration)
    Registration of the 'get-template-modifications' tool using McpServer.tool(), specifying name, description, input schema, and handler function.
    server.tool( "get-template-modifications", "Get available modifications for a specific template (works for both library and studio templates). For studio templates, you can use either ID or name.", { apiKey: z.string().optional().describe("Orshot API key for authentication (optional if set in environment)"), templateId: z.string().describe("The ID or name of the template to get modifications for"), templateType: z.enum(["library", "studio", "auto"]).default("auto").describe("Type of template (library, studio, or auto-detect)"), }, async (args) => {
  • Zod schema defining input parameters for the tool: apiKey (optional), templateId (required), templateType (optional, defaults to 'auto').
    { apiKey: z.string().optional().describe("Orshot API key for authentication (optional if set in environment)"), templateId: z.string().describe("The ID or name of the template to get modifications for"), templateType: z.enum(["library", "studio", "auto"]).default("auto").describe("Type of template (library, studio, or auto-detect)"), },
  • Main handler function that implements the tool logic: API key handling, template type detection/auto-resolution, fetching modifications via Orshot API for both library and studio templates, and formatted response.
    async (args) => { const { apiKey, templateId, templateType } = 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 { let modifications: any[] = []; let detectedType: "library" | "studio" = templateType === "auto" ? "library" : templateType; if (templateType === "auto") { // Auto-detect template type const autoDetectedType = await getTemplateType(templateId, actualApiKey); if (!autoDetectedType) { return { content: [ { type: "text", text: `Template "${templateId}" not found in either library or studio templates.`, }, ], }; } detectedType = autoDetectedType; } if (detectedType === "library") { // Get library template modifications try { // First try to get template details from the templates endpoint const templatesResponse = await fetch(`${ORSHOT_API_BASE}/v1/templates`, { method: "GET", headers: { "Authorization": `Bearer ${actualApiKey}`, "Content-Type": "application/json", }, }); if (templatesResponse.ok) { const templates = await templatesResponse.json(); const templateArray = Array.isArray(templates) ? templates : []; const selectedTemplate = templateArray.find((template: any) => template.id === templateId); if (selectedTemplate && selectedTemplate.modifications) { modifications = selectedTemplate.modifications; } } // Fallback to modifications endpoint if template doesn't have modifications if (modifications.length === 0) { const modResponse = await fetch(`${ORSHOT_API_BASE}/v1/templates/modifications?template_id=${templateId}`, { method: "GET", headers: { "Authorization": `Bearer ${actualApiKey}`, "Content-Type": "application/json", }, }); if (modResponse.ok) { const modData = await modResponse.json(); modifications = Array.isArray(modData) ? modData : []; } } } catch (error) { console.error("Error fetching library template modifications:", error); } } else if (detectedType === "studio") { // Get studio template modifications try { // First try to get template details from the templates endpoint const templatesResponse = await fetch(`${ORSHOT_API_BASE}/v1/studio/templates`, { method: "GET", headers: { "Authorization": `Bearer ${actualApiKey}`, "Content-Type": "application/json", }, }); if (templatesResponse.ok) { const templates = await templatesResponse.json(); const templatesArray = Array.isArray(templates) ? templates : []; // Find template by ID or name const selectedTemplate = templatesArray.find((template: any) => template.id === templateId || template.id === parseInt(templateId) || template.name?.toLowerCase() === templateId.toLowerCase() ); if (selectedTemplate && selectedTemplate.modifications) { modifications = selectedTemplate.modifications; } } // Fallback to the old modifications endpoint if template doesn't have modifications if (modifications.length === 0) { const resolvedTemplateId = await resolveStudioTemplateId(templateId, actualApiKey); if (resolvedTemplateId) { const response = await fetch(`${ORSHOT_API_BASE}/v1/studio/template/modifications?templateId=${resolvedTemplateId}`, { method: "GET", headers: { "Authorization": `Bearer ${actualApiKey}`, "Content-Type": "application/json", }, }); if (response.ok) { const modData = await response.json(); modifications = Array.isArray(modData) ? modData : []; } } } } catch (error) { console.error("Error fetching studio template modifications:", error); } } if (modifications.length === 0) { return { content: [ { type: "text", text: `No modifications found for ${detectedType} template "${templateId}". This template may not have any customizable elements.`, }, ], }; } const modificationsList = modifications.map((mod: any, index: number) => { const key = mod.key || mod.id; const description = mod.helpText || mod.description || 'No description'; const example = mod.example ? ` (e.g., "${mod.example}")` : ''; const type = mod.type ? ` [${mod.type}]` : ''; return `${index + 1}. **${key}**${type}${example} ${description}`; }).join('\n\n'); return { content: [ { type: "text", text: `Found ${modifications.length} modification(s) for ${detectedType} template "${templateId}":\n\n${modificationsList}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Failed to fetch template modifications: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], }; } } );
  • Helper function to auto-detect template type (library vs studio) used in the handler.
    // Helper function to determine template type (library vs studio) async function getTemplateType(templateId: string, apiKey: string): Promise<'library' | 'studio' | null> { try { // If it's a numeric ID, it's likely a studio template - check studio first if (isLikelyStudioTemplate(templateId)) { // Check studio templates first for numeric IDs const studioResponse = await fetch(`${ORSHOT_API_BASE}/v1/studio/templates`, { headers: { "Authorization": `Bearer ${apiKey}`, "Content-Type": "application/json", }, }); if (studioResponse.ok) { const studioTemplates = await studioResponse.json(); const templatesArray = Array.isArray(studioTemplates) ? studioTemplates : []; // Check if templateId exists in studio templates (supports both numeric ID and name matching) const isStudioTemplate = templatesArray.some((template: any) => template.id === templateId || template.id === parseInt(templateId) || template.name?.toLowerCase() === templateId.toLowerCase() ); if (isStudioTemplate) { return 'studio'; } } } // First check if it's a library template const libraryResponse = await fetch(`${ORSHOT_API_BASE}/v1/templates`, { headers: { "Authorization": `Bearer ${apiKey}`, "Content-Type": "application/json", }, }); if (libraryResponse.ok) { const libraryData = await libraryResponse.json(); const libraryTemplates = Array.isArray(libraryData) ? libraryData : []; // Check if templateId exists in library templates const isLibraryTemplate = libraryTemplates.some((template: any) => template.id === templateId || template.template_id === templateId ); if (isLibraryTemplate) { return 'library'; } } // If not found in library and not numeric, check studio templates (including name matching) if (!isLikelyStudioTemplate(templateId)) { const studioResponse = await fetch(`${ORSHOT_API_BASE}/v1/studio/templates`, { headers: { "Authorization": `Bearer ${apiKey}`, "Content-Type": "application/json", }, }); if (studioResponse.ok) { const studioTemplates = await studioResponse.json(); const templatesArray = Array.isArray(studioTemplates) ? studioTemplates : []; // Check if templateId exists in studio templates (supports name matching for non-numeric IDs) const isStudioTemplate = templatesArray.some((template: any) => template.id === templateId || template.name?.toLowerCase() === templateId.toLowerCase() ); if (isStudioTemplate) { return 'studio'; } } } return null; // Template not found in either } catch (error) { console.error("Error determining template type:", error); return null; } }
  • Helper function to resolve studio template ID from name, used as fallback in studio modifications fetch.
    async function resolveStudioTemplateId(templateIdOrName: string, apiKey: string): Promise<string | null> { try { // If it's already a numeric ID, return as-is if (isLikelyStudioTemplate(templateIdOrName)) { return templateIdOrName; } // Fetch studio templates to find by name const studioResponse = await fetch(`${ORSHOT_API_BASE}/v1/studio/templates`, { headers: { "Authorization": `Bearer ${apiKey}`, "Content-Type": "application/json", }, }); if (studioResponse.ok) { const studioTemplates = await studioResponse.json(); const templatesArray = Array.isArray(studioTemplates) ? studioTemplates : []; // Find template by name (case-insensitive) or exact ID match const matchedTemplate = templatesArray.find((template: any) => template.name?.toLowerCase() === templateIdOrName.toLowerCase() || template.id === templateIdOrName ); if (matchedTemplate) { logger.debug(`Resolved template name "${templateIdOrName}" to ID: ${matchedTemplate.id}`); return String(matchedTemplate.id); } } return null; // Template not found } catch (error) { logger.error("Error resolving studio template ID", { templateIdOrName, error: error instanceof Error ? error.message : String(error) }); return null; } }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rishimohan/orshot-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server