Skip to main content
Glama
hostinger

hostinger-api-mcp

Official

hosting_deployWordpressPlugin

Upload and deploy a WordPress plugin from a local directory to your hosting server. Specify domain, plugin slug, and file path to trigger automatic 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 from domain, scans plugin directory, generates random upload directory name, uploads all plugin files via TUS to wp-content/plugins/{slug}-{random}/, then calls the deploy API to trigger plugin deployment.
    private async handleWordpressPluginDeploy(params: Record<string, any>): Promise<any> {
      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: any;
      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: any[] = [];
      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) {
  • Schema/definition for the hosting_deployWordpressPlugin tool. Defines name, description, inputSchema with required params (domain, slug, pluginPath), and maps to handlerMethod 'handleWordpressPluginDeploy'.
    {
      "name": "hosting_deployWordpressPlugin",
      "topic": "hosting",
      "description": "Deploy a WordPress plugin from a directory to a hosting server. This tool uploads all plugin files and triggers plugin deployment.",
      "method": "",
      "path": "",
      "inputSchema": {
        "type": "object",
        "properties": {
          "domain": {
            "type": "string",
            "description": "Domain name associated with the hosting account (e.g., example.com)"
          },
          "slug": {
            "type": "string",
            "description": "WordPress plugin slug (e.g., omnisend)"
          },
          "pluginPath": {
            "type": "string",
            "description": "Absolute or relative path to the plugin directory containing all plugin files"
          }
        },
        "required": [
          "domain",
          "slug",
          "pluginPath"
        ]
      },
  • Registration of the custom tool in executeCustomTool switch statement routing 'hosting_deployWordpressPlugin' to handleWordpressPluginDeploy method.
    private async executeCustomTool(tool: OpenApiTool, params: Record<string, any>): Promise<any> {
      switch (tool.name) {
        case 'hosting_importWordpressWebsite':
          return await this.handleWordpressWebsiteImport(params);
        case 'hosting_deployWordpressPlugin':
          return await this.handleWordpressPluginDeploy(params);
  • Helper that generates a random 8-character alphanumeric string used as a suffix for the upload directory name to avoid collisions.
    private hosting_deployWordpressPlugin_generateRandomString(length: number): string {
      const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
      let result = '';
      for (let i = 0; i < length; i++) {
        result += chars.charAt(Math.floor(Math.random() * chars.length));
      }
      return result;
    }
  • Helper that calls the Hostinger API (POST /api/hosting/v1/accounts/{username}/websites/{domain}/wordpress/plugins/deploy) to trigger plugin deployment after files are uploaded.
    private async hosting_deployWordpressPlugin_deployPlugin(username: string, domain: string, slug: string, pluginPath: string): Promise<boolean> {
      const baseUrl = this.baseUrl.endsWith("/") ? this.baseUrl : `${this.baseUrl}/`;
      const url = new URL(`api/hosting/v1/accounts/${username}/websites/${domain}/wordpress/plugins/deploy`, baseUrl).toString();
    
      try {
        const bearerToken = process.env['API_TOKEN'] || process.env['APITOKEN'];
        if (!bearerToken) {
          throw new Error('API_TOKEN environment variable not found');
        }
    
        const config: AxiosRequestConfig = {
          method: 'post',
          url,
          headers: {
            ...this.headers,
            'Authorization': `Bearer ${bearerToken}`,
            'Content-Type': 'application/json'
          },
          data: {
            slug,
            plugin_path: pluginPath
          },
          timeout: 60000, // 60s
          validateStatus: function (status: number): boolean {
            return status < 500;
          }
        };
    
        const response = await axios(config);
    
        if (response.status !== 200) {
          throw new Error(`API returned status ${response.status}: ${JSON.stringify(response.data)}`);
        }
    
        this.log('info', `Successfully triggered plugin deployment for ${domain}`);
        return true;
    
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        this.log('error', `Failed to trigger plugin deployment: ${errorMessage}`);
    
        if (axios.isAxiosError(error)) {
          const responseData = error.response?.data;
          const responseStatus = error.response?.status;
          this.log('error', 'API Error Details:', {
            status: responseStatus,
            data: typeof responseData === 'object' ? JSON.stringify(responseData) : responseData
          });
        }
    
        throw error;
      }
    }
Behavior2/5

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

Minimal disclosure: only that it uploads files and triggers deployment. No info on overwriting, idempotency, error handling, or side effects. No annotations to compensate.

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

Conciseness4/5

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

Two sentences, no redundancy, but lacks detail; could include more guidance without sacrificing conciseness.

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?

Missing critical context: return value, error conditions, required server state, permission requirements. Not complete for a deployment tool.

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 covers 100% of parameters with descriptions; tool description adds no extra meaning beyond schema.

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?

Description clearly states verb 'deploy' and resource 'WordPress plugin', distinguishing from sibling tools like hosting_deployWordpressTheme and hosting_deployJsApplication.

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 when-to-use or when-not-to-use guidance; no mention of alternatives or prerequisites like WordPress being installed on the domain.

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