@t4dhg/mcp-factorial 1.1.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +175 -58
  3. package/dist/api.d.ts +424 -8
  4. package/dist/api.d.ts.map +1 -1
  5. package/dist/api.js +1156 -100
  6. package/dist/api.js.map +1 -1
  7. package/dist/audit.d.ts +86 -0
  8. package/dist/audit.d.ts.map +1 -0
  9. package/dist/audit.js +119 -0
  10. package/dist/audit.js.map +1 -0
  11. package/dist/cache.d.ts +88 -0
  12. package/dist/cache.d.ts.map +1 -0
  13. package/dist/cache.js +169 -0
  14. package/dist/cache.js.map +1 -0
  15. package/dist/config.d.ts +57 -0
  16. package/dist/config.d.ts.map +1 -0
  17. package/dist/config.js +112 -0
  18. package/dist/config.js.map +1 -0
  19. package/dist/confirmation.d.ts +118 -0
  20. package/dist/confirmation.d.ts.map +1 -0
  21. package/dist/confirmation.js +153 -0
  22. package/dist/confirmation.js.map +1 -0
  23. package/dist/errors.d.ts +133 -0
  24. package/dist/errors.d.ts.map +1 -0
  25. package/dist/errors.js +251 -0
  26. package/dist/errors.js.map +1 -0
  27. package/dist/http-client.d.ts +80 -0
  28. package/dist/http-client.d.ts.map +1 -0
  29. package/dist/http-client.js +243 -0
  30. package/dist/http-client.js.map +1 -0
  31. package/dist/index.d.ts +12 -2
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +3272 -73
  34. package/dist/index.js.map +1 -1
  35. package/dist/pagination.d.ts +96 -0
  36. package/dist/pagination.d.ts.map +1 -0
  37. package/dist/pagination.js +114 -0
  38. package/dist/pagination.js.map +1 -0
  39. package/dist/schemas.d.ts +1789 -0
  40. package/dist/schemas.d.ts.map +1 -0
  41. package/dist/schemas.js +718 -0
  42. package/dist/schemas.js.map +1 -0
  43. package/dist/types.d.ts +61 -50
  44. package/dist/types.d.ts.map +1 -1
  45. package/dist/types.js +6 -1
  46. package/dist/types.js.map +1 -1
  47. package/dist/write-safety.d.ts +53 -0
  48. package/dist/write-safety.d.ts.map +1 -0
  49. package/dist/write-safety.js +239 -0
  50. package/dist/write-safety.js.map +1 -0
  51. package/llms.txt +115 -0
  52. package/package.json +63 -7
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2025 Taig Mac Carthy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,44 +1,68 @@
1
1
  # MCP FactorialHR
2
2
 
