Skip to main content
Glama
leejersey

Hexo Blog MCP Server

by leejersey

preview_blog

Start a local preview server for Hexo blogs to view content changes in real-time before publishing.

Instructions

启动 Hexo 本地预览服务器(localhost:4000)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The implementation of the preview_blog tool handler in hexo-tools.ts, which starts the Hexo server.
    server.tool(
        "preview_blog",
        "启动 Hexo 本地预览服务器(localhost:4000)",
        {},
        async () => {
            try {
                // 先清理和生成
                await hexoCommand("clean");
                await hexoCommand("generate");
    
                // 启动 server(后台进程)
                if (previewProcess) {
                    previewProcess.kill();
                    previewProcess = null;
                }
    
                previewProcess = exec("npx hexo server", { cwd: BLOG_ROOT });
    
                // 等待服务启动
                await new Promise((resolve) => setTimeout(resolve, 2000));
    
                return {
                    content: [
                        {
                            type: "text" as const,
                            text: `🚀 本地预览服务器已启动!\n\n请在浏览器中打开: http://localhost:4000\n\n完成预览后,可使用 stop_preview 停止服务器。`,
                        },
                    ],
                };
            } catch (e: any) {
                return { content: [{ type: "text" as const, text: `错误: ${e.message}` }], isError: true };
            }
        }
  • Registration function registerHexoTools where preview_blog is defined.
    export function registerHexoTools(server: McpServer): void {
        // 预览博客
        server.tool(
            "preview_blog",
            "启动 Hexo 本地预览服务器(localhost:4000)",
            {},
            async () => {
                try {
                    // 先清理和生成
                    await hexoCommand("clean");
                    await hexoCommand("generate");
    
                    // 启动 server(后台进程)
                    if (previewProcess) {
                        previewProcess.kill();
                        previewProcess = null;
                    }
    
                    previewProcess = exec("npx hexo server", { cwd: BLOG_ROOT });
    
                    // 等待服务启动
                    await new Promise((resolve) => setTimeout(resolve, 2000));
    
                    return {
                        content: [
                            {
                                type: "text" as const,
                                text: `🚀 本地预览服务器已启动!\n\n请在浏览器中打开: http://localhost:4000\n\n完成预览后,可使用 stop_preview 停止服务器。`,
                            },
                        ],
                    };
                } catch (e: any) {
                    return { content: [{ type: "text" as const, text: `错误: ${e.message}` }], isError: true };
                }
            }
        );
    
        // 停止预览
        server.tool(
            "stop_preview",
            "停止正在运行的 Hexo 本地预览服务器",
            {},
            async () => {
                if (previewProcess) {
                    previewProcess.kill();
                    previewProcess = null;
                    return {
                        content: [{ type: "text" as const, text: "✅ 预览服务器已停止。" }],
                    };
                }
                return {
                    content: [{ type: "text" as const, text: "ℹ️ 当前没有正在运行的预览服务器。" }],
                };
            }
        );
    
        // 部署博客
        server.tool(
            "deploy_blog",
            "构建并发布博客到 GitHub Pages(执行 hexo clean && hexo generate && hexo deploy)",
            {},
            async () => {
                try {
                    await hexoCommand("clean");
                    const genOutput = await hexoCommand("generate");
                    const deployOutput = await hexoCommand("deploy");
                    return {
                        content: [
                            {
                                type: "text" as const,
                                text: `🎉 博客已成功发布到 GitHub Pages!\n\n网址: https://leejersey.github.io\n\n⚠️ GitHub Pages 需要 1~3 分钟刷新缓存。\n\n建议接下来执行 backup_source 备份源码。`,
                            },
                        ],
                    };
                } 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?

No annotations are provided, so the description carries full burden. It states the tool starts a local preview server but doesn't disclose behavioral traits such as whether it runs in the background, requires specific permissions, has rate limits, or what happens if the server is already running. This leaves significant gaps for a tool that likely involves process management.

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 in Chinese that directly states the tool's purpose and key detail (localhost:4000). It's front-loaded with the main action and has zero wasted words, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool likely starts a server process (implied complexity), no annotations, and no output schema, the description is minimal. It covers the basic purpose but lacks details on behavior, output, or error handling. For a tool with potential side effects (e.g., port binding), more context would be helpful, but it's adequate for a simple preview tool.

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

Parameters4/5

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

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description doesn't add parameter details, which is appropriate here. Baseline is 4 for 0 parameters, as it avoids unnecessary information.

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 ('启动' meaning 'start' or 'launch') and the resource ('Hexo 本地预览服务器' meaning 'Hexo local preview server'), specifying it runs on localhost:4000. It distinguishes from siblings like 'deploy_blog' (production deployment) and 'stop_preview' (stopping the server), but doesn't explicitly differentiate from all siblings.

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

Usage Guidelines3/5

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

The description implies usage context by specifying it's a local preview server (localhost:4000), suggesting it's for testing before deployment. However, it doesn't explicitly state when to use this vs. alternatives like 'deploy_blog' for production or 'stop_preview' to terminate, nor does it mention prerequisites or exclusions.

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