Skip to main content
Glama
4tal

MCP Google Contacts Server

by 4tal

create_contact

Add new contacts to Google Contacts with comprehensive details including name, email, phone, organization, address, birthday, and notes.

Instructions

Create a new contact with comprehensive field support.

    Args:
        given_name: First name of the contact
        family_name: Last name of the contact
        email: Email address of the contact
        phone: Phone number of the contact
        organization: Company/organization name
        job_title: Job title or position
        address: Physical address
        birthday: Birthday in YYYY-MM-DD format
        website: Website URL
        notes: Notes or biography
        nickname: Nickname
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
given_nameYes
family_nameNo
emailNo
phoneNo
organizationNo
job_titleNo
addressNo
birthdayNo
websiteNo
notesNo
nicknameNo

Implementation Reference

  • The MCP tool handler function for 'create_contact', decorated with @mcp.tool(). Constructs contact_data from input parameters and delegates to GoogleContactsService.create_contact().
    @mcp.tool()
    async def create_contact(
        given_name: str,
        family_name: Optional[str] = None,
        email: Optional[str] = None,
        phone: Optional[str] = None,
        organization: Optional[str] = None,
        job_title: Optional[str] = None,
        address: Optional[str] = None,
        birthday: Optional[str] = None,
        website: Optional[str] = None,
        notes: Optional[str] = None,
        nickname: Optional[str] = None,
    ) -> str:
        """Create a new contact with comprehensive field support.
    
        Args:
            given_name: First name of the contact
            family_name: Last name of the contact
            email: Email address of the contact
            phone: Phone number of the contact
            organization: Company/organization name
            job_title: Job title or position
            address: Physical address
            birthday: Birthday in YYYY-MM-DD format
            website: Website URL
            notes: Notes or biography
            nickname: Nickname
        """
        service = init_service()
        if not service:
            return "Error: Google Contacts service is not available. Please check your credentials."
    
        try:
            contact_data = {"given_name": given_name}
    
            # Add optional fields if provided
            if family_name:
                contact_data["family_name"] = family_name
            if email:
                contact_data["email"] = email
            if phone:
                contact_data["phone"] = phone
            if organization:
                contact_data["organization"] = organization
            if job_title:
                contact_data["job_title"] = job_title
            if address:
                contact_data["address"] = address
            if birthday:
                contact_data["birthday"] = birthday
            if website:
                contact_data["website"] = website
            if notes:
                contact_data["notes"] = notes
            if nickname:
                contact_data["nickname"] = nickname
    
            contact = service.create_contact(contact_data)
            return f"Contact created successfully!\n\n{format_contact(contact)}"
        except Exception as e:
            return f"Error: Failed to create contact - {str(e)}"
  • The core implementation in GoogleContactsService that builds the API request body using _build_contact_body and executes people.createContact to create the contact via Google API.
    def create_contact(self, contact_data: Dict[str, Any]) -> Dict[str, Any]:
        """Create a new contact with comprehensive field support.
    
        Args:
            contact_data: Dictionary containing contact information
    
        Returns:
            Created contact dictionary
        """
        try:
            contact_body = self._build_contact_body(contact_data)
    
            person = self.service.people().createContact(body=contact_body).execute()
    
            return self._format_contact_enhanced(person)
    
        except HttpError as error:
            raise GoogleContactsError(f"Error creating contact: {error}")
  • src/main.py:74-74 (registration)
    The call to register_tools(mcp) in main.py, which triggers registration of all tools including create_contact via the decorators in tools.py.
    register_tools(mcp)
  • The register_tools function that orchestrates registration of contact tools, including the create_contact handler.
    def register_tools(mcp: FastMCP) -> None:
        """Register all Google Contacts tools with the MCP server.
    
        Args:
            mcp: FastMCP server instance
        """
        register_contact_tools(mcp)
        register_directory_tools(mcp)
        register_contact_group_tools(mcp)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/4tal/mcp-google-contacts'

If you have feedback or need assistance with the MCP directory API, please join our Discord server