Skip to main content
Glama
lkm1developer

HubSpot MCP Server

hubspot_get_active_contacts

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

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 function that performs a search on HubSpot CRM contacts API, sorted by lastmodifieddate descending to get active contacts, applies datetime conversion, handles 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 call handler (switch case) that extracts arguments, calls HubSpotClient.getRecentContacts, and formats response as MCP content.
    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)
        }]
      };
  • src/index.ts:172-185 (registration)
    Tool registration in ListToolsRequestSchema handler, defining name, description, and input schema.
    {
      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
          }
        }
      }
    },
  • Input schema definition for the tool.
    inputSchema: {
      type: 'object',
      properties: {
        limit: { 
          type: 'number', 
          description: 'Maximum number of contacts to return (default: 10)',
          default: 10
        }
      }
    }
  • Recursive utility function to convert any Date objects to ISO strings in the response data.
    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;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions retrieving 'most recently active contacts' but doesn't explain what 'active' means, how recency is determined, whether this is a read-only operation, what permissions are required, or how results are formatted. This leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's function without unnecessary words. It's appropriately sized for a simple retrieval tool and gets straight to the point.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a data retrieval tool with no annotations and no output schema, the description is insufficient. It doesn't explain what constitutes 'active' contacts, how results are sorted, what fields are returned, or any limitations. Given the lack of structured metadata, the description should provide more operational context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the 'limit' parameter clearly documented. The description doesn't add any parameter-specific information beyond what the schema provides, which is acceptable given the high schema coverage. The baseline of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get') and resource ('most recently active contacts from HubSpot'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'hubspot_get_company_activity' or 'hubspot_get_recent_engagements', which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. There are multiple sibling tools for retrieving HubSpot data, but no indication of when this specific 'active contacts' tool is appropriate versus other contact or activity-related tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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