VPS_createNewProjectV1
Deploy a Docker Compose project on a virtual machine using YAML content, a URL, or a GitHub repository. Projects with the same name are replaced.
Instructions
Deploy new project from docker-compose.yaml contents or download contents from URL.
URL can be Github repository url in format https://github.com/[user]/[repo] and it will be automatically resolved to docker-compose.yaml file in master branch. Any other URL provided must return docker-compose.yaml file contents.
If project with the same name already exists, existing project will be replaced.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| virtualMachineId | Yes | Virtual Machine ID | |
| project_name | Yes | Docker Compose project name using alphanumeric characters, dashes, and underscores only | |
| content | Yes | URL pointing to docker-compose.yaml file, Github repository or raw YAML content of the compose file | |
| environment | No | Project environment variables |
Implementation Reference
- src/core/tools/vps.ts:141-178 (schema)Tool definition (schema) for VPS_createNewProjectV1 - defines name, description, HTTP method (POST), API path, input parameters (virtualMachineId, project_name, content, environment), and security scheme.
{ "name": "VPS_createNewProjectV1", "description": "Deploy new project from docker-compose.yaml contents or download contents from URL. \n\nURL can be Github repository url in format https://github.com/[user]/[repo]\nand it will be automatically resolved to docker-compose.yaml file in\nmaster branch. Any other URL provided must return docker-compose.yaml\nfile contents.\n\nIf project with the same name already exists, existing project will be replaced.", "method": "POST", "path": "/api/vps/v1/virtual-machines/{virtualMachineId}/docker", "inputSchema": { "type": "object", "properties": { "virtualMachineId": { "type": "integer", "description": "Virtual Machine ID" }, "project_name": { "type": "string", "description": "Docker Compose project name using alphanumeric characters, dashes, and underscores only" }, "content": { "type": "string", "description": "URL pointing to docker-compose.yaml file, Github repository or raw YAML content of the compose file" }, "environment": { "type": "string", "description": "Project environment variables" } }, "required": [ "virtualMachineId", "project_name", "content" ] }, "security": [ { "apiToken": [] } ], "group": "vps" }, - src/core/runtime.js:86-99 (registration)Generic tool registration in MCPServer.initializeTools() - iterates all tools (including VPS_createNewProjectV1) and registers them in the tools Map.
initializeTools() { // Initialize each tool in the tools map for (const tool of this.toolList) { this.tools.set(tool.name, { name: tool.name, description: tool.description, inputSchema: tool.inputSchema, // Don't include security at the tool level }); } // Don't log here, we're not connected yet console.error(`Initialized ${this.tools.size} tools`); } - src/core/runtime.js:1879-1966 (handler)Generic API call handler executeApiCall() - processes all standard REST API tools including VPS_createNewProjectV1. Substitutes path parameters, sends POST request with JSON body to the Hostinger API.
async executeApiCall(tool, params) { // 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 = { method: method.toLowerCase(), url, headers: { ...this.headers }, timeout: 60000, // 60s validateStatus: function (status) { 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['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; config.headers["Content-Type"] = "application/json"; } this.log('debug', "Request config:", { url: config.url, method: config.method, params: config.params, 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 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 }); // Rethrow with more context for better error handling const detailedError = new Error(`API request failed with status ${responseStatus}: ${errorMessage}`); detailedError.response = error.response; throw detailedError; } throw error; } } - src/servers/vps.ts:1-6 (registration)Server entry point - imports the VPS tools array (which includes VPS_createNewProjectV1) and starts the MCP server.
#!/usr/bin/env node // Auto-generated entry for group: vps import { startServer } from '../core/runtime.js'; import tools from '../core/tools/vps.js'; startServer({ name: 'hostinger-vps-mcp', version: '0.1.41', tools });