get_direct_reports
List direct reports for an employee by providing their person ID. Useful for understanding reporting relationships.
Instructions
List direct reports of the given person. Reads the directReports array on the person record.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| person_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- humaans_mcp/server.py:163-175 (handler)The tool handler: fetches the person by ID, reads the directReports array, indexes all people, and returns a list of summaries for each direct report.
@mcp.tool() async def get_direct_reports(person_id: str) -> list[dict[str, Any]]: """List direct reports of the given person. Reads the `directReports` array on the person record.""" person = await client().get(f"/people/{person_id}") report_ids = person.get("directReports") or [] if not report_ids: return [] by_id, _, custom_by_person = await _people_index() return [ _person_summary(by_id[rid], custom_by_person.get(rid)) for rid in report_ids if rid in by_id ] - humaans_mcp/server.py:163-175 (registration)Registration via the @mcp.tool() decorator on an async function, registering it with the FastMCP server.
@mcp.tool() async def get_direct_reports(person_id: str) -> list[dict[str, Any]]: """List direct reports of the given person. Reads the `directReports` array on the person record.""" person = await client().get(f"/people/{person_id}") report_ids = person.get("directReports") or [] if not report_ids: return [] by_id, _, custom_by_person = await _people_index() return [ _person_summary(by_id[rid], custom_by_person.get(rid)) for rid in report_ids if rid in by_id ] - humaans_mcp/server.py:151-160 (helper)Helper function that formats a person record into a summary dict, used by get_direct_reports to build the response.
def _person_summary(p: dict[str, Any], custom: dict[str, Any] | None = None) -> dict[str, Any]: return { **(custom or {}), "id": p.get("id"), "firstName": p.get("firstName"), "lastName": p.get("lastName"), "jobTitle": p.get("jobTitle"), "email": p.get("email"), "contractType": p.get("contractType"), } - humaans_mcp/server.py:127-148 (helper)Helper that builds an index of all people (by id), a parent_of mapping, and custom field values per person — used by get_direct_reports to look up direct reports.
async def _people_index() -> tuple[dict[str, dict[str, Any]], dict[str, str], dict[str, dict[str, Any]]]: """Return (by_id, parent_of, custom_by_person). parent_of maps a report's id to their manager's id; custom_by_person maps personId to {fieldName: value}.""" all_people = await client().list_all("/people") by_id = {p["id"]: p for p in all_people if "id" in p} parent_of: dict[str, str] = {} for p in all_people: mgr_id = p.get("id") for child_id in p.get("directReports") or []: parent_of[child_id] = mgr_id names = await _custom_field_names() all_values = await client().list_all("/custom-values") values_by_person: dict[str, list[dict[str, Any]]] = {} for v in all_values: pid = v.get("personId") if pid: values_by_person.setdefault(pid, []).append(v) custom_by_person = { pid: _resolve_custom(vs, names) for pid, vs in values_by_person.items() } return by_id, parent_of, custom_by_person