一个用于通过大型语言模型 (LLM) 接口与 Ghost CMS 交互的 Model Context Protocol (MCP) 服务器。此服务器提供安全且全面的 Ghost 博客访问权限,并利用 JWT 认证和丰富的 MCP 工具集,支持管理文章、用户、成员、订阅层级、优惠和简报。
要与此 MCP 服务器配合使用,请在 claude_desktop.yaml 中添加以下内容:
ghost-mcp-server:
enabled: true
endpoint: http://localhost:5000
默认端口为 5000。请参考 配置文件 了解详细信息。
我完全使用 TypeScript 重写了 Ghost MCP Server,并在 v0.1.0 版本中发布。此次重大变更带来了以下好处:
请参阅下方更新文档,了解如何从 Python 版本迁移。如果遇到问题,请在 GitHub 上提交 issue。
以下是运行服务器所需的环境变量:
GHOST_ADMIN_URL: Ghost 行政界面 URL(必需)GHOST_ADMIN_KEY: Ghost 行政 API 密钥(必需)PORT:服务器监听的端口,默认为 5000NODE_ENV:环境模式,生产或开发要与此 MCP 服务器配合使用,请在 claude_desktop.yaml 中添加以下内容:
ghost-mcp-server:
enabled: true
endpoint: http://localhost:5000
以下展示了文章管理和用户管理的代码示例:
interface GhostArticleToolParams {
title: string;
content: string;
authorId?: string;
publishedAt?: string;
}
async function createGhostArticle(params: GhostArticleToolParams): Promise<void> {
// 创建文章逻辑
}
async function updateGhostArticle(articleId: string, params: Omit<GhostArticleToolParams, 'title'>): Promise<void> {
// 更新文章逻辑
}
async function deleteGhostArticle(articleId: string): Promise<void> {
// 删除文章逻辑
}
interface GhostUserToolParams {
email: string;
password: string;
username?: string;
}
async function createUser(params: GhostUserToolParams): Promise<string> {
// 创建用户逻辑,返回用户 ID
}
async function updateUser(userId: string, params: Omit<GhostUserToolParams, 'email'>): Promise<void> {
// 更新用户逻辑
}
Ghost MCP Server 使用自定义的 GhostError 异常来处理 API 通信错误和处理问题,以确保清晰且详细的错误消息,便于故障排除。
MIT