Hexo Blog MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
npm install
npm run build
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add -e "BLOG_ROOT=${BLOG_ROOT}" hexo-blog -- node "<FULL_PATH_TO_HEXO_MCP_SERVER>/dist/index.js"

Replace <FULL_PATH_TO_HEXO_MCP_SERVER>/dist/index.js with the actual folder you prepared in step 1.

Required:BLOG_ROOT
README.md

Manage your Hexo blog directly from AI clients like Claude Desktop and Cursor.

🚀 Hexo Blog MCP Server

一个基于 Model Context Protocol 的 Hexo 博客管理服务器,让 AI 客户端(Claude Desktop、Cursor 等)能够直接管理你的 Hexo 博客。

✨ 功能特性

  • 📝 文章管理 — 列出、搜索、读取、创建、编辑、删除博客文章
  • 👀 本地预览 — 一键启动/停止 Hexo 本地预览服务器
  • 🌐 一键发布 — 构建并部署到 GitHub Pages
  • 💾 源码备份 — 自动 Git 提交并推送到 hexo-source 分支
  • 🔒 安全防护 — 路径沙盒、分支锁定、命令超时保护

📦 安装

# 克隆或进入项目目录
cd /Users/lizexi/Documents/AI/aiMcp/hexo-mcp-server

# 安装依赖
npm install

# 构建
npm run build

⚙️ MCP 客户端配置

在你的 AI 客户端中添加以下 MCP 配置:

Claude Desktop

编辑 ~/Library/Application Support/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "hexo-blog": {
      "command": "node",
      "args": ["/Users/lizexi/Documents/AI/aiMcp/hexo-mcp-server/dist/index.js"],
      "env": {
        "BLOG_ROOT": "/Users/lizexi/Documents/code/leejersey.github.io"
      }
    }
  }
}

Cursor

在 Cursor Settings → MCP 中添加相同配置。

🛠️ 可用的 Tools

文章管理

工具 参数 功能
list_posts keyword? 列出所有文章,支持按关键词过滤标题和标签
search_posts query 按关键词全文搜索文章(标题+正文)
read_post filename 读取指定文章的完整内容(含 Front-matter)
create_post title, content?, tags? 创建新文章并自动生成 Front-matter
update_post filename, content, title?, tags? 修改文章内容或元数据
delete_post filename 删除指定文章

博客操作

工具 功能
preview_blog 执行 hexo clean && hexo g && hexo s,启动本地预览(localhost:4000)
stop_preview 停止正在运行的预览服务器
deploy_blog 执行 hexo clean && hexo g && hexo d,发布到 GitHub Pages

Git 操作

工具 参数 功能
backup_source message? Git add → commit → push 到 hexo-source 分支
quick_publish message? 一键完成 deploy + backup 组合操作
git_status 查看当前工作区的 Git 状态

📚 可用的 Resources

URI 描述
blog://config/site 站点配置 _config.yml 的内容
blog://config/theme Apollo 主题配置 _config.apollo.yml 的内容
blog://posts/summary 所有文章的元数据汇总(标题、日期、标签、字数)

🏗️ 项目结构

src/
├── index.ts              # MCP 服务器入口
├── config.ts             # 路径与常量配置
├── tools/
│   ├── post-tools.ts     # 文章管理工具(6个)
│   ├── hexo-tools.ts     # 构建/预览/部署工具(3个)
│   └── git-tools.ts      # Git 操作工具(3个)
├── resources/
│   └── blog-resources.ts # 博客数据资源(3个)
└── utils/
    ├── post-manager.ts   # 文章文件操作核心逻辑
    ├── hexo-runner.ts    # shell/hexo 命令封装
    └── git-runner.ts     # git 命令封装

🔧 技术栈

  • TypeScript + Node.js 18+
  • @modelcontextprotocol/sdk — MCP 官方 SDK(stdio 传输)
  • zod — 工具参数验证
  • gray-matter — Hexo 文章 Front-matter 解析

📄 License

MIT

Tools (12)

list_postsList all blog posts with optional keyword filtering.
search_postsFull-text search through blog posts.
read_postRead the full content of a specific post.
create_postCreate a new blog post with auto-generated front-matter.
update_postUpdate an existing post's content or metadata.
delete_postDelete a specific blog post.
preview_blogStart the local Hexo preview server.
stop_previewStop the running preview server.
deploy_blogBuild and deploy the blog to GitHub Pages.
backup_sourceGit commit and push source files to the hexo-source branch.
quick_publishPerform both deployment and source backup.
git_statusCheck the current Git status of the blog repository.

Environment Variables

BLOG_ROOTrequiredThe absolute path to the root directory of your Hexo blog.

Configuration

claude_desktop_config.json
{"mcpServers": {"hexo-blog": {"command": "node", "args": ["/path/to/hexo-mcp-server/dist/index.js"], "env": {"BLOG_ROOT": "/path/to/your/blog"}}}}

Try it

Create a new blog post titled 'My First AI-Generated Post' with tags 'AI' and 'Hexo'.
Search for all posts containing the word 'tutorial' and summarize them.
Start the local preview server so I can check my recent changes.
Deploy my blog to GitHub Pages and backup the source code to Git.
Read the content of 'hello-world.md' and update the title to 'Welcome to My Blog'.

Frequently Asked Questions

What are the key features of Hexo Blog?

Full CRUD operations for blog articles. Integrated local preview server management. One-click deployment to GitHub Pages. Automated Git source code backups. Access to site and theme configuration files.

What can I use Hexo Blog for?

Drafting and publishing blog posts entirely through an AI chat interface.. Automating the deployment workflow for static site maintenance.. Managing blog metadata and configuration without manual file editing.. Maintaining consistent Git backups of blog source files during content creation..

How do I install Hexo Blog?

Install Hexo Blog by running: npm install && npm run build

What MCP clients work with Hexo Blog?

Hexo Blog works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Hexo Blog docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare