How mfydev/ghost-mcp works
Project Type and Purpose
• This is an open-source backend service (a Node.js/TypeScript “MCP server”) that exposes Ghost CMS’s Admin API through a Model Context Protocol (MCP) interface to LLM clients (e.g., Claude).
• Its core purpose is to act as a secure, type-safe adapter between MCP-capable LLM clients and the Ghost CMS Admin API, providing CRUD operations on posts, members, tiers, etc.
File Structure Analysis
• Top-level directories:
• src/ – application source code
· config.ts – loads environment variables (API URL, key, version)
· ghostApi.ts – wraps the official @tryghost/admin-api client
· prompts.ts – text templates for human-readable outputs
· resources.ts – maps MCP resource definitions to tool implementations
· server.ts – entry point that initializes the MCP server and registers tools
· tools/ – one file per Ghost resource (posts.ts, members.ts, etc.) implementing browse/read/create/edit/delete
• assets/ – demo GIF
• types/ – TypeScript declaration for the Ghost Admin API client
• Configuration & scripts:
• package.json/lock – npm config
• tsconfig.json – TypeScript compiler settings
• .gitignore, LICENSE, README.md
Key Insights from README
• Describes migration from Python to TS, usage as an npm package, and environment variable configuration.
• Lists all “tools” (resources) exposed via MCP: posts, members, newsletters, offers, invites, roles, tags, tiers, users, webhooks.
• Emphasizes error handling (GhostError), logging integration, and the use of the official admin API client.
Main Components
a. External LLM Client (e.g., Claude Desktop)
b. MCP Server
• Entry Layer: server.ts (MCP protocol listener)
• Configuration Layer: config.ts (env variables)
• Adapter Layer: ghostApi.ts wrapping @tryghost/admin-api
• Tools Layer: individual modules in src/tools/* implementing resource operations
• Utility Layer: models.ts, prompts.ts, resources.ts, error handling
c. Ghost CMS Admin API (External Service)
Relationships & Data Flows
• LLM Client → MCP Server: JSON-RPC or MCP calls invoking a “tool” by name
• MCP Server → Config module: load API endpoint + credentials
• MCP Server → Adapter (ghostApi.ts) → Ghost Admin API: actual HTTP requests to Ghost endpoint
• Ghost Admin API → Adapter → MCP Server → LLM Client: returns data, formatted via prompts/models
Architectural Patterns & Design Principles
• Layered architecture (entry → config → adapter → tools → external API)
• Adapter/Facade pattern: ghostApi.ts abstracts the official client
• Single Responsibility: each tool file handles only one resource
• Dependency Injection via MCP context (for logging, error handling)
Technologies & Frameworks
• Node.js, TypeScript
• @tryghost/admin-api (official Ghost Admin client)
• MCP protocol framework (implicit in server.ts)
• npm packaging for distribution