delete_contact
Remove a specific contact from Google Contacts by providing its unique resource name. Facilitates contact management directly within Google Workspace.
Instructions
Delete a contact by resource name.
Args:
resource_name: Contact resource name (people/*) to delete
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| resource_name | Yes |
Input Schema (JSON Schema)
{
"properties": {
"resource_name": {
"title": "Resource Name",
"type": "string"
}
},
"required": [
"resource_name"
],
"title": "delete_contactArguments",
"type": "object"
}
Implementation Reference
- The MCP tool handler for 'delete_contact'. This async function is decorated with @mcp.tool() for registration and handles the tool execution by calling the service method.@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)}"
- The core implementation in GoogleContactsService that calls the Google People API to delete the contact by resource name.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-84 (registration)The call to register_tools(mcp) which defines and registers all MCP tools, including delete_contact.register_tools(mcp)