Skip to main content
Glama
ajaystream

HubSpot MCP Server

by ajaystream

hubspot-list-objects

Read-only

Retrieve a paginated list of HubSpot objects by type for initial data exploration when search criteria are unclear. Use to understand data structure before targeted queries.

Instructions

🎯 Purpose:
  1. Retrieves a paginated list of objects of a specified type from HubSpot.

📦 Returns:
  1. Collection of objects with their properties and metadata, plus pagination information.

🧭 Usage Guidance:
  1. Use for initial data exploration to understand the data structure of a HubSpot object type.
  2. Helps list objects when the search criteria or filter criteria is not clear.
  3. Use hubspot-search-objects for targeted queries when the data structure is known.
  4. Use hubspot-batch-read-objects to retrieve specific objects by their IDs.
  5. Use hubspot-list-associations to list associations between objects.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
objectTypeYesThe type of HubSpot object to list. Valid values include: appointments, companies, contacts, courses, deals, leads, line_items, listings, marketing_events, meetings, orders, postal_mail, products, quotes, services, subscriptions, tickets, users. For custom objects, use the hubspot-get-schemas tool to get the objectType.
limitNoThe maximum number of results to display per page (max: 500).
afterNoThe paging cursor token of the last successfully read resource.
propertiesNoA list of the properties to be returned in the response.
associationsNoA list of object types to retrieve associated IDs for (e.g., appointments, companies, contacts, courses, deals, leads, line_items, listings, marketing_events, meetings, orders, postal_mail, products, quotes, services, subscriptions, tickets, users).
archivedNoWhether to return only results that have been archived.

Implementation Reference

  • The main handler function that constructs the API request to HubSpot's CRM v3 objects endpoint and processes the response.
    async process(args) {
        try {
            const queryParams = new URLSearchParams();
            const paramMappings = {
                limit: args.limit?.toString(),
                after: args.after,
                properties: args.properties && args.properties.length > 0 ? args.properties.join(',') : undefined,
                associations: args.associations && args.associations.length > 0
                    ? args.associations.join(',')
                    : undefined,
                archived: args.archived?.toString() || 'false',
            };
            Object.entries(paramMappings).forEach(([key, value]) => {
                if (value !== undefined) {
                    queryParams.append(key, value);
                }
            });
            const response = await this.client.get(`/crm/v3/objects/${args.objectType}?${queryParams.toString()}`);
            return {
                content: [
                    {
                        type: 'text',
                        text: JSON.stringify({
                            results: response.results.map(item => ({
                                id: item.id,
                                properties: item.properties,
                                createdAt: item.createdAt,
                                updatedAt: item.updatedAt,
                                archived: item.archived,
                                archivedAt: item.archivedAt,
                                associations: item.associations,
                            })),
                            paging: response.paging,
                        }, null, 2),
                    },
                ],
            };
        }
        catch (error) {
            return {
                content: [
                    {
                        type: 'text',
                        text: `Error listing HubSpot ${args.objectType}: ${error instanceof Error ? error.message : String(error)}`,
                    },
                ],
                isError: true,
            };
        }
    }
  • Zod schema defining the input parameters for the tool, including objectType, limit, pagination, properties, associations, and archived filter.
    const ObjectListSchema = z.object({
        objectType: z
            .string()
            .describe(`The type of HubSpot object to list. Valid values include: ${HUBSPOT_OBJECT_TYPES.join(', ')}. For custom objects, use the hubspot-get-schemas tool to get the objectType.`),
        limit: z
            .number()
            .int()
            .min(1)
            .max(500)
            .default(100)
            .describe('The maximum number of results to display per page (max: 500).'),
        after: z
            .string()
            .optional()
            .describe('The paging cursor token of the last successfully read resource.'),
        properties: z
            .array(z.string())
            .optional()
            .describe('A list of the properties to be returned in the response.'),
        associations: z
            .array(z.string())
            .optional()
            .describe(`A list of object types to retrieve associated IDs for (e.g., ${HUBSPOT_OBJECT_TYPES.join(', ')}).`),
        archived: z
            .boolean()
            .default(false)
            .describe('Whether to return only results that have been archived.'),
    });
  • Tool definition object containing the name 'hubspot-list-objects', description, input schema, and annotations used in the BaseTool constructor.
    const ToolDefinition = {
        name: 'hubspot-list-objects',
        description: `
        🎯 Purpose:
          1. Retrieves a paginated list of objects of a specified type from HubSpot.
    
        📦 Returns:
          1. Collection of objects with their properties and metadata, plus pagination information.
    
        🧭 Usage Guidance:
          1. Use for initial data exploration to understand the data structure of a HubSpot object type.
          2. Helps list objects when the search criteria or filter criteria is not clear.
          3. Use hubspot-search-objects for targeted queries when the data structure is known.
          4. Use hubspot-batch-read-objects to retrieve specific objects by their IDs.
          5. Use hubspot-list-associations to list associations between objects.
      `,
        inputSchema: zodToJsonSchema(ObjectListSchema),
        annotations: {
            title: 'List CRM Objects',
            readOnlyHint: true,
            destructiveHint: false,
            idempotentHint: false,
            openWorldHint: true,
        },
    };
  • Registration of the ObjectListTool instance in the tools registry.
    registerTool(new ObjectListTool());
  • Import statement for the ObjectListTool class.
    import { ObjectListTool } from './objects/listObjectsTool.js';
Behavior4/5

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

Annotations already provide readOnlyHint=true, destructiveHint=false, openWorldHint=true, and idempotentHint=false, covering safety and idempotency. The description adds value by specifying 'paginated list' (implying pagination behavior) and 'initial data exploration' (context for usage), but doesn't detail rate limits or auth needs. No contradiction with annotations.

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 well-structured with emoji headings (🎯, 📦, 🧭) and bullet points, making it easy to scan. Each sentence adds value: purpose, returns, and usage guidance. No wasted words, and it's front-loaded with the core purpose.

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

Completeness5/5

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

Given the tool's complexity (6 parameters, 1 required), rich annotations (readOnlyHint, openWorldHint, etc.), and 100% schema coverage, the description is complete. It covers purpose, returns, and usage guidance, and while there's no output schema, it mentions 'Collection of objects with their properties and metadata, plus pagination information,' which is sufficient.

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?

Schema description coverage is 100%, so the schema fully documents all 6 parameters. The description doesn't add any parameter-specific details beyond what the schema provides (e.g., it mentions 'specified type' but doesn't elaborate on objectType options). Baseline 3 is appropriate since the schema does the heavy lifting.

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

Purpose5/5

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

The description clearly states the tool's purpose: 'Retrieves a paginated list of objects of a specified type from HubSpot.' This is specific (verb: 'retrieves', resource: 'objects'), and it distinguishes from siblings by explicitly mentioning 'paginated list' and 'specified type', which differentiates it from search or batch operations.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool vs. alternatives: 'Use for initial data exploration...', 'Use hubspot-search-objects for targeted queries...', 'Use hubspot-batch-read-objects to retrieve specific objects...', and 'Use hubspot-list-associations to list associations...'. This covers both when-to-use and when-not-to-use scenarios with named alternatives.

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/ajaystream/hubspot-mcp-custom'

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