gearvn-pages-mcp-server 1.4.0 → 1.5.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/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/tools/deploy-page.d.ts.map +1 -1
- package/dist/tools/deploy-page.js +18 -4
- package/dist/tools/deploy-page.js.map +1 -1
- package/dist/tools/update-page.d.ts +9 -0
- package/dist/tools/update-page.d.ts.map +1 -0
- package/dist/tools/update-page.js +69 -0
- package/dist/tools/update-page.js.map +1 -0
- package/dist/types.d.ts +12 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +4 -1
- package/src/tools/deploy-page.ts +25 -4
- package/src/tools/update-page.ts +92 -0
- package/src/types.ts +14 -0
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
4
4
|
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
5
5
|
import { DEPLOY_PAGE_TOOL, handleDeployPage } from "./tools/deploy-page.js";
|
|
6
6
|
import { LIST_PAGES_TOOL, handleListPages } from "./tools/list-pages.js";
|
|
7
|
+
import { UPDATE_PAGE_TOOL, handleUpdatePage } from "./tools/update-page.js";
|
|
7
8
|
import { DELETE_PAGE_TOOL, handleDeletePage } from "./tools/delete-page.js";
|
|
8
9
|
// Create MCP server
|
|
9
10
|
const server = new Server({
|
|
@@ -17,7 +18,7 @@ const server = new Server({
|
|
|
17
18
|
// Handler for listing available tools
|
|
18
19
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
19
20
|
return {
|
|
20
|
-
tools: [DEPLOY_PAGE_TOOL, LIST_PAGES_TOOL, DELETE_PAGE_TOOL],
|
|
21
|
+
tools: [DEPLOY_PAGE_TOOL, LIST_PAGES_TOOL, UPDATE_PAGE_TOOL, DELETE_PAGE_TOOL],
|
|
21
22
|
};
|
|
22
23
|
});
|
|
23
24
|
// Handler for tool calls
|
|
@@ -30,6 +31,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
30
31
|
else if (name === "list-pages") {
|
|
31
32
|
return await handleListPages();
|
|
32
33
|
}
|
|
34
|
+
else if (name === "update-page") {
|
|
35
|
+
return await handleUpdatePage(args);
|
|
36
|
+
}
|
|
33
37
|
else if (name === "delete-page") {
|
|
34
38
|
return await handleDeletePage(args);
|
|
35
39
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE5E,oBAAoB;AACpB,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB;IACE,IAAI,EAAE,yBAAyB;IAC/B,OAAO,EAAE,OAAO;CACjB,EACD;IACE,YAAY,EAAE;QACZ,KAAK,EAAE,EAAE;KACV;CACF,CACF,CAAC;AAEF,sCAAsC;AACtC,MAAM,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE;IAC1D,OAAO;QACL,KAAK,EAAE,CAAC,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,2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AC;AAI1D,eAAO,MAAM,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"deploy-page.d.ts","sourceRoot":"","sources":["../../src/tools/deploy-page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAI1D,eAAO,MAAM,gBAAgB,EAAE,IAmC9B,CAAC;AAEF,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,OAAO;;;;;GA8CnD"}
|
|
@@ -19,22 +19,35 @@ export const DEPLOY_PAGE_TOOL = {
|
|
|
19
19
|
"Generate a simple kebab-case slug (e.g., 'quan-ly-thu-chi', 'landing-page')." +
|
|
20
20
|
"FOR UPDATING EXISTING PAGES: Use the EXACT full slug including timestamp (e.g., 'quan-ly-thu-chi-1730229600') from the backend response. ",
|
|
21
21
|
},
|
|
22
|
+
tags: {
|
|
23
|
+
type: "array",
|
|
24
|
+
items: {
|
|
25
|
+
type: "string",
|
|
26
|
+
},
|
|
27
|
+
description: "Optional array of tags to categorize the page (e.g., ['dashboard', 'finance']). Tags are case-insensitive for filtering.",
|
|
28
|
+
},
|
|
22
29
|
},
|
|
23
30
|
required: ["title", "content", "slug"],
|
|
24
31
|
},
|
|
25
32
|
};
|
|
26
33
|
export async function handleDeployPage(args) {
|
|
27
|
-
const { title, content, slug } = args;
|
|
34
|
+
const { title, content, slug, tags } = args;
|
|
28
35
|
// Validate inputs
|
|
29
36
|
if (!title || !content || !slug) {
|
|
30
37
|
throw new Error("Missing required parameters: title, content, and slug are required");
|
|
31
38
|
}
|
|
32
|
-
//
|
|
33
|
-
const
|
|
39
|
+
// Build request body
|
|
40
|
+
const requestBody = {
|
|
34
41
|
title,
|
|
35
42
|
content,
|
|
36
43
|
slug,
|
|
37
|
-
}
|
|
44
|
+
};
|
|
45
|
+
// Add tags if provided
|
|
46
|
+
if (tags && tags.length > 0) {
|
|
47
|
+
requestBody.tags = tags;
|
|
48
|
+
}
|
|
49
|
+
// Call the deploy API
|
|
50
|
+
const response = await callAPI("/v1/deploy", "POST", requestBody);
|
|
38
51
|
return {
|
|
39
52
|
content: [
|
|
40
53
|
{
|
|
@@ -43,6 +56,7 @@ export async function handleDeployPage(args) {
|
|
|
43
56
|
success: true,
|
|
44
57
|
message: "Page deployed successfully",
|
|
45
58
|
url: response.url,
|
|
59
|
+
tags: tags || [],
|
|
46
60
|
}, null, 2),
|
|
47
61
|
},
|
|
48
62
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy-page.js","sourceRoot":"","sources":["../../src/tools/deploy-page.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,MAAM,CAAC,MAAM,gBAAgB,GAAS;IACpC,IAAI,EAAE,aAAa;IACnB,WAAW,EACT,6sBAA6sB;IAC/sB,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,6FAA6F;aAChG;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,ypBAAypB;aAC5pB;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,iDAAiD;oBACjD,8EAA8E;oBAC9E,2IAA2I;aAC9I;SACF;QACD,QAAQ,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC;KACvC;CACF,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,IAAa;IAClD,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,IAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"deploy-page.js","sourceRoot":"","sources":["../../src/tools/deploy-page.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,MAAM,CAAC,MAAM,gBAAgB,GAAS;IACpC,IAAI,EAAE,aAAa;IACnB,W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,CAAC,SAAS,CAClB;oBACE,OAAO,EAAE,IAAI;oBACb,OAAO,EAAE,4BAA4B;oBACrC,GAAG,EAAE,QAAQ,CAAC,GAAG;oBACjB,IAAI,EAAE,IAAI,IAAI,EAAE;iBACjB,EACD,IAAI,EACJ,CAAC,CACF;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Tool } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
export declare const UPDATE_PAGE_TOOL: Tool;
|
|
3
|
+
export declare function handleUpdatePage(args: unknown): Promise<{
|
|
4
|
+
content: {
|
|
5
|
+
type: "text";
|
|
6
|
+
text: string;
|
|
7
|
+
}[];
|
|
8
|
+
}>;
|
|
9
|
+
//# sourceMappingURL=update-page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-page.d.ts","sourceRoot":"","sources":["../../src/tools/update-page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAI1D,eAAO,MAAM,gBAAgB,EAAE,IAgC9B,CAAC;AAEF,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,OAAO;;;;;GAqDnD"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { callAPI } from "../api.js";
|
|
2
|
+
export const UPDATE_PAGE_TOOL = {
|
|
3
|
+
name: "update-page",
|
|
4
|
+
description: "Update an existing page by slug. You can update title, content, or tags individually or in combination. IMPORTANT: You must use the EXACT slug from list-pages response, including the timestamp suffix (e.g., 'my-page-1730229600'). At least one field (title, content, or tags) must be provided for update.",
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: "object",
|
|
7
|
+
properties: {
|
|
8
|
+
slug: {
|
|
9
|
+
type: "string",
|
|
10
|
+
description: "The exact slug of the page to update. Must match the slug from list-pages response, including timestamp suffix.",
|
|
11
|
+
},
|
|
12
|
+
title: {
|
|
13
|
+
type: "string",
|
|
14
|
+
description: "Optional new title for the page.",
|
|
15
|
+
},
|
|
16
|
+
content: {
|
|
17
|
+
type: "string",
|
|
18
|
+
description: "Optional new HTML content for the page. Must be complete, valid HTML document with TailwindCSS for styling.",
|
|
19
|
+
},
|
|
20
|
+
tags: {
|
|
21
|
+
type: "array",
|
|
22
|
+
items: {
|
|
23
|
+
type: "string",
|
|
24
|
+
},
|
|
25
|
+
description: "Optional new array of tags to categorize the page (e.g., ['dashboard', 'finance']). This will replace existing tags. Tags are case-insensitive for filtering.",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
required: ["slug"],
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
export async function handleUpdatePage(args) {
|
|
32
|
+
const { slug, title, content, tags } = args;
|
|
33
|
+
// Validate inputs
|
|
34
|
+
if (!slug) {
|
|
35
|
+
throw new Error("Missing required parameter: slug is required");
|
|
36
|
+
}
|
|
37
|
+
// Check if at least one field is provided
|
|
38
|
+
if (!title && !content && (!tags || tags.length === 0)) {
|
|
39
|
+
throw new Error("At least one field (title, content, or tags) must be provided for update");
|
|
40
|
+
}
|
|
41
|
+
// Build request body
|
|
42
|
+
const requestBody = {
|
|
43
|
+
slug,
|
|
44
|
+
};
|
|
45
|
+
if (title) {
|
|
46
|
+
requestBody.title = title;
|
|
47
|
+
}
|
|
48
|
+
if (content) {
|
|
49
|
+
requestBody.content = content;
|
|
50
|
+
}
|
|
51
|
+
if (tags && tags.length > 0) {
|
|
52
|
+
requestBody.tags = tags;
|
|
53
|
+
}
|
|
54
|
+
// Call the update API
|
|
55
|
+
const response = await callAPI("/v1/pages", "PUT", requestBody);
|
|
56
|
+
return {
|
|
57
|
+
content: [
|
|
58
|
+
{
|
|
59
|
+
type: "text",
|
|
60
|
+
text: JSON.stringify({
|
|
61
|
+
success: true,
|
|
62
|
+
message: response.message,
|
|
63
|
+
slug: response.slug,
|
|
64
|
+
}, null, 2),
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=update-page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-page.js","sourceRoot":"","sources":["../../src/tools/update-page.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,MAAM,CAAC,MAAM,gBAAgB,GAAS;IACpC,IAAI,EAAE,aAAa;IACnB,WAAW,EACT,iTAAiT;IACnT,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,iHAAiH;aACpH;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,kCAAkC;aAChD;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,6GAA6G;aAChH;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;iBACf;gBACD,WAAW,EACT,+JAA+J;aAClK;SACF;QACD,QAAQ,EAAE,CAAC,MAAM,CAAC;KACnB;CACF,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,IAAa;IAClD,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,IAAsB,CAAC;IAE9D,kBAAkB;IAClB,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IAED,0CAA0C;IAC1C,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC;QACvD,MAAM,IAAI,KAAK,CACb,0EAA0E,CAC3E,CAAC;IACJ,CAAC;IAED,qBAAqB;IACrB,MAAM,WAAW,GAAmB;QAClC,IAAI;KACL,CAAC;IAEF,IAAI,KAAK,EAAE,CAAC;QACV,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC;IAC5B,CAAC;IACD,IAAI,OAAO,EAAE,CAAC;QACZ,WAAW,CAAC,OAAO,GAAG,OAAO,CAAC;IAChC,CAAC;IACD,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5B,WAAW,CAAC,IAAI,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED,sBAAsB;IACtB,MAAM,QAAQ,GAAG,MAAM,OAAO,CAC5B,WAAW,EACX,KAAK,EACL,WAAW,CACZ,CAAC;IAEF,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAe;gBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAClB;oBACE,OAAO,EAAE,IAAI;oBACb,OAAO,EAAE,QAAQ,CAAC,OAAO;oBACzB,IAAI,EAAE,QAAQ,CAAC,IAAI;iBACpB,EACD,IAAI,EACJ,CAAC,CACF;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export interface DeployPageArgs {
|
|
|
2
2
|
title: string;
|
|
3
3
|
content: string;
|
|
4
4
|
slug: string;
|
|
5
|
+
tags?: string[];
|
|
5
6
|
}
|
|
6
7
|
export interface DeployPageResponse {
|
|
7
8
|
url: string;
|
|
@@ -10,6 +11,7 @@ export interface PageSummary {
|
|
|
10
11
|
id: number;
|
|
11
12
|
slug: string;
|
|
12
13
|
title: string;
|
|
14
|
+
tags?: string[];
|
|
13
15
|
created_at: string;
|
|
14
16
|
updated_at: string;
|
|
15
17
|
}
|
|
@@ -17,6 +19,16 @@ export interface ListPagesResponse {
|
|
|
17
19
|
count: number;
|
|
18
20
|
pages: PageSummary[];
|
|
19
21
|
}
|
|
22
|
+
export interface UpdatePageArgs {
|
|
23
|
+
slug: string;
|
|
24
|
+
title?: string;
|
|
25
|
+
content?: string;
|
|
26
|
+
tags?: string[];
|
|
27
|
+
}
|
|
28
|
+
export interface UpdatePageResponse {
|
|
29
|
+
message: string;
|
|
30
|
+
slug: string;
|
|
31
|
+
}
|
|
20
32
|
export interface DeletePageArgs {
|
|
21
33
|
slug: string;
|
|
22
34
|
}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,WAAW,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
9
9
|
import { DEPLOY_PAGE_TOOL, handleDeployPage } from "./tools/deploy-page.js";
|
|
10
10
|
import { LIST_PAGES_TOOL, handleListPages } from "./tools/list-pages.js";
|
|
11
|
+
import { UPDATE_PAGE_TOOL, handleUpdatePage } from "./tools/update-page.js";
|
|
11
12
|
import { DELETE_PAGE_TOOL, handleDeletePage } from "./tools/delete-page.js";
|
|
12
13
|
|
|
13
14
|
// Create MCP server
|
|
@@ -26,7 +27,7 @@ const server = new Server(
|
|
|
26
27
|
// Handler for listing available tools
|
|
27
28
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
28
29
|
return {
|
|
29
|
-
tools: [DEPLOY_PAGE_TOOL, LIST_PAGES_TOOL, DELETE_PAGE_TOOL],
|
|
30
|
+
tools: [DEPLOY_PAGE_TOOL, LIST_PAGES_TOOL, UPDATE_PAGE_TOOL, DELETE_PAGE_TOOL],
|
|
30
31
|
};
|
|
31
32
|
});
|
|
32
33
|
|
|
@@ -39,6 +40,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
39
40
|
return await handleDeployPage(args);
|
|
40
41
|
} else if (name === "list-pages") {
|
|
41
42
|
return await handleListPages();
|
|
43
|
+
} else if (name === "update-page") {
|
|
44
|
+
return await handleUpdatePage(args);
|
|
42
45
|
} else if (name === "delete-page") {
|
|
43
46
|
return await handleDeletePage(args);
|
|
44
47
|
} else {
|
package/src/tools/deploy-page.ts
CHANGED
|
@@ -26,13 +26,21 @@ export const DEPLOY_PAGE_TOOL: Tool = {
|
|
|
26
26
|
"Generate a simple kebab-case slug (e.g., 'quan-ly-thu-chi', 'landing-page')." +
|
|
27
27
|
"FOR UPDATING EXISTING PAGES: Use the EXACT full slug including timestamp (e.g., 'quan-ly-thu-chi-1730229600') from the backend response. ",
|
|
28
28
|
},
|
|
29
|
+
tags: {
|
|
30
|
+
type: "array",
|
|
31
|
+
items: {
|
|
32
|
+
type: "string",
|
|
33
|
+
},
|
|
34
|
+
description:
|
|
35
|
+
"Optional array of tags to categorize the page (e.g., ['dashboard', 'finance']). Tags are case-insensitive for filtering.",
|
|
36
|
+
},
|
|
29
37
|
},
|
|
30
38
|
required: ["title", "content", "slug"],
|
|
31
39
|
},
|
|
32
40
|
};
|
|
33
41
|
|
|
34
42
|
export async function handleDeployPage(args: unknown) {
|
|
35
|
-
const { title, content, slug } = args as DeployPageArgs;
|
|
43
|
+
const { title, content, slug, tags } = args as DeployPageArgs;
|
|
36
44
|
|
|
37
45
|
// Validate inputs
|
|
38
46
|
if (!title || !content || !slug) {
|
|
@@ -41,12 +49,24 @@ export async function handleDeployPage(args: unknown) {
|
|
|
41
49
|
);
|
|
42
50
|
}
|
|
43
51
|
|
|
44
|
-
//
|
|
45
|
-
const
|
|
52
|
+
// Build request body
|
|
53
|
+
const requestBody: DeployPageArgs = {
|
|
46
54
|
title,
|
|
47
55
|
content,
|
|
48
56
|
slug,
|
|
49
|
-
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// Add tags if provided
|
|
60
|
+
if (tags && tags.length > 0) {
|
|
61
|
+
requestBody.tags = tags;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Call the deploy API
|
|
65
|
+
const response = await callAPI<DeployPageResponse>(
|
|
66
|
+
"/v1/deploy",
|
|
67
|
+
"POST",
|
|
68
|
+
requestBody
|
|
69
|
+
);
|
|
50
70
|
|
|
51
71
|
return {
|
|
52
72
|
content: [
|
|
@@ -57,6 +77,7 @@ export async function handleDeployPage(args: unknown) {
|
|
|
57
77
|
success: true,
|
|
58
78
|
message: "Page deployed successfully",
|
|
59
79
|
url: response.url,
|
|
80
|
+
tags: tags || [],
|
|
60
81
|
},
|
|
61
82
|
null,
|
|
62
83
|
2
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Tool } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
import { callAPI } from "../api.js";
|
|
3
|
+
import { UpdatePageArgs, UpdatePageResponse } from "../types.js";
|
|
4
|
+
|
|
5
|
+
export const UPDATE_PAGE_TOOL: Tool = {
|
|
6
|
+
name: "update-page",
|
|
7
|
+
description:
|
|
8
|
+
"Update an existing page by slug. You can update title, content, or tags individually or in combination. IMPORTANT: You must use the EXACT slug from list-pages response, including the timestamp suffix (e.g., 'my-page-1730229600'). At least one field (title, content, or tags) must be provided for update.",
|
|
9
|
+
inputSchema: {
|
|
10
|
+
type: "object",
|
|
11
|
+
properties: {
|
|
12
|
+
slug: {
|
|
13
|
+
type: "string",
|
|
14
|
+
description:
|
|
15
|
+
"The exact slug of the page to update. Must match the slug from list-pages response, including timestamp suffix.",
|
|
16
|
+
},
|
|
17
|
+
title: {
|
|
18
|
+
type: "string",
|
|
19
|
+
description: "Optional new title for the page.",
|
|
20
|
+
},
|
|
21
|
+
content: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description:
|
|
24
|
+
"Optional new HTML content for the page. Must be complete, valid HTML document with TailwindCSS for styling.",
|
|
25
|
+
},
|
|
26
|
+
tags: {
|
|
27
|
+
type: "array",
|
|
28
|
+
items: {
|
|
29
|
+
type: "string",
|
|
30
|
+
},
|
|
31
|
+
description:
|
|
32
|
+
"Optional new array of tags to categorize the page (e.g., ['dashboard', 'finance']). This will replace existing tags. Tags are case-insensitive for filtering.",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
required: ["slug"],
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export async function handleUpdatePage(args: unknown) {
|
|
40
|
+
const { slug, title, content, tags } = args as UpdatePageArgs;
|
|
41
|
+
|
|
42
|
+
// Validate inputs
|
|
43
|
+
if (!slug) {
|
|
44
|
+
throw new Error("Missing required parameter: slug is required");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Check if at least one field is provided
|
|
48
|
+
if (!title && !content && (!tags || tags.length === 0)) {
|
|
49
|
+
throw new Error(
|
|
50
|
+
"At least one field (title, content, or tags) must be provided for update"
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Build request body
|
|
55
|
+
const requestBody: UpdatePageArgs = {
|
|
56
|
+
slug,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
if (title) {
|
|
60
|
+
requestBody.title = title;
|
|
61
|
+
}
|
|
62
|
+
if (content) {
|
|
63
|
+
requestBody.content = content;
|
|
64
|
+
}
|
|
65
|
+
if (tags && tags.length > 0) {
|
|
66
|
+
requestBody.tags = tags;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Call the update API
|
|
70
|
+
const response = await callAPI<UpdatePageResponse>(
|
|
71
|
+
"/v1/pages",
|
|
72
|
+
"PUT",
|
|
73
|
+
requestBody
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
content: [
|
|
78
|
+
{
|
|
79
|
+
type: "text" as const,
|
|
80
|
+
text: JSON.stringify(
|
|
81
|
+
{
|
|
82
|
+
success: true,
|
|
83
|
+
message: response.message,
|
|
84
|
+
slug: response.slug,
|
|
85
|
+
},
|
|
86
|
+
null,
|
|
87
|
+
2
|
|
88
|
+
),
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
};
|
|
92
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -2,6 +2,7 @@ export interface DeployPageArgs {
|
|
|
2
2
|
title: string;
|
|
3
3
|
content: string;
|
|
4
4
|
slug: string;
|
|
5
|
+
tags?: string[];
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
export interface DeployPageResponse {
|
|
@@ -12,6 +13,7 @@ export interface PageSummary {
|
|
|
12
13
|
id: number;
|
|
13
14
|
slug: string;
|
|
14
15
|
title: string;
|
|
16
|
+
tags?: string[];
|
|
15
17
|
created_at: string;
|
|
16
18
|
updated_at: string;
|
|
17
19
|
}
|
|
@@ -21,6 +23,18 @@ export interface ListPagesResponse {
|
|
|
21
23
|
pages: PageSummary[];
|
|
22
24
|
}
|
|
23
25
|
|
|
26
|
+
export interface UpdatePageArgs {
|
|
27
|
+
slug: string;
|
|
28
|
+
title?: string;
|
|
29
|
+
content?: string;
|
|
30
|
+
tags?: string[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface UpdatePageResponse {
|
|
34
|
+
message: string;
|
|
35
|
+
slug: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
24
38
|
export interface DeletePageArgs {
|
|
25
39
|
slug: string;
|
|
26
40
|
}
|