Skip to main content
Glama

get-library-templates

Retrieve all available image templates from Orshot's library to use with your API key for generating customized images.

Instructions

Get all available library templates for the user using their API key

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
apiKeyNoOrshot API key for authentication (optional if set in environment)

Implementation Reference

  • The handler function for the 'get-library-templates' tool. It fetches the list of library templates from the Orshot API endpoint '/v1/templates' using the provided API key (or environment variable), processes the response, formats a readable list including template details and modifications, and returns it as MCP content. Handles errors and empty lists gracefully.
    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/templates`, { method: "GET", headers: { "Authorization": `Bearer ${actualApiKey}`, "Content-Type": "application/json", }, }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const templates = await response.json(); const templateArray = Array.isArray(templates) ? templates : []; if (templateArray.length === 0) { return { content: [ { type: "text", text: "No library templates found for your account.", }, ], }; } const templateList = templateArray.map((template: any, index: number) => { const modifications = template.modifications || []; const modificationsList = modifications.length > 0 ? modifications.map((mod: any) => ` - ${mod.key}: ${mod.description || 'No description'}`).join('\n') : ' - No modifications available'; return `${index + 1}. **${template.title || 'Untitled'}** ID: ${template.id} Description: ${template.description || 'No description'} Available Modifications: ${modificationsList}`; }).join('\n\n'); return { content: [ { type: "text", text: `Found ${templateArray.length} library template(s):\n\n${templateList}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Failed to fetch library templates: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], }; } }
  • Input schema for the 'get-library-templates' tool using Zod. Defines an optional 'apiKey' string parameter.
    apiKey: z.string().optional().describe("Orshot API key for authentication (optional if set in environment)"), }, async (args) => {
  • src/index.ts:1080-1160 (registration)
    Registration of the 'get-library-templates' tool on the MCP server using server.tool(). Includes the tool name, description, input schema, and inline handler function.
    "get-library-templates", "Get all available library 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/templates`, { method: "GET", headers: { "Authorization": `Bearer ${actualApiKey}`, "Content-Type": "application/json", }, }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const templates = await response.json(); const templateArray = Array.isArray(templates) ? templates : []; if (templateArray.length === 0) { return { content: [ { type: "text", text: "No library templates found for your account.", }, ], }; } const templateList = templateArray.map((template: any, index: number) => { const modifications = template.modifications || []; const modificationsList = modifications.length > 0 ? modifications.map((mod: any) => ` - ${mod.key}: ${mod.description || 'No description'}`).join('\n') : ' - No modifications available'; return `${index + 1}. **${template.title || 'Untitled'}** ID: ${template.id} Description: ${template.description || 'No description'} Available Modifications: ${modificationsList}`; }).join('\n\n'); return { content: [ { type: "text", text: `Found ${templateArray.length} library template(s):\n\n${templateList}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Failed to fetch library templates: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], }; } } );

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