Skip to main content
Glama

create_contact

Generate and manage new contacts by inputting essential details like account ID, name, email, and phone numbers using Microsoft MCP's integration with Microsoft Graph API.

Instructions

Create a new contact

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_idYes
email_addressesNo
given_nameYes
phone_numbersNo
surnameNo

Implementation Reference

  • The main handler function for the 'create_contact' tool. It is decorated with @mcp.tool, which handles registration and schema inference based on the function signature and docstring. The function constructs a contact object using Microsoft Graph API and posts it to /me/contacts.
    @mcp.tool
    def create_contact(
        account_id: str,
        given_name: str,
        surname: str | None = None,
        email_addresses: str | list[str] | None = None,
        phone_numbers: dict[str, str] | None = None,
    ) -> dict[str, Any]:
        """Create a new contact"""
        contact: dict[str, Any] = {"givenName": given_name}
    
        if surname:
            contact["surname"] = surname
    
        if email_addresses:
            email_list = (
                [email_addresses] if isinstance(email_addresses, str) else email_addresses
            )
            contact["emailAddresses"] = [
                {"address": email, "name": f"{given_name} {surname or ''}".strip()}
                for email in email_list
            ]
    
        if phone_numbers:
            if "business" in phone_numbers:
                contact["businessPhones"] = [phone_numbers["business"]]
            if "home" in phone_numbers:
                contact["homePhones"] = [phone_numbers["home"]]
            if "mobile" in phone_numbers:
                contact["mobilePhone"] = phone_numbers["mobile"]
    
        result = graph.request("POST", "/me/contacts", account_id, json=contact)
        if not result:
            raise ValueError("Failed to create contact")
        return result

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/elyxlz/microsoft-mcp'

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