hubspot_update_contact
Update existing HubSpot contact information by specifying contact ID and properties to modify. Maintains current data if contact does not exist.
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/hubspot-client.ts:439-473 (handler)The primary handler function that executes the tool logic: checks if the contact exists using getById, then updates the properties via HubSpot CRM contacts.basicApi.update. Returns success message or handles not found gracefully.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}`); } }
- src/index.ts:186-204 (registration)Tool registration in the ListToolsRequestHandler, defining name, description, and input schema.{ 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:189-202 (schema)Input schema defining required contact_id and arbitrary properties object for the tool.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 server handler dispatcher in CallToolRequestHandler that invokes the HubSpotClient updateContact method and formats the response.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) }] }; }