Skip to main content
Glama
leejersey

Hexo Blog MCP Server

by leejersey

backup_source

Backup Hexo blog source code to a dedicated Git branch for version control and safe storage.

Instructions

将博客源码通过 Git 备份到 hexo-source 分支

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messageNo可选的 Git 提交信息

Implementation Reference

  • The core implementation logic for backing up the source code via git add, commit, and push.
    export async function backupSource(message?: string): Promise<string> {
        const commitMsg = message || `Auto backup: ${new Date().toISOString()}`;
    
        await runCommand("git add .");
    
        try {
            await runCommand(`git commit -m "${commitMsg}"`);
        } catch (e: any) {
            if (e.message?.includes("nothing to commit")) {
                return "没有需要提交的更改。";
            }
            throw e;
        }
    
        await runCommand(`git push origin ${GIT_BRANCH}`);
        return `源码已备份到 ${GIT_BRANCH} 分支。提交信息: ${commitMsg}`;
    }
  • Registration of the 'backup_source' tool using MCP server, which calls the backupSource handler.
    server.tool(
        "backup_source",
        "将博客源码通过 Git 备份到 hexo-source 分支",
        {
            message: z.string().optional().describe("可选的 Git 提交信息"),
        },
        async ({ message }) => {
            try {
                const result = await backupSource(message);
                return {
                    content: [{ type: "text" as const, text: `✅ ${result}` }],
                };
            } 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