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'),
    });

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