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

post_blog

Publish blog articles to a CMS API with structured validation for content management and publishing workflows.

Instructions

Post a blog article to the CMS API using Zod validation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYesTitle of the blog post
descriptionYesDescription of the blog post
contentYesContent of the blog post
slugYesURL slug for the blog post
statusNoStatus of the blog post (draft), only draft is supported
cover_urlNoCover image URL
author_nameNoAuthor name
author_avatar_urlNoAuthor avatar URL
localeNoLanguage locale

Implementation Reference

  • The MCP tool handler for 'post_blog' in the CallToolRequestSchema. It invokes cmsClient.postBlog with tool arguments and formats the response.
    case 'post_blog': {
      try {
        // 使用 CMS 客户端发布博客,内置 Zod 验证
        const result = await cmsClient.postBlog(request.params.arguments || {})
    
        return {
          content: [
            {
              type: 'text',
              text: `Successfully posted blog!\nResponse: ${JSON.stringify(result, null, 2)}`,
            },
          ],
        }
      } catch (error) {
        throw new Error(`Failed to post blog: ${error instanceof Error ? error.message : String(error)}`)
      }
    }
  • src/index.ts:140-185 (registration)
    Registration of the 'post_blog' tool in ListToolsRequestSchema handler, defining name, description, and input schema.
      name: 'post_blog',
      description: 'Post a blog article to the CMS API using Zod validation',
      inputSchema: {
        type: 'object',
        properties: {
          title: {
            type: 'string',
            description: 'Title of the blog post',
          },
          description: {
            type: 'string',
            description: 'Description of the blog post',
          },
          content: {
            type: 'string',
            description: 'Content of the blog post',
          },
          slug: {
            type: 'string',
            description: 'URL slug for the blog post',
          },
          status: {
            type: 'string',
            description: 'Status of the blog post (draft), only draft is supported',
            enum: ['draft'],
          },
          cover_url: {
            type: 'string',
            description: 'Cover image URL',
          },
          author_name: {
            type: 'string',
            description: 'Author name',
          },
          author_avatar_url: {
            type: 'string',
            description: 'Author avatar URL',
          },
          locale: {
            type: 'string',
            description: 'Language locale',
          },
        },
        required: ['title', 'description', 'content', 'slug'],
      },
    },
  • Zod schema BlogPostSchema for validating blog post input data, used in the postBlog 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'),
    })
  • Core helper function postBlog in CMSBlogClient that performs Zod validation, API POST request to CMS, and error handling.
    async postBlog(blogData: Partial<BlogPost>): Promise<BlogApiResponse> {
      try {
        // 使用 Zod 验证和标准化数据
        const validatedData = BlogPostSchema.parse(blogData)
    
        console.log('Posting blog with data:', validatedData)
    
        const response = await fetch(`${this.apiUrl}/blog`, {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json',
          },
          body: JSON.stringify(validatedData),
        })
    
        if (!response.ok) {
          throw new Error(`HTTP error! status: ${response.status} ${response.statusText}`)
        }
    
        const result = (await response.json()) as BlogApiResponse
    
        if (!result.success) {
          throw new Error(`API error: ${result.errMsg || 'Unknown error'}`)
        }
    
        return result
      } catch (error) {
        if (error instanceof z.ZodError) {
          // 处理验证错误
          const errorMessages = error.issues.map((err: any) => `${err.path.join('.')}: ${err.message}`).join(', ')
          throw new Error(`数据验证失败: ${errorMessages}`)
        }
    
        console.error('Failed to post blog:', error)
        throw error
      }
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'Zod validation' but doesn't explain what this entails (e.g., validation errors, requirements) or other traits like authentication needs, rate limits, or mutation effects. This is inadequate for a write operation tool.

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 with zero waste. It's front-loaded with the core action and includes a relevant detail ('Zod validation'), making it appropriately sized and structured.

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 of a 9-parameter mutation tool with no annotations and no output schema, the description is incomplete. It lacks details on behavioral traits, usage context, and output expectations, leaving significant gaps for an agent to understand the tool fully.

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

Parameters3/5

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

The schema description coverage is 100%, so the input schema fully documents all 9 parameters. The description adds no additional meaning beyond the schema, such as explaining 'Zod validation' in relation to parameters. Baseline 3 is appropriate as the schema does the heavy lifting.

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 action ('Post') and resource ('blog article to the CMS API'), making the purpose evident. However, it doesn't explicitly differentiate from sibling tools like 'create_note' or 'write_note', which might have overlapping functionality, preventing a perfect score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'create_note' or 'validate_blog'. It mentions 'Zod validation' but doesn't explain if this is a prerequisite or how it relates to usage, leaving the agent without clear context for selection.

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