delete_contact
Remove a specific contact from Google Contacts by providing its resource name. This tool permanently deletes contact information from your Google account.
Instructions
Delete a contact by resource name.
Args:
resource_name: Contact resource name (people/*) to delete
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| resource_name | Yes |
Implementation Reference
- The MCP tool handler for 'delete_contact': an async function decorated with @mcp.tool() that initializes the service, calls service.delete_contact(), and returns success/error messages.@mcp.tool() async def delete_contact(resource_name: str) -> str: """Delete a contact by resource name. Args: resource_name: Contact resource name (people/*) to delete """ service = init_service() if not service: return "Error: Google Contacts service is not available. Please check your credentials." try: result = service.delete_contact(resource_name) if result.get('success'): return f"Contact {resource_name} deleted successfully." else: return f"Failed to delete contact: {result.get('message', 'Unknown error')}" except Exception as e: return f"Error: Failed to delete contact - {str(e)}"
- Supporting method in GoogleContactsService class that executes the Google People API deleteContact call.def delete_contact(self, resource_name: str) -> Dict: """Delete a contact by resource name.""" try: self.service.people().deleteContact( resourceName=resource_name ).execute() return {'success': True, 'resourceName': resource_name} except HttpError as error: raise GoogleContactsError(f"Error deleting contact: {error}")
- mcp_google_contacts_server/main.py:84-85 (registration)Invocation of register_tools(mcp) in main.py, which defines and registers the delete_contact tool (along with others) using @mcp.tool() decorators.register_tools(mcp)