get_company_summary
Retrieve workforce summary data including headcount, department breakdowns, job titles, and reporting structures from Paylocity company records.
Instructions
Get a high-level workforce summary: total headcount, breakdown by status, department (with names), job title, and reporting relationships.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| companyId | No | Paylocity company ID (defaults to PAYLOCITY_COMPANY_ID env var) |
Implementation Reference
- src/server.ts:341-399 (handler)The handler for the 'get_company_summary' tool, which calculates workforce statistics (total headcount, status breakdown, department, and job title) for a given company.
server.tool( "get_company_summary", `Get a high-level workforce summary: total headcount, breakdown by status, department (with names), job title, and reporting relationships.`, { companyId: companyIdParam, }, async ({ companyId }) => { try { const cid = resolveCompanyId(companyId); const dir = await getDirectory(cid); const byStatus: Record<string, number> = {}; const byDept: Record<string, number> = {}; const byTitle: Record<string, number> = {}; for (const e of dir) { const s = e.status === "A" ? "Active" : e.status === "T" ? "Terminated" : e.status; byStatus[s] = (byStatus[s] ?? 0) + 1; if (e.status === "A") { byDept[e.department || "Unknown"] = (byDept[e.department || "Unknown"] ?? 0) + 1; byTitle[e.jobTitle || "Unknown"] = (byTitle[e.jobTitle || "Unknown"] ?? 0) + 1; } } // Resolve cost center codes to names let costCenterNames: Record<string, string> = {}; try { const codes = (await client.get( `/v2/companies/${cid}/codes/costcenter1` )) as Array<{ code: string; description: string }>; for (const c of codes) costCenterNames[c.code] = c.description; } catch { // codes endpoint may not be available } const byDeptNamed: Record<string, number> = {}; for (const [code, count] of Object.entries(byDept)) { byDeptNamed[costCenterNames[code] ?? code] = count; } return ok({ totalEmployees: dir.length, byStatus, byDepartment: byDeptNamed, byTitle, }); } catch (e) { return err(e); } } );