@opentiny/webmcp-cli 0.0.1-alpha.1 → 0.0.1-alpha.3

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.
@@ -0,0 +1,72 @@
1
+ ;(function(){
2
+ "use strict";
3
+ (() => {
4
+ // webmcp-tools/juejin.cn/index.ts
5
+ var mcp = navigator.modelContext;
6
+ if (!mcp || typeof mcp.registerTool !== "function") {
7
+ console.warn("[webmcp-tools] juejin.cn: navigator.modelContext.registerTool \u672A\u5C31\u7EEA\uFF0C\u8DF3\u8FC7\u6CE8\u5165");
8
+ } else if (!window.__webmcptools_juejincn) {
9
+ try {
10
+ mcp.registerTool({
11
+ name: "create_article",
12
+ title: "\u53D1\u5E03\u65B0\u6587\u7AE0",
13
+ description: "\u63A5\u6536\u6587\u7AE0\u7684\u6807\u9898\u548C\u6B63\u6587\uFF0C\u5C06\u5B83\u4EEC\u586B\u5199\u5230\u7F51\u9875\u4E2D\u3002",
14
+ inputSchema: {
15
+ type: "object",
16
+ properties: {
17
+ title: {
18
+ type: "string",
19
+ description: "\u6587\u7AE0\u6807\u9898\uFF0C\u5FC5\u586B\uFF0C \u5EFA\u8BAE\u4E0D\u8D85\u8FC715\u4E2A\u5B57\uFF0C\u4E0D\u5141\u8BB8\u6709\u7279\u6B8A\u7B26\u53F7\u5F71\u54CD\u547D\u4EE4\u884C\u53C2\u6570\u89E3\u6790"
20
+ },
21
+ content: {
22
+ type: "string",
23
+ description: "\u6587\u7AE0\u5185\u5BB9\u7684base64\u7F16\u7801\u540E\u7684\u5B57\u7B26\u4E32\uFF0C\u5FC5\u586B\u3002"
24
+ }
25
+ },
26
+ required: ["title", "content"]
27
+ },
28
+ execute: async ({ title, content }) => {
29
+ if (!location.href.startsWith("https://juejin.cn/editor/drafts/new")) {
30
+ return {
31
+ content: [
32
+ { type: "text", text: "\u5F53\u524D\u9875\u9762\u4E0D\u662F\u53D1\u5E03\u65B0\u6587\u7AE0\u9875\u9762\uFF0C\u8BF7\u5148\u8BBF\u95EE https://juejin.cn/editor/drafts/new?v=2" }
33
+ ]
34
+ };
35
+ }
36
+ const titleInput = document.querySelector(".edit-draft .header .title-input");
37
+ if (titleInput) {
38
+ titleInput.focus();
39
+ titleInput.value = title;
40
+ titleInput.dispatchEvent(
41
+ new InputEvent("input", {
42
+ bubbles: true,
43
+ cancelable: true,
44
+ data: title
45
+ })
46
+ );
47
+ titleInput.dispatchEvent(new Event("change", { bubbles: true }));
48
+ titleInput.blur();
49
+ }
50
+ const decodeContent = decodeURIComponent(escape(atob(content)));
51
+ const cm5El = document.querySelector(".edit-draft .CodeMirror");
52
+ if (cm5El && cm5El.CodeMirror) {
53
+ cm5El.CodeMirror.setValue(decodeContent);
54
+ } else {
55
+ const cm6View = document.querySelector(".cm-editor")?.cmView?.view;
56
+ if (cm6View) {
57
+ cm6View.dispatch({
58
+ changes: { from: 0, to: cm6View.state.doc.length, insert: decodeContent }
59
+ });
60
+ }
61
+ }
62
+ return { content: [{ type: "text", text: "\u6587\u7AE0\u6807\u9898\u548C\u5185\u5BB9\u5DF2\u7ECF\u586B\u5199\u5230\u7F51\u9875" }] };
63
+ }
64
+ });
65
+ window.__webmcptools_juejincn = true;
66
+ console.log("[webmcp-tools] juejin.cn \u5DE5\u5177\u6CE8\u518C\u6210\u529F");
67
+ } catch (e) {
68
+ console.error("[webmcp-tools] juejin.cn \u5DE5\u5177\u6CE8\u518C\u5931\u8D25:", e.message);
69
+ }
70
+ }
71
+ })();
72
+ })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentiny/webmcp-cli",
3
- "version": "0.0.1-alpha.1",
3
+ "version": "0.0.1-alpha.3",
4
4
  "type": "module",
5
5
  "description": "WebMCP CLI for AI Agents to interact with browser via Puppeteer",
6
6
  "main": "dist/index.js",
@@ -27,7 +27,8 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@mcp-b/webmcp-polyfill": "^2.2.0",
30
- "@page-agent/page-controller": "^1.7.1",
30
+ "@page-agent/page-controller": "^1.8.2",
31
+ "clipboardy": "^5.3.1",
31
32
  "commander": "^11.1.0",
32
33
  "picocolors": "^1.0.0",
33
34
  "puppeteer-core": "^22.0.0",
@@ -43,7 +44,6 @@
43
44
  "scripts": {
44
45
  "dev": "tsup --watch",
45
46
  "build:inject": "node scripts/build-inject.mjs",
46
- "build:tools": "node scripts/build-inject.mjs",
47
47
  "build": "tsup && pnpm run build:inject",
48
48
  "link:global": "npm install -g .",
49
49
  "start": "node dist/bin.js"