@junis/ghost-mcp 0.2.0 → 0.3.0
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/build/server.js +10 -0
- package/build/tools/pages.js +87 -0
- package/build/tools/posts.js +12 -0
- package/build/tools/redirects.js +26 -0
- package/build/tools/settings.js +54 -0
- package/build/tools/site.js +12 -0
- package/build/tools/themes.js +41 -0
- package/build/utils/ghostHttp.js +68 -0
- package/package.json +3 -1
package/build/server.js
CHANGED
|
@@ -46,6 +46,16 @@ const webhooks_1 = require("./tools/webhooks");
|
|
|
46
46
|
(0, webhooks_1.registerWebhookTools)(server);
|
|
47
47
|
const upload_1 = require("./tools/upload");
|
|
48
48
|
(0, upload_1.registerUploadTools)(server);
|
|
49
|
+
const pages_1 = require("./tools/pages");
|
|
50
|
+
(0, pages_1.registerPageTools)(server);
|
|
51
|
+
const site_1 = require("./tools/site");
|
|
52
|
+
(0, site_1.registerSiteTools)(server);
|
|
53
|
+
const settings_1 = require("./tools/settings");
|
|
54
|
+
(0, settings_1.registerSettingsTools)(server);
|
|
55
|
+
const themes_1 = require("./tools/themes");
|
|
56
|
+
(0, themes_1.registerThemeTools)(server);
|
|
57
|
+
const redirects_1 = require("./tools/redirects");
|
|
58
|
+
(0, redirects_1.registerRedirectsAndRoutesTools)(server);
|
|
49
59
|
const prompts_1 = require("./prompts");
|
|
50
60
|
(0, prompts_1.registerPrompts)(server);
|
|
51
61
|
// Set up and connect to the standard I/O transport
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerPageTools = registerPageTools;
|
|
4
|
+
// src/tools/pages.ts
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const ghostApi_1 = require("../ghostApi");
|
|
7
|
+
const browseParams = {
|
|
8
|
+
filter: zod_1.z.string().optional(),
|
|
9
|
+
limit: zod_1.z.number().optional(),
|
|
10
|
+
page: zod_1.z.number().optional(),
|
|
11
|
+
order: zod_1.z.string().optional(),
|
|
12
|
+
};
|
|
13
|
+
const readParams = {
|
|
14
|
+
id: zod_1.z.string().optional(),
|
|
15
|
+
slug: zod_1.z.string().optional(),
|
|
16
|
+
};
|
|
17
|
+
const addParams = {
|
|
18
|
+
title: zod_1.z.string(),
|
|
19
|
+
html: zod_1.z.string().optional(),
|
|
20
|
+
lexical: zod_1.z.string().optional(),
|
|
21
|
+
status: zod_1.z.string().optional(),
|
|
22
|
+
tags: zod_1.z.array(zod_1.z.object({ name: zod_1.z.string() })).optional(),
|
|
23
|
+
codeinjection_head: zod_1.z.string().optional(),
|
|
24
|
+
codeinjection_foot: zod_1.z.string().optional(),
|
|
25
|
+
meta_title: zod_1.z.string().optional(),
|
|
26
|
+
meta_description: zod_1.z.string().optional(),
|
|
27
|
+
slug: zod_1.z.string().optional(),
|
|
28
|
+
feature_image: zod_1.z.string().optional(),
|
|
29
|
+
og_title: zod_1.z.string().optional(),
|
|
30
|
+
og_description: zod_1.z.string().optional(),
|
|
31
|
+
custom_excerpt: zod_1.z.string().optional(),
|
|
32
|
+
};
|
|
33
|
+
const editParams = {
|
|
34
|
+
id: zod_1.z.string(),
|
|
35
|
+
title: zod_1.z.string().optional(),
|
|
36
|
+
html: zod_1.z.string().optional(),
|
|
37
|
+
lexical: zod_1.z.string().optional(),
|
|
38
|
+
status: zod_1.z.string().optional(),
|
|
39
|
+
updated_at: zod_1.z.string(),
|
|
40
|
+
tags: zod_1.z.array(zod_1.z.object({ name: zod_1.z.string() })).optional(),
|
|
41
|
+
codeinjection_head: zod_1.z.string().optional(),
|
|
42
|
+
codeinjection_foot: zod_1.z.string().optional(),
|
|
43
|
+
meta_title: zod_1.z.string().optional(),
|
|
44
|
+
meta_description: zod_1.z.string().optional(),
|
|
45
|
+
slug: zod_1.z.string().optional(),
|
|
46
|
+
feature_image: zod_1.z.string().optional(),
|
|
47
|
+
og_title: zod_1.z.string().optional(),
|
|
48
|
+
og_description: zod_1.z.string().optional(),
|
|
49
|
+
custom_excerpt: zod_1.z.string().optional(),
|
|
50
|
+
};
|
|
51
|
+
const deleteParams = {
|
|
52
|
+
id: zod_1.z.string(),
|
|
53
|
+
};
|
|
54
|
+
function registerPageTools(server) {
|
|
55
|
+
server.tool("pages_browse", "Browse Ghost pages (About, Contact, etc.)", browseParams, async (args, _extra) => {
|
|
56
|
+
const pages = await ghostApi_1.ghostApiClient.pages.browse(args);
|
|
57
|
+
return {
|
|
58
|
+
content: [{ type: "text", text: JSON.stringify(pages, null, 2) }],
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
server.tool("pages_read", "Read a single Ghost page by id or slug", readParams, async (args, _extra) => {
|
|
62
|
+
const page = await ghostApi_1.ghostApiClient.pages.read(args);
|
|
63
|
+
return {
|
|
64
|
+
content: [{ type: "text", text: JSON.stringify(page, null, 2) }],
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
server.tool("pages_add", "Create a new Ghost page", addParams, async (args, _extra) => {
|
|
68
|
+
const options = args.html ? { source: "html" } : undefined;
|
|
69
|
+
const page = await ghostApi_1.ghostApiClient.pages.add(args, options);
|
|
70
|
+
return {
|
|
71
|
+
content: [{ type: "text", text: JSON.stringify(page, null, 2) }],
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
server.tool("pages_edit", "Edit an existing Ghost page", editParams, async (args, _extra) => {
|
|
75
|
+
const options = args.html ? { source: "html" } : undefined;
|
|
76
|
+
const page = await ghostApi_1.ghostApiClient.pages.edit(args, options);
|
|
77
|
+
return {
|
|
78
|
+
content: [{ type: "text", text: JSON.stringify(page, null, 2) }],
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
server.tool("pages_delete", "Delete a Ghost page", deleteParams, async (args, _extra) => {
|
|
82
|
+
await ghostApi_1.ghostApiClient.pages.delete(args);
|
|
83
|
+
return {
|
|
84
|
+
content: [{ type: "text", text: `Page with id ${args.id} deleted.` }],
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
}
|
package/build/tools/posts.js
CHANGED
|
@@ -29,6 +29,12 @@ const addParams = {
|
|
|
29
29
|
feature_image: zod_1.z.string().optional(),
|
|
30
30
|
og_title: zod_1.z.string().optional(),
|
|
31
31
|
og_description: zod_1.z.string().optional(),
|
|
32
|
+
og_image: zod_1.z.string().optional(),
|
|
33
|
+
twitter_title: zod_1.z.string().optional(),
|
|
34
|
+
twitter_description: zod_1.z.string().optional(),
|
|
35
|
+
twitter_image: zod_1.z.string().optional(),
|
|
36
|
+
feature_image_alt: zod_1.z.string().optional(),
|
|
37
|
+
feature_image_caption: zod_1.z.string().optional(),
|
|
32
38
|
custom_excerpt: zod_1.z.string().optional(),
|
|
33
39
|
};
|
|
34
40
|
const editParams = {
|
|
@@ -47,6 +53,12 @@ const editParams = {
|
|
|
47
53
|
feature_image: zod_1.z.string().optional(),
|
|
48
54
|
og_title: zod_1.z.string().optional(),
|
|
49
55
|
og_description: zod_1.z.string().optional(),
|
|
56
|
+
og_image: zod_1.z.string().optional(),
|
|
57
|
+
twitter_title: zod_1.z.string().optional(),
|
|
58
|
+
twitter_description: zod_1.z.string().optional(),
|
|
59
|
+
twitter_image: zod_1.z.string().optional(),
|
|
60
|
+
feature_image_alt: zod_1.z.string().optional(),
|
|
61
|
+
feature_image_caption: zod_1.z.string().optional(),
|
|
50
62
|
custom_excerpt: zod_1.z.string().optional(),
|
|
51
63
|
};
|
|
52
64
|
const deleteParams = {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerRedirectsAndRoutesTools = registerRedirectsAndRoutesTools;
|
|
4
|
+
// src/tools/redirects.ts
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const ghostHttp_1 = require("../utils/ghostHttp");
|
|
7
|
+
function registerRedirectsAndRoutesTools(server) {
|
|
8
|
+
server.tool("redirects_download", "Download current Ghost redirects configuration (JSON/YAML)", {}, async (_args, _extra) => {
|
|
9
|
+
const data = await (0, ghostHttp_1.ghostGet)("redirects/download/");
|
|
10
|
+
return {
|
|
11
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
server.tool("redirects_upload", "Upload a redirects.yaml or redirects.json file to Ghost", { file: zod_1.z.string().describe("Absolute path to the redirects file") }, async (args, _extra) => {
|
|
15
|
+
const result = await (0, ghostHttp_1.ghostUploadFile)("redirects/upload/", args.file);
|
|
16
|
+
return {
|
|
17
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
server.tool("routes_upload", "Upload a routes.yaml file to Ghost", { file: zod_1.z.string().describe("Absolute path to the routes.yaml file") }, async (args, _extra) => {
|
|
21
|
+
const result = await (0, ghostHttp_1.ghostUploadFile)("settings/routes/yaml/", args.file);
|
|
22
|
+
return {
|
|
23
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerSettingsTools = registerSettingsTools;
|
|
4
|
+
// src/tools/settings.ts
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const ghostHttp_1 = require("../utils/ghostHttp");
|
|
7
|
+
const navigationItem = zod_1.z.object({
|
|
8
|
+
label: zod_1.z.string(),
|
|
9
|
+
url: zod_1.z.string(),
|
|
10
|
+
});
|
|
11
|
+
const editParams = {
|
|
12
|
+
title: zod_1.z.string().optional(),
|
|
13
|
+
description: zod_1.z.string().optional(),
|
|
14
|
+
logo: zod_1.z.string().optional(),
|
|
15
|
+
icon: zod_1.z.string().optional(),
|
|
16
|
+
cover_image: zod_1.z.string().optional(),
|
|
17
|
+
accent_color: zod_1.z.string().optional(),
|
|
18
|
+
locale: zod_1.z.string().optional(),
|
|
19
|
+
timezone: zod_1.z.string().optional(),
|
|
20
|
+
codeinjection_head: zod_1.z.string().optional(),
|
|
21
|
+
codeinjection_foot: zod_1.z.string().optional(),
|
|
22
|
+
facebook: zod_1.z.string().optional(),
|
|
23
|
+
twitter: zod_1.z.string().optional(),
|
|
24
|
+
navigation: zod_1.z.array(navigationItem).optional(),
|
|
25
|
+
secondary_navigation: zod_1.z.array(navigationItem).optional(),
|
|
26
|
+
meta_title: zod_1.z.string().optional(),
|
|
27
|
+
meta_description: zod_1.z.string().optional(),
|
|
28
|
+
og_image: zod_1.z.string().optional(),
|
|
29
|
+
og_title: zod_1.z.string().optional(),
|
|
30
|
+
og_description: zod_1.z.string().optional(),
|
|
31
|
+
twitter_image: zod_1.z.string().optional(),
|
|
32
|
+
twitter_title: zod_1.z.string().optional(),
|
|
33
|
+
twitter_description: zod_1.z.string().optional(),
|
|
34
|
+
posts_per_page: zod_1.z.number().optional(),
|
|
35
|
+
members_support_address: zod_1.z.string().optional(),
|
|
36
|
+
};
|
|
37
|
+
function registerSettingsTools(server) {
|
|
38
|
+
server.tool("settings_read", "Read all Ghost site settings (SEO, branding, code injection, navigation, social, etc.)", {}, async (_args, _extra) => {
|
|
39
|
+
const data = await (0, ghostHttp_1.ghostGet)("settings/");
|
|
40
|
+
return {
|
|
41
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
server.tool("settings_edit", "Edit Ghost site settings (title, description, logo, icon, meta, OG, code injection, navigation, etc.)", editParams, async (args, _extra) => {
|
|
45
|
+
// Ghost settings API expects { settings: [{ key, value }, ...] }
|
|
46
|
+
const settings = Object.entries(args)
|
|
47
|
+
.filter(([_, v]) => v !== undefined)
|
|
48
|
+
.map(([key, value]) => ({ key, value }));
|
|
49
|
+
const data = await (0, ghostHttp_1.ghostPut)("settings/", { settings });
|
|
50
|
+
return {
|
|
51
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerSiteTools = registerSiteTools;
|
|
4
|
+
const ghostApi_1 = require("../ghostApi");
|
|
5
|
+
function registerSiteTools(server) {
|
|
6
|
+
server.tool("site_read", "Read site basic info (title, description, logo, url, version, etc.)", {}, async (_args, _extra) => {
|
|
7
|
+
const site = await ghostApi_1.ghostApiClient.site.read();
|
|
8
|
+
return {
|
|
9
|
+
content: [{ type: "text", text: JSON.stringify(site, null, 2) }],
|
|
10
|
+
};
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.registerThemeTools = registerThemeTools;
|
|
7
|
+
// src/tools/themes.ts
|
|
8
|
+
const zod_1 = require("zod");
|
|
9
|
+
const ghostApi_1 = require("../ghostApi");
|
|
10
|
+
const ghostHttp_1 = require("../utils/ghostHttp");
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
|
+
function registerThemeTools(server) {
|
|
13
|
+
server.tool("themes_browse", "List all installed Ghost themes", {}, async (_args, _extra) => {
|
|
14
|
+
const data = await (0, ghostHttp_1.ghostGet)("themes/");
|
|
15
|
+
return {
|
|
16
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
server.tool("themes_upload", "Upload a Ghost theme zip file", { file: zod_1.z.string().describe("Absolute path to the theme zip file") }, async (args, _extra) => {
|
|
20
|
+
const result = await ghostApi_1.ghostApiClient.themes.upload(args);
|
|
21
|
+
return {
|
|
22
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
server.tool("themes_activate", "Activate an installed Ghost theme by name", { name: zod_1.z.string().describe("Theme name to activate") }, async (args, _extra) => {
|
|
26
|
+
const result = await ghostApi_1.ghostApiClient.themes.activate(args.name);
|
|
27
|
+
return {
|
|
28
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
server.tool("themes_download", "Download a Ghost theme as zip. Returns the saved file path.", {
|
|
32
|
+
name: zod_1.z.string().describe("Theme name to download"),
|
|
33
|
+
output_path: zod_1.z.string().describe("Absolute path to save the downloaded zip"),
|
|
34
|
+
}, async (args, _extra) => {
|
|
35
|
+
const data = await (0, ghostHttp_1.ghostDownload)(`themes/${args.name}/download/`);
|
|
36
|
+
fs_1.default.writeFileSync(args.output_path, data);
|
|
37
|
+
return {
|
|
38
|
+
content: [{ type: "text", text: `Theme saved to ${args.output_path}` }],
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ghostGet = ghostGet;
|
|
7
|
+
exports.ghostPut = ghostPut;
|
|
8
|
+
exports.ghostPost = ghostPost;
|
|
9
|
+
exports.ghostUploadFile = ghostUploadFile;
|
|
10
|
+
exports.ghostDownload = ghostDownload;
|
|
11
|
+
// src/utils/ghostHttp.ts
|
|
12
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
13
|
+
const axios_1 = __importDefault(require("axios"));
|
|
14
|
+
const fs_1 = __importDefault(require("fs"));
|
|
15
|
+
const config_1 = require("../config");
|
|
16
|
+
function generateToken() {
|
|
17
|
+
const [id, secret] = config_1.GHOST_ADMIN_API_KEY.split(":");
|
|
18
|
+
return jsonwebtoken_1.default.sign({}, Buffer.from(secret, "hex"), {
|
|
19
|
+
keyid: id,
|
|
20
|
+
algorithm: "HS256",
|
|
21
|
+
expiresIn: "5m",
|
|
22
|
+
audience: `/${config_1.GHOST_API_VERSION}/admin/`,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function apiUrl(endpoint) {
|
|
26
|
+
return `${config_1.GHOST_API_URL.replace(/\/+$/, "")}/ghost/api/admin/${endpoint.replace(/^\/+/, "")}`;
|
|
27
|
+
}
|
|
28
|
+
function authHeaders() {
|
|
29
|
+
return { Authorization: `Ghost ${generateToken()}` };
|
|
30
|
+
}
|
|
31
|
+
async function ghostGet(endpoint, params) {
|
|
32
|
+
const res = await axios_1.default.get(apiUrl(endpoint), {
|
|
33
|
+
headers: authHeaders(),
|
|
34
|
+
params,
|
|
35
|
+
});
|
|
36
|
+
return res.data;
|
|
37
|
+
}
|
|
38
|
+
async function ghostPut(endpoint, data) {
|
|
39
|
+
const res = await axios_1.default.put(apiUrl(endpoint), data, {
|
|
40
|
+
headers: { ...authHeaders(), "Content-Type": "application/json" },
|
|
41
|
+
});
|
|
42
|
+
return res.data;
|
|
43
|
+
}
|
|
44
|
+
async function ghostPost(endpoint, data) {
|
|
45
|
+
const res = await axios_1.default.post(apiUrl(endpoint), data, {
|
|
46
|
+
headers: { ...authHeaders(), "Content-Type": "application/json" },
|
|
47
|
+
});
|
|
48
|
+
return res.data;
|
|
49
|
+
}
|
|
50
|
+
async function ghostUploadFile(endpoint, filePath, fieldName = "file") {
|
|
51
|
+
const FormData = (await import("form-data")).default;
|
|
52
|
+
const form = new FormData();
|
|
53
|
+
form.append(fieldName, fs_1.default.createReadStream(filePath));
|
|
54
|
+
const res = await axios_1.default.post(apiUrl(endpoint), form, {
|
|
55
|
+
headers: {
|
|
56
|
+
...authHeaders(),
|
|
57
|
+
...form.getHeaders(),
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
return res.data;
|
|
61
|
+
}
|
|
62
|
+
async function ghostDownload(endpoint) {
|
|
63
|
+
const res = await axios_1.default.get(apiUrl(endpoint), {
|
|
64
|
+
headers: authHeaders(),
|
|
65
|
+
responseType: "arraybuffer",
|
|
66
|
+
});
|
|
67
|
+
return res.data;
|
|
68
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@junis/ghost-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "MCP server for using the Ghost API",
|
|
5
5
|
"main": "build/server.js",
|
|
6
6
|
"bin": {
|
|
@@ -26,10 +26,12 @@
|
|
|
26
26
|
"@modelcontextprotocol/sdk": "^1.10.1",
|
|
27
27
|
"@tryghost/admin-api": "^1.13.13",
|
|
28
28
|
"axios": "^1.8.4",
|
|
29
|
+
"jsonwebtoken": "^9.0.3",
|
|
29
30
|
"zod": "^3.24.3"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@types/axios": "^0.9.36",
|
|
34
|
+
"@types/jsonwebtoken": "^9.0.10",
|
|
33
35
|
"@types/node": "^22.14.1",
|
|
34
36
|
"typescript": "^5.8.3"
|
|
35
37
|
}
|