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
| Name | Required | Description | Default |
|---|---|---|---|
| filename | Yes | 文章文件名,如 react-hooks笔记.md |
Implementation Reference
- src/utils/post-manager.ts:112-126 (handler)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, }; } - src/tools/post-tools.ts:69-85 (registration)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 }; } } );