hubspot_update_contact
Modify existing contact information in HubSpot CRM by updating specific properties using the contact ID.
Instructions
Update an existing contact in HubSpot (ignores if contact does not exist)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contact_id | Yes | HubSpot contact ID to update | |
| properties | Yes | Contact properties to update |
Implementation Reference
- src/index.ts:186-204 (registration)Registration of the hubspot_update_contact tool including its name, description, and input schema in the MCP ListTools response.{ name: 'hubspot_update_contact', description: 'Update an existing contact in HubSpot (ignores if contact does not exist)', inputSchema: { type: 'object', properties: { contact_id: { type: 'string', description: 'HubSpot contact ID to update' }, properties: { type: 'object', description: 'Contact properties to update', additionalProperties: true } }, required: ['contact_id', 'properties'] } },
- src/index.ts:305-316 (handler)MCP CallTool handler case for hubspot_update_contact that extracts arguments and delegates execution to HubSpotClient.updateContact method.case 'hubspot_update_contact': { const result = await this.hubspot.updateContact( args.contact_id as string, args.properties as Record<string, any> ); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }
- src/hubspot-client.ts:439-473 (handler)Core handler implementation in HubSpotClient that verifies contact existence and performs the update via HubSpot CRM Contacts API, returning success/error details.async updateContact( contactId: string, properties: Record<string, any> ): Promise<any> { try { // Check if contact exists try { await this.client.crm.contacts.basicApi.getById(contactId); } catch (error: any) { // If contact doesn't exist, return a message if (error.statusCode === 404) { return { message: 'Contact not found, no update performed', contactId }; } // For other errors, throw them to be caught by the outer try/catch throw error; } // Update the contact const apiResponse = await this.client.crm.contacts.basicApi.update(contactId, { properties }); return { message: 'Contact updated successfully', contactId, properties }; } catch (error: any) { console.error('Error updating contact:', error); throw new Error(`HubSpot API error: ${error.message}`); } }