Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/main/java/run/halo/mcpserver/tools/PostTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class PostTools extends ToolSupport implements ToolGroup {
static final String RESTORE_POST = "halo_restore_post";

private static final int MAX_CONTENT_CHARS = 65_536;
private static final String DEFAULT_RAW_TYPE = "html";

private final ReactiveExtensionClient client;
private final PostContentService contentService;
Expand Down Expand Up @@ -277,12 +276,13 @@ private BuiltInTool createTool() {
"name", stringSchema("Post metadata.name (a lowercase DNS label)."),
"title", stringSchema(),
"slug", stringSchema(),
"raw", stringSchema("Editable source content stored in the snapshot."),
"raw",
stringSchema("Editable source content stored in the snapshot."
+ " Provide an HTML body fragment by default (no <html>, <head>,"
+ " <body>, <script>, or <style> tags) so Halo's built-in rich text"
+ " editor can preview and edit it."),
"content", stringSchema("Rendered content; defaults to raw when omitted."),
"rawType",
described(
stringSchemaWithDefault(DEFAULT_RAW_TYPE),
"Format identifier for raw, such as html or markdown."),
"rawType", described(stringSchemaWithDefault(DEFAULT_RAW_TYPE), RAW_TYPE_DESCRIPTION),
"publish",
described(
booleanSchema(false),
Expand Down Expand Up @@ -317,12 +317,18 @@ private BuiltInTool updateTool() {
"name", stringSchema("Post metadata.name."),
"title", stringSchema(),
"slug", stringSchema(),
"raw", stringSchema("New editable source; omit for a metadata-only update."),
"raw",
stringSchema("New editable source; omit for a metadata-only update."
+ " Provide an HTML body fragment by default (no <html>, <head>,"
+ " <body>, <script>, or <style> tags) so Halo's built-in rich text"
+ " editor can preview and edit it."),
"content", stringSchema("Rendered content; valid only when raw is provided."),
"rawType",
described(
stringSchemaWithDefault(DEFAULT_RAW_TYPE),
"Format identifier for raw; valid only when raw is provided."),
RAW_TYPE_DESCRIPTION + " Only valid when raw is provided; when"
+ " updating existing content, reuse the rawType returned by"
+ " the read tool."),
"visible", enumSchema(Post.VisibleEnum.class),
"allowComment", booleanSchema(),
"cover", nullableStringSchema(),
Expand Down
22 changes: 14 additions & 8 deletions src/main/java/run/halo/mcpserver/tools/SinglePageTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class SinglePageTools extends ToolSupport implements ToolGroup {
static final String RESTORE_PAGE = "halo_restore_single_page";

private static final int MAX_CONTENT_CHARS = 65_536;
private static final String DEFAULT_RAW_TYPE = "html";

private final ReactiveExtensionClient client;
private final ContentSnapshots snapshots;
Expand Down Expand Up @@ -276,12 +275,13 @@ private BuiltInTool createTool() {
"name", stringSchema("SinglePage metadata.name (a lowercase DNS label)."),
"title", stringSchema(),
"slug", stringSchema(),
"raw", stringSchema("Editable source content stored in the snapshot."),
"raw",
stringSchema("Editable source content stored in the snapshot."
+ " Provide an HTML body fragment by default (no <html>, <head>,"
+ " <body>, <script>, or <style> tags) so Halo's built-in rich text"
+ " editor can preview and edit it."),
"content", stringSchema("Rendered content; defaults to raw when omitted."),
"rawType",
described(
stringSchemaWithDefault(DEFAULT_RAW_TYPE),
"Format identifier for raw, such as html or markdown."),
"rawType", described(stringSchemaWithDefault(DEFAULT_RAW_TYPE), RAW_TYPE_DESCRIPTION),
"publish",
described(
booleanSchema(false),
Expand All @@ -307,12 +307,18 @@ private BuiltInTool updateTool() {
"name", stringSchema("SinglePage metadata.name."),
"title", stringSchema(),
"slug", stringSchema(),
"raw", stringSchema("New editable source; omit for a metadata-only update."),
"raw",
stringSchema("New editable source; omit for a metadata-only update."
+ " Provide an HTML body fragment by default (no <html>, <head>,"
+ " <body>, <script>, or <style> tags) so Halo's built-in rich text"
+ " editor can preview and edit it."),
"content", stringSchema("Rendered content; valid only when raw is provided."),
"rawType",
described(
stringSchemaWithDefault(DEFAULT_RAW_TYPE),
"Format identifier for raw; valid only when raw is provided."),
RAW_TYPE_DESCRIPTION + " Only valid when raw is provided; when"
+ " updating existing content, reuse the rawType returned by"
+ " the read tool."),
"visible", enumSchema(Post.VisibleEnum.class),
"allowComment", booleanSchema()),
List.of("name")),
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/run/halo/mcpserver/tools/ToolSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ abstract class ToolSupport {

static final int DEFAULT_PAGE_SIZE = 20;
static final int MAX_PAGE_SIZE = 100;
static final String DEFAULT_RAW_TYPE = "html";
static final String RAW_TYPE_DESCRIPTION =
"Format identifier for raw. " + DEFAULT_RAW_TYPE + " (the default) is compatible with Halo's built-in"
+ " rich text editor; use markdown only when the user explicitly requests Markdown or confirms a"
+ " Markdown editor plugin is installed.";
static final McpSchema.ToolAnnotations READ_ONLY = annotations(true, false, true, false);
static final McpSchema.ToolAnnotations CREATE = annotations(false, false, false, false);
static final McpSchema.ToolAnnotations UPDATE = annotations(false, true, true, false);
Expand Down
Loading