hubspot_update_company
Modify existing company records in HubSpot CRM by updating specific properties using the company ID, ensuring data accuracy without creating duplicates.
Instructions
Update an existing company in HubSpot (ignores if company does not exist)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| company_id | Yes | HubSpot company ID to update | |
| properties | Yes | Company properties to update |
Implementation Reference
- src/hubspot-client.ts:475-509 (handler)Core handler function in HubSpotClient that implements the company update logic using HubSpot CRM API: checks existence, updates properties if exists, handles errors.async updateCompany( companyId: string, properties: Record<string, any> ): Promise<any> { try { // Check if company exists try { await this.client.crm.companies.basicApi.getById(companyId); } catch (error: any) { // If company doesn't exist, return a message if (error.statusCode === 404) { return { message: 'Company not found, no update performed', companyId }; } // For other errors, throw them to be caught by the outer try/catch throw error; } // Update the company const apiResponse = await this.client.crm.companies.basicApi.update(companyId, { properties }); return { message: 'Company updated successfully', companyId, properties }; } catch (error: any) { console.error('Error updating company:', error); throw new Error(`HubSpot API error: ${error.message}`); } }
- src/index.ts:318-329 (handler)MCP CallToolRequestSchema dispatch handler that invokes the HubSpotClient.updateCompany with parsed arguments and formats response.case 'hubspot_update_company': { const result = await this.hubspot.updateCompany( args.company_id as string, args.properties as Record<string, any> ); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }
- src/index.ts:208-222 (schema)Input schema defining parameters for hubspot_update_company tool: company_id (required string), properties (required object).inputSchema: { type: 'object', properties: { company_id: { type: 'string', description: 'HubSpot company ID to update' }, properties: { type: 'object', description: 'Company properties to update', additionalProperties: true } }, required: ['company_id', 'properties'] }
- src/index.ts:205-223 (registration)Tool registration in ListToolsRequestSchema handler, including name, description, and schema.{ name: 'hubspot_update_company', description: 'Update an existing company in HubSpot (ignores if company does not exist)', inputSchema: { type: 'object', properties: { company_id: { type: 'string', description: 'HubSpot company ID to update' }, properties: { type: 'object', description: 'Company properties to update', additionalProperties: true } }, required: ['company_id', 'properties'] } }