UNPKG

@usethoth/mcp-server

Version:

Model Context Protocol server for Thoth content creation platform

82 lines 3.06 kB
import { z } from 'zod'; import { createHeaders } from '../config.js'; /** * Zod schema for get-brand-styles tool input * No parameters required for this endpoint */ export const getBrandStylesInputSchema = z.object({}); /** * Get all brand styles via the Thoth API */ export async function getBrandStyles(config) { const url = `${config.baseUrl}/api/v1/brand-styles`; const response = await fetch(url, { method: 'GET', headers: createHeaders(config.apiKey), }); if (!response.ok) { const errorData = (await response.json()); throw new Error(`API request failed: ${response.status} - ${'error' in errorData ? errorData.error : 'Unknown error'}`); } const data = (await response.json()); if (!data.success) { throw new Error(`API error: ${'error' in data ? data.error : 'Unknown error'}`); } return data.data; } /** * Format the get-brand-styles response for MCP */ export function formatGetBrandStylesResponse(brandStyles) { const lines = [`# Brand Styles`, ``, `**Total:** ${brandStyles.length}`, ``]; if (brandStyles.length === 0) { lines.push('No brand styles found.'); return lines.join('\n'); } lines.push('## Your Brand Styles'); for (const style of brandStyles) { lines.push(''); lines.push(`### ${style.name}`); lines.push(`- **ID:** ${style.id}`); lines.push(`- **Content Mode:** ${style.contentMode}`); if (style.isDefault === 'true') { lines.push(`- **Default:** Yes`); } // Add purpose if available if (style.tone?.purpose) { lines.push(`- **Purpose:** ${style.tone.purpose}`); } // Add audience if available if (style.tone?.audience) { lines.push(`- **Target Audience:** ${style.tone.audience}`); } // Add brand voice and style if (style.tone?.voice || style.tone?.style) { const voiceStyle = []; if (style.tone.voice) voiceStyle.push(style.tone.voice); if (style.tone.style) voiceStyle.push(style.tone.style); lines.push(`- **Voice & Style:** ${voiceStyle.join(', ')}`); } // Add key visual info if (style.imageryStyle && typeof style.imageryStyle !== 'string') { const visualInfo = []; if (style.imageryStyle.image_type) { visualInfo.push(style.imageryStyle.image_type); } if (style.imageryStyle.tone) { visualInfo.push(style.imageryStyle.tone); } if (visualInfo.length > 0) { lines.push(`- **Visual Style:** ${visualInfo.join(', ')}`); } } lines.push(`- **Created:** ${new Date(style.createdAt).toLocaleString()}`); if (style.updatedAt) { lines.push(`- **Updated:** ${new Date(style.updatedAt).toLocaleString()}`); } } return lines.join('\n'); } //# sourceMappingURL=get-brand-styles.js.map