mcp__getDsl
Retrieve raw DSL data and code generation rules from MasterGo design files. Analyze component hierarchy and design properties to transform designs into code.
Instructions
"Use this tool to retrieve the DSL (Domain Specific Language) data from MasterGo design files and the rules you must follow when generating code. This tool is useful when you need to analyze the structure of a design, understand component hierarchy, or extract design properties. You must provide a fileId and layerId to identify the specific design element. This tool returns the raw DSL data in JSON format that you can then parse and analyze. This tool also returns the rules you must follow when generating code. The DSL data can also be used to transform and generate code for different frameworks."
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fileId | Yes | MasterGo design file ID (format: file/<fileId> in MasterGo URL) | |
| layerId | Yes | Layer ID of the specific component or element to retrieve (format: ?layer_id=<layerId> / file=<fileId> in MasterGo URL) |
Implementation Reference
- src/tools/get-dsl.ts:38-60 (handler)The execute() method is the handler for the mcp__getDsl tool. It calls httpUtil.getDsl(fileId, layerId) and returns the result as JSON text. On failure, it returns an error message.
async execute({ fileId, layerId }: z.infer<typeof this.schema>) { try { const dsl = await this.httpUtil.getDsl(fileId, layerId); return { content: [ { type: "text" as const, text: JSON.stringify(dsl), }, ], }; } catch (error) { return { content: [ { type: "text" as const, text: JSON.stringify({ error: "Failed to get DSL" }), }, ], }; } } } - src/tools/get-dsl.ts:25-36 (schema)Zod schema defining the two input parameters for the mcp__getDsl tool: fileId (string) and layerId (string).
schema = z.object({ fileId: z .string() .describe( "MasterGo design file ID (format: file/<fileId> in MasterGo URL)" ), layerId: z .string() .describe( "Layer ID of the specific component or element to retrieve (format: ?layer_id=<layerId> / file=<fileId> in MasterGo URL)" ), }); - src/index.ts:41-42 (registration)Registration of the GetDslTool on the MCP server. A new GetDslTool instance is created with the httpUtil and registered via the BaseTool.register() method.
new GetDslTool(httpUtil).register(server); new GetComponentLinkTool(httpUtil).register(server); - src/http-util.ts:87-121 (helper)The getDsl() method in HttpUtil that actually performs the HTTP GET request to /mcp/dsl endpoint with fileId/layerId params, and enriches the response with componentDocumentLinks (extracted from DSL nodes) and rules.
public async getDsl(fileId: string, layerId: string): Promise<DslResponse> { try { const params: any = { fileId, layerId }; const response = await this.httpClient.get("/mcp/dsl", { params }); const result = { dsl: response.data, componentDocumentLinks: this.handleDslComponentDocumentLinks( response.data ), rules: [ "token filed must be generated as a variable (colors, shadows, fonts, etc.) and the token field must be displayed in the comment", ` componentDocumentLinks is a list of frontend component documentation links used in the DSL layer, designed to help you understand how to use the components. When it exists and is not empty, you need to use mcp__getComponentLink in a for loop to get the URL content of all components in the list, understand how to use the components, and generate code using the components. For example: \`\`\`js const componentDocumentLinks = [ 'https://example.com/ant/button.mdx', 'https://example.com/ant/button.mdx' ] for (const url of componentDocumentLinks) { const componentLink = await mcp__getComponentLink(url); console.log(componentLink); } \`\`\` `, ...(JSON.parse(process.env.RULES ?? "[]") as string[]), ], }; return result; } catch (error) { throw error; } } - src/tools/get-dsl.ts:15-16 (registration)Class definition and name property setting DSL_TOOL_NAME = 'mcp__getDsl' on the GetDslTool class, which extends BaseTool.
export class GetDslTool extends BaseTool { name = DSL_TOOL_NAME;