@wenyan-md/mcp 1.0.9 → 1.0.10

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.
Files changed (2) hide show
  1. package/dist/index.js +13 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -57,7 +57,6 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
57
57
  description: "ID of the theme to use (e.g., default, orangeheart, rainbow, lapis, pie, maize, purple, phycat).",
58
58
  },
59
59
  },
60
- anyOf: [{ required: ["content"] }, { required: ["file"] }],
61
60
  },
62
61
  },
63
62
  {
@@ -81,24 +80,29 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
81
80
  // level: "debug",
82
81
  // data: JSON.stringify(request.params.arguments),
83
82
  // });
84
- let content = String(request.params.arguments?.content || "");
85
- const file = String(request.params.arguments?.file || "");
83
+ const contentArg = request.params.arguments?.content;
84
+ const fileArg = request.params.arguments?.file;
85
+ if (!contentArg && !fileArg) {
86
+ throw new Error("You must provide either 'content' or 'file' to publish an article.");
87
+ }
88
+ let content = String(contentArg || "");
89
+ const file = String(fileArg || "");
86
90
  const themeId = String(request.params.arguments?.theme_id || "");
87
- let absoluteDirPath = undefined;
91
+ let absoluteDirPath;
88
92
  if (!content && file) {
89
93
  const normalizePath = getNormalizeFilePath(file);
90
94
  content = await fs.readFile(normalizePath, "utf-8");
95
+ if (!content) {
96
+ throw new Error("Can't read content from the specified file.");
97
+ }
91
98
  absoluteDirPath = path.dirname(normalizePath);
92
99
  }
93
- if (!content) {
94
- throw new Error("Missing content to publish");
95
- }
96
100
  const gzhContent = await getGzhContent(content, themeId, "solarized-light", true, true);
97
101
  if (!gzhContent.title) {
98
- throw new Error("未能找到文章标题");
102
+ throw new Error("Can't extract a valid title from the frontmatter.");
99
103
  }
100
104
  if (!gzhContent.cover) {
101
- throw new Error("未能找到文章封面");
105
+ throw new Error("Can't extract a valid cover from the frontmatter or article.");
102
106
  }
103
107
  const response = await publishToDraft(gzhContent.title, gzhContent.content, gzhContent.cover, {
104
108
  relativePath: absoluteDirPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wenyan-md/mcp",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "MCP server for Wenyan, a Markdown formatting tool that allows AI assistants to apply elegant built-in themes and publish articles directly to 微信公众号.",
5
5
  "author": "Lei <caol64@gmail.com> (https://github.com/caol64)",
6
6
  "license": "Apache-2.0",