make-html-page
Generate HTML pages using GPT-5 and save them to specified file paths for creating web content directly from AI interactions.
Instructions
Generate an HTML page using GPT-5 and save it to a file path
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"type": "object"
}
Implementation Reference
- src/index.ts:27-59 (handler)The async handler function that generates HTML using OpenAI GPT-5 based on the description prompt and saves the generated HTML to the specified file path after ensuring the directory exists.async ({ description, filePath }) => { if (!process.env.OPENAI_API_KEY) { throw new Error("OPENAI_API_KEY environment variable is required"); } const openai = createOpenAI({ apiKey: process.env.OPENAI_API_KEY, }); const { text } = await generateText({ model: openai("gpt-5"), prompt: ` Generate complete, valid HTML code for a 1080x720pxwebpage based on this description: ${description} Return ONLY the HTML code, no explanations or markdown formatting. The HTML should be complete and ready to save as a .html file.`, }); const dir = dirname(filePath); mkdirSync(dir, { recursive: true }); writeFileSync(filePath, text, "utf8"); return { content: [ { type: "text", text: `Success: HTML page generated and saved to ${filePath}`, }, ], }; }
- src/index.ts:19-26 (schema)Zod schema defining the input parameters: description (string) and filePath (string).{ description: z .string() .describe("A detailed description of the HTML page to generate"), filePath: z .string() .describe("Absolute file path where the HTML should be saved"), },
- src/index.ts:16-60 (registration)Registration of the 'make-html-page' tool using server.tool(), including name, description, input schema, and handler function.server.tool( "make-html-page", "Generate an HTML page using GPT-5 and save it to a file path", { description: z .string() .describe("A detailed description of the HTML page to generate"), filePath: z .string() .describe("Absolute file path where the HTML should be saved"), }, async ({ description, filePath }) => { if (!process.env.OPENAI_API_KEY) { throw new Error("OPENAI_API_KEY environment variable is required"); } const openai = createOpenAI({ apiKey: process.env.OPENAI_API_KEY, }); const { text } = await generateText({ model: openai("gpt-5"), prompt: ` Generate complete, valid HTML code for a 1080x720pxwebpage based on this description: ${description} Return ONLY the HTML code, no explanations or markdown formatting. The HTML should be complete and ready to save as a .html file.`, }); const dir = dirname(filePath); mkdirSync(dir, { recursive: true }); writeFileSync(filePath, text, "utf8"); return { content: [ { type: "text", text: `Success: HTML page generated and saved to ${filePath}`, }, ], }; } );