MCP FactorialHR

平台与服务

by t4dhg

面向 FactorialHR 的全功能 CRUD MCP 服务器,覆盖员工、团队、请假、项目、ATS 与薪资管理。

什么是 MCP FactorialHR

面向 FactorialHR 的全功能 CRUD MCP 服务器,覆盖员工、团队、请假、项目、ATS 与薪资管理。

README

<p align="center"> <img src="https://raw.githubusercontent.com/t4dhg/mcp-factorial/main/assets/factorial-logo.svg" alt="FactorialHR" height="48"> </p>

MCP FactorialHR

The definitive Model Context Protocol server for FactorialHR

License: MIT CI codecov bundle TypeScript Node.js npm version MCP Compatible

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.

Why This MCP Server?

  • Context-Optimized: 14 hierarchical tools (117 operations) with 88% less context usage than individual tools
  • Full CRUD Operations: Create, read, update, and delete across all major entities
  • Safety Guardrails: High-risk operations require explicit confirmation
  • Audit Logging: All write operations are logged for compliance
  • Enterprise Ready: Built for companies who need AI integration with proper controls

Features

Hierarchical Tool Discovery (v8.0.0+)

The MCP server uses a hierarchical tool structure for optimal context usage. Instead of 117 individual tools, you get 14 category-based tools with an action parameter.

ToolDescriptionActions
factorial_discoverDiscover available categories-
factorial_employeesEmployee managementlist, get, search, create, update, terminate
factorial_teamsTeam managementlist, get, create, update, delete
factorial_locationsLocation managementlist, get, create, update, delete
factorial_contractsContract/salary datalist, get_with_employee, by_job_role, by_job_level
factorial_time_offLeave management10 actions
factorial_attendanceShift managementlist, get, create, update, delete
factorial_documentsDocument management8 actions (downloads require OAuth2 - see below)
factorial_job_catalogJob roles/levelslist_roles, get_role, list_levels
factorial_projectsProject management16 actions for projects, tasks, workers, time
factorial_trainingTraining management12 actions for trainings, sessions, enrollments
factorial_work_areasWork area managementlist, get, create, update, archive, unarchive
factorial_atsApplicant tracking17 actions for recruiting
factorial_payrollPayroll data (read-only)6 actions

Example Usage:

typescript
// List all employees
factorial_employees({ action: 'list', page: 1, limit: 50 });

// Get a specific employee
factorial_employees({ action: 'get', id: 123 });

// Search employees
factorial_employees({ action: 'search', query: 'john' });

// Create a leave request
factorial_time_off({
  action: 'create',
  employee_id: 123,
  leave_type_id: 1,
  start_on: '2026-02-01',
  finish_on: '2026-02-05',
});

// Discover available actions for a category
factorial_discover({ category: 'employees' });

117 Operations Across 14 Categories

CategoryOperations
Employeeslist, get, search, create, update, terminate
Teamslist, get, create, update, delete
Locationslist, get, create, update, delete
Time Offlist_leaves, get_leave, list_types, get_type, list_allowances, create, update, cancel, approve, reject
Attendancelist, get, create, update, delete
Projects16 operations for projects, tasks, workers, time records
Training12 operations for trainings, sessions, enrollments
Work Areaslist, get, create, update, archive, unarchive
ATS17 operations for job postings, candidates, applications, hiring stages
Payrolllist/get supplements, tax identifiers, family situations (read-only)
Documents8 operations for folders, documents, and downloads (⚠️ downloads require OAuth2)
Job Cataloglist_roles, get_role, list_levels (read-only)
Contractslist, get_with_employee, by_job_role, by_job_level (read-only)

5 MCP Resources

Resource URIDescription
factorial://org-chartComplete organizational hierarchy (Markdown)
factorial://employees/directoryEmployee directory by team (Markdown)
factorial://locations/directoryLocation directory with employee counts (Markdown)
factorial://timeoff/policiesAll leave types and policies (JSON)
factorial://teams/{team_id}Team details with member list (JSON, templated)

4 MCP Prompts

PromptDescription
onboard-employeeGenerate personalized onboarding checklists
analyze-org-structureAnalyze org structure (reporting lines, team sizes, distribution)
timeoff-reportGenerate time off reports by team or date range
team-document-summarySummarize documents across a team (certifications, payslips, etc)

