VPS_updatePostInstallScriptV1
Modify an existing automation script by providing its ID, a new name, and updated content. Useful for adjusting VPS post-install behavior.
Instructions
Update a specific post-install script.
Use this endpoint to modify existing automation scripts.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| postInstallScriptId | Yes | Post-install script ID | |
| name | Yes | Name of the script | |
| content | Yes | Content of the script |
Implementation Reference
- src/core/tools/vps.ts:689-721 (schema)Schema/definition of the VPS_updatePostInstallScriptV1 tool: a PUT request to /api/vps/v1/post-install-scripts/{postInstallScriptId} with input properties for postInstallScriptId (integer), name (string), and content (string), all required.
{ "name": "VPS_updatePostInstallScriptV1", "description": "Update a specific post-install script.\n\nUse this endpoint to modify existing automation scripts.", "method": "PUT", "path": "/api/vps/v1/post-install-scripts/{postInstallScriptId}", "inputSchema": { "type": "object", "properties": { "postInstallScriptId": { "type": "integer", "description": "Post-install script ID" }, "name": { "type": "string", "description": "Name of the script" }, "content": { "type": "string", "description": "Content of the script" } }, "required": [ "postInstallScriptId", "name", "content" ] }, "security": [ { "apiToken": [] } ], "group": "vps" - src/servers/vps.ts:3-6 (registration)Registration entry point: imports the tools array from src/core/tools/vps.ts and passes it to startServer, which registers all tools including VPS_updatePostInstallScriptV1 with the MCP server.
import { startServer } from '../core/runtime.js'; import tools from '../core/tools/vps.js'; startServer({ name: 'hostinger-vps-mcp', version: '0.1.42', tools }); - src/core/runtime.ts:1909-1999 (handler)Handler/execution logic for the tool. Since VPS_updatePostInstallScriptV1 is an API-based tool (not custom), the executeApiCall method in MCPServer (runtime.ts) handles it: it takes the tool's method (PUT) and path, substitutes path parameters (postInstallScriptId), sends the remaining params (name, content) as JSON body in a PUT request via axios.
private async executeApiCall(tool: OpenApiTool, params: Record<string, any>): Promise<any> { // Get method and path from tool const method = tool.method; let path = tool.path; // Clone params to avoid modifying the original const requestParams = { ...params }; // Replace path parameters with values from params Object.entries(requestParams).forEach(([key, value]) => { const placeholder = `{${key}}`; if (path.includes(placeholder)) { path = path.replace(placeholder, encodeURIComponent(String(value))); delete requestParams[key]; // Remove used parameter } }); // Build the full URL const baseUrl = this.baseUrl.endsWith("/") ? this.baseUrl : `${this.baseUrl}/`; const cleanPath = path.startsWith("/") ? path.slice(1) : path; const url = new URL(cleanPath, baseUrl).toString(); this.log('debug', `API Request: ${method} ${url}`); try { // Configure the request const config: AxiosRequestConfig = { method: method.toLowerCase(), url, headers: { ...this.headers }, timeout: 60000, // 60s validateStatus: function (status: number): boolean { return status < 500; // Resolve only if the status code is less than 500 } }; const bearerToken = process.env['API_TOKEN'] || process.env['APITOKEN']; // APITOKEN for backwards compatibility if (bearerToken && config.headers) { config.headers['Authorization'] = `Bearer ${bearerToken}`; } else { this.log('error', `Bearer Token environment variable not found: API_TOKEN`); } // Add parameters based on request method if (["GET", "DELETE"].includes(method)) { // For GET/DELETE, send params as query string config.params = { ...(config.params || {}), ...requestParams }; } else { // For POST/PUT/PATCH, send params as JSON body config.data = requestParams; if (config.headers) { config.headers["Content-Type"] = "application/json"; } } this.log('debug', "Request config:", { url: config.url, method: config.method, params: config.params, headers: config.headers ? Object.keys(config.headers) : [] }); // Execute the request const response = await axios(config); this.log('debug', `Response status: ${response.status}`); return response.data; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); this.log('error', `API request failed: ${errorMessage}`); if (axios.isAxiosError(error)) { const axiosError = error as AxiosError; const responseData = axiosError.response?.data; const responseStatus = axiosError.response?.status; this.log('error', 'API Error Details:', { status: responseStatus, data: typeof responseData === 'object' ? JSON.stringify(responseData) : String(responseData) }); // Rethrow with more context for better error handling const detailedError = new Error(`API request failed with status ${responseStatus}: ${errorMessage}`); (detailedError as any).response = axiosError.response; throw detailedError; } throw error; } }