Skip to main content
Glama
ajaystream

HubSpot MCP Server

by ajaystream

hubspot-batch-create-objects

Create multiple HubSpot CRM objects of the same type in a single batch operation to optimize bulk data entry and management.

Instructions

🛡️ Guardrails:
  1. Data Modification Warning: This tool modifies HubSpot data. Only use when the user has explicitly requested to update their CRM.

🎯 Purpose:
  1. Creates multiple HubSpot objects of the same objectType in a single API call, optimizing for bulk operations.

📋 Prerequisites:
  1. Use the hubspot-get-user-details tool to get the OwnerId and UserId if you don't have that already.
  2. Use the hubspot-list-objects tool to sample existing objects for the object type.
  3. Use the hubspot-get-association-definitions tool to identify valid association types before creating associations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
objectTypeYesThe type of HubSpot object to create. 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 objects to create (maximum 100 per batch)

Implementation Reference

  • The process method in BatchCreateObjectsTool class that handles the tool execution by calling the HubSpot batch create API and processing the response.
    async process(args) {
        try {
            const response = await this.client.post(`/crm/v3/objects/${args.objectType}/batch/create`, {
                body: {
                    inputs: args.inputs,
                },
            });
            return {
                content: [
                    {
                        type: 'text',
                        text: JSON.stringify({
                            status: response.status,
                            results: response.results.map(result => ({
                                id: result.id,
                                properties: result.properties,
                                createdAt: result.createdAt,
                                updatedAt: result.updatedAt,
                            })),
                            requestedAt: response.requestedAt,
                            startedAt: response.startedAt,
                            completedAt: response.completedAt,
                        }, null, 2),
                    },
                ],
            };
        }
        catch (error) {
            return {
                content: [
                    {
                        type: 'text',
                        text: `Error batch creating HubSpot objects. : ${error instanceof Error ? error.message : String(error)}
            `,
                    },
                ],
                isError: true,
            };
        }
    }
  • Zod schema defining the input structure for the batch create objects tool, including objectType and array of inputs.
    const BatchCreateObjectsSchema = z.object({
        objectType: z
            .string()
            .describe(`The type of HubSpot object to create. Valid values include: ${HUBSPOT_OBJECT_TYPES.join(', ')}. For custom objects, use the hubspot-get-schemas tool to get the objectType.`),
        inputs: z
            .array(ObjectInputSchema)
            .min(1)
            .max(100)
            .describe('Array of objects to create (maximum 100 per batch)'),
    });
  • Registration of the BatchCreateObjectsTool instance in the tools registry.
    registerTool(new BatchCreateObjectsTool());
  • ToolDefinition object containing the name, description, schema, and annotations used for tool registration.
    const ToolDefinition = {
        name: 'hubspot-batch-create-objects',
        description: `
        🛡️ Guardrails:
          1. Data Modification Warning: This tool modifies HubSpot data. Only use when the user has explicitly requested to update their CRM.
    
        🎯 Purpose:
          1. Creates multiple HubSpot objects of the same objectType in a single API call, optimizing for bulk operations.
    
        📋 Prerequisites:
          1. Use the hubspot-get-user-details tool to get the OwnerId and UserId if you don't have that already.
          2. Use the hubspot-list-objects tool to sample existing objects for the object type.
          3. Use the hubspot-get-association-definitions tool to identify valid association types before creating associations.
      `,
        inputSchema: zodToJsonSchema(BatchCreateObjectsSchema),
        annotations: {
            title: 'Create CRM Objects',
            readOnlyHint: false,
            destructiveHint: false,
            idempotentHint: false,
            openWorldHint: true,
        },
    };
  • Supporting schema for individual object inputs in the batch.
    const ObjectInputSchema = z.object({
        properties: PropertiesSchema.describe('Object properties as key-value pairs'),
        associations: z
            .array(AssociationSchema)
            .optional()
            .describe('Optional list of associations to create with this object'),
        objectWriteTraceId: z.string().optional().describe('Optional trace ID for debugging purposes'),
    });
Behavior4/5

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

Annotations already indicate this is a non-readOnly, non-destructive, non-idempotent operation. The description adds valuable context beyond annotations: the data modification warning, the bulk optimization nature, and the prerequisite steps needed for successful execution. However, it doesn't mention rate limits, error handling, or what happens on partial failures in the batch.

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 clear sections (Guardrails, Purpose, Prerequisites) and uses emojis for visual organization. Each sentence earns its place by providing distinct guidance. It could be slightly more concise by combining some points, but overall it's efficiently organized and front-loaded with important warnings.

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 batch creation tool with comprehensive annotations and 100% schema coverage, the description provides good contextual completeness. It covers the mutation nature, prerequisites, and bulk optimization purpose. The main gap is the lack of output schema, so the description doesn't explain what the tool returns, but given the annotations and schema coverage, it's reasonably complete.

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 already fully documents both parameters. The description doesn't add any parameter-specific information beyond what's in the schema. The baseline score of 3 is appropriate when the schema does all the heavy lifting for parameter documentation.

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 explicitly states the tool's purpose: 'Creates multiple HubSpot objects of the same objectType in a single API call, optimizing for bulk operations.' This is a specific verb ('creates') with clear resource ('HubSpot objects') and distinguishes it from siblings like hubspot-create-engagement (single engagement) or hubspot-batch-update-objects (updates instead of creates).

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: 'Only use when the user has explicitly requested to update their CRM.' It also lists three prerequisite tools (hubspot-get-user-details, hubspot-list-objects, hubspot-get-association-definitions) that should be used before invoking this tool, giving clear context for proper usage.

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