Skip to main content
Glama

hubspot_get_active_contacts

Retrieve recently active contacts from HubSpot CRM to monitor engagement and manage customer relationships effectively.

Instructions

Get most recently active contacts from HubSpot

Input Schema

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

Implementation Reference

  • Core handler implementation: Searches HubSpot CRM contacts sorted by lastmodifieddate descending, returns top 'limit' (default 10) with key properties, handles datetime conversion and errors.
    async getRecentContacts(limit: number = 10): Promise<any> { try { // Create search request with sort by lastmodifieddate const searchRequest = { sorts: ['lastmodifieddate:desc'], limit, properties: ['firstname', 'lastname', 'email', 'phone', 'company', 'hs_lastmodifieddate', 'lastmodifieddate'] }; // Execute the search const searchResponse = await this.client.crm.contacts.searchApi.doSearch(searchRequest); // Convert the response to a dictionary const contactsDict = searchResponse.results; return convertDatetimeFields(contactsDict); } catch (error: any) { console.error('Error getting recent contacts:', error); return { error: error.message }; } }
  • MCP tool schema definition including name, description, and inputSchema with optional 'limit' parameter.
    { 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 } } } },
  • src/index.ts:295-302 (registration)
    Tool handler registration in MCP CallToolRequestSchema: extracts 'limit' arg, calls HubSpotClient.getRecentContacts, returns JSON stringified result.
    case 'hubspot_get_active_contacts': { const result = await this.hubspot.getRecentContacts(args.limit as number | undefined); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
  • Helper utility to recursively convert Date objects to ISO strings in API responses, used by getRecentContacts.
    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