Architecture Features

  • Safety Guardrails: High-risk operations (terminate, delete) marked for confirmation
  • Audit Logging: All write operations logged with timestamps and context
  • Caching: In-memory TTL-based caching (configurable by resource type)
  • Pagination: All list operations support pagination
  • Retry Logic: Exponential backoff with rate limit handling
  • Validation: Runtime validation with Zod schemas

Quick Start

1. Add to your MCP configuration

json
{
  "mcpServers": {
    "factorial": {
      "command": "npx",
      "args": ["-y", "@t4dhg/mcp-factorial"]
    }
  }
}

2. Set your API key

Create a .env file in your project root:

env
FACTORIAL_API_KEY=your-api-key-here

Or pass it directly in the MCP config:

json
{
  "mcpServers": {
    "factorial": {
      "command": "npx",
      "args": ["-y", "@t4dhg/mcp-factorial"],
      "env": {
        "FACTORIAL_API_KEY": "your-api-key-here"
      }
    }
  }
}

3. Start using it!

Once configured, ask Claude things like:

  • "Who's on the Engineering team?"
  • "Create a new employee John Smith"
  • "Approve the pending time off request for employee 42"
  • "Create a new project called Q1 Marketing Campaign"
  • "Enroll Sarah in the Leadership Training program"
  • "Show me all open job postings"
  • "What candidates applied for the Senior Developer position?"

Getting an API Key

You'll need a FactorialHR API key to use this MCP server. Here's how to get one:

  1. Log in to FactorialHR as an administrator
  2. Go to Settings → API keys
  3. Click the "New API key" button
  4. Give your key a descriptive name (e.g., "Claude Code" or "MCP Server")
  5. Click Create - your API key will be displayed
  6. Copy the key immediately - it's only shown once and cannot be retrieved later
  7. Add the key to your .env file or MCP configuration

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.

OAuth2 Setup (Required for Document Downloads)

Document download actions (download_payslips, download) require OAuth2 authentication. This is a Factorial API limitation - the download endpoint does not accept API key authentication.

Note: You need admin access in Factorial to create OAuth applications.

Step 1: Create an OAuth2 Application

  1. Go to: https://api.factorialhr.com/oauth/applications
  2. Click "New application"
  3. Fill in:
    • Redirect URI: http://localhost:8080/callback (or any URL you can access)
    • Confidentiality: Yes (server application)
    • Scopes: Select the scopes you need:
      • Required for downloads: Documents, Employees
      • Recommended for full MCP functionality: Contracts, Payroll, Payroll supplements, Time off, Shift management, Trainings, Recruitment, Company locations, Job catalog
  4. Save and note your Client ID and Client Secret

Step 2: Get Authorization Code

Open this URL in your browser (replace YOUR_CLIENT_ID):

code
https://api.factorialhr.com/oauth/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=http://localhost:8080/callback&response_type=code
  • Log in and authorize the app
  • You'll be redirected to your callback URL with ?code=AUTHORIZATION_CODE
  • Copy that code from the URL (it expires quickly, so proceed to step 3 immediately)

Step 3: Exchange Code for Tokens

Run this curl command (replace placeholders):

bash
curl -X POST 'https://api.factorialhr.com/oauth/token' \
  -d 'client_id=YOUR_CLIENT_ID' \
  -d 'client_secret=YOUR_CLIENT_SECRET' \
  -d 'code=AUTHORIZATION_CODE' \
  -d 'grant_type=authorization_code' \
  -d 'redirect_uri=http://localhost:8080/callback'

You'll get a response with access_token and refresh_token. Save the refresh_token.

Step 4: Configure MCP Server

Add OAuth2 credentials to your MCP configuration:

json
{
  "mcpServers": {
    "factorial": {
      "command": "npx",
      "args": ["-y", "@t4dhg/mcp-factorial"],
      "env": {
        "FACTORIAL_API_KEY": "your-api-key",
        "FACTORIAL_OAUTH_CLIENT_ID": "your-client-id",
        "FACTORIAL_OAUTH_CLIENT_SECRET": "your-client-secret",
        "FACTORIAL_OAUTH_REFRESH_TOKEN": "your-refresh-token"
      }
    }
  }
}

