Skip to main content
Glama
La-fe
by La-fe

validate_blog

Validate blog post data against a Zod schema to ensure required fields and proper formatting before publishing.

Instructions

Validate blog data using Zod schema without posting

Input Schema

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

Implementation Reference

  • Handler for the 'validate_blog' tool that invokes cmsClient.validateBlogData and formats success/error responses.
    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 (BlogPostSchema) used for validating the input data structure of the blog post.
    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:186-204 (registration)
    Tool registration in ListToolsRequestHandler, defining name, description, and input schema matching the Zod schema.
    {
      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 in CMSBlogClient.validateBlogData method using BlogPostSchema.parse, returns structured success/error response.
    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: ['未知验证错误'] }
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses that validation occurs 'without posting', indicating a read-only, non-destructive operation. However, it lacks details on behavioral traits like error handling, output format, rate limits, or permissions needed. For a validation tool with zero annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence: 'Validate blog data using Zod schema without posting'. It is front-loaded with the core purpose, has zero wasted words, and appropriately sized for the tool's complexity, earning a top score for conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (9 parameters, 4 required), no annotations, no output schema, and 0% schema description coverage, the description is incomplete. It covers the basic purpose but lacks details on validation rules, error responses, or how results are returned, making it inadequate for effective tool use without additional context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate by explaining parameters. It mentions 'blog data' but does not detail what fields are validated (e.g., title, content) or their semantics. With 9 parameters and no schema descriptions, the description adds minimal value beyond the schema's structure, failing to adequately clarify parameter meanings.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Validate blog data using Zod schema without posting'. It specifies the verb (validate), resource (blog data), and method (Zod schema), and distinguishes it from siblings by emphasizing 'without posting'. However, it doesn't explicitly differentiate from validation-like siblings if any exist, keeping it at 4 rather than 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by stating 'without posting', suggesting this tool is for validation before creation/posting, which aligns with siblings like 'post_blog'. However, it lacks explicit guidance on when to use this vs. alternatives (e.g., 'create_note' or 'write_note'), no exclusions, and no prerequisites, making it adequate but with gaps.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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