Skip to main content
Glama
hostinger

hostinger-api-mcp

Official

hosting_deployWordpressPlugin

Upload a WordPress plugin directory to a hosting server and trigger its deployment.

Instructions

Deploy a WordPress plugin from a directory to a hosting server. This tool uploads all plugin files and triggers plugin deployment.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainYesDomain name associated with the hosting account (e.g., example.com)
slugYesWordPress plugin slug (e.g., omnisend)
pluginPathYesAbsolute or relative path to the plugin directory containing all plugin files

Implementation Reference

  • Main handler function for hosting_deployWordpressPlugin. Validates params, resolves username, scans plugin directory, uploads all plugin files to wp-content/plugins/<slug>-<random>/ dir, then triggers plugin deployment via API.
    async handleWordpressPluginDeploy(params) {
      const { domain, slug, pluginPath } = params;
    
      this.hosting_deployWordpressPlugin_validateRequiredParams(params);
      this.hosting_deployWordpressPlugin_validatePluginDirectory(pluginPath);
    
      this.log('info', `Resolving username from domain: ${domain}`);
      const username = await this.resolveUsername(domain);
    
      const randomSuffix = this.hosting_deployWordpressPlugin_generateRandomString(8);
      const uploadDirName = `${slug}-${randomSuffix}`;
    
      this.log('info', `Scanning plugin directory: ${pluginPath}`);
      const pluginFiles = this.hosting_deployWordpressPlugin_scanDirectory(pluginPath);
    
      if (pluginFiles.length === 0) {
        throw new Error(`No files found in plugin directory: ${pluginPath}`);
      }
    
      this.log('info', `Found ${pluginFiles.length} files to upload`);
    
      let uploadCredentials;
      try {
        uploadCredentials = await this.fetchUploadCredentials(username, domain);
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        throw new Error(`Failed to fetch upload credentials: ${errorMessage}`);
      }
    
      const { url: uploadUrl, auth_key: authToken, rest_auth_key: authRestToken } = uploadCredentials;
    
      if (!uploadUrl || !authToken || !authRestToken) {
        throw new Error('Invalid upload credentials received from API');
      }
    
      this.log('info', `Starting plugin file upload to ${uploadUrl}`);
    
      const results = [];
      let successCount = 0;
      let failureCount = 0;
    
      for (const fileInfo of pluginFiles) {
        try {
          const normalizedRelativePath = this.normalizePath(fileInfo.relativePath);
          const uploadPath = `wp-content/plugins/${uploadDirName}/${normalizedRelativePath}`;
          this.log('info', `Uploading: ${fileInfo.absolutePath} -> ${uploadPath}`);
    
          const stats = fs.statSync(fileInfo.absolutePath);
          const uploadResult = await this.uploadFile(
            fileInfo.absolutePath,
            uploadPath,
            uploadUrl,
            authRestToken,
            authToken
          );
    
          results.push({
            file: fileInfo.absolutePath,
            remotePath: uploadPath,
            status: 'success',
            uploadUrl: uploadResult.url,
            size: stats.size
          });
    
          successCount++;
          this.log('info', `Successfully uploaded: ${uploadPath}`);
    
        } catch (error) {
          const errorMessage = error instanceof Error ? error.message : String(error);
          const normalizedRelativePath = this.normalizePath(fileInfo.relativePath);
          const uploadPath = `wp-content/plugins/${uploadDirName}/${normalizedRelativePath}`;
          
          results.push({
            file: fileInfo.absolutePath,
            remotePath: uploadPath,
            status: 'error',
            error: errorMessage
          });
    
          failureCount++;
          this.log('error', `Failed to upload ${fileInfo.absolutePath}: ${errorMessage}`);
        }
      }
    
      const overallStatus = failureCount === 0 ? 'success' : (successCount === 0 ? 'failure' : 'partial');
    
      if (failureCount === 0) {
        try {
          this.log('info', 'All files uploaded successfully, triggering plugin deployment...');
          await this.hosting_deployWordpressPlugin_deployPlugin(username, domain, slug, uploadDirName);
        } catch (error) {
          const errorMessage = error instanceof Error ? error.message : String(error);
          this.log('error', `Plugin deployment failed: ${errorMessage}`);
          return {
            status: 'partial',
            summary: {
              total: pluginFiles.length,
              successful: successCount,
              failed: failureCount
            },
            results,
            deploymentError: errorMessage
          };
        }
      }
    
      return {
        status: overallStatus,
        summary: {
          total: pluginFiles.length,
          successful: successCount,
          failed: failureCount
        },
        results,
        uploadDirName
      };
    }
  • Generates a random 8-character alphanumeric string used as a suffix for the upload directory name.
    hosting_deployWordpressPlugin_generateRandomString(length) {
      const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
      let result = '';
      for (let i = 0; i < length; i++) {
        result += chars.charAt(Math.floor(Math.random() * chars.length));
      }
      return result;
    }
  • Validates the required params for the deploy plugin tool: domain, slug, and pluginPath must be present and strings.
    hosting_deployWordpressPlugin_validateRequiredParams(params) {
      const { domain, slug, pluginPath } = params;
    
      if (!domain || typeof domain !== 'string') {
        throw new Error('domain is required and must be a string');
      }
    
      if (!slug || typeof slug !== 'string') {
        throw new Error('slug is required and must be a string');
      }
    
      if (!pluginPath || typeof pluginPath !== 'string') {
        throw new Error('pluginPath is required and must be a string');
      }
    }
  • Validates that the pluginPath exists and is a directory.
    hosting_deployWordpressPlugin_validatePluginDirectory(pluginPath) {
      if (!fs.existsSync(pluginPath)) {
        throw new Error(`Plugin directory not found: ${pluginPath}`);
      }
    
      const pluginStats = fs.statSync(pluginPath);
      if (!pluginStats.isDirectory()) {
        throw new Error(`Plugin path is not a directory: ${pluginPath}`);
      }
    }
  • Recursively scans a directory and returns all files with absolute and relative paths.
    hosting_deployWordpressPlugin_scanDirectory(dirPath, basePath = dirPath) {
      const files = [];
      
      const scanDir = (currentPath) => {
        const items = fs.readdirSync(currentPath);
        
        for (const item of items) {
          const itemPath = path.join(currentPath, item);
          const stats = fs.statSync(itemPath);
          
          if (stats.isDirectory()) {
            scanDir(itemPath);
          } else if (stats.isFile()) {
            const relativePath = path.relative(basePath, itemPath);
            files.push({
              absolutePath: itemPath,
              relativePath: relativePath
            });
          }
        }
      };
      
      scanDir(dirPath);
      return files;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided. Description states it uploads files and triggers deployment but does not disclose potential side effects (e.g., overwriting existing plugin, downtime), authorization requirements, or error conditions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two concise sentences, no unnecessary words or redundancy. Key action and scope front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema and no annotations; description lacks detail on return values, success/failure indicators, or required permissions. Incomplete for a deployment tool with side effects.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema documentation covers all parameters (100% coverage). Description does not add additional meaning beyond field names; baseline 3 applies as schema already describes parameters adequately.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description explicitly states the verb 'Deploy' and resource 'WordPress plugin', with context 'from a directory to a hosting server'. It distinguishes from sibling tools like hosting_deployWordpressTheme by specifying plugin instead of theme.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives (e.g., hosting_deployWordpressTheme, hosting_deployJsApplication). No prerequisites or when-not-to-use conditions mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/hostinger/api-mcp-server'

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