Skip to main content
Glama
leejersey

Hexo Blog MCP Server

by leejersey

read_post

Retrieve complete Hexo blog post content including Front-matter and body text by specifying the filename. This tool enables AI clients to access and process full article data for blog management tasks.

Instructions

读取指定文章的完整内容(含 Front-matter 和正文)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYes文章文件名,如 react-hooks笔记.md

Implementation Reference

  • The actual logic that reads the post content from the file system.
    export async function readPost(filename: string): Promise<PostFull> {
        const fullPath = postPath(filename);
        const raw = await fs.readFile(fullPath, "utf-8");
        const { data, content } = matter(raw);
    
        return {
            title: data.title || filename.replace(/\.md$/, ""),
            date: data.date ? String(data.date) : "未知",
            tags: Array.isArray(data.tags) ? data.tags : data.tags ? [data.tags] : [],
            filename,
            wordCount: content.length,
            content,
            rawContent: raw,
        };
    }
  • The tool registration for "read_post" and its MCP tool handler implementation.
    // 读取文章
    server.tool(
        "read_post",
        "读取指定文章的完整内容(含 Front-matter 和正文)",
        { filename: z.string().describe("文章文件名,如 react-hooks笔记.md") },
        async ({ filename }) => {
            try {
                const post = await readPost(filename);
                const header = `# ${post.title}\n日期: ${post.date}\n标签: ${post.tags.join(", ") || "无"}\n字数: ${post.wordCount}\n---\n`;
                return {
                    content: [{ type: "text" as const, text: header + post.content }],
                };
            } catch (e: any) {
                return { content: [{ type: "text" as const, text: `错误: ${e.message}` }], isError: true };
            }
        }
    );

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