mcp-ghost-optimized 1.0.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/LICENSE +21 -0
- package/README.md +151 -0
- package/dist/api/auth.d.ts +19 -0
- package/dist/api/auth.d.ts.map +1 -0
- package/dist/api/auth.js +67 -0
- package/dist/api/auth.js.map +1 -0
- package/dist/api/client.d.ts +111 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +262 -0
- package/dist/api/client.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +8 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +378 -0
- package/dist/server.js.map +1 -0
- package/dist/utils/fields.d.ts +55 -0
- package/dist/utils/fields.d.ts.map +1 -0
- package/dist/utils/fields.js +101 -0
- package/dist/utils/fields.js.map +1 -0
- package/dist/utils/html.d.ts +26 -0
- package/dist/utils/html.d.ts.map +1 -0
- package/dist/utils/html.js +69 -0
- package/dist/utils/html.js.map +1 -0
- package/package.json +53 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTML to plaintext conversion utilities
|
|
3
|
+
*
|
|
4
|
+
* Ghost stores content as HTML (or Lexical JSON internally).
|
|
5
|
+
* For LLM consumption, plaintext is more token-efficient.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Convert HTML to plaintext
|
|
9
|
+
*
|
|
10
|
+
* Removes all HTML tags, scripts, styles, and normalizes whitespace.
|
|
11
|
+
* Also decodes common HTML entities.
|
|
12
|
+
*
|
|
13
|
+
* @param html - HTML string to convert
|
|
14
|
+
* @returns Clean plaintext
|
|
15
|
+
*/
|
|
16
|
+
export function htmlToPlaintext(html) {
|
|
17
|
+
return (html
|
|
18
|
+
// Remove script tags and content
|
|
19
|
+
.replace(/<script[^>]*>[\s\S]*?<\/script>/gi, "")
|
|
20
|
+
// Remove style tags and content
|
|
21
|
+
.replace(/<style[^>]*>[\s\S]*?<\/style>/gi, "")
|
|
22
|
+
// Replace block elements with newlines for better readability
|
|
23
|
+
.replace(/<\/(p|div|h[1-6]|li|tr|blockquote)>/gi, "\n")
|
|
24
|
+
.replace(/<br\s*\/?>/gi, "\n")
|
|
25
|
+
.replace(/<hr\s*\/?>/gi, "\n---\n")
|
|
26
|
+
// Remove all remaining HTML tags
|
|
27
|
+
.replace(/<[^>]+>/g, " ")
|
|
28
|
+
// Decode common HTML entities
|
|
29
|
+
.replace(/ /g, " ")
|
|
30
|
+
.replace(/&/g, "&")
|
|
31
|
+
.replace(/</g, "<")
|
|
32
|
+
.replace(/>/g, ">")
|
|
33
|
+
.replace(/"/g, '"')
|
|
34
|
+
.replace(/'/g, "'")
|
|
35
|
+
.replace(/’/g, "'")
|
|
36
|
+
.replace(/‘/g, "'")
|
|
37
|
+
.replace(/”/g, '"')
|
|
38
|
+
.replace(/“/g, '"')
|
|
39
|
+
.replace(/—/g, "—")
|
|
40
|
+
.replace(/–/g, "–")
|
|
41
|
+
.replace(/…/g, "...")
|
|
42
|
+
// Normalize whitespace
|
|
43
|
+
.replace(/[ \t]+/g, " ")
|
|
44
|
+
.replace(/\n[ \t]+/g, "\n")
|
|
45
|
+
.replace(/[ \t]+\n/g, "\n")
|
|
46
|
+
.replace(/\n{3,}/g, "\n\n")
|
|
47
|
+
.trim());
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Truncate text to a maximum length, preserving word boundaries
|
|
51
|
+
*
|
|
52
|
+
* @param text - Text to truncate
|
|
53
|
+
* @param maxLength - Maximum character length
|
|
54
|
+
* @param suffix - Suffix to add if truncated (default: "...")
|
|
55
|
+
* @returns Truncated text
|
|
56
|
+
*/
|
|
57
|
+
export function truncateText(text, maxLength, suffix = "...") {
|
|
58
|
+
if (text.length <= maxLength) {
|
|
59
|
+
return text;
|
|
60
|
+
}
|
|
61
|
+
// Find last space before maxLength
|
|
62
|
+
const truncated = text.substring(0, maxLength - suffix.length);
|
|
63
|
+
const lastSpace = truncated.lastIndexOf(" ");
|
|
64
|
+
if (lastSpace > maxLength * 0.8) {
|
|
65
|
+
return truncated.substring(0, lastSpace) + suffix;
|
|
66
|
+
}
|
|
67
|
+
return truncated + suffix;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=html.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.js","sourceRoot":"","sources":["../../src/utils/html.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,CACL,IAAI;QACF,iCAAiC;SAChC,OAAO,CAAC,mCAAmC,EAAE,EAAE,CAAC;QACjD,gCAAgC;SAC/B,OAAO,CAAC,iCAAiC,EAAE,EAAE,CAAC;QAC/C,8DAA8D;SAC7D,OAAO,CAAC,uCAAuC,EAAE,IAAI,CAAC;SACtD,OAAO,CAAC,cAAc,EAAE,IAAI,CAAC;SAC7B,OAAO,CAAC,cAAc,EAAE,SAAS,CAAC;QACnC,iCAAiC;SAChC,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;QACzB,8BAA8B;SAC7B,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;SACvB,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;SACtB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;SACrB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;SACrB,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;SACvB,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;SACtB,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;SACxB,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;SACxB,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;SACxB,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;SACxB,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;SACxB,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;SACxB,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC;QAC5B,uBAAuB;SACtB,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;SACvB,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC;SAC1B,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC;SAC1B,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC;SAC1B,IAAI,EAAE,CACV,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAC1B,IAAY,EACZ,SAAiB,EACjB,SAAiB,KAAK;IAEtB,IAAI,IAAI,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,mCAAmC;IACnC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAC/D,MAAM,SAAS,GAAG,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAE7C,IAAI,SAAS,GAAG,SAAS,GAAG,GAAG,EAAE,CAAC;QAChC,OAAO,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,MAAM,CAAC;IACpD,CAAC;IAED,OAAO,SAAS,GAAG,MAAM,CAAC;AAC5B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mcp-ghost-optimized",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MCP server for Ghost CMS with optimized field projection - reduces token usage by 90-98%",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"mcp-ghost-optimized": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"dev": "tsc -w",
|
|
17
|
+
"start": "node dist/index.js",
|
|
18
|
+
"typecheck": "tsc --noEmit",
|
|
19
|
+
"prepublishOnly": "npm run build"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/Mathunterix/mcp-ghost-perso.git"
|
|
24
|
+
},
|
|
25
|
+
"author": "Matthieu Cousin",
|
|
26
|
+
"homepage": "https://github.com/Mathunterix/mcp-ghost-perso#readme",
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/Mathunterix/mcp-ghost-perso/issues"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"mcp",
|
|
32
|
+
"model-context-protocol",
|
|
33
|
+
"ghost",
|
|
34
|
+
"ghost-cms",
|
|
35
|
+
"cms",
|
|
36
|
+
"blog",
|
|
37
|
+
"claude",
|
|
38
|
+
"ai",
|
|
39
|
+
"anthropic"
|
|
40
|
+
],
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
44
|
+
"zod": "^3.25.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/node": "^22.0.0",
|
|
48
|
+
"typescript": "^5.8.0"
|
|
49
|
+
},
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=18.0.0"
|
|
52
|
+
}
|
|
53
|
+
}
|