hubspot-list-objects
Retrieve a paginated list of HubSpot objects by type to explore data structure, properties, and metadata. Ideal for initial data exploration when search criteria are unclear. Supports custom properties and associations.
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
| Name | Required | Description | Default |
|---|---|---|---|
| after | No | The paging cursor token of the last successfully read resource. | |
| archived | No | Whether to return only results that have been archived. | |
| associations | No | A 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). | |
| limit | No | The maximum number of results to display per page (max: 500). | |
| objectType | Yes | The 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. | |
| properties | No | A list of the properties to be returned in the response. |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"after": {
"description": "The paging cursor token of the last successfully read resource.",
"type": "string"
},
"archived": {
"default": false,
"description": "Whether to return only results that have been archived.",
"type": "boolean"
},
"associations": {
"description": "A 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).",
"items": {
"type": "string"
},
"type": "array"
},
"limit": {
"default": 100,
"description": "The maximum number of results to display per page (max: 500).",
"maximum": 500,
"minimum": 1,
"type": "integer"
},
"objectType": {
"description": "The 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.",
"type": "string"
},
"properties": {
"description": "A list of the properties to be returned in the response.",
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"objectType"
],
"type": "object"
}
Implementation Reference
- dist/tools/toolsRegistry.js:28-28 (registration)Registers the instance of ObjectListTool, which implements the 'hubspot-list-objects' tool.registerTool(new ObjectListTool());
- Zod input schema defining parameters for the hubspot-list-objects tool: objectType, limit, after, properties, associations, archived.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.'), });
- The main handler function that constructs query parameters and calls the HubSpot CRM API to list objects of the specified type, formats and returns 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, }; } }
- Tool definition object including name 'hubspot-list-objects', description, input schema, and annotations used in 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, }, };