Or add to your .env file:

env
FACTORIAL_API_KEY=your-api-key
FACTORIAL_OAUTH_CLIENT_ID=your-client-id
FACTORIAL_OAUTH_CLIENT_SECRET=your-client-secret
FACTORIAL_OAUTH_REFRESH_TOKEN=your-refresh-token

Important Notes

  • Refresh tokens expire after 1 week - you'll need to repeat steps 2-3 if it expires
  • The MCP server automatically refreshes access tokens using the refresh token
  • If document downloads suddenly stop working, your refresh token has likely expired

Use Cases

For Managers

  • Create and manage team structures
  • Approve or reject time off requests
  • Assign employees to projects
  • Track project time records
  • Monitor training enrollments

For HR

  • Onboard new employees with full data entry
  • Manage job postings and recruiting pipeline
  • Track candidate applications through hiring stages
  • Generate org structure analysis
  • Manage training programs and enrollments

For Developers

  • Build AI workflows that need employee context
  • Create custom Claude integrations
  • Automate HR processes with AI assistance
  • Generate reports and analytics

Configuration Options

Environment VariableDescriptionDefault
FACTORIAL_API_KEYYour FactorialHR API keyRequired
FACTORIAL_API_VERSIONAPI version2025-10-01
FACTORIAL_TIMEOUT_MSRequest timeout (ms)30000
FACTORIAL_MAX_RETRIESMax retry attempts3
DEBUGEnable debug loggingfalse
FACTORIAL_OAUTH_CLIENT_IDOAuth2 client ID (for downloads)-
FACTORIAL_OAUTH_CLIENT_SECRETOAuth2 client secret (for downloads)-
FACTORIAL_OAUTH_REFRESH_TOKENOAuth2 refresh token (for downloads)-

Safety & Security

High-Risk Operations

The following operations are marked as high-risk and require explicit confirmation (confirm: true):

  • factorial_employees({ action: 'terminate' }) - Terminates an employee
  • factorial_teams({ action: 'delete' }) - Permanently deletes a team
  • factorial_locations({ action: 'delete' }) - Permanently deletes a location
  • factorial_projects({ action: 'delete' }) - Permanently deletes a project
  • factorial_ats({ action: 'delete_candidate' }) - Permanently deletes a candidate

Read-Only Categories

Some categories are intentionally read-only for security:

  • Payroll: Supplements, tax identifiers, family situations
  • Documents: Folder and document metadata (download tools available for payslips and documents)
  • Contracts: Historical contract data

Response Optimization

Document and contract list operations return summary format by default to prevent token overflow:

Documents (factorial_documents({ action: 'list' })):

  • Returns: id, name, folder_id, employee_id, mime_type (5 fields)
  • Default limit: 100 documents per page
  • For full details: Use factorial_documents({ action: 'get', id: X }) for complete metadata

Contracts (factorial_contracts({ action: 'list' })):

  • Returns: id, employee_id, job_title, effective_on (4 fields)
  • Default limit: 100 contracts per page

All list operations accept page and limit parameters for pagination control.

Audit Logging

All write operations (create, update, delete, approve, reject) are logged with:

  • Timestamp
  • Operation type
  • Entity type and ID
  • Changes made

Development

bash
# Clone the repository
git clone https://github.com/t4dhg/mcp-factorial.git
cd mcp-factorial

# Install dependencies
npm install

# Build
npm run build

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

# Lint
npm run lint

# Format
npm run format

# Run locally
FACTORIAL_API_KEY=your-key npm start

# Test with MCP Inspector
npx @modelcontextprotocol/inspector

Project Structure

The codebase is organized into domain-based modules for maintainability:

