hs_create_contact
Create a new contact in HubSpot CRM by providing an email address. Optionally add name, phone, company, job title, and lifecycle stage. Email is required.
Instructions
Create a new HubSpot contact. Email is required; all other fields are optional.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| Yes | |||
| firstname | No | ||
| lastname | No | ||
| phone | No | ||
| company | No | ||
| jobtitle | No | ||
| lifecyclestage | No |
Implementation Reference
- src/index.ts:110-115 (registration)Registration of the 'hs_create_contact' tool with the MCP server, binding CreateContactSchema and the createContact handler.
server.tool( "hs_create_contact", "Create a new HubSpot contact. Email is required; all other fields are optional.", CreateContactSchema.shape, async (args) => { try { return ok(await createContact(args)); } catch (e) { return err(e); } }, ); - src/tools/contacts.ts:68-76 (schema)CreateContactSchema: Zod schema defining the input properties for hs_create_contact (email required, firstname/lastname/phone/company/jobtitle/lifecyclestage optional).
export const CreateContactSchema = z.object({ email: z.string().email(), firstname: z.string().optional(), lastname: z.string().optional(), phone: z.string().optional(), company: z.string().optional(), jobtitle: z.string().optional(), lifecyclestage: z.string().optional(), }); - src/tools/contacts.ts:78-85 (handler)createContact handler: constructs properties object from args and calls POST /crm/v3/objects/contacts to create a HubSpot contact.
export async function createContact(args: z.infer<typeof CreateContactSchema>) { const { email, ...rest } = args; const properties: Record<string, string> = { email }; for (const [k, v] of Object.entries(rest)) { if (v !== undefined) properties[k] = v; } return hubspot("/crm/v3/objects/contacts", "POST", { properties }); } - src/index.ts:7-14 (helper)Import statement bringing createContact and CreateContactSchema from src/tools/contacts.ts into the main server file.
import { SearchContactsSchema, searchContacts, GetContactSchema, getContact, ContactByEmailSchema, contactByEmail, RecentContactsSchema, recentContacts, CreateContactSchema, createContact, UpdateContactSchema, updateContact, } from "./tools/contacts.js";