Ghost MCP Server

Integrations

  • Supports configuration through environment variables for storing Ghost API credentials and server settings.

  • Optionally integrates with 1Password CLI for securely storing and accessing Ghost API credentials.

  • Implements a REST API server alongside the MCP server functionality.

Ghost MCP 服务器

该项目( ghost-mcp-server )实现了模型上下文协议(MCP)服务器,允许 MCP 客户端(如 Cursor 或 Claude Desktop)通过定义的工具与 Ghost CMS 实例进行交互。

要求

  • Node.js 14.0.0 或更高版本
  • Ghost Admin API URL 和密钥

Ghost MCP 服务器详情

该服务器将 Ghost CMS 管理功能作为 MCP 工具公开,允许 Cursor 或 Claude Desktop 等 AI 客户端管理 Ghost 博客。

MCP 客户端可以通过查询其根端点 (例如http://localhost:3001/ ) 上正在运行的 MCP 服务器(通常默认监听 3001 端口)来发现这些资源和工具。服务器会根据模型上下文协议 (MCP) 规范返回其功能。

资源定义

  • ghost/tag :代表 Ghost CMS 中的标签。包含idnameslugdescription
  • ghost/post :代表 Ghost CMS 中的一篇文章。包含idtitleslughtmlstatusfeature_imagepublished_attagsghost/tag数组)、元数据字段等。

(有关完整资源模式,请参阅src/mcp_server.js 。)

工具定义

以下是使用可用 MCP 工具的指南:

  1. ghost_create_tag
    • 目的:创建一个新标签。
    • 输入
      • name (字符串,必需):新标签的名称。
      • description (字符串,可选):标签的描述。
      • slug (字符串,可选):URL 友好的 slug(如果省略则自动生成)。
    • 输出:创建的ghost/tag资源。
  2. ghost_get_tags
    • 用途:检索现有标签。可用于查找标签 ID 或在创建标签之前检查标签是否存在。
    • 输入
      • name (字符串,可选):按精确名称过滤标签。
    • 输出:与过滤器匹配的ghost/tag资源数组(如果未提供名称,则为所有标签)。
  3. ghost_upload_image
    • 目的:将图像上传到 Ghost 以供使用,通常作为帖子的特色图片。
    • 输入
      • imageUrl (字符串 URL,必需):要上传的图像的可公开访问的 URL。
      • alt (字符串,可选):图像的 Alt 文本(如果省略则生成默认值)。
    • 输出:包含最终url (上传图像的 Ghost URL)和确定的alt文本的对象。
    • 使用说明:在创建需要特色图像的帖子之前,请先调用此工具来获取 Ghost 图像 URL。
  4. ghost_create_post
    • 目的:创建新帖子。
    • 输入
      • title (字符串,必需):帖子的标题。
      • html (字符串,必需):HTML 格式的帖子主要内容。
      • status (字符串,可选,默认值:“草稿”):将状态设置为“草稿”、“已发布”或“已安排”。
      • tags (字符串数组,可选):要关联的标签名称列表。标签将被自动查找或创建。
      • published_at (string ISO 日期,可选):发布或安排的日期/时间。状态为“已安排”时必填。
      • custom_excerpt (字符串,可选):简短摘要。
      • feature_image (字符串 URL,可选):特色图片的 URL(使用ghost_upload_image输出的url )。
      • feature_image_alt (字符串,可选):特征图像的替代文本。
      • feature_image_caption (字符串,可选):特征图像的标题。
      • meta_title (字符串,可选):自定义 SEO 标题。
      • meta_description (字符串,可选):自定义 SEO 描述。
    • 输出:创建的ghost/post资源。

安装和运行

  1. 克隆存储库
    git clone <repository_url> cd ghost-mcp-server
  2. 安装依赖项
    npm install
  3. 配置环境变量:在项目根目录中创建一个.env文件并添加您的 Ghost Admin API 凭据:
    # Required: GHOST_ADMIN_API_URL=https://your-ghost-site.com GHOST_ADMIN_API_KEY=your_admin_api_key # Optional: # PORT=3000 # Port for the (optional) Express REST API server # MCP_PORT=3001 # Port for the MCP server # NODE_ENV=development # Set to 'production' for production deployments # LOG_LEVEL=info # Set logging level (debug, info, warn, error) # If using 1Password CLI for secrets: # You might store the API key in 1Password and use `op run --env-file=.env -- ...`
    • 在“集成”->“自定义集成”下的 Ghost Admin 设置中找到您的 Ghost Admin API URL 和密钥。
  4. 运行服务器
    npm start # OR directly: # node src/index.js
    此命令将启动 Express 服务器(如果路由仍处于挂载状态)和 MCP 服务器。
    • MCP 服务器通常可通过http://localhost:3001 (或您指定的MCP_PORT )访问。
    • MCP 客户端可以连接到该地址来发现和使用这些工具。
  5. 开发模式(使用 nodemon) :用于自动重启的开发:
    npm run dev

故障排除

  • **Ghost 出现 401 未授权错误:**请检查.env文件中的GHOST_ADMIN_API_URLGHOST_ADMIN_API_KEY是否正确,以及 Ghost 中的自定义集成是否已启用。
  • **MCP 服务器连接问题:**确保 MCP 服务器正在运行(检查控制台日志)。验证端口( MCP_PORT ,默认值为 3001)未被防火墙阻止。检查客户端是否连接到正确的地址和端口。
  • **工具执行错误:**检查服务器控制台日志,了解特定工具实现(例如ghost_create_postghost_upload_image )的详细错误消息。常见问题包括无效输入(请对照src/mcp_server.js中的工具架构和 README 指南进行检查)、从imageUrl下载时出现问题、图片处理失败或 Ghost API 的上游错误。
  • **依赖项安装问题:**请确保您已安装兼容的 Node.js 版本(请参阅“要求”部分)。尝试删除node_modulespackage-lock.json ,然后再次运行npm install
-
security - not tested
A
license - permissive license
-
quality - not tested

模型上下文协议服务器的实现,允许 Cursor 或 Claude Desktop 等 AI 客户端通过公开创建帖子、添加标签和上传图像等功能来管理 Ghost CMS 博客。

  1. Requirements
    1. Ghost MCP Server Details
      1. Resources Defined
      2. Tools Defined
    2. Installation and Running
      1. Troubleshooting
        ID: 1gerxdlb96