Skip to main content
Glama
TencentEdgeOne

EdgeOne Pages MCP

Official

deploy_folder_or_zip

Deploy a built frontend directory or zip file to EdgeOne Pages, generating a public URL and project metadata for easy access and sharing.

Instructions

Deploy a built frontend directory (or zip file) to EdgeOne Pages. Returns: the deployment URL and project metadata.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
builtFolderPathYesProvide the absolute path to the built frontend folder(or zip file) you wish to deploy.

Implementation Reference

  • Main implementation of the deploy_folder_or_zip tool. Handles validation, COS upload, project management, deployment creation, status polling, and result formatting with logs.
    export const deployFolderOrZipToEdgeOne = async (
      localPath: string,
      env: 'Production' | 'Preview' = 'Production'
    ): Promise<string> => {
      // Reset logs and override console at the start
      resetLogs();
      overrideConsole();
    
      try {
        // Reset token cache at the start of deployment
        resetTokenCache();
        resetTempProjectName();
    
        // Validate folder or zip file
        const isZip = await validateFolder(localPath);
    
        await checkAndSetBaseUrl();
    
        // 1. Upload folder to COS
        const uploadResult = await uploadToEdgeOneCOS(localPath);
        if (!uploadResult.targetPath) {
          throw new Error('COS upload succeeded but targetPath is missing.');
        }
        const targetPath = uploadResult.targetPath;
    
        // 2. Get or create project
        console.log(`[getOrCreateProject] Getting or creating project...`);
        const projectResult = await getOrCreateProject();
        if (!projectResult?.Data?.Response?.Projects?.[0]?.ProjectId) {
          console.error('Invalid project data received: ' + projectResult);
          throw new Error('Failed to retrieve Project ID after get/create.');
        }
        const projectId = projectResult.Data.Response.Projects[0].ProjectId;
        console.log(`[getOrCreateProject] Using Project ID: ${projectId}`);
    
        // 3. Create deployment
        console.log(
          `[createPagesDeployment] Creating deployment in ${env} environment...`
        );
        const res = await createPagesDeployment({
          projectId,
          targetPath: targetPath,
          isZip,
          env,
        });
        const deploymentId = res.Data.Response.DeploymentId;
    
        // 4. Wait for deployment to complete
        console.log(
          `[pollProjectStatus] Waiting for deployment to complete (polling status)...`
        );
        await sleep(5000);
        const deploymentResult = await pollProjectStatus(projectId, deploymentId);
    
        // 5. Get structured deployment result and format message
        const structuredResult = await getDeploymentStructuredResult(
          deploymentResult,
          projectId,
          env
        );
    
        /**
         * Format deployment result into user-friendly message
         * @param deploymentResult The structured deployment result
         * @returns Text message describing the deployment status
         */
    
        // Append deployment logs to the result
        const logs = formatLogs();
        const finalText = `${logs}
    
    results:
    ${JSON.stringify(structuredResult, null, 2)}`;
    
        return finalText;
      } catch (error) {
        // Ensure logs are captured even on error
        const logs = formatLogs();
        const errorMessage = error instanceof Error ? error.message : String(error);
        const finalText = `${logs}Deployment failed: ${errorMessage}`;
        throw new Error(finalText);
      } finally {
        // Always restore console
        restoreConsole();
      }
    };
  • index.ts:62-87 (registration)
    MCP server.tool registration for 'deploy_folder_or_zip', including input schema, description, and thin wrapper calling the main handler.
    server.tool(
      'deploy_folder_or_zip',
      'Deploy a built frontend directory (or zip file) to EdgeOne Pages. Returns: the deployment URL and project metadata.',
      {
        builtFolderPath: z
          .string()
          .describe(
            'Provide the absolute path to the built frontend folder(or zip file) you wish to deploy.'
          ),
      },
      async ({ builtFolderPath }) => {
        try {
          const result = await deployFolderOrZipToEdgeOne(builtFolderPath);
          return {
            content: [
              {
                type: 'text' as const,
                text: result,
              },
            ],
          };
        } catch (e) {
          return handleUncaughtError(e);
        }
      }
    );
  • Zod schema for the tool input parameter 'builtFolderPath'.
      builtFolderPath: z
        .string()
        .describe(
          'Provide the absolute path to the built frontend folder(or zip file) you wish to deploy.'
        ),
    },
Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/TencentEdgeOne/edgeone-pages-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server