fetch_company_codes
Retrieve company-specific codes for resources like earnings or deductions from Paylocity. Specify a company ID and code resource to access structured data.
Instructions
Fetch company codes for a specific resource.
Args: company_id: Optional company ID (string or integer). If not provided, uses the first company ID from configuration. code_resource: Code resource to fetch (e.g., 'earnings', 'deductions', 'costcenter1', etc.)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| company_id | No | ||
| code_resource | No |
Implementation Reference
- src/mcppaylocity/__init__.py:276-289 (handler)MCP tool handler for 'fetch_company_codes'. Validates input parameters and calls PaylocityClient.get_company_codes to fetch the data. The @mcp.tool() decorator registers it with the MCP server.@mcp.tool() def fetch_company_codes(company_id: Optional[Union[str, int]] = None, code_resource: str = None) -> Dict[str, Any]: """ Fetch company codes for a specific resource. Args: company_id: Optional company ID (string or integer). If not provided, uses the first company ID from configuration. code_resource: Code resource to fetch (e.g., 'earnings', 'deductions', 'costcenter1', etc.) """ if code_resource is None: raise ValueError("code_resource is required") company_id_str = str(company_id) if company_id is not None else company_ids[0] return client.get_company_codes(company_id_str, code_resource)
- Supporting method in PaylocityClient class that constructs the API endpoint and performs the authenticated GET request to retrieve company codes, using the internal _make_request method which handles retries and token management.def get_company_codes(self, company_id, code_resource): """Get company codes for a specific resource""" endpoint = "/api/v2/companies/{}/codes/{}".format(company_id, code_resource) return self._make_request("GET", endpoint).json()