@jgardner04/ghost-mcp-server 1.12.0 → 1.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -21,51 +21,189 @@ An MCP client can discover these resources and tools by querying the running MCP
21
21
  ### Resources Defined
22
22
 
23
23
  - **`ghost/tag`**: Represents a tag in Ghost CMS. Contains `id`, `name`, `slug`, `description`.
24
- - **`ghost/post`**: Represents a post in Ghost CMS. Contains `id`, `title`, `slug`, `html`, `status`, `feature_image`, `published_at`, `tags` (array of `ghost/tag`), metadata fields, etc.
24
+ - **`ghost/post`**: Represents a post in Ghost CMS. Contains `id`, `title`, `slug`, `html`, `status`, `feature_image`, `published_at`, `tags`, metadata fields.
25
+ - **`ghost/page`**: Represents a page in Ghost CMS. Similar to posts but without tag support.
26
+ - **`ghost/member`**: Represents a member/subscriber in Ghost CMS. Contains `id`, `email`, `name`, `status`, `labels`, subscriptions.
27
+ - **`ghost/newsletter`**: Represents a newsletter in Ghost CMS. Contains `id`, `name`, `description`, sender settings.
28
+ - **`ghost/tier`**: Represents a membership tier in Ghost CMS. Contains `id`, `name`, `description`, pricing, benefits.
25
29
 
26
- _(Refer to `src/mcp_server.js` for full resource schemas.)_
30
+ _(Refer to `src/mcp_server_improved.js` for full resource schemas.)_
27
31
 
28
32
  ### Tools Defined
29
33
 
