html_deploy
Deploy HTML pages to ESA Edge Routine (ER) and generate access URLs for immediate use.
Instructions
Quickly deploy an HTML page to ESA Edge Routine (ER) and return a default access URL to the user.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | The name of the routine, supports lowercase English letters, numbers, and hyphens, must start with a lowercase letter, and must be at least 2 characters long. For example: hello-world | |
| html | Yes | An HTML string which user want to deploy. For example: <html><body>Hello World</body></html> |
Implementation Reference
- src/tools/er/routine.ts:101-220 (handler)The handler function that implements the html_deploy tool logic: escapes HTML, generates JS code for ER, creates routine, uploads to OSS, commits staging code, publishes to production, and returns routine details.export const html_deploy = async (request: CallToolRequest) => { // Escape backticks and dollar signs in the HTML string const html = (request?.params?.arguments?.html as string) .replace(/`/g, '\\`') .replace(/\$/g, '\\$'); const code = `const html = \`${html}\`; async function handleRequest(request) { return new Response(html, { headers: { "content-type": "text/html;charset=UTF-8", }, }); } export default { async fetch(request) { return handleRequest(request); }, }; `; const createRoutineRes = await api.createRoutine({ name: request?.params?.arguments?.name || '', code: code, } as unknown as CreateRoutineRequest); // Create Edge Routine if ( createRoutineRes.statusCode === 200 && createRoutineRes.body?.status === 'OK' ) { const getOssInfoRes = await api.getRoutineStagingCodeUploadInfo( request.params.arguments as GetRoutineStagingCodeUploadInfoRequest, ); if ( !getOssInfoRes || getOssInfoRes?.statusCode !== 200 || !getOssInfoRes?.body?.ossPostConfig?.OSSAccessKeyId ) { return { content: [ { type: 'text', text: `Failed to get routine staging code upload info. ${JSON.stringify(getOssInfoRes)}`, }, ], success: false, }; } else { const uploadRes = await uploadCodeToOSS(getOssInfoRes, code as string); if (uploadRes !== true) { return { content: [ { type: 'text', text: `Failed to upload code to OSS. ${uploadRes}`, }, ], success: false, }; } else { const commitRes = await api.commitRoutineStagingCode( request.params.arguments as CommitRoutineStagingCodeRequest, ); if (commitRes.statusCode !== 200) { return { content: [ { type: 'text', text: `Failed to commit routine staging code. ${JSON.stringify(commitRes)}`, }, ], success: false, }; } else { const deployRes = await api.publishRoutineCodeVersion({ name: request?.params?.arguments?.name || '', env: 'production', codeVersion: commitRes?.body?.codeVersion, } as PublishRoutineCodeVersionRequest); if (deployRes.statusCode === 200) { const res = await api.getRoutine({ name: request?.params?.arguments?.name || '', } as GetRoutineRequest); return { content: [ { type: 'text', text: JSON.stringify(res), }, ], success: true, }; } else { return { content: [ { type: 'text', text: `Failed to get routine. ${JSON.stringify(deployRes)}`, }, ], success: false, }; } } } } } else { return { content: [ { type: 'text', text: `Failed to create routine. ${JSON.stringify(createRoutineRes)}`, }, ], success: false, }; } };
- src/tools/er/routine.ts:14-38 (registration)Tool registration definition including name 'html_deploy', description, input schema (name and html params), and annotations.export const HTML_DEPLOY_TOOL: Tool = { name: 'html_deploy', description: 'Quickly deploy an HTML page to ESA Edge Routine (ER) and return a default access URL to the user.', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'The name of the routine, supports lowercase English letters, numbers, and hyphens, must start with a lowercase letter, and must be at least 2 characters long. For example: hello-world', }, html: { type: 'string', description: 'An HTML string which user want to deploy. For example: <html><body>Hello World</body></html>', }, }, required: ['name', 'html'], }, annotations: { readOnlyHint: false, idempotentHint: false, }, };
- src/tools/list-esa-function.ts:164-184 (registration)Top-level registration of the html_deploy handler in the esaHandlers object used for MCP tool dispatching.export const esaHandlers: ToolHandlers = { site_active_list, site_match, site_route_list, site_record_list, routine_create, routine_code_commit, routine_delete, routine_list, routine_get, routine_code_deploy, routine_route_list, deployment_delete, route_create, route_delete, route_update, route_get, er_record_create, er_record_delete, er_record_list, html_deploy,
- src/tools/list-esa-function.ts:103-104 (registration)Inclusion of HTML_DEPLOY_TOOL in the ESA_OPENAPI_ER_LIST array for tool listing.export const ESA_OPENAPI_ER_LIST = [ HTML_DEPLOY_TOOL,