archiveContact
Permanently archive contacts in Mailmodo by submitting their email address, ensuring streamlined contact management and data organization.
Instructions
permanently archive contact in mailmodo
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| Yes |
Implementation Reference
- src/server.ts:307-337 (registration)Registration of the 'archiveContact' MCP tool, including inline input schema (email: z.string()) and handler function that invokes the deleteContact helper and returns a text response.server.tool( "archiveContact", "permanently archive contact in mailmodo", { email: z.string() }, async (params) => { try { const respone = await deleteContact(mmApiKey,params.email); // Here you would typically integrate with your event sending system // For example: eventBus.emit(eventName, eventData) // For demonstration, we'll just return a success message return { content: [{ type: "text", text: respone.success ?`Successfully deleted '${params.email} with message ${respone.message}`: `Something went wrong. Please check if the email is correct`, }] }; } catch (error) { return { content: [{ type: "text", text: error instanceof Error ? error.message : "Failed to delete", }], isError: true }; } } );
- src/server.ts:313-336 (handler)Handler function for the 'archiveContact' tool, which calls the deleteContact API helper and formats the response.async (params) => { try { const respone = await deleteContact(mmApiKey,params.email); // Here you would typically integrate with your event sending system // For example: eventBus.emit(eventName, eventData) // For demonstration, we'll just return a success message return { content: [{ type: "text", text: respone.success ?`Successfully deleted '${params.email} with message ${respone.message}`: `Something went wrong. Please check if the email is correct`, }] }; } catch (error) { return { content: [{ type: "text", text: error instanceof Error ? error.message : "Failed to delete", }], isError: true }; } }
- src/server.ts:310-312 (schema)Input schema for the 'archiveContact' tool using Zod (requires email string).{ email: z.string() },
- The deleteContact helper function that makes the actual DELETE API call to Mailmodo's /contacts endpoint to archive the contact.export async function deleteContact( mmApiKey: string, email: string ): Promise<AddContactToListResponse> { if (!email) { throw new Error('Email is a required field'); } try { const response = await axios.delete<AddContactToListResponse>( 'https://api.mailmodo.com/api/v1/contacts', { headers: { 'Accept': 'application/json', 'mmApiKey': mmApiKey || '' }, data: { email } } ); return response.data; } catch (error) { if (error instanceof AxiosError) { if(error.status === 400){ return { success: true, message: "User Doesn't exist in system or already archived" }; } return { success: false, message: error.response?.data?.message || 'Failed to delete contact' }; } throw new Error('An unexpected error occurred'); } }