30
- Below is a guide for using the available MCP tools:
31
-
32
- 1. **`ghost_create_tag`**
33
- - **Purpose**: Creates a new tag.
34
- - **Inputs**:
35
- - `name` (string, required): The name for the new tag.
36
- - `description` (string, optional): A description for the tag.
37
- - `slug` (string, optional): A URL-friendly slug (auto-generated if omitted).
38
- - **Output**: The created `ghost/tag` resource.
39
-
40
- 2. **`ghost_get_tags`**
41
- - **Purpose**: Retrieves existing tags. Can be used to find a tag ID or check if a tag exists before creation.
42
- - **Inputs**:
43
- - `name` (string, optional): Filter tags by exact name.
44
- - **Output**: An array of `ghost/tag` resources matching the filter (or all tags if no name is provided).
45
-
46
- 3. **`ghost_upload_image`**
47
- - **Purpose**: Uploads an image to Ghost for use, typically as a post's featured image.
48
- - **Inputs**:
49
- - `imageUrl` (string URL, required): A publicly accessible URL of the image to upload.
50
- - `alt` (string, optional): Alt text for the image (a default is generated if omitted).
51
- - **Output**: An object containing the final `url` (the Ghost URL for the uploaded image) and the determined `alt` text.
52
- - **Usage Note**: Call this tool first to get a Ghost image URL before creating a post that needs a featured image.
53
-
54
- 4. **`ghost_create_post`**
55
- - **Purpose**: Creates a new post.
56
- - **Inputs**:
57
- - `title` (string, required): The title of the post.
58
- - `html` (string, required): The main content of the post in HTML format.
59
- - `status` (string, optional, default: 'draft'): Set status to 'draft', 'published', or 'scheduled'.
60
- - `tags` (array of strings, optional): List of tag _names_ to associate. Tags will be looked up or created automatically.
61
- - `published_at` (string ISO date, optional): Date/time to publish or schedule. Required if status is 'scheduled'.
62
- - `custom_excerpt` (string, optional): A short summary.
63
- - `feature_image` (string URL, optional): The URL of the featured image (use the `url` output from `ghost_upload_image`).
64
- - `feature_image_alt` (string, optional): Alt text for the feature image.
65
- - `feature_image_caption` (string, optional): Caption for the feature image.
66
- - `meta_title` (string, optional): Custom SEO title.
67
- - `meta_description` (string, optional): Custom SEO description.
68
- - **Output**: The created `ghost/post` resource.
34
+ The Ghost MCP Server provides **34 tools** across 7 resource types. Below is a comprehensive guide:
35
+
36
+ ---
37
+
38
+ #### Tag Tools (5 tools)
39
+
40
+ 1. **`ghost_create_tag`** - Creates a new tag.
41
+ - `name` (string, required): The name for the new tag.
42
+ - `description` (string, optional): A description for the tag.
43
+ - `slug` (string, optional): A URL-friendly slug (auto-generated if omitted).
44
+
45
+ 2. **`ghost_get_tags`** - Retrieves a list of tags with optional filtering.
46
+ - `name` (string, optional): Filter tags by exact name.
47
+ - `limit`, `page`, `order` (optional): Pagination and sorting options.
48
+
49
+ 3. **`ghost_get_tag`** - Retrieves a single tag by ID or slug.
50
+ - `id` (string, optional): The ID of the tag.
51
+ - `slug` (string, optional): The slug of the tag.
52
+ - `include` (string, optional): Additional resources to include (e.g., "count.posts").
53
+
54
+ 4. **`ghost_update_tag`** - Updates an existing tag.
55
+ - `id` (string, required): The ID of the tag to update.
56
+ - `name`, `description`, `slug` (optional): Fields to update.
57
+
58
+ 5. **`ghost_delete_tag`** - Deletes a tag permanently.
59
+ - `id` (string, required): The ID of the tag to delete.
60
+
61
+ ---
62
+
63
+ #### Image Tools (1 tool)
64
+
65
+ 6. **`ghost_upload_image`** - Downloads, processes, and uploads an image to Ghost.
66
+ - `imageUrl` (string, required): A publicly accessible URL of the image.
67
+ - `alt` (string, optional): Alt text (auto-generated if omitted).
68
+ - **Returns**: `{ url, alt }` - the Ghost URL and alt text.
69
+ - **Usage Note**: Call this first to get a Ghost image URL before creating posts/pages.
70
+
71
+ ---
72
+
73
+ #### Post Tools (6 tools)
74
+
75
+ 7. **`ghost_create_post`** - Creates a new post.
76
+ - `title` (string, required): The title of the post.
77
+ - `html` (string, required): The main content in HTML format.
78
+ - `status` (string, optional): 'draft', 'published', or 'scheduled'.
79
+ - `tags` (array, optional): Tag names (auto-created if missing).
80
+ - `published_at` (ISO date, optional): Required if status is 'scheduled'.
81
+ - `feature_image`, `feature_image_alt`, `feature_image_caption` (optional): Featured image settings.
82
+ - `custom_excerpt`, `meta_title`, `meta_description` (optional): SEO fields.
83
+
84
+ 8. **`ghost_get_posts`** - Retrieves posts with pagination and filtering.
85
+ - `status` (optional): Filter by 'published', 'draft', 'scheduled', or 'all'.
86
+ - `limit`, `page`, `filter`, `order`, `include` (optional): Query options.
87
+
88
+ 9. **`ghost_get_post`** - Retrieves a single post by ID or slug.
89
+ - `id` (string, optional): The ID of the post.
90
+ - `slug` (string, optional): The slug of the post.
91
+ - `include` (string, optional): Relations to include (e.g., "tags,authors").
92
+
93
+ 10. **`ghost_search_posts`** - Searches posts by title/content.
94
+ - `query` (string, required): Search query.
95
+ - `status` (optional): Filter by status.
96
+ - `limit` (optional): Max results (1-50).
97
+
98
+ 11. **`ghost_update_post`** - Updates an existing post.
99
+ - `id` (string, required): The ID of the post to update.
100
+ - All other post fields are optional.
101
+
102
+ 12. **`ghost_delete_post`** - Deletes a post permanently.
103
+ - `id` (string, required): The ID of the post to delete.
104
+
105
+ ---
106
+
107
+ #### Page Tools (6 tools)
108
+
109
+ 13. **`ghost_create_page`** - Creates a new page (pages do NOT support tags).
110
+ - `title` (string, required): The title of the page.
111
+ - `html` (string, required): The main content in HTML format.
112
+ - `status`, `published_at`, `feature_image`, SEO fields (optional).
113
+
114
+ 14. **`ghost_get_pages`** - Retrieves pages with pagination and filtering.
115
+ - `limit`, `page`, `filter`, `order`, `include` (optional): Query options.
116
+
117
+ 15. **`ghost_get_page`** - Retrieves a single page by ID or slug.
118
+ - `id` (string, optional): The ID of the page.
119
+ - `slug` (string, optional): The slug of the page.
120
+
121
+ 16. **`ghost_search_pages`** - Searches pages by title/content.
122
+ - `query` (string, required): Search query.
123
+ - `status`, `limit` (optional): Filtering options.
124
+
125
+ 17. **`ghost_update_page`** - Updates an existing page.
126
+ - `id` (string, required): The ID of the page to update.
127
+
128
+ 18. **`ghost_delete_page`** - Deletes a page permanently.
129
+ - `id` (string, required): The ID of the page to delete.
130
+
131
+ ---
132
+
133
+ #### Member Tools (6 tools)
134
+
135
+ 19. **`ghost_create_member`** - Creates a new member/subscriber.
136
+ - `email` (string, required): The member's email address.
137
+ - `name` (string, optional): The member's name.
138
+ - `note` (string, optional): Internal notes about the member.
139
+ - `labels` (array, optional): Labels to assign.
140
+ - `newsletters` (array, optional): Newsletter IDs to subscribe to.
141
+
142
+ 20. **`ghost_get_members`** - Retrieves members with pagination and filtering.
143
+ - `limit`, `page`, `filter`, `order`, `include` (optional): Query options.
144
+
145
+ 21. **`ghost_get_member`** - Retrieves a single member by ID or email.
146
+ - `id` (string, optional): The ID of the member.
147
+ - `email` (string, optional): The email of the member.
148
+
149
+ 22. **`ghost_search_members`** - Searches members by name or email.
150
+ - `query` (string, required): Search query.
151
+ - `limit` (optional): Max results (1-50).
152
+
153
+ 23. **`ghost_update_member`** - Updates an existing member.
154
+ - `id` (string, required): The ID of the member to update.
155
+ - `email`, `name`, `note`, `labels`, `newsletters` (optional).
156
+
157
+ 24. **`ghost_delete_member`** - Deletes a member permanently.
158
+ - `id` (string, required): The ID of the member to delete.
159
+
160
+ ---
161
+
162
+ #### Newsletter Tools (5 tools)
163
+
164
+ 25. **`ghost_create_newsletter`** - Creates a new newsletter.
165
+ - `name` (string, required): The newsletter name.
166
+ - `description` (string, optional): Newsletter description.
167
+ - `sender_name`, `sender_email` (optional): Sender configuration.
168
+ - `subscribe_on_signup` (boolean, optional): Auto-subscribe new members.
169
+
170
+ 26. **`ghost_get_newsletters`** - Retrieves all newsletters with filtering.
171
+ - `limit`, `page`, `filter`, `order` (optional): Query options.
172
+
173
+ 27. **`ghost_get_newsletter`** - Retrieves a single newsletter by ID.
174
+ - `id` (string, required): The ID of the newsletter.
175
+
176
+ 28. **`ghost_update_newsletter`** - Updates an existing newsletter.
177
+ - `id` (string, required): The ID of the newsletter to update.
178
+ - `name`, `description`, sender settings (optional).
179
+
180
+ 29. **`ghost_delete_newsletter`** - Deletes a newsletter permanently.
181
+ - `id` (string, required): The ID of the newsletter to delete.
182
+
183
+ ---
184
+
185
+ #### Tier Tools (5 tools)
186
+
187
+ 30. **`ghost_create_tier`** - Creates a new membership tier.
188
+ - `name` (string, required): The tier name.
189
+ - `description` (string, optional): Tier description.
190
+ - `monthly_price`, `yearly_price` (number, optional): Pricing in cents.
191
+ - `currency` (string, optional): 3-letter currency code (e.g., "USD").
192
+ - `benefits` (array, optional): List of tier benefits.
193
+
194
+ 31. **`ghost_get_tiers`** - Retrieves all tiers with filtering.
195
+ - `type` (optional): Filter by 'free' or 'paid'.
196
+ - `limit`, `page`, `filter` (optional): Query options.
197
+
198
+ 32. **`ghost_get_tier`** - Retrieves a single tier by ID.
199
+ - `id` (string, required): The ID of the tier.
200
+
201
+ 33. **`ghost_update_tier`** - Updates an existing tier.
202
+ - `id` (string, required): The ID of the tier to update.
203
+ - Pricing, benefits, and other tier fields (optional).
204
+
205
+ 34. **`ghost_delete_tier`** - Deletes a tier permanently.
206
+ - `id` (string, required): The ID of the tier to delete.
69
207
 
