@jgardner04/ghost-mcp-server 1.11.0 → 1.12.1

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.11.0",
3
+ "version": "1.12.1",
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
  },
@@ -83,15 +83,21 @@ vi.mock('axios', () => ({
83
83
  }));
84
84
 
85
85
  // Mock fs
86
- const mockUnlink = vi.fn((path, cb) => cb(null));
87
86
  const mockCreateWriteStream = vi.fn();
88
87
  vi.mock('fs', () => ({
89
88
  default: {
90
- unlink: (...args) => mockUnlink(...args),
91
89
  createWriteStream: (...args) => mockCreateWriteStream(...args),
92
90
  },
93
91
  }));
94
92
 
93
+ // Mock tempFileManager
94
+ const mockTrackTempFile = vi.fn();
95
+ const mockCleanupTempFiles = vi.fn().mockResolvedValue(undefined);
96
+ vi.mock('../utils/tempFileManager.js', () => ({
97
+ trackTempFile: (...args) => mockTrackTempFile(...args),
98
+ cleanupTempFiles: (...args) => mockCleanupTempFiles(...args),
99
+ }));
100
+
95
101
  // Mock os
96
102
  vi.mock('os', () => ({
97
103
  default: { tmpdir: vi.fn().mockReturnValue('/tmp') },
@@ -251,7 +257,7 @@ describe('mcp_server', () => {
251
257
  const input = { imageUrl: 'https://example.com/image.jpg' };
252
258
  await toolImplementations.ghost_upload_image(input);
253
259
 
254
- expect(mockUnlink).toHaveBeenCalled();
260
+ expect(mockCleanupTempFiles).toHaveBeenCalled();
255
261
  });
256
262
 
257
263
  it('should cleanup temporary files on error', async () => {
@@ -260,7 +266,7 @@ describe('mcp_server', () => {
260
266
  const input = { imageUrl: 'https://example.com/image.jpg' };
261
267
  await expect(toolImplementations.ghost_upload_image(input)).rejects.toThrow();
262
268
 
263
- expect(mockUnlink).toHaveBeenCalled();
269
+ expect(mockCleanupTempFiles).toHaveBeenCalled();
264
270
  });
265
271
 
266
272
  it('should handle download errors', async () => {