Skip to main content
Glama

hubspot-batch-read-objects

Retrieve multiple HubSpot objects by their IDs in a single batch operation using this tool. Specify the object type and up to 100 IDs to efficiently fetch data, with optional properties and history included.

Instructions

🎯 Purpose: 1. Retrieves multiple HubSpot objects of the same object type by their IDs in a single batch operation. 🧭 Usage Guidance: 1. Use this tool to retrieve objects when the object IDs are known.

Input Schema

NameRequiredDescriptionDefault
inputsYesArray of object IDs to read (maximum 100 per batch)
objectTypeYesThe type of HubSpot object to read. 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.
propertiesNoOptional list of property names to include in the results
propertiesWithHistoryNoOptional list of property names to include with history

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "inputs": { "description": "Array of object IDs to read (maximum 100 per batch)", "items": { "additionalProperties": false, "properties": { "id": { "description": "ID of the object to read", "type": "string" } }, "required": [ "id" ], "type": "object" }, "maxItems": 100, "minItems": 1, "type": "array" }, "objectType": { "description": "The type of HubSpot object to read. 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": "Optional list of property names to include in the results", "items": { "type": "string" }, "type": "array" }, "propertiesWithHistory": { "description": "Optional list of property names to include with history", "items": { "type": "string" }, "type": "array" } }, "required": [ "objectType", "inputs" ], "type": "object" }

Implementation Reference

  • The process method that implements the core logic for batch reading HubSpot objects using the HubSpot API /crm/v3/objects/{objectType}/batch/read endpoint.
    async process(args) { try { const requestBody = { inputs: args.inputs, }; if (args.properties && args.properties.length > 0) { requestBody.properties = args.properties; } if (args.propertiesWithHistory && args.propertiesWithHistory.length > 0) { requestBody.propertiesWithHistory = args.propertiesWithHistory; } const response = await this.client.post(`/crm/v3/objects/${args.objectType}/batch/read`, { body: requestBody, }); return { content: [ { type: 'text', text: JSON.stringify({ status: response.status, results: response.results.map(result => { const formattedResult = { id: result.id, properties: result.properties, createdAt: result.createdAt, updatedAt: result.updatedAt, }; if (result.propertiesWithHistory) { formattedResult.propertiesWithHistory = result.propertiesWithHistory; } if (result.archived !== undefined) { formattedResult.archived = result.archived; } if (result.archivedAt) { formattedResult.archivedAt = result.archivedAt; } if (result.objectWriteTraceId) { formattedResult.objectWriteTraceId = result.objectWriteTraceId; } return formattedResult; }), requestedAt: response.requestedAt, startedAt: response.startedAt, completedAt: response.completedAt, }, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error batch reading HubSpot objects: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }
  • Zod schemas defining the input structure for the batch read operation, including objectType, inputs array, and optional properties.
    const ObjectReadInputSchema = z.object({ id: z.string().describe('ID of the object to read'), }); const BatchReadObjectsSchema = z.object({ objectType: z .string() .describe(`The type of HubSpot object to read. Valid values include: ${HUBSPOT_OBJECT_TYPES.join(', ')}. For custom objects, use the hubspot-get-schemas tool to get the objectType.`), inputs: z .array(ObjectReadInputSchema) .min(1) .max(100) .describe('Array of object IDs to read (maximum 100 per batch)'), properties: z .array(z.string()) .optional() .describe('Optional list of property names to include in the results'), propertiesWithHistory: z .array(z.string()) .optional() .describe('Optional list of property names to include with history'), });
  • Registers the BatchReadObjectsTool instance with the tools registry.
    registerTool(new BatchReadObjectsTool());
  • Tool definition object specifying the tool name, description, input schema, and annotations, passed to the BaseTool superclass.
    const ToolDefinition = { name: 'hubspot-batch-read-objects', description: ` 🎯 Purpose: 1. Retrieves multiple HubSpot objects of the same object type by their IDs in a single batch operation. 🧭 Usage Guidance: 1. Use this tool to retrieve objects when the object IDs are known. `, inputSchema: zodToJsonSchema(BatchReadObjectsSchema), annotations: { title: 'Read Multiple CRM Objects', readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true, }, };

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