w2w-mcp
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@w2w-mcpwhat are the shifts for next week?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
When2Work MCP Server
A Model Context Protocol (MCP) server that provides seamless integration with the When2Work scheduling API. This server exposes When2Work data as MCP tools, allowing AI assistants like Claude to query employee schedules, shifts, time off, and reports.
๐ Support Our Mission
This tool was built for Dumont Volunteer Ambulance Corps, a member-owned non-profit volunteer ambulance service. If you find this tool useful, please consider supporting our life-saving work:
Your donation helps us continue providing emergency medical services to those in need!
Related MCP server: MCP OpenClaw
โจ Features
Feature | Description |
๐ฅ Employee Management | List all employees with contact information |
๐ฏ Position Management | List all positions/job roles |
๐ท๏ธ Category Management | List all shift categories |
๐ Shift Queries | Get assigned shifts with date range support and automatic pagination |
๐๏ธ Time Off Tracking | Get approved time off requests |
๐ Daily Reports | Get daily schedule totals and position breakdowns |
๐ Automatic Pagination | Handles When2Work's 31-day limit by chunking requests automatically |
๐ Type Safety | Full TypeScript support with proper type definitions |
โ Testing Status
All 7 tools have been tested and verified working:
Tool | Status | Description |
| โ Tested | Retrieve all employees with contact info |
| โ Tested | Retrieve all positions/job roles |
| โ Tested | Retrieve all shift categories |
| โ Tested | Get assigned shifts with date range support |
| โ Tested | Get approved time off requests |
| โ Tested | Get daily schedule totals |
| โ Tested | Get daily totals by position |
๐ Prerequisites
Node.js 18 or higher
When2Work Pro Plan with API access
When2Work API key
๐ Installation
1. Clone or create the project
cd /home/dvac_workspace/DVAC/dvac-w2w-mcp2. Install dependencies
npm install3. Build the project
npm run build4. Set up environment variables
export W2W_API_KEY=your_api_key_hereTo make this permanent, add it to your shell profile (~/.bashrc, ~/.zshrc, etc.):
echo 'export W2W_API_KEY=your_api_key_here' >> ~/.bashrc
source ~/.bashrc๐ป Usage
โถ๏ธ Running the server
npm startOr directly:
node dist/index.jsFor development with auto-rebuild:
npm run dev๐ค Using with Claude Desktop
Add this server to your Claude Desktop configuration:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"when2work": {
"command": "node",
"args": ["/home/dvac_workspace/DVAC/dvac-w2w-mcp/dist/index.js"],
"env": {
"W2W_API_KEY": "your_api_key_here"
}
}
}
}๐ ๏ธ Available Tools
w2w_get_employees
Get all employees from When2Work.
Parameters: None
Example:
{
"name": "w2w_get_employees",
"arguments": {}
}w2w_get_positions
Get all positions from When2Work.
Parameters: None
Example:
{
"name": "w2w_get_positions",
"arguments": {}
}w2w_get_categories
Get all shift categories from When2Work.
Parameters: None
Example:
{
"name": "w2w_get_categories",
"arguments": {}
}w2w_get_shifts
Get assigned shifts for a date range. Automatically handles pagination for ranges over 31 days.
Parameters:
start_date(string, required): Start date in mm/dd/yyyy format (e.g., "01/15/2024")end_date(string, required): End date in mm/dd/yyyy format (e.g., "01/31/2024")position_id(string, optional): Filter by position ID
Example:
{
"name": "w2w_get_shifts",
"arguments": {
"start_date": "01/01/2024",
"end_date": "01/31/2024",
"position_id": "12345"
}
}w2w_get_timeoff
Get approved time off for a date range. Automatically handles pagination for ranges over 31 days.
Parameters:
start_date(string, required): Start date in mm/dd/yyyy formatend_date(string, required): End date in mm/dd/yyyy format
Example:
{
"name": "w2w_get_timeoff",
"arguments": {
"start_date": "01/01/2024",
"end_date": "01/31/2024"
}
}w2w_get_daily_totals
Get daily schedule totals (shifts and hours) for a date range. Automatically handles pagination for ranges over 31 days.
Parameters:
start_date(string, required): Start date in mm/dd/yyyy formatend_date(string, required): End date in mm/dd/yyyy format
Example:
{
"name": "w2w_get_daily_totals",
"arguments": {
"start_date": "01/01/2024",
"end_date": "01/31/2024"
}
}w2w_get_daily_position_totals
Get daily schedule totals broken down by position for a date range. Automatically handles pagination for ranges over 31 days.
Parameters:
start_date(string, required): Start date in mm/dd/yyyy formatend_date(string, required): End date in mm/dd/yyyy format
Example:
{
"name": "w2w_get_daily_position_totals",
"arguments": {
"start_date": "01/01/2024",
"end_date": "01/31/2024"
}
}๐ API Details
When2Work API Endpoint
Base URL: https://www8.whentowork.com/cgi-bin/w2wJ.dll
Note: This is the correct production endpoint for the When2Work API, not https://api.when2work.com.
Authentication
The When2Work API uses query parameter authentication:
API key is passed as a
keyquery parameterNo Authorization header is used
Example request URL:
https://www8.whentowork.com/cgi-bin/w2wJ.dll/api/employees?key=YOUR_API_KEY&detail=YWhen2Work API Constraints
Date Format: All dates must be in mm/dd/yyyy format (not ISO 8601)
Date Range Limit: Maximum 31 days per query (this server handles pagination automatically)
Plan Requirement: Pro Plan required for API access
Response Format
The When2Work API returns data in specific keys depending on the endpoint:
Endpoint | Response Key |
Employees |
|
Positions |
|
Categories |
|
Shifts |
|
Time Off |
|
Daily Totals |
|
Daily Position Totals |
|
The MCP server normalizes these responses into consistent arrays for easier consumption.
Automatic Pagination
The server automatically handles When2Work's 31-day limit by:
Splitting date ranges > 31 days into chunks
Making multiple API requests in parallel
Merging results into a single response
This allows you to query any date range without worrying about the limit.
๐จโ๐ป Development
Project Structure
dvac-w2w-mcp/
โโโ package.json
โโโ tsconfig.json
โโโ README.md
โโโ src/
โ โโโ index.ts # MCP server entry point
โ โโโ w2w-client.ts # When2Work API client
โ โโโ tools/ # MCP tool implementations
โ โ โโโ employees.ts
โ โ โโโ positions.ts
โ โ โโโ categories.ts
โ โ โโโ shifts.ts
โ โ โโโ timeoff.ts
โ โ โโโ reports.ts
โ โโโ types/
โ โโโ w2w.ts # TypeScript interfacesAdding New Tools
Create a new file in
src/tools/Define the tool schema and handler function
Export both from the file
Import and register in
src/index.ts
Type Checking
npm run typecheckLinting
npm run lint๐ Troubleshooting
Error: "W2W_API_KEY environment variable is required"
Make sure you've set the W2W_API_KEY environment variable:
export W2W_API_KEY=your_api_key_hereError: "When2Work API error (401)"
Your API key may be invalid or expired. Verify your API key in your When2Work account settings:
Log in to your When2Work account
Go to Settings > Company Settings > Integrations
Check or regenerate your API key
Error: "Invalid date format"
Make sure dates are in mm/dd/yyyy format (e.g., "01/15/2024"), not ISO 8601 format.
Error: "When2Work API error (429)"
You're being rate limited. The server automatically handles most rate limiting through pagination, but very large queries may still hit limits. Try reducing your date range.
Empty Results
If tools return empty arrays, check:
The date range contains data in your When2Work account
Your API key has access to the requested data
The position/category filters (if used) match existing records
Connection Issues
If you see connection errors:
Verify your internet connection
Check that
https://www8.whentowork.comis accessibleEnsure no firewall is blocking the connection
๐งช Testing
To verify the server is working correctly:
Start the server:
npm startTest with Claude Desktop or any MCP client:
Try
w2w_get_employeesfirst (no parameters needed)Then test date-based tools with a small date range
Verify pagination by querying a 60+ day range
All tools have been verified to work with real When2Work API calls.
๐ License
This project is licensed under the MIT License - see below for details:
MIT License
Copyright (c) 2024 Dumont Volunteer Ambulance Corps
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.๐ Support
For issues related to this MCP server, please check:
โ Your When2Work Pro Plan subscription status
โ Your API key validity
โ The date format (must be mm/dd/yyyy)
โ The API endpoint URL is correct:
https://www8.whentowork.com/cgi-bin/w2wJ.dllFinally, if you're still having an issue please submit an issue here on github.
๐ Getting Your API Key
Log in to your When2Work account as a Tech Administrator
Navigate to Pro > API Config
Copy your API key (or generate a new one if needed)
๐ When2Work Resources
API Documentation (requires Pro Plan)
๐ Acknowledgments
Built with โค๏ธ by Dumont Volunteer Ambulance Corps
If this tool has been helpful to your organization, please consider making a donation to support our volunteer emergency services.
This server cannot be installed
Maintenance
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/TheRealAlexV/w2w-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server