hubspot_update_company
Modify existing company records in HubSpot CRM by updating specific properties using the company ID. Ensures data accuracy by only processing valid company entries.
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-510 (handler)Core handler logic for updating a HubSpot company: checks if company exists, updates properties via HubSpot API, handles 404 gracefully, and returns success/error info.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 tool execution handler: receives arguments, calls HubSpotClient.updateCompany, and returns JSON-formatted result as MCP 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:205-223 (registration)Tool registration in ListTools handler: defines name, description, and input schema for hubspot_update_company.{ 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'] } }
- src/index.ts:208-222 (schema)Input schema definition validating company_id (string, required) and properties (object, required).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'] }