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
| Name | Required | Description | Default |
|---|---|---|---|
| account_id | Yes | ||
| email_addresses | No | ||
| given_name | Yes | ||
| phone_numbers | No | ||
| surname | No |
Implementation Reference
- src/microsoft_mcp/tools.py:661-696 (handler)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