@mastergo/magic-mcp 0.0.5 → 0.0.6

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 +3 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -35,11 +35,11 @@
35
35
  This tool is useful when you need to analyze the structure of a design, understand component hierarchy, or extract design properties.
36
36
  You can provide either:
37
37
  1. fileId and layerId directly, or
38
- 2. a MasterGo short link (like https://mastergo.com/goto/LhGgBAK)
38
+ 2. a short link (like https://{domain}/goto/LhGgBAK)
39
39
  This tool returns the raw DSL data in JSON format that you can then parse and analyze.
40
40
  This tool also returns the rules you must follow when generating code.
41
41
  The DSL data can also be used to transform and generate code for different frameworks."
42
- `,wn=class extends ft{constructor(a){super();this.name=aw;this.description=rw;this.schema=u.object({fileId:u.string().optional().describe("MasterGo design file ID (format: file/<fileId> in MasterGo URL). Required if shortLink is not provided."),layerId:u.string().optional().describe("Layer ID of the specific component or element to retrieve (format: ?layer_id=<layerId> / file=<fileId> in MasterGo URL). Required if shortLink is not provided."),shortLink:u.string().optional().describe("MasterGo short link (like https://mastergo.com/goto/LhGgBAK).")});this.httpUtil=a}async execute({fileId:a,layerId:s,shortLink:r}){var n;try{if(!r&&(!a||!s))throw new Error("Either provide both fileId and layerId, or provide a MasterGo URL");let i=a,o=s;if(r){let c=await this.httpUtil.extractIdsFromUrl(r);i=c.fileId,o=c.layerId}if(!i||!o)throw new Error("Could not determine fileId or layerId");let p=await this.httpUtil.getDsl(i,o);return{content:[{type:"text",text:JSON.stringify(p)}]}}catch(i){let o=((n=i.response)==null?void 0:n.data)??(i==null?void 0:i.message);return{isError:!0,content:[{type:"text",text:JSON.stringify(o)}]}}}};var sw="mcp__getComponentLink",nw="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.",En=class extends ft{constructor(a){super();this.name=sw;this.description=nw;this.schema=u.object({url:u.string().describe("Component documentation link URL, from the componentDocumentLinks property, please ensure the URL is valid")});this.httpUtil=a}async execute({url:a}){try{return{content:[{type:"text",text:`${await this.httpUtil.request({method:"GET",url:a})}`}]}}catch(s){return{content:[{type:"text",text:JSON.stringify({error:"Failed to get component documentation",message:s instanceof Error?s.message:String(s)})}]}}}};var qf=`The \`results\` returns an XML file, which contains two types of information:
42
+ `,wn=class extends ft{constructor(a){super();this.name=aw;this.description=rw;this.schema=u.object({fileId:u.string().optional().describe("MasterGo design file ID (format: file/<fileId> in MasterGo URL). Required if shortLink is not provided."),layerId:u.string().optional().describe("Layer ID of the specific component or element to retrieve (format: ?layer_id=<layerId> / file=<fileId> in MasterGo URL). Required if shortLink is not provided."),shortLink:u.string().optional().describe("Short link (like https://{domain}/goto/LhGgBAK).")});this.httpUtil=a}async execute({fileId:a,layerId:s,shortLink:r}){var n;try{if(!r&&(!a||!s))throw new Error("Either provide both fileId and layerId, or provide a MasterGo URL");let i=a,o=s;if(r){let c=await this.httpUtil.extractIdsFromUrl(r);i=c.fileId,o=c.layerId}if(!i||!o)throw new Error("Could not determine fileId or layerId");let p=await this.httpUtil.getDsl(i,o);return{content:[{type:"text",text:JSON.stringify(p)}]}}catch(i){let o=((n=i.response)==null?void 0:n.data)??(i==null?void 0:i.message);return{isError:!0,content:[{type:"text",text:JSON.stringify(o)}]}}}};var sw="mcp__getComponentLink",nw="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.",En=class extends ft{constructor(a){super();this.name=sw;this.description=nw;this.schema=u.object({url:u.string().describe("Component documentation link URL, from the componentDocumentLinks property, please ensure the URL is valid")});this.httpUtil=a}async execute({url:a}){try{return{content:[{type:"text",text:`${await this.httpUtil.request({method:"GET",url:a})}`}]}}catch(s){return{content:[{type:"text",text:JSON.stringify({error:"Failed to get component documentation",message:s instanceof Error?s.message:String(s)})}]}}}};var qf=`The \`results\` returns an XML file, which contains two types of information:
43
43
 
44
44
  - **meta**: Describes the site, environment, requirements, and other context.
45
45
  - **action**: Corresponds to the entry page name and \`targetLayerId\`, which is the ID of the target page.
@@ -444,7 +444,7 @@ This tool provides a structured workflow for component development following bes
444
444
  You must provide an absolute rootPath of workspace to save workflow files.
445
445
  `,Pn=class extends ft{constructor(a){super();this.name=pw;this.description=uw;this.schema=u.object({rootPath:u.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:u.string().describe("MasterGo design file ID (format: file/<fileId> in MasterGo URL)"),layerId:u.string().describe("Layer ID of the specific component or element to retrieve (format: ?layer_id=<layerId> / file=<fileId> in MasterGo URL)")});this.httpUtil=a}async execute({rootPath:a,fileId:s,layerId:r}){var l;let n=`${a}/.mastergo/`;Ot.default.existsSync(n)||Ot.default.mkdirSync(n,{recursive:!0});let i=`${n}/component-workflow.md`,o=await this.httpUtil.getComponentStyleJson(s,r),p=`${n}/${o[0].name}.json`,c=m=>{if(m.path&&m.path.length>0){m.imageUrls=[];let x=m.id.replaceAll("/","&"),d=`${n}/images`;Ot.default.existsSync(d)||Ot.default.mkdirSync(d,{recursive:!0}),(m.path??[]).forEach((f,g)=>{let h=`${d}/${x}-${g}.svg`;Ot.default.existsSync(h)||Ot.default.writeFileSync(h,`<svg width="100%" height="100%" viewBox="0 0 16 16"xmlns="http://www.w3.org/2000/svg">
446
446
  <path d="${f}" fill="currentColor"/>
447
- </svg>`),m.imageUrls.push(h)}),delete m.path}m.children&&m.children.forEach(x=>{c(x)})};c(o[0]),Ot.default.existsSync(i)||Ot.default.writeFileSync(i,Uf),Ot.default.writeFileSync(p,JSON.stringify(o[0]));try{return{content:[{type:"text",text:JSON.stringify({files:{workflow:i,componentSpec:p},message:"Component development files successfully created",rules:[`Follow the component workflow process defined in file://${i} 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://${p}, ensuring all properties and states are properly handled.`]})}]}}catch(m){let x=((l=m.response)==null?void 0:l.data)??(m==null?void 0:m.message);return{isError:!0,content:[{type:"text",text:JSON.stringify(x)}]}}}};var Rn={name:"@mastergo/magic-mcp",version:"0.0.5",description:"MasterGo MCP standalone service",main:"dist/index.js",bin:{"mastergo-magic-mcp":"bin/cli.js"},files:["dist/**/*","bin/**/*","!**/*.map","!**/.DS_Store","!**/.idea","!**/.vscode"],engines:{node:">=18"},scripts:{build:"node build.js",start:"node bin/cli.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 mw=`version_${Rn.version.replace(/\./g,"_")}`,fw=`the current version is ${Rn.version}`,kn=class extends ft{constructor(){super();this.name=mw;this.description=fw;this.schema=u.object({})}async execute({}){return{content:[{type:"text",text:JSON.stringify(Rn.version)}]}}};var zf=t=>{process.env.DEBUG==="true"&&console.log(t)};function hw(){let t=process.env.MASTERGO_API_TOKEN,e=process.env.API_BASE_URL||"http://localhost:3000",a=process.env.DEBUG==="true";t||(console.error("Error: MASTERGO_API_TOKEN environment variable not set"),process.exit(1)),zf("Starting MasterGo MCP server..."),zf(`API base URL: ${e}`);let s=new Ms({name:"MasterGoMcpServer",version:"0.0.1"}),r=new _n(e,t);new kn().register(s),new wn(r).register(s),new En(r).register(s),new Sn(r).register(s),new Pn(r).register(s),s.connect(new Hs),a&&console.log("MasterGo MCP server started and waiting for connection...")}hw();
447
+ </svg>`),m.imageUrls.push(h)}),delete m.path}m.children&&m.children.forEach(x=>{c(x)})};c(o[0]),Ot.default.existsSync(i)||Ot.default.writeFileSync(i,Uf),Ot.default.writeFileSync(p,JSON.stringify(o[0]));try{return{content:[{type:"text",text:JSON.stringify({files:{workflow:i,componentSpec:p},message:"Component development files successfully created",rules:[`Follow the component workflow process defined in file://${i} 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://${p}, ensuring all properties and states are properly handled.`]})}]}}catch(m){let x=((l=m.response)==null?void 0:l.data)??(m==null?void 0:m.message);return{isError:!0,content:[{type:"text",text:JSON.stringify(x)}]}}}};var Rn={name:"@mastergo/magic-mcp",version:"0.0.6",description:"MasterGo MCP standalone service",main:"dist/index.js",bin:{"mastergo-magic-mcp":"bin/cli.js"},files:["dist/**/*","bin/**/*","!**/*.map","!**/.DS_Store","!**/.idea","!**/.vscode"],engines:{node:">=18"},scripts:{build:"node build.js",start:"node bin/cli.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 mw=`version_${Rn.version.replace(/\./g,"_")}`,fw=`the current version is ${Rn.version}`,kn=class extends ft{constructor(){super();this.name=mw;this.description=fw;this.schema=u.object({})}async execute({}){return{content:[{type:"text",text:JSON.stringify(Rn.version)}]}}};var zf=t=>{process.env.DEBUG==="true"&&console.log(t)};function hw(){let t=process.env.MASTERGO_API_TOKEN,e=process.env.API_BASE_URL||"http://localhost:3000",a=process.env.DEBUG==="true";t||(console.error("Error: MASTERGO_API_TOKEN environment variable not set"),process.exit(1)),zf("Starting MasterGo MCP server..."),zf(`API base URL: ${e}`);let s=new Ms({name:"MasterGoMcpServer",version:"0.0.1"}),r=new _n(e,t);new kn().register(s),new wn(r).register(s),new En(r).register(s),new Sn(r).register(s),new Pn(r).register(s),s.connect(new Hs),a&&console.log("MasterGo MCP server started and waiting for connection...")}hw();
448
448
  /*! Bundled license information:
449
449
 
450
450
  uri-js/dist/es5/uri.all.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastergo/magic-mcp",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "MasterGo MCP standalone service",
5
5
  "main": "dist/index.js",
6
6
  "bin": {