code
src/
├── schemas/           # Zod schemas by domain
│   ├── employees.ts   # Employee, Team, Location, Contract schemas
│   ├── time-off.ts    # Leave, LeaveType, Allowance, Shift schemas
│   ├── projects.ts    # Project, Task, Worker, TimeRecord schemas
│   ├── training.ts    # Training, Session, Membership schemas
│   ├── ats.ts         # JobPosting, Candidate, Application schemas
│   └── ...
├── api/               # API functions by domain
│   ├── employees.ts   # listEmployees, getEmployee, createEmployee, etc.
│   ├── time-off.ts    # listLeaves, createLeave, approveLeave, etc.
│   ├── projects.ts    # listProjects, createProject, etc.
│   └── ...
├── tools/             # MCP tool registrations by domain
│   ├── employees.ts   # factorial_employees tool registration
│   ├── time-off.ts    # factorial_time_off tool registration
│   ├── index.ts       # Server setup, discovery tool, resources, prompts
│   └── ...
├── index.ts           # Entry point (re-exports from tools/)
├── api.ts             # Re-exports from api/
└── schemas.ts         # Re-exports from schemas/

Adding a new feature:

  1. Add schemas to src/schemas/{domain}.ts
  2. Add API functions to src/api/{domain}.ts
  3. Add tool actions to src/tools/{domain}.ts
  4. Update src/schemas/index.ts, src/api/index.ts exports if needed
  5. Run npm test to verify

Troubleshooting

API Key Not Working

  • Ensure the API key has appropriate permissions
  • Check if the key has been revoked or expired
  • Verify the key is set correctly in environment variables

Rate Limiting

The server implements exponential backoff for rate limits. If you're hitting limits frequently:

  • Reduce request frequency
  • Use pagination with smaller page sizes
  • Enable caching by avoiding cache-busting parameters

Missing Data

  • hired_on field: The FactorialHR API may not populate this for all employees
  • Team membership: Some employees may not be assigned to teams
  • Empty responses: Check if the resource exists in your Factorial account

Document Downloads Not Working

Document downloads require OAuth2 authentication. This is a Factorial API limitation - the download endpoint does not accept API key authentication.

If you see an error like:

"Document download requires OAuth2 authentication"

You need to set up OAuth2 credentials. See OAuth2 Setup above.

Note: OAuth2 refresh tokens expire after 1 week. If downloads suddenly stop working, re-authorize and get a new refresh token.

"Document with ID X not found" Error

The Factorial API's individual document endpoint (GET /documents/{id}) has limitations accessing employee-specific documents. This happens because:

  1. list_documents with employee_ids filter correctly returns all employee documents
  2. get_document by ID cannot access those same documents individually

Workaround: Use download_payslips action instead of download action. The download_payslips action uses the document metadata from the list operation directly, bypassing the problematic individual GET endpoint:

typescript
// This works - uses document list internally
factorial_documents({
  action: 'download_payslips',
  employee_id: 123,
  output_dir: '/path/to/downloads',
});

FAQ

Q: Does this expose salary/payroll data? A: Payroll data (supplements, tax identifiers, family situations) is available read-only. No write operations for payroll are supported.

Q: Can Claude modify data in Factorial? A: Yes! Full CRUD operations are available for employees, teams, locations, time off, projects, training, and recruiting. High-risk operations are clearly marked.

Q: How is data cached? A: Data is cached in-memory with TTLs: employees (5 min), teams (10 min), locations (15 min), contracts (3 min).

Q: What FactorialHR API version is used? A: Version 2025-10-01 by default. Override with FACTORIAL_API_VERSION environment variable.

Q: Are write operations logged? A: Yes, all write operations are logged via the audit module for compliance and debugging.

Factorial API Quirks and Limitations

The FactorialHR API has some design patterns that differ from typical REST APIs. This MCP server handles these automatically, but understanding them helps when debugging or extending:

Data Location Quirks

DataExpected LocationActual LocationImpact
Team membershipOn Employee object (team_ids)On Team object (employee_ids)Use list_teams to find an employee's teams
Job role assignmentOn Employee object (job_role_id)In Contract object (job_catalog_role_id)Use get_employee_with_contract for role info
Salary informationOn Employee objectIn Contract object (salary_amount, salary_frequency)Use get_employee_with_contract for salary
Job titleOn Employee objectIn Contract object (job_title)May be null if not set in Factorial

Endpoint Quirks

