hs_recent_deals
Retrieve the most recently created deals from HubSpot CRM. Optionally exclude closed deals by setting openOnly to true. Configure the number of deals returned with the limit parameter.
Instructions
Most recently created deals. Pass openOnly=true to exclude closed deals.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| openOnly | No | Exclude closed deals |
Implementation Reference
- src/tools/deals.ts:60-70 (handler)The actual handler function that executes the 'hs_recent_deals' tool logic. Calls the HubSpot API to search deals sorted by createdate descending, optionally filtering out closed deals.
export async function recentDeals(args: z.infer<typeof RecentDealsSchema>) { const filters = args.openOnly ? [{ propertyName: "hs_is_closed", operator: "EQ", value: "false" }] : []; return hubspot("/crm/v3/objects/deals/search", "POST", { filterGroups: filters.length ? [{ filters }] : [], properties: DEAL_PROPS.split(","), sorts: [{ propertyName: "createdate", direction: "DESCENDING" }], limit: args.limit ?? 25, }); } - src/tools/deals.ts:55-58 (schema)Zod schema defining the input parameters for the recentDeals handler: limit (1-100, default 25) and openOnly (boolean, default false).
export const RecentDealsSchema = z.object({ limit: z.number().int().min(1).max(100).default(25).optional(), openOnly: z.boolean().default(false).optional().describe("Exclude closed deals"), }); - src/index.ts:170-175 (registration)Registers 'hs_recent_deals' as an MCP tool on the server with its schema and a callback that invokes recentDeals().
server.tool( "hs_recent_deals", "Most recently created deals. Pass openOnly=true to exclude closed deals.", RecentDealsSchema.shape, async (args) => { try { return ok(await recentDeals(args)); } catch (e) { return err(e); } }, ); - src/tools/deals.ts:4-8 (helper)Shared DEAL_PROPS constant defining the properties fetched for all deal-related tools, including hs_recent_deals.
const DEAL_PROPS = [ "dealname", "amount", "dealstage", "pipeline", "closedate", "hubspot_owner_id", "hs_deal_stage_probability", "createdate", "hs_is_closed_won", "hs_is_closed", "associated_contact_ids", ].join(",");