@mastergo/magic-mcp 0.1.6-beta.1 → 0.1.6-beta.2
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 +6 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -81,11 +81,13 @@ The DSL data can also be used to transform and generate code for different frame
|
|
|
81
81
|
|
|
82
82
|
\u53C2\u6570\u8BF4\u660E\uFF1A
|
|
83
83
|
- data\uFF1A\u9700\u8981\u8F6C\u6362\u7684\u4EE3\u7801\u5185\u5BB9\uFF0C\u4E00\u822C\u4E3A\u5B8C\u6574\u7684 HTML \u5B57\u7B26\u4E32\uFF0C\u4E5F\u53EF\u4EE5\u662F\u5176\u4ED6\u6587\u672C\u683C\u5F0F\u3002
|
|
84
|
-
- fileId / layerId\uFF1A\u53EF\u9009\uFF1B\u4E0D\u63D0\u4F9B shortLink \u65F6\u81F3\u5C11\u9700\u8981 fileId\
|
|
85
|
-
- shortLink\uFF1A\u53EF\u9009\uFF0C\u77ED\u94FE\u63A5\u5F62\u5F0F\uFF08\u4F8B\u5982 https://{domain}/goto/xxxx\uFF09\
|
|
84
|
+
- fileId / layerId\uFF1A\u53EF\u9009\uFF1B\u4E0D\u63D0\u4F9B shortLink \u65F6\u81F3\u5C11\u9700\u8981 fileId\u3002layerId \u53EF\u4E0D\u4F20\u3002
|
|
85
|
+
- shortLink\uFF1A\u53EF\u9009\uFF0C\u77ED\u94FE\u63A5\u5F62\u5F0F\uFF08\u4F8B\u5982 https://{domain}/goto/xxxx\uFF09\u3002
|
|
86
|
+
\u6CE8\u610F\u4E8B\u9879\uFF1A\u4EC5\u4ECE URL \u4E2D\u7684 layer_id \u53C2\u6570\u8BFB\u53D6 layerId\uFF1Bpageid/page_id \u4E0D\u4F1A\u88AB\u5F53\u4F5C layerId\u3002
|
|
87
|
+
\u5982\u679C\u77ED\u94FE\u63A5\u6216 URL \u4E2D\u6CA1\u6709\u89E3\u6790\u51FA layer_id\uFF0C\u4E5F\u53EF\u4EE5\u4E0D\u4F20 layerId\u3002
|
|
86
88
|
|
|
87
89
|
\u5DE5\u5177\u628A data \u539F\u6837\u4F20\u7ED9\u540E\u7AEF\uFF0C\u5E76\u9644\u5E26 fileId \u4E0E\u53EF\u9009\u7684 layerId\u3002
|
|
88
|
-
`,Cc=class extends Xe{constructor(){super();this.name=Eq;this.description=Tq;this.schema=ce.object({data:ce.string().min(1,"data \u4E0D\u80FD\u4E3A\u7A7A").describe("\u9700\u8981\u8FDB\u884C C2D\uFF08\u4EE3\u7801\u8F6C\u8BBE\u8BA1\uFF09\u7684\u4EE3\u7801\u5185\u5BB9\uFF0C\u901A\u5E38\u662F\u4E00\u6574\u4EFD HTML \u5B57\u7B26\u4E32"),fileId:ce.string().optional().describe("\u6587\u4EF6 ID\uFF08URL \u4E2D file= \u6216\u8DEF\u5F84\u4E2D\u7684\u6570\u5B57\u6BB5\uFF09\u3002\u672A\u4F20 shortLink \u65F6\u5FC5\u586B\u3002"),layerId:ce.string().optional().describe("\u53EF\u9009\u3002\u56FE\u5C42 ID\
|
|
90
|
+
`,Cc=class extends Xe{constructor(){super();this.name=Eq;this.description=Tq;this.schema=ce.object({data:ce.string().min(1,"data \u4E0D\u80FD\u4E3A\u7A7A").describe("\u9700\u8981\u8FDB\u884C C2D\uFF08\u4EE3\u7801\u8F6C\u8BBE\u8BA1\uFF09\u7684\u4EE3\u7801\u5185\u5BB9\uFF0C\u901A\u5E38\u662F\u4E00\u6574\u4EFD HTML \u5B57\u7B26\u4E32"),fileId:ce.string().optional().describe("\u6587\u4EF6 ID\uFF08URL \u4E2D file= \u6216\u8DEF\u5F84\u4E2D\u7684\u6570\u5B57\u6BB5\uFF09\u3002\u672A\u4F20 shortLink \u65F6\u5FC5\u586B\u3002"),layerId:ce.string().optional().describe("\u53EF\u9009\u3002\u56FE\u5C42 ID\uFF08\u53EA\u8BFB\u53D6 URL \u53C2\u6570 layer_id\uFF09\u3002\u4E0D\u4F20\u6216\u89E3\u6790\u4E0D\u5230\u5219\u4EC5\u6309 file \u7EF4\u5EA6\u540C\u6B65\uFF1Bpageid/page_id \u4E0D\u4F1A\u88AB\u5F53\u4F5C layerId\u3002"),shortLink:ce.string().optional().describe("Short link (like https://{domain}/goto/LhGgBAK).")})}async execute({data:r,fileId:n,layerId:o,shortLink:i}){var s;try{let a=i==null?void 0:i.trim(),c=n==null?void 0:n.trim(),u=o==null?void 0:o.trim(),l,p;if(a){let h=await bt.extractIdsFromUrl(a);l=this.normalizeFileId(h.fileId),p=h.layerId}else if(c)l=this.normalizeFileId(c),p=u||void 0;else throw new Error("\u8BF7\u4F20 shortLink\uFF0C\u6216\u81F3\u5C11\u4F20 fileId\uFF08layerId \u53EF\u9009\uFF09");if(!l)throw new Error("Could not determine fileId");let m=await bt.postC2d(r,l,p);return{content:[{type:"text",text:JSON.stringify(m)}]}}catch(a){let c=((s=a==null?void 0:a.response)==null?void 0:s.data)??(a==null?void 0:a.message);return{isError:!0,content:[{type:"text",text:JSON.stringify(c)}]}}}normalizeFileId(r){return r&&r.replace(/^file\//,"")}};var Rq="mcp__getComponentLink",Pq="When the data returned by mcp__getDsl contains a non-empty componentDocumentLinks array, this tool is used to sequentially retrieve URLs from the componentDocumentLinks array and then obtain component documentation data. The returned document data is used for you to generate frontend code based on components.",Oc=class extends Xe{constructor(){super();this.name=Rq;this.description=Pq;this.schema=ce.object({url:ce.string().describe("Component documentation link URL, from the componentDocumentLinks property, please ensure the URL is valid")})}async execute({url:r}){try{return{content:[{type:"text",text:`${await bt.request({method:"GET",url:r})}`}]}}catch(n){return{content:[{type:"text",text:JSON.stringify({error:"Failed to get component documentation",message:n instanceof Error?n.message:String(n)})}]}}}};var ak=`The \`results\` returns an XML file, which contains two types of information:
|
|
89
91
|
|
|
90
92
|
- **meta**: Describes the site, environment, requirements, and other context.
|
|
91
93
|
- **action**: Corresponds to the entry page name and \`targetLayerId\`, which is the ID of the target page.
|
|
@@ -490,7 +492,7 @@ This tool provides a structured workflow for component development following bes
|
|
|
490
492
|
You must provide an absolute rootPath of workspace to save workflow files.
|
|
491
493
|
`,Ic=class extends Xe{constructor(){super();this.name=Aq;this.description=Nq;this.schema=ce.object({rootPath:ce.string().describe("The root path of the project, if the user does not provide, you can use the current directory as the root path"),fileId:ce.string().describe("MasterGo design file ID (format: file/<fileId> in MasterGo URL)"),layerId:ce.string().describe("Layer ID of the specific component or element to retrieve (format: ?layer_id=<layerId> / file=<fileId> in MasterGo URL)")})}async execute({rootPath:r,fileId:n,layerId:o}){var l;let i=`${r}/.mastergo/`;pr.default.existsSync(i)||pr.default.mkdirSync(i,{recursive:!0});let s=`${i}/component-workflow.md`,a=await bt.getComponentStyleJson(n,o),c=`${i}/${a[0].name}.json`,u=p=>{if(p.path&&p.path.length>0){p.imageUrls=[];let m=p.id.replaceAll("/","&"),h=`${i}/images`;pr.default.existsSync(h)||pr.default.mkdirSync(h,{recursive:!0}),(p.path??[]).forEach((d,g)=>{let f=`${h}/${m}-${g}.svg`;pr.default.existsSync(f)||pr.default.writeFileSync(f,`<svg width="100%" height="100%" viewBox="0 0 16 16"xmlns="http://www.w3.org/2000/svg">
|
|
492
494
|
<path d="${d}" fill="currentColor"/>
|
|
493
|
-
</svg>`),p.imageUrls.push(f)}),delete p.path}p.children&&p.children.forEach(m=>{u(m)})};u(a[0]),pr.default.existsSync(s)||pr.default.writeFileSync(s,ck),pr.default.writeFileSync(c,JSON.stringify(a[0]));try{return{content:[{type:"text",text:JSON.stringify({files:{workflow:s,componentSpec:c},message:"Component development files successfully created",rules:[`Follow the component workflow process defined in file://${s} for structured development. This workflow contains a lot of content, you'll need to read it in multiple sessions.`,`Implement the component according to the specifications in file://${c}, ensuring all properties and states are properly handled.`]})}]}}catch(p){let m=((l=p.response)==null?void 0:l.data)??(p==null?void 0:p.message);return{isError:!0,content:[{type:"text",text:JSON.stringify(m)}]}}}};var Ac={name:"@mastergo/magic-mcp",version:"0.1.6-beta.
|
|
495
|
+
</svg>`),p.imageUrls.push(f)}),delete p.path}p.children&&p.children.forEach(m=>{u(m)})};u(a[0]),pr.default.existsSync(s)||pr.default.writeFileSync(s,ck),pr.default.writeFileSync(c,JSON.stringify(a[0]));try{return{content:[{type:"text",text:JSON.stringify({files:{workflow:s,componentSpec:c},message:"Component development files successfully created",rules:[`Follow the component workflow process defined in file://${s} for structured development. This workflow contains a lot of content, you'll need to read it in multiple sessions.`,`Implement the component according to the specifications in file://${c}, ensuring all properties and states are properly handled.`]})}]}}catch(p){let m=((l=p.response)==null?void 0:l.data)??(p==null?void 0:p.message);return{isError:!0,content:[{type:"text",text:JSON.stringify(m)}]}}}};var Ac={name:"@mastergo/magic-mcp",version:"0.1.6-beta.2",description:"MasterGo MCP standalone service",main:"dist/index.js",bin:{"mastergo-magic-mcp":"dist/index.js"},files:["dist/**/*","!**/*.map","!**/.DS_Store","!**/.idea","!**/.vscode"],engines:{node:">=18"},scripts:{build:"node build.js",start:"node dist/index.js --token=test --url=http://localhost:3000 --debug",prepublishOnly:"npm run build"},keywords:["mastergo","mcp","ai"],author:"",license:"ISC",private:!1,dependencies:{"@modelcontextprotocol/sdk":"^1.6.1",axios:"^1.6.0",zod:"^3.22.4"},devDependencies:{"@types/node":"^20.8.10","@typescript-eslint/eslint-plugin":"^6.9.1","@typescript-eslint/parser":"^6.9.1",esbuild:"^0.25.1","esbuild-plugin-tsc":"^0.5.0",eslint:"^8.52.0",pkg:"^5.8.1",prettier:"^3.0.3","ts-node":"^10.9.1",typescript:"^5.2.2"}};var Zq=`version_${Ac.version.replace(/\./g,"_")}`,Mq=`the current version is ${Ac.version}`,Nc=class extends Xe{constructor(){super();this.name=Zq;this.description=Mq;this.schema=ce.object({})}async execute({}){return{content:[{type:"text",text:JSON.stringify(Ac.version)}]}}};function Dq(){let{token:t,baseUrl:e,rules:r,debug:n,noRule:o}=ok();n&&(process.env.DEBUG="true",console.log("Debug information:"),console.log(`Token: ${t?"set":"not set"}`),console.log(`API URL: ${e||"default"}`),console.log(`Rules: ${r.length>0?r.join(", "):"none"}`),console.log(`No Rule: ${o?"enabled":"disabled"}`),console.log("Debug mode: enabled"));let i=new Ya({name:"MasterGoMcpServer",version:"0.0.1"});new Nc().register(i),new Tc().register(i),new Pc().register(i),new Cc().register(i),new Oc().register(i),new jc().register(i),new Ic().register(i),i.connect(new ec)}Dq();
|
|
494
496
|
/*! Bundled license information:
|
|
495
497
|
|
|
496
498
|
mime-db/index.js:
|