Skip to main content
Glama
leejersey

Hexo Blog MCP Server

by leejersey

list_posts

Retrieve and filter blog posts by title or tag keywords to manage content in Hexo blogging workflows.

Instructions

列出所有博客文章,支持按关键词过滤标题和标签

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keywordNo可选的过滤关键词

Implementation Reference

  • The implementation of the `listPosts` function, which reads Markdown files from the posts directory, parses their front-matter, applies keyword filtering, and returns the sorted post metadata.
    export async function listPosts(keyword?: string): Promise<PostMeta[]> {
        const files = await fs.readdir(POSTS_DIR);
        const mdFiles = files.filter((f) => f.endsWith(".md"));
    
        const posts: PostMeta[] = [];
    
        for (const file of mdFiles) {
            const fullPath = path.join(POSTS_DIR, file);
            const raw = await fs.readFile(fullPath, "utf-8");
            const { data, content } = matter(raw);
    
            const meta: PostMeta = {
                title: data.title || file.replace(/\.md$/, ""),
                date: data.date ? String(data.date) : "未知",
                tags: Array.isArray(data.tags) ? data.tags : data.tags ? [data.tags] : [],
                filename: file,
                wordCount: content.length,
            };
    
            if (keyword) {
                const kw = keyword.toLowerCase();
                if (
                    meta.title.toLowerCase().includes(kw) ||
                    meta.tags.some((t) => t.toLowerCase().includes(kw))
                ) {
                    posts.push(meta);
                }
            } else {
                posts.push(meta);
            }
        }
    
        return posts.sort(
            (a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()
        );
    }
  • The registration of the "list_posts" tool, which invokes the `listPosts` helper and formats the results for the MCP response.
    server.tool(
        "list_posts",
        "列出所有博客文章,支持按关键词过滤标题和标签",
        { keyword: z.string().optional().describe("可选的过滤关键词") },
        async ({ keyword }) => {
            try {
                const posts = await listPosts(keyword);
                const summary = posts
                    .map(
                        (p, i) =>
                            `${i + 1}. 【${p.title}】\n   日期: ${p.date} | 标签: ${p.tags.join(", ") || "无"} | 字数: ${p.wordCount}\n   文件: ${p.filename}`
                    )
                    .join("\n\n");
                return {
                    content: [
                        {
                            type: "text" as const,
                            text: `共 ${posts.length} 篇文章:\n\n${summary}`,
                        },
                    ],
                };
            } catch (e: any) {
                return { content: [{ type: "text" as const, text: `错误: ${e.message}` }], isError: true };
            }
        }
    );
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states it's a listing/filtering operation but doesn't describe return format, pagination behavior, permissions required, rate limits, or whether it's read-only versus destructive. The description is minimal and lacks important behavioral context.

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

Conciseness4/5

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

The description is a single, efficient sentence that states the core functionality upfront. There's no wasted verbiage, though it could be slightly more structured by separating listing from filtering capabilities.

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?

For a listing tool with no annotations and no output schema, the description is insufficient. It doesn't explain what information is returned (post titles, IDs, dates, content snippets?), format, pagination, or error conditions. Given the complexity of blog post listing and the lack of structured metadata, more completeness is needed.

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?

Schema description coverage is 100%, so the schema already documents the single optional 'keyword' parameter. The description adds marginal value by specifying that filtering applies to '标题和标签' (title and tags), which provides slightly more context than the schema's '可选的过滤关键词' (optional filtering keyword). Baseline 3 is appropriate when schema does most of the work.

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: '列出所有博客文章' (list all blog posts) with the specific capability '支持按关键词过滤标题和标签' (supports filtering by keyword in title and tags). It uses a specific verb ('列出' - list) and resource ('博客文章' - blog posts), but doesn't explicitly distinguish it from sibling tools like 'search_posts' or 'read_post'.

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 'search_posts' or 'read_post'. It mentions filtering capability but doesn't clarify if this is for broad listing versus targeted searching, or any prerequisites for use.

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/leejersey/hexo-mcp-server'

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