hs_search_companies
Search companies by name, domain, or industry using full-text queries. Specify search terms and optional result limit to find relevant company records in HubSpot CRM.
Instructions
Full-text search across companies by name, domain, or industry.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Full-text search (company name, domain, etc.) | |
| limit | No |
Implementation Reference
- src/tools/companies.ts:15-22 (handler)The actual handler function for hs_search_companies. Calls hubspot('/crm/v3/objects/companies/search', 'POST') with the query, limit, and properties.
export async function searchCompanies(args: z.infer<typeof SearchCompaniesSchema>) { return hubspot("/crm/v3/objects/companies/search", "POST", { query: args.query, limit: args.limit ?? 20, properties: COMPANY_PROPS.split(","), sorts: [{ propertyName: "createdate", direction: "DESCENDING" }], }); } - src/tools/companies.ts:10-13 (schema)Zod schema defining input validation for hs_search_companies: query (string) and limit (number, 1-100, default 20).
export const SearchCompaniesSchema = z.object({ query: z.string().describe("Full-text search (company name, domain, etc.)"), limit: z.number().int().min(1).max(100).default(20).optional(), }); - src/index.ts:126-131 (registration)Registration of the 'hs_search_companies' tool with the MCP server, binding the schema and the searchCompanies handler.
server.tool( "hs_search_companies", "Full-text search across companies by name, domain, or industry.", SearchCompaniesSchema.shape, async (args) => { try { return ok(await searchCompanies(args)); } catch (e) { return err(e); } }, ); - src/tools/companies.ts:4-8 (helper)Constant list of company properties returned by the search.
const COMPANY_PROPS = [ "name", "domain", "industry", "numberofemployees", "annualrevenue", "city", "state", "country", "phone", "website", "hs_lead_status", "lifecyclestage", "createdate", "hubspot_owner_id", ].join(",");