3
- > **Secure, privacy-focused access to FactorialHR data for AI assistants**
3
+ > **The definitive Model Context Protocol server for FactorialHR**
4
4
 
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6
6
  [![MCP Compatible](https://img.shields.io/badge/MCP-Compatible-green.svg)](https://modelcontextprotocol.io/)
7
7
  [![Node.js](https://img.shields.io/badge/Node.js-18%2B-brightgreen.svg)](https://nodejs.org/)
8
+ [![npm version](https://img.shields.io/npm/v/@t4dhg/mcp-factorial.svg)](https://www.npmjs.com/package/@t4dhg/mcp-factorial)
8
9
 
9
- A Model Context Protocol (MCP) server that provides AI assistants like Claude with secure, read-only access to your FactorialHR employee and organizational data. Built with privacy and security as core principles.
10
+ A comprehensive Model Context Protocol (MCP) server that provides AI assistants like Claude with full access to FactorialHR. Manage employees, teams, time off, projects, training, recruiting, and more - all with built-in safety guardrails.
10
11
 
11
12
  ## Why This MCP Server?
12
13
 
13
- - **Privacy-First Design**: Deliberately excludes payroll, compensation, and sensitive financial data. Your salary information stays private.
14
- - **Read-Only Access**: No write operations - Claude can view but never modify your HR data.
15
- - **Organizational Focus**: Optimized for team structure, employee directories, and location lookups - the data you actually need for AI-assisted workflows.
16
- - **Enterprise Ready**: Built for companies who need AI integration without compromising data security.
17
-
18
- ## Security by Design
19
-
20
- This MCP server intentionally **does NOT expose**:
21
- - Payroll and salary information
22
- - Bank account details
23
- - Tax documents
24
- - Compensation packages
25
- - Benefits enrollment data
26
- - Personal identification numbers
27
-
28
- We believe AI assistants should help with organizational tasks without having access to your most sensitive HR data.
29
-
30
- ## Available Tools
31
-
32
- | Tool | Description |
33
- |------|-------------|
34
- | `list_employees` | Get all employees with optional team/location filters. Returns name, email, role, manager, hire date, and more. |
35
- | `get_employee` | Get detailed information about a specific employee by ID |
36
- | `search_employees` | Search employees by name or email |
37
- | `list_teams` | View organizational team structure |
38
- | `get_team` | Get team details and member list |
39
- | `list_locations` | Get company office locations |
40
- | `get_location` | Get location details (address, contact info) |
41
- | `get_employee_contracts` | View job titles and contract effective dates for an employee |
14
+ - **Comprehensive Coverage**: 80+ tools spanning employees, teams, time off, attendance, projects, training, recruiting (ATS), and payroll
15
+ - **Full CRUD Operations**: Create, read, update, and delete across all major entities
16
+ - **Safety Guardrails**: High-risk operations require explicit confirmation
17
+ - **Audit Logging**: All write operations are logged for compliance
18
+ - **Enterprise Ready**: Built for companies who need AI integration with proper controls
19
+
20
+ ## Features
21
+
22
+ ### 80+ Tools
23
+
24
+ | Category | Tools | Operations |
25
+ | --------------- | ----- | ----------------------------------------------------------------------- |
26
+ | **Employees** | 6 | List, get, search, create, update, terminate |
27
+ | **Teams** | 5 | List, get, create, update, delete |
28
+ | **Locations** | 5 | List, get, create, update, delete |
29
+ | **Time Off** | 10 | List leaves/types/allowances, create, update, cancel, approve, reject |
30
+ | **Attendance** | 5 | List shifts, create, update, delete |
31
+ | **Projects** | 17 | Full CRUD for projects, tasks, workers, time records |
32
+ | **Training** | 14 | Full CRUD for trainings, sessions, enrollments |
33
+ | **Work Areas** | 6 | List, get, create, update, archive, unarchive |
34
+ | **ATS** | 16 | Job postings, candidates, applications, hiring stages, advance workflow |
35
+ | **Payroll** | 6 | List/get supplements, tax identifiers, family situations (read-only) |
36
+ | **Documents** | 4 | List/get folders and documents (read-only) |
37
+ | **Job Catalog** | 3 | List/get job roles and levels (read-only) |
38
+ | **Contracts** | 1 | Get employee contract history (read-only) |
39
+
40
+ ### 5 MCP Resources
41
+
42
+ | Resource URI | Description |
43
+ | --------------------------------- | -------------------------------------------------- |
44
+ | `factorial://org-chart` | Complete organizational hierarchy (Markdown) |
45
+ | `factorial://employees/directory` | Employee directory by team (Markdown) |
46
+ | `factorial://locations/directory` | Location directory with employee counts (Markdown) |
47
+ | `factorial://timeoff/policies` | All leave types and policies (JSON) |
48
+ | `factorial://teams/{team_id}` | Team details with member list (JSON, templated) |
49
+
50
+ ### 3 MCP Prompts
51
+
52
+ | Prompt | Description |
53
+ | ----------------------- | ----------------------------------------------------------------- |
54
+ | `onboard-employee` | Generate personalized onboarding checklists |
55
+ | `analyze-org-structure` | Analyze org structure (reporting lines, team sizes, distribution) |
56
+ | `timeoff-report` | Generate time off reports by team or date range |
57
+
58
+ ### Architecture Features
59
+
60
+ - **Safety Guardrails**: High-risk operations (terminate, delete) marked for confirmation
61
+ - **Audit Logging**: All write operations logged with timestamps and context
62
+ - **Caching**: In-memory TTL-based caching (configurable by resource type)
63
+ - **Pagination**: All list operations support pagination
64
+ - **Retry Logic**: Exponential backoff with rate limit handling
65
+ - **Validation**: Runtime validation with Zod schemas
42
66
 
43
67
  ## Quick Start
44
68
 
@@ -83,36 +107,91 @@ Or pass it directly in the MCP config:
83
107
 
84
108
  Once configured, ask Claude things like:
85
109
 
86
- - *"Who's on the Engineering team?"*
87
- - *"Find the email for John Smith"*
88
- - *"What offices do we have?"*
89
- - *"Show me the org structure"*
110
+ - _"Who's on the Engineering team?"_
111
+ - _"Create a new employee John Smith with email john@company.com"_
112
+ - _"Approve the pending time off request for employee 42"_
113
+ - _"Create a new project called Q1 Marketing Campaign"_
114
+ - _"Enroll Sarah in the Leadership Training program"_
115
+ - _"Show me all open job postings"_
116
+ - _"What candidates applied for the Senior Developer position?"_
90
117
 
91
118
  ## Getting an API Key
92
119
 
120
+ You'll need a FactorialHR API key to use this MCP server. Here's how to get one:
121
+
93
122
  1. Log in to [FactorialHR](https://app.factorialhr.com) as an administrator
94
- 2. Navigate to **Settings → Integrations → API**
95
- 3. Generate a new API key
96
- 4. Add it to your `.env` file
123
+ 2. Go to [**Settings → API keys**](https://app.factorialhr.com/settings/api-keys)
124
+ 3. Click the **"New API key"** button
125
+ 4. Give your key a descriptive name (e.g., "Claude Code" or "MCP Server")
126
+ 5. Click **Create** - your API key will be displayed
127
+ 6. **Copy the key immediately** - it's only shown once and cannot be retrieved later
128
+ 7. Add the key to your `.env` file or MCP configuration
97
129
 
98
- > **Important**: API keys have full access to FactorialHR and never expire. Store them securely and rotate them periodically.
130
+ > **Important**: API keys have full access to your FactorialHR data and never expire. Store them securely, never commit them to version control, and rotate them periodically.
99
131
 
100
132
  ## Use Cases
101
133
 
102
134
  ### For Managers
103
- - Quickly look up team member contact information
104
- - Understand org chart and reporting structures
105
- - Find employees by skill or department
135
+
136
+ - Create and manage team structures
137
+ - Approve or reject time off requests
138
+ - Assign employees to projects
139
+ - Track project time records
140
+ - Monitor training enrollments
106
141
 
107
142
  ### For HR
108
- - Power AI-assisted employee directory searches
109
- - Streamline onboarding information lookups
110
- - Support with organizational queries
143
+
144
+ - Onboard new employees with full data entry
145
+ - Manage job postings and recruiting pipeline
146
+ - Track candidate applications through hiring stages
147
+ - Generate org structure analysis
148
+ - Manage training programs and enrollments
111
149
 
112
150
  ### For Developers
151
+
113
152
  - Build AI workflows that need employee context
114
153
  - Create custom Claude integrations
115
- - Automate org-chart-aware processes
154
+ - Automate HR processes with AI assistance
155
+ - Generate reports and analytics
156
+
157
+ ## Configuration Options
158
+
159
+ | Environment Variable | Description | Default |
160
+ | ----------------------- | ------------------------ | ------------ |
161
+ | `FACTORIAL_API_KEY` | Your FactorialHR API key | Required |
162
+ | `FACTORIAL_API_VERSION` | API version | `2025-10-01` |
163
+ | `FACTORIAL_TIMEOUT` | Request timeout (ms) | `30000` |
164
+ | `FACTORIAL_MAX_RETRIES` | Max retry attempts | `3` |
165
+ | `DEBUG` | Enable debug logging | `false` |
166
+
167
+ ## Safety & Security
168
+
169
+ ### High-Risk Operations
170
+
171
+ The following operations are marked as high-risk and should be used with care:
172
+
173
+ - `terminate_employee` - Terminates an employee (sets termination date)
174
+ - `delete_team` - Permanently deletes a team
175
+ - `delete_location` - Permanently deletes a location
176
+ - `delete_project` - Permanently deletes a project
177
+ - `delete_candidate` - Permanently deletes a candidate
178
+
179
+ ### Read-Only Categories
180
+
181
+ Some categories are intentionally read-only for security:
182
+
183
+ - **Payroll**: Supplements, tax identifiers, family situations
184
+ - **Documents**: Folder and document metadata only
185
+ - **Contracts**: Historical contract data
186
+
187
+ ### Audit Logging
188
+
189
+ All write operations (create, update, delete, approve, reject) are logged with:
190
+
191
+ - Timestamp
192
+ - Operation type
193
+ - Entity type and ID
194
+ - Changes made
116
195
 
117
196
  ## Development
118
197
 
@@ -127,6 +206,18 @@ npm install
127
206
  # Build
128
207
  npm run build
129
208
 
209
+ # Run tests
210
+ npm test
211
+
212
+ # Run tests with coverage
213
+ npm run test:coverage
214
+
215
+ # Lint
216
+ npm run lint
217
+
218
+ # Format
219
+ npm run format
220
+
130
221
  # Run locally
131
222
  FACTORIAL_API_KEY=your-key npm start
132
223
 
@@ -134,27 +225,53 @@ FACTORIAL_API_KEY=your-key npm start
134
225
  npx @modelcontextprotocol/inspector
135
226
  ```
136
227
 
137
- ## Configuration Options
228
+ ## Troubleshooting
229
+
230
+ ### API Key Not Working
231
+
232
+ - Ensure the API key has appropriate permissions
233
+ - Check if the key has been revoked or expired
234
+ - Verify the key is set correctly in environment variables
235
+
236
+ ### Rate Limiting
237
+
238
+ The server implements exponential backoff for rate limits. If you're hitting limits frequently:
239
+
240
+ - Reduce request frequency
241
+ - Use pagination with smaller page sizes
242
+ - Enable caching by avoiding cache-busting parameters
243
+
244
+ ### Missing Data
245
+
246
+ - **`hired_on` field**: The FactorialHR API may not populate this for all employees
247
+ - **Team membership**: Some employees may not be assigned to teams
248
+ - **Empty responses**: Check if the resource exists in your Factorial account
249
+
250
+ ## FAQ
251
+
252
+ **Q: Does this expose salary/payroll data?**
253
+ A: Payroll data (supplements, tax identifiers, family situations) is available read-only. No write operations for payroll are supported.
254
+
255
+ **Q: Can Claude modify data in Factorial?**
256
+ A: Yes! Full CRUD operations are available for employees, teams, locations, time off, projects, training, and recruiting. High-risk operations are clearly marked.
138
257
 
139
- | Environment Variable | Description | Required |
140
- |---------------------|-------------|----------|
141
- | `FACTORIAL_API_KEY` | Your FactorialHR API key | Yes |
142
- | `DEBUG` | Enable debug logging (`true`/`false`) | No |
258
+ **Q: How is data cached?**
259
+ A: Data is cached in-memory with TTLs: employees (5 min), teams (10 min), locations (15 min), contracts (3 min).
143
260
 
144
- ## Known Limitations
261
+ **Q: What FactorialHR API version is used?**
262
+ A: Version `2025-10-01` by default. Override with `FACTORIAL_API_VERSION` environment variable.
145
263
 
146
- - **`hired_on` field**: The FactorialHR API may not populate the `hired_on` field for all employees. If you need hire dates, you may need to use contract effective dates as a proxy.
147
- - **Contract filtering**: The `get_employee_contracts` tool fetches all contracts and filters client-side, which may be slow for organizations with many employees.
148
- - **Employee IDs**: Higher employee IDs generally indicate more recent additions, but this is not guaranteed.
264
+ **Q: Are write operations logged?**
265
+ A: Yes, all write operations are logged via the audit module for compliance and debugging.
149
266
 
150
267
  ## Contributing
151
268
 
152
- Contributions are welcome! Please feel free to submit a Pull Request.
269
+ Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
153
270
 
154
271
  ## License
155
272
 
156
- MIT © [t4dhg](https://github.com/t4dhg)
273
+ MIT © [Taig Mac Carthy](https://taigmaccarthy.com/)
157
274
 
158
275
  ---
159
276
 
160
- *Built with the [Model Context Protocol](https://modelcontextprotocol.io/) by Anthropic*
277
+ _Built with the [Model Context Protocol](https://modelcontextprotocol.io/) by Anthropic_