Skip to main content
Glama
ajaystream

HubSpot MCP Server

by ajaystream

hubspot-batch-read-objects

Read-onlyIdempotent

Retrieve multiple HubSpot objects by their IDs in a single batch operation to efficiently access CRM data when object IDs are known.

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

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

Implementation Reference

  • The process method implements the core logic: constructs the request body, calls the HubSpot CRM v3 batch read API, formats the response results, and handles errors.
    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 for input validation: ObjectReadInputSchema for individual inputs and BatchReadObjectsSchema for the batch parameters including objectType, inputs array (1-100), 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'),
    });
  • ToolDefinition object with name 'hubspot-batch-read-objects', description, inputSchema, and annotations. The BatchReadObjectsTool class constructor calls super() to register the tool using the schema and definition.
    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,
        },
    };
    export class BatchReadObjectsTool extends BaseTool {
        client;
        constructor() {
            super(BatchReadObjectsSchema, ToolDefinition);
            this.client = new HubSpotClient();
        }
Behavior4/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false, idempotentHint=true, and openWorldHint=true, covering safety and idempotency. The description adds valuable context about batch operation and the 100-item limit (implied by 'multiple'), which isn't in annotations. It doesn't describe rate limits or auth needs, but with good annotation coverage, this is acceptable.

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

Conciseness4/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. Both sentences are relevant and add value. It could be slightly more concise by combining points, but it's efficient overall with no wasted words.

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

Completeness4/5

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

For a read operation with rich annotations (readOnlyHint, idempotentHint) and full schema coverage, the description is reasonably complete. It covers purpose and usage well. However, without an output schema, it doesn't describe return values (e.g., format, error handling), leaving a minor gap for a batch tool.

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 4 parameters. The description doesn't add any parameter-specific details beyond what's in the schema (e.g., it doesn't explain 'objectType' values or 'properties' usage). Baseline 3 is appropriate when 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 specific action ('retrieves multiple HubSpot objects'), resource ('objects of the same object type'), and scope ('by their IDs in a single batch operation'). It distinguishes from siblings like 'hubspot-list-objects' (list all) and 'hubspot-search-objects' (search with criteria) by specifying retrieval by known IDs in batch mode.

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

Usage Guidelines4/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 ('when the object IDs are known'), which is clear and helpful. However, it doesn't mention when NOT to use or name specific alternatives (e.g., 'hubspot-list-objects' for listing all objects or 'hubspot-search-objects' for searching without IDs), which prevents a perfect score.

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