Skip to main content
Glama

hubspot_get_active_companies

Retrieve recently active companies from HubSpot CRM to monitor business engagement and manage customer relationships.

Instructions

Get most recently active companies from HubSpot

Input Schema

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

Implementation Reference

  • MCP tool handler for 'hubspot_get_active_companies': delegates to HubSpotClient.getRecentCompanies with optional limit and returns JSON-formatted result.
    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) }] }; }
  • src/index.ts:158-171 (registration)
    Registration of the 'hubspot_get_active_companies' tool in the MCP server, including name, description, and input schema.
    { 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 } } } },
  • Input schema for 'hubspot_get_active_companies' tool: accepts optional 'limit' parameter (number, default 10).
    inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Maximum number of companies to return (default: 10)', default: 10 } } }
  • Helper method implementing the core logic: searches HubSpot CRM companies sorted by 'lastmodifieddate' descending, retrieves specified properties, converts datetime fields, handles errors.
    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 }; } }
  • Utility helper to recursively convert Date objects to ISO strings in response objects, used by getRecentCompanies.
    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