EndpointQuirkWorkaround
GET /employees/{id}May return 404 for valid employeesServer falls back to listing all and filtering
GET /documents/{id}May return 404 for employee-specific documentsUse download_payslips which bypasses this
GET /contracts?employee_id=XFiltering unreliableServer fetches all and filters client-side
Empty resultsReturns {"errors": null} instead of `{"data": []}Server handles both formats
Document download URLsRequires OAuth2 (API key does not work)Configure OAuth2 credentials for downloads

Field Availability

Some fields may be null even when you expect data:

  • job_title: Only populated if set in employee's contract
  • manager_id: Only populated if reporting structure is configured
  • seniority_calculation_date: Use this instead of the non-existent hired_on field
  • Document metadata (name, mime_type, size_bytes): May be null for some documents

Salary Data

Salary information is available in the Contract entity, not the Employee entity:

code
salary_amount: number (in cents, e.g., 7000000 = €70,000)
salary_frequency: 'yearly' | 'monthly' | 'weekly' | 'daily' | 'hourly'

Use get_employee_with_contract to retrieve employee data with their latest salary information.

Best Practices

  1. To get an employee's job role: Use get_employee_with_contract instead of get_employee
  2. To find employees by role: Use list_employees_by_job_role with a job role ID
  3. To find an employee's teams: Query list_teams and check employee_ids arrays
  4. For salary data: Always use contract endpoints, not employee endpoints

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

License

MIT © Taig Mac Carthy


Built with the Model Context Protocol by Anthropic

常见问题

MCP FactorialHR 是什么?

面向 FactorialHR 的全功能 CRUD MCP 服务器,覆盖员工、团队、请假、项目、ATS 与薪资管理。

相关 Skills

MCP构建

by anthropics

Universal
热门

聚焦高质量 MCP Server 开发,覆盖协议研究、工具设计、错误处理与传输选型,适合用 FastMCP 或 MCP SDK 对接外部 API、封装服务能力。

想让 LLM 稳定调用外部 API,就用 MCP构建:从 Python 到 Node 都有成熟指引,帮你更快做出高质量 MCP 服务器。

平台与服务
未扫描114.1k

Slack动图

by anthropics

Universal
热门

面向Slack的动图制作Skill,内置emoji/消息GIF的尺寸、帧率和色彩约束、校验与优化流程,适合把创意或上传图片快速做成可直接发送的Slack动画。

帮你快速做出适配 Slack 的动图,内置约束规则和校验工具,少踩上传与播放坑,做表情包和演示都更省心。

平台与服务
未扫描114.1k

MCP服务构建器

by alirezarezvani

Universal
热门

从 OpenAPI 一键生成 Python/TypeScript MCP server 脚手架,并校验 tool schema、命名规范与版本兼容性,适合把现有 REST API 快速发布成可生产演进的 MCP 服务。

帮你快速搭建 MCP 服务与后端 API,脚手架完善、扩展顺手,尤其适合想高效验证服务能力的开发者。

平台与服务
未扫描10.2k

相关 MCP Server

Slack 消息

编辑精选

by Anthropic

热门

Slack 是让 AI 助手直接读写你的 Slack 频道和消息的 MCP 服务器。

这个服务器解决了团队协作中需要 AI 实时获取 Slack 信息的痛点,特别适合开发团队让 Claude 帮忙汇总频道讨论或发送通知。不过,它目前只是参考实现,文档有限,不建议在生产环境直接使用——更适合开发者学习 MCP 如何集成第三方服务。

平台与服务
83.4k

by netdata

热门

io.github.netdata/mcp-server 是让 AI 助手实时监控服务器指标和日志的 MCP 服务器。

这个工具解决了运维人员需要手动检查系统状态的痛点,最适合 DevOps 团队让 Claude 自动分析性能数据。不过,它依赖 NetData 的现有部署,如果你没用过这个监控平台,得先花时间配置。

平台与服务
78.4k

by d4vinci

热门

Scrapling MCP Server 是专为现代网页设计的智能爬虫工具,支持绕过 Cloudflare 等反爬机制。

这个工具解决了爬取动态网页和反爬网站时的头疼问题,特别适合需要批量采集电商价格或新闻数据的开发者。不过,它依赖外部浏览器引擎,资源消耗较大,不适合轻量级任务。

平台与服务
35.4k

评论