reach_deleteAContactV1
Delete a contact from the email marketing system by specifying its UUID. Permanently removes the contact from the database.
Instructions
Delete a contact with the specified UUID.
This endpoint permanently removes a contact from the email marketing system.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uuid | Yes | UUID of the contact to delete |
Implementation Reference
- src/core/tools/reach.ts:14-36 (schema)Schema definition for reach_deleteAContactV1 tool. Defines the DELETE endpoint /api/reach/v1/contacts/{uuid} with required uuid parameter.
"name": "reach_deleteAContactV1", "description": "Delete a contact with the specified UUID.\n\nThis endpoint permanently removes a contact from the email marketing system.", "method": "DELETE", "path": "/api/reach/v1/contacts/{uuid}", "inputSchema": { "type": "object", "properties": { "uuid": { "type": "string", "description": "UUID of the contact to delete" } }, "required": [ "uuid" ] }, "security": [ { "apiToken": [] } ], "group": "reach" }, - src/servers/reach.ts:3-7 (registration)Registration of the reach tools (including reach_deleteAContactV1) into the MCP server via startServer().
import { startServer } from '../core/runtime.js'; import tools from '../core/tools/reach.js'; startServer({ name: 'hostinger-reach-mcp', version: '0.1.42', tools }); - src/core/runtime.js:1879-1966 (handler)Handler for reach_deleteAContactV1. Since it is NOT a custom tool, it executes via executeApiCall(). This performs a DELETE request to /api/reach/v1/contacts/{uuid}, substituting the uuid path parameter, and returning the API response.
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; } }