70
208
  ## Installation
71
209
 
@@ -115,13 +253,31 @@ ghost-mcp-server
115
253
  # Or using npx
116
254
  npx @jgardner04/ghost-mcp-server
117
255
 
118
- # Run the MCP server with transport options
256
+ # Run the improved MCP server (recommended for MCP clients)
119
257
  ghost-mcp
120
258
 
121
259
  # Or with specific transport
122
260
  MCP_TRANSPORT=stdio ghost-mcp
261
+ MCP_TRANSPORT=http ghost-mcp
262
+ MCP_TRANSPORT=websocket ghost-mcp
123
263
  ```
124
264
 
265
+ ### Available npm Scripts
266
+
267
+ For development, the following scripts are available:
268
+
269
+ | Script | Description |
270
+ | ----------------------------- | ------------------------------------ |
271
+ | `npm start` | Start Express REST API + MCP servers |
272
+ | `npm run start:mcp` | Start improved MCP server only |
273
+ | `npm run start:mcp:stdio` | MCP server with stdio transport |
274
+ | `npm run start:mcp:http` | MCP server with HTTP/SSE transport |
275
+ | `npm run start:mcp:websocket` | MCP server with WebSocket transport |
276
+ | `npm test` | Run tests |
277
+ | `npm run test:coverage` | Run tests with coverage report |
278
+ | `npm run lint` | Check code for linting errors |
279
+ | `npm run lint:fix` | Auto-fix linting errors |
280
+
125
281
  ## Development Setup
126
282
 
127
283
  For contributors or advanced users who want to modify the source code:
@@ -160,6 +316,6 @@ For contributors or advanced users who want to modify the source code:
160
316
 
161
317
  - **401 Unauthorized Error from Ghost:** Check that your `GHOST_ADMIN_API_URL` and `GHOST_ADMIN_API_KEY` in the `.env` file are correct and that the Custom Integration in Ghost is enabled.
162
318
  - **MCP Server Connection Issues:** Ensure the MCP server is running (check console logs). Verify the port (`MCP_PORT`, default 3001) is not blocked by a firewall. Check that the client is connecting to the correct address and port.
163
- - **Tool Execution Errors:** Check the server console logs for detailed error messages from the specific tool implementation (e.g., `ghost_create_post`, `ghost_upload_image`). Common issues include invalid input (check against tool schemas in `src/mcp_server.js` and the README guide), problems downloading from `imageUrl`, image processing failures, or upstream errors from the Ghost API.
319
+ - **Tool Execution Errors:** Check the server console logs for detailed error messages from the specific tool implementation. Common issues include invalid input (check against tool schemas in `src/mcp_server_improved.js` and the README guide), problems downloading from `imageUrl`, image processing failures, or upstream errors from the Ghost API.
164
320
  - **Command Not Found:** If `ghost-mcp-server` or `ghost-mcp` commands are not found after global installation, ensure npm's global bin directory is in your PATH. You can find it with `npm bin -g`.
165
321
  - **Dependency Installation Issues:** Ensure you have a compatible Node.js version installed (Node.js 18.0.0 or higher - see Requirements section). For global installation issues, try `npm install -g @jgardner04/ghost-mcp-server --force`. For development setup, try removing `node_modules` and `package-lock.json` and running `npm install` again.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jgardner04/ghost-mcp-server",
3
- "version": "1.12.0",
3
+ "version": "1.12.2",
4
4
  "description": "A Model Context Protocol (MCP) server for interacting with Ghost CMS via the Admin API",
5
5
  "author": "Jonathan Gardner",
6
6
  "type": "module",
@@ -71,6 +71,7 @@
71
71
  "ora": "^7.0.1",
72
72
  "sanitize-html": "^2.17.0",
73
73
  "sharp": "^0.34.1",
74
+ "uuid": "^11.1.0",
74
75
  "winston": "^3.17.0",
75
76
  "zod": "^3.25.76"
76
77
  },
@@ -54,25 +54,87 @@ const mockUpdatePost = vi.fn();
54
54
  const mockDeletePost = vi.fn();
55
55
  const mockSearchPosts = vi.fn();
56
56
 
57
- vi.mock('../services/ghostService.js', () => ({
58
- getPosts: (...args) => mockGetPosts(...args),
59
- getPost: (...args) => mockGetPost(...args),
60
- getTags: (...args) => mockGetTags(...args),
61
- createTag: (...args) => mockCreateTag(...args),
62
- uploadImage: (...args) => mockUploadImage(...args),
63
- }));
57
+ // Page mocks
58
+ const mockGetPages = vi.fn();
59
+ const mockGetPage = vi.fn();
60
+ const mockCreatePageService = vi.fn();
61
+ const mockUpdatePage = vi.fn();
62
+ const mockDeletePage = vi.fn();
63
+ const mockSearchPages = vi.fn();
64
+
65
+ // Member mocks
66
+ const mockCreateMember = vi.fn();
67
+ const mockUpdateMember = vi.fn();
68
+ const mockDeleteMember = vi.fn();
69
+ const mockGetMembers = vi.fn();
70
+ const mockGetMember = vi.fn();
71
+ const mockSearchMembers = vi.fn();
72
+
73
+ // Newsletter mocks
74
+ const mockGetNewsletters = vi.fn();
75
+ const mockGetNewsletter = vi.fn();
76
+ const mockCreateNewsletterService = vi.fn();
77
+ const mockUpdateNewsletter = vi.fn();
78
+ const mockDeleteNewsletter = vi.fn();
79
+
80
+ // Tier mocks
81
+ const mockGetTiers = vi.fn();
82
+ const mockGetTier = vi.fn();
83
+ const mockCreateTier = vi.fn();
84
+ const mockUpdateTier = vi.fn();
85
+ const mockDeleteTier = vi.fn();
64
86
 
65
87
  vi.mock('../services/postService.js', () => ({
66
88
  createPostService: (...args) => mockCreatePostService(...args),
67
89
  }));
68
90
 
91
+ vi.mock('../services/pageService.js', () => ({
92
+ createPageService: (...args) => mockCreatePageService(...args),
93
+ }));
94
+
95
+ vi.mock('../services/newsletterService.js', () => ({
96
+ createNewsletterService: (...args) => mockCreateNewsletterService(...args),
97
+ }));
98
+
69
99
  vi.mock('../services/ghostServiceImproved.js', () => ({
100
+ // Posts
101
+ getPosts: (...args) => mockGetPosts(...args),
102
+ getPost: (...args) => mockGetPost(...args),
70
103
  updatePost: (...args) => mockUpdatePost(...args),
71
104
  deletePost: (...args) => mockDeletePost(...args),
72
105
  searchPosts: (...args) => mockSearchPosts(...args),
106
+ // Tags
107
+ getTags: (...args) => mockGetTags(...args),
73
108
  getTag: (...args) => mockGetTag(...args),
109
+ createTag: (...args) => mockCreateTag(...args),
74
110
  updateTag: (...args) => mockUpdateTag(...args),
75
111
  deleteTag: (...args) => mockDeleteTag(...args),
112
+ // Images
113
+ uploadImage: (...args) => mockUploadImage(...args),
114
+ // Pages
115
+ getPages: (...args) => mockGetPages(...args),
116
+ getPage: (...args) => mockGetPage(...args),
117
+ updatePage: (...args) => mockUpdatePage(...args),
118
+ deletePage: (...args) => mockDeletePage(...args),
119
+ searchPages: (...args) => mockSearchPages(...args),
120
+ // Members
121
+ createMember: (...args) => mockCreateMember(...args),
122
+ updateMember: (...args) => mockUpdateMember(...args),
123
+ deleteMember: (...args) => mockDeleteMember(...args),
124
+ getMembers: (...args) => mockGetMembers(...args),
125
+ getMember: (...args) => mockGetMember(...args),
126
+ searchMembers: (...args) => mockSearchMembers(...args),
127
+ // Newsletters
128
+ getNewsletters: (...args) => mockGetNewsletters(...args),
129
+ getNewsletter: (...args) => mockGetNewsletter(...args),
130
+ updateNewsletter: (...args) => mockUpdateNewsletter(...args),
131
+ deleteNewsletter: (...args) => mockDeleteNewsletter(...args),
132
+ // Tiers
133
+ getTiers: (...args) => mockGetTiers(...args),
134
+ getTier: (...args) => mockGetTier(...args),
135
+ createTier: (...args) => mockCreateTier(...args),
136
+ updateTier: (...args) => mockUpdateTier(...args),
137
+ deleteTier: (...args) => mockDeleteTier(...args),
76
138
  }));
77
139
 
78
140
  vi.mock('../services/imageProcessingService.js', () => ({
@@ -332,10 +394,11 @@ describe('mcp_server_improved - ghost_get_post tool', () => {
332
394
  expect(tool).toBeDefined();
333
395
  expect(tool.description).toContain('post');
334
396
  expect(tool.schema).toBeDefined();
335
- // Zod schemas store field definitions in schema.shape
336
- expect(tool.schema.shape.id).toBeDefined();
337
- expect(tool.schema.shape.slug).toBeDefined();
338
- expect(tool.schema.shape.include).toBeDefined();
397
+ // ghost_get_post uses a refined schema, access via _def.schema.shape
398
+ const shape = tool.schema._def.schema.shape;
399
+ expect(shape.id).toBeDefined();
400
+ expect(shape.slug).toBeDefined();
401
+ expect(shape.include).toBeDefined();
339
402
  });
340
403
 
341
404
  it('should retrieve post by ID', async () => {
@@ -965,10 +1028,11 @@ describe('ghost_get_tag', () => {
965
1028
 
966
1029
  it('should have correct schema with id and slug as optional', () => {
967
1030
  const tool = mockTools.get('ghost_get_tag');
968
- // Zod schemas store field definitions in schema.shape
969
- expect(tool.schema.shape.id).toBeDefined();
970
- expect(tool.schema.shape.slug).toBeDefined();
971
- expect(tool.schema.shape.include).toBeDefined();
1031
+ // ghost_get_tag uses a refined schema, access via _def.schema.shape
1032
+ const shape = tool.schema._def.schema.shape;
1033
+ expect(shape.id).toBeDefined();
1034
+ expect(shape.slug).toBeDefined();
1035
+ expect(shape.include).toBeDefined();
972
1036
  });
973
1037
 
974
1038
  it('should retrieve tag by ID', async () => {
@@ -1027,7 +1091,7 @@ describe('ghost_get_tag', () => {
1027
1091
  const result = await tool.handler({});
1028
1092
 
1029
1093
  expect(result.content[0].type).toBe('text');
1030
- expect(result.content[0].text).toContain('Either id or slug must be provided');
1094
+ expect(result.content[0].text).toContain('Either id or slug is required');
1031
1095
  expect(result.isError).toBe(true);
1032
1096
  });
1033
1097
 
@@ -40,6 +40,13 @@ export class ValidationError extends BaseError {
40
40
  this.errors = errors;
41
41
  }
42
42
 
43
+ toJSON() {
44
+ return {
45
+ ...super.toJSON(),
46
+ ...(this.errors.length > 0 && { errors: this.errors }),
47
+ };
48
+ }
49
+
43
50
  static fromJoi(joiError) {
44
51
  const errors = joiError.details.map((detail) => ({
45
52
  field: detail.path.join('.'),