Skip to main content
Glama
ZLeventer

hubspot-mcp

hs_search_contacts

Search contacts by name, email, company, or any indexed field to quickly find relevant records. Supports full-text queries with customizable result limits.

Instructions

Full-text search across contacts by name, email, company, or any indexed field.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesFull-text search string (name, email, company, etc.)
limitNo

Implementation Reference

  • Schema definition for hs_search_contacts: accepts 'query' (string) and optional 'limit' (1-100, default 20).
    export const SearchContactsSchema = z.object({
      query: z.string().describe("Full-text search string (name, email, company, etc.)"),
      limit: z.number().int().min(1).max(100).default(20).optional(),
    });
  • Handler function that calls HubSpot /crm/v3/objects/contacts/search POST API with full-text query, limit, configured properties, and descending sort by lastmodifieddate.
    export async function searchContacts(args: z.infer<typeof SearchContactsSchema>) {
      return hubspot("/crm/v3/objects/contacts/search", "POST", {
        query: args.query,
        limit: args.limit ?? 20,
        properties: CONTACT_PROPS.split(","),
        sorts: [{ propertyName: "lastmodifieddate", direction: "DESCENDING" }],
      });
    }
  • src/index.ts:82-87 (registration)
    Registration of hs_search_contacts tool on the MCP server with description, schema shape, and async handler wrapping searchContacts.
    server.tool(
      "hs_search_contacts",
      "Full-text search across contacts by name, email, company, or any indexed field.",
      SearchContactsSchema.shape,
      async (args) => { try { return ok(await searchContacts(args)); } catch (e) { return err(e); } },
    );
  • Import of SearchContactsSchema and searchContacts from contacts.ts into the registration file.
    // Contacts
    import {
      SearchContactsSchema, searchContacts,
      GetContactSchema, getContact,
      ContactByEmailSchema, contactByEmail,
      RecentContactsSchema, recentContacts,
      CreateContactSchema, createContact,
      UpdateContactSchema, updateContact,
    } from "./tools/contacts.js";
  • The hubspot() HTTP client used by searchContacts to make 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 provided, so description carries full burden. It reveals the search behavior but omits details like read-only nature, return format, pagination, or limitations.

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?

One sentence, front-loaded with key info, no unnecessary words. Efficient and clear.

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?

Given no output schema and simple parameters, description covers the search intent. But missing details on return structure and pagination for a search 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 covers 'query' with a description; 'limit' lacks description (50% coverage). Description adds value by listing searchable fields, compensating for schema gaps partially.

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?

Description clearly states it performs full-text search across contacts, specifying searchable fields (name, email, company). This distinguishes it from siblings like hs_get_contact (exact) or hs_search_companies.

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

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool vs alternatives like hs_crm_search or hs_contact_by_email. The description implies usage for full-text search but lacks exclusions or context.

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