hs_list_members
Retrieve contacts from a specific HubSpot contact list using the list ID. Set an optional limit to control the number of members returned. Supports list analysis and segmentation.
Instructions
Get contacts that are members of a specific list.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| listId | Yes | HubSpot contact list ID | |
| limit | No |
Implementation Reference
- src/tools/lists.ts:31-36 (handler)The `listMembers` function that executes the tool logic. It calls the HubSpot API endpoint `/contacts/v1/lists/{listId}/contacts/all` to retrieve contacts that are members of a specific list.
export async function listMembers(args: z.infer<typeof ListMembersSchema>) { return hubspot(`/contacts/v1/lists/${args.listId}/contacts/all`, "GET", undefined, { count: args.limit ?? 25, property: "firstname,lastname,email,jobtitle,lifecyclestage", }); } - src/tools/lists.ts:26-29 (schema)The `ListMembersSchema` Zod schema defining the input parameters: listId (required number) and limit (optional number, min 1, max 100, default 25).
export const ListMembersSchema = z.object({ listId: z.number().int().describe("HubSpot contact list ID"), limit: z.number().int().min(1).max(100).default(25).optional(), }); - src/index.ts:209-214 (registration)Registration of the 'hs_list_members' tool on the MCP server using server.tool(), binding the schema and handler.
server.tool( "hs_list_members", "Get contacts that are members of a specific list.", ListMembersSchema.shape, async (args) => { try { return ok(await listMembers(args)); } catch (e) { return err(e); } }, ); - src/index.ts:37-42 (registration)Import of ListMembersSchema and listMembers from the lists module into the main server file.
// Lists import { ListListsSchema, listLists, GetListSchema, getList, ListMembersSchema, listMembers, } from "./tools/lists.js";