( server: McpServer, context: McpAuthContext, )
| 7 | } from '../shared'; |
| 8 | |
| 9 | export function registerGroupTools( |
| 10 | server: McpServer, |
| 11 | context: McpAuthContext, |
| 12 | ) { |
| 13 | server.tool( |
| 14 | 'list_group_types', |
| 15 | 'List all group types defined in this project (e.g. "company", "team", "account"). Groups represent B2B entities. Call this first to discover what group types exist before querying groups.', |
| 16 | { |
| 17 | projectId: projectIdSchema(context), |
| 18 | }, |
| 19 | async ({ projectId: inputProjectId }) => |
| 20 | withErrorHandling(async () => { |
| 21 | const projectId = await resolveProjectId(context, inputProjectId); |
| 22 | const types = await getGroupTypes(projectId); |
| 23 | return { types }; |
| 24 | }), |
| 25 | ); |
| 26 | |
| 27 | server.tool( |
| 28 | 'find_groups', |
| 29 | 'Search for groups (companies, teams, accounts) by name, ID, or type. Groups are B2B entities that profiles (users) belong to.', |
| 30 | { |
| 31 | projectId: projectIdSchema(context), |
| 32 | type: z |
| 33 | .string() |
| 34 | .optional() |
| 35 | .describe('Filter by group type (e.g. "company", "team"). Use list_group_types to discover available types.'), |
| 36 | search: z |
| 37 | .string() |
| 38 | .optional() |
| 39 | .describe('Partial match against group name or ID'), |
| 40 | limit: z |
| 41 | .number() |
| 42 | .int() |
| 43 | .min(1) |
| 44 | .max(100) |
| 45 | .default(20) |
| 46 | .optional() |
| 47 | .describe('Maximum number of groups to return (default 20)'), |
| 48 | }, |
| 49 | async ({ projectId: inputProjectId, type, search, limit }) => |
| 50 | withErrorHandling(async () => { |
| 51 | const projectId = await resolveProjectId(context, inputProjectId); |
| 52 | return getGroupList({ projectId, type, search, take: limit ?? 20 }); |
| 53 | }), |
| 54 | ); |
| 55 | |
| 56 | server.tool( |
| 57 | 'get_group', |
| 58 | 'Get a specific group by ID including its properties, and fetch the member profiles (users) that belong to it.', |
| 59 | { |
| 60 | projectId: projectIdSchema(context), |
| 61 | groupId: z.string().describe('The group ID to look up'), |
| 62 | memberLimit: z |
| 63 | .number() |
| 64 | .int() |
| 65 | .min(1) |
| 66 | .max(50) |
no test coverage detected