Skip to main content
Glama

hubspot_get_active_companies

Retrieve recently active companies from HubSpot CRM to monitor business engagement and track customer interactions.

Instructions

Get most recently active companies from HubSpot

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of companies to return (default: 10)

Implementation Reference

  • Core implementation of the tool logic: fetches most recently modified companies using HubSpot CRM search API, sorted by lastmodifieddate descending.
    async getRecentCompanies(limit: number = 10): Promise<any> { try { // Create search request with sort by lastmodifieddate const searchRequest = { sorts: ['lastmodifieddate:desc'], limit, properties: ['name', 'domain', 'website', 'phone', 'industry', 'hs_lastmodifieddate'] }; // Execute the search const searchResponse = await this.client.crm.companies.searchApi.doSearch(searchRequest); // Convert the response to a dictionary const companiesDict = searchResponse.results; return convertDatetimeFields(companiesDict); } catch (error: any) { console.error('Error getting recent companies:', error); return { error: error.message }; } }
  • MCP tool handler switch case that invokes the HubSpotClient.getRecentCompanies method and formats the response.
    case 'hubspot_get_active_companies': { const result = await this.hubspot.getRecentCompanies(args.limit as number | undefined); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }
  • Input schema definition for the tool, including optional limit parameter.
    name: 'hubspot_get_active_companies', description: 'Get most recently active companies from HubSpot', inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Maximum number of companies to return (default: 10)', default: 10 } } } },
  • src/index.ts:76-227 (registration)
    Registration of the tool in the ListTools response handler.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => { // Define available tools const tools: Tool[] = [ { name: 'hubspot_create_contact', description: 'Create a new contact in HubSpot', inputSchema: { type: 'object', properties: { firstname: { type: 'string', description: "Contact's first name" }, lastname: { type: 'string', description: "Contact's last name" }, email: { type: 'string', description: "Contact's email address" }, properties: { type: 'object', description: 'Additional contact properties', additionalProperties: true } }, required: ['firstname', 'lastname'] } }, { name: 'hubspot_create_company', description: 'Create a new company in HubSpot', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Company name' }, properties: { type: 'object', description: 'Additional company properties', additionalProperties: true } }, required: ['name'] } }, { name: 'hubspot_get_company_activity', description: 'Get activity history for a specific company', inputSchema: { type: 'object', properties: { company_id: { type: 'string', description: 'HubSpot company ID' } }, required: ['company_id'] } }, { name: 'hubspot_get_recent_engagements', description: 'Get recent engagement activities across all contacts and companies', inputSchema: { type: 'object', properties: { days: { type: 'number', description: 'Number of days to look back (default: 7)', default: 7 }, limit: { type: 'number', description: 'Maximum number of engagements to return (default: 50)', default: 50 } } } }, { name: 'hubspot_get_active_companies', description: 'Get most recently active companies from HubSpot', inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Maximum number of companies to return (default: 10)', default: 10 } } } }, { name: 'hubspot_get_active_contacts', description: 'Get most recently active contacts from HubSpot', inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Maximum number of contacts to return (default: 10)', default: 10 } } } }, { 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'] } }, { 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'] } } ]; return { tools }; });
  • Helper function used to convert datetime fields to ISO strings in the response.
    export function convertDatetimeFields(obj: any): any { if (obj === null || obj === undefined) { return obj; } if (typeof obj === 'object') { if (obj instanceof Date) { return obj.toISOString(); } if (Array.isArray(obj)) { return obj.map(item => convertDatetimeFields(item)); } const result: Record<string, any> = {}; for (const [key, value] of Object.entries(obj)) { result[key] = convertDatetimeFields(value); } return result; } return obj; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lkm1developer/hubspot-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server