Skip to main content
Glama

validate_blog

Validate blog post data against schema requirements to ensure proper formatting and completeness before publication.

Instructions

Validate blog data using Zod schema without posting

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
author_avatar_urlNo
author_nameNo
contentYes
cover_urlNo
descriptionYes
localeNo
slugYes
statusNo
titleYes

Implementation Reference

  • Handler for the 'validate_blog' tool call, which invokes cmsClient.validateBlogData and formats the response.
    case 'validate_blog': { try { // 验证博客数据但不发布 const validation = cmsClient.validateBlogData(request.params.arguments || {}) if (validation.success) { return { content: [ { type: 'text', text: `✅ Blog data validation successful!\nValidated data: ${JSON.stringify(validation.data, null, 2)}`, }, ], } } else { return { content: [ { type: 'text', text: `❌ Blog data validation failed!\nErrors: ${validation.errors?.join(', ')}`, }, ], } } } catch (error) { throw new Error(`Validation error: ${error instanceof Error ? error.message : String(error)}`) } }
  • Zod schema used for validating blog post data in validateBlogData method.
    export const BlogPostSchema = z.object({ title: z.string().min(1, '标题不能为空'), description: z.string().min(1, '描述不能为空'), content: z.string().min(1, '内容不能为空'), slug: z.string().min(1, 'URL 地址不能为空'), status: z.enum(['draft', 'published']).default('draft'), cover_url: z.url('封面图片 URL 格式不正确').default('https://example.com/cover.jpg'), author_name: z.string().default('Lafe'), author_avatar_url: z.url('作者头像 URL 格式不正确').default('https://example.com/avatar.jpg'), locale: z.string().default('en'), })
  • src/index.ts:187-204 (registration)
    Tool registration in ListToolsRequestSchema handler, including name, description, and inputSchema.
    name: 'validate_blog', description: 'Validate blog data using Zod schema without posting', inputSchema: { type: 'object', properties: { title: { type: 'string' }, description: { type: 'string' }, content: { type: 'string' }, slug: { type: 'string' }, status: { type: 'string' }, cover_url: { type: 'string' }, author_name: { type: 'string' }, author_avatar_url: { type: 'string' }, locale: { type: 'string' }, }, required: ['title', 'description', 'content', 'slug'], }, },
  • Core validation logic that uses BlogPostSchema to validate input data and returns success/data or errors.
    validateBlogData(blogData: any): { success: boolean; data?: BlogPost; errors?: string[] } { try { const validatedData = BlogPostSchema.parse(blogData) return { success: true, data: validatedData } } catch (error) { if (error instanceof z.ZodError) { const errors = error.issues.map((err: any) => `${err.path.join('.')}: ${err.message}`) return { success: false, errors } } return { success: false, errors: ['未知验证错误'] } } }

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/La-fe/seo-mcp'

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