html_deploy
Deploy HTML pages to ESA Edge Routine and generate access URLs. Input HTML string and routine name to manage deployments efficiently using ESA MCP Server.
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 |
|---|---|---|---|
| html | Yes | An HTML string which user want to deploy. For example: <html><body>Hello World</body></html> | |
| 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 |
Implementation Reference
- src/tools/er/routine.ts:101-220 (handler)The main handler function 'html_deploy' that implements the tool logic: escapes HTML, generates JS wrapper code for Edge Routine, creates the routine, handles OSS upload for staging code, commits, publishes to production, and retrieves 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 (schema)Schema definition for the 'html_deploy' tool, specifying input parameters 'name' (routine name) and 'html' (HTML content), along with description 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:103-123 (registration)Registration of the 'html_deploy' tool schema (HTML_DEPLOY_TOOL) in the ESA_OPENAPI_ER_LIST array of available Edge Routine (ER) tools.export const ESA_OPENAPI_ER_LIST = [ HTML_DEPLOY_TOOL, ROUTINE_CREATE_TOOL, ROUTINE_DELETE_TOOL, ROUTINE_LIST_TOOL, ROUTINE_GET_TOOL, ROUTINE_CODE_COMMIT_TOOL, ROUTINE_CODE_DEPLOY_TOOL, ROUTINE_ROUTE_LIST_TOOL, DEPLOYMENT_DELETE_TOOL, SITE_ACTIVE_LIST_TOOL, SITE_ROUTE_LIST_TOOL, ROUTE_CREATE_TOOL, ROUTE_DELETE_TOOL, ROUTE_UPDATE_TOOL, ROUTE_GET_TOOL, SITE_MATCH_TOOL, ER_RECORD_CREATE_TOOL, ER_RECORD_DELETE_TOOL, ER_RECORD_LIST_TOOL, ];
- src/tools/list-esa-function.ts:164-208 (registration)Registration of the 'html_deploy' handler function in the esaHandlers object mapping tool names to their implementations.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, create_site, update_site_pause, get_site_pause, create_site_mx_record, create_site_ns_record, create_site_txt_record, create_site_cname_record, create_site_a_or_aaaa_record, update_record, list_records, get_record, delete_record, update_ipv6, get_ipv6, update_managed_transform, get_managed_transform, set_certificate, apply_certificate, get_certificate, delete_certificate, list_certificates, get_certificate_quota, list_sites, };