Skip to main content
Glama
ZLeventer

hubspot-mcp

hs_crm_search

Run structured CRM searches with custom filters against any object type. Supports operators, sorting, and property selection. Use when preset tools don't cover your query.

Instructions

Escape hatch: run a structured CRM search with custom filter conditions against any object type. Use when preset tools don't cover your query. Docs: developers.hubspot.com/docs/api/crm/search

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
objectTypeYesCRM object type to search
filtersYesFilter conditions to apply
propertiesNoProperties to return
sortsNo
limitNo

Implementation Reference

  • The crmSearch handler function that executes the HubSpot CRM search. It calls the POST /crm/v3/objects/{objectType}/search endpoint with filter groups, properties, sorts, and limit.
    export async function crmSearch(args: z.infer<typeof CrmSearchSchema>) {
      return hubspot(`/crm/v3/objects/${args.objectType}/search`, "POST", {
        filterGroups: [{ filters: args.filters }],
        properties: args.properties,
        sorts: args.sorts ?? [{ propertyName: "createdate", direction: "DESCENDING" }],
        limit: args.limit ?? 50,
      });
    }
  • The CrmSearchSchema Zod schema defining the input shape: objectType (enum of CRM types), filters (array of filter conditions), properties, sorts, and limit.
    export const CrmSearchSchema = z.object({
      objectType: z.enum(OBJECT_TYPES).describe("CRM object type to search"),
      filters: z.array(z.object({
        propertyName: z.string(),
        operator: z.enum(["EQ", "NEQ", "LT", "LTE", "GT", "GTE", "BETWEEN", "IN", "NOT_IN", "HAS_PROPERTY", "NOT_HAS_PROPERTY", "CONTAINS_TOKEN", "NOT_CONTAINS_TOKEN"]),
        value: z.string().optional(),
        values: z.array(z.string()).optional(),
        highValue: z.string().optional(),
      })).describe("Filter conditions to apply"),
      properties: z.array(z.string()).optional().describe("Properties to return"),
      sorts: z.array(z.object({
        propertyName: z.string(),
        direction: z.enum(["ASCENDING", "DESCENDING"]).default("DESCENDING"),
      })).optional(),
      limit: z.number().int().min(1).max(200).default(50).optional(),
    });
  • src/index.ts:305-310 (registration)
    Registration of the 'hs_crm_search' tool on the MCP server with its schema and handler.
    server.tool(
      "hs_crm_search",
      "Escape hatch: run a structured CRM search with custom filter conditions against any object type. Use when preset tools don't cover your query. Docs: developers.hubspot.com/docs/api/crm/search",
      CrmSearchSchema.shape,
      async (args) => { try { return ok(await crmSearch(args)); } catch (e) { return err(e); } },
    );
  • Import of CrmSearchSchema and crmSearch from the power module.
    import { CrmSearchSchema, crmSearch } from "./tools/power.js";
  • The hubspot() helper function used by crmSearch to make authenticated API calls to HubSpot.
    export async function hubspot<T = unknown>(
      path: string,
      method: "GET" | "POST" | "PATCH" | "DELETE" = "GET",
      body?: unknown,
      params?: Record<string, string | number | boolean>,
    ): Promise<T> {
      const token = getToken();
    
      let url = `${BASE_URL}${path}`;
      if (params && method === "GET") {
        const qs = new URLSearchParams(
          Object.entries(params).map(([k, v]) => [k, String(v)]),
        ).toString();
        if (qs) url += `?${qs}`;
      }
    
      const res = await fetch(url, {
        method,
        headers: {
          Authorization: `Bearer ${token}`,
          "Content-Type": "application/json",
        },
        ...(body && method !== "GET" ? { body: JSON.stringify(body) } : {}),
      });
    
      if (!res.ok) {
        const text = await res.text().catch(() => res.statusText);
        throw new HubSpotError(`HubSpot API error (${res.status}): ${text}`, res.status);
      }
    
      if (res.status === 204) return undefined as T;
      return (await res.json()) as T;
    }
Behavior2/5

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

No annotations are provided, so the description must disclose behavioral traits. It only states 'search', implying read-only, but does not confirm idempotence, permissions, or side effects. No mention of rate limits, pagination, or error behavior. A docs link is given but does not inline key details.

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

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Extremely concise: two sentences plus a link. Front-loaded with 'Escape hatch' for instant context, no wasted words, and every sentence adds value.

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

Completeness3/5

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

Adequate for a search tool given the presence of many siblings, but lacks behavioral transparency and parameter detail. Does not mention result format, pagination, or read-only nature, which are important for correct invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description mentions 'custom filter conditions' and 'any object type', but does not elaborate on how to use the parameters (e.g., filter structure, operator semantics, property selection, sorting, limit). Schema descriptions cover 60% of parameters, but the description adds no value beyond them, failing to compensate for the remaining 40%.

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?

Clearly states it performs a structured CRM search against any object type, and explicitly distinguishes from preset tools by labeling itself an 'escape hatch'. This makes its purpose specific and differentiated from siblings.

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?

Directly advises to use when preset tools don't cover the query, providing clear context for tool selection. Lacks explicit exclusion of other scenarios but the guidance is sufficient for an agent.

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/ZLeventer/hubspot-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server