シフト屋さん Public API & MCP サーバー
シフト屋さんのシフト自動作成エンジン (制約最適化エンジンによる数理最適化)を、公開 HTTP API と MCP サーバーとして提供します。 Claude や ChatGPT などの AI エージェントに話しかけるだけでシフト表を作成・最適化できます。
クイックスタート(MCP — Claude から使う)
接続先は https://api.shiftyasan.com/mcp です。
サーバー側の更新は自動で反映されるので、パッケージを入れ直す手間はかかりません。
Claude Code
HTTP で直接つながるので、お使いの PC に Node.js は要りません。
export SHIFTYASAN_API_KEY=sk_live_...
claude mcp add --transport http shiftyasan https://api.shiftyasan.com/mcp \
--header "Authorization: Bearer $SHIFTYASAN_API_KEY"
キーは環境変数から読ませています。コマンドに直接書くとシェル履歴や
ps の出力に残るためです。export も履歴に残るので、
シェル設定ファイルや普段お使いのシークレット管理に置くことをおすすめします。
Claude Desktop
Claude Desktop は現在リモート MCP への直接接続に対応していないため、
mcp-remote という中継を挟みます。この方式だけは
お使いの PC に Node.js 20 以上が必要です(claude_desktop_config.json):
{
"mcpServers": {
"shiftyasan": {
"command": "npx",
"args": [
"-y", "mcp-remote",
"https://api.shiftyasan.com/mcp",
"--header", "Authorization: Bearer sk_live_..."
]
}
}
}
Claude.ai(Web 版)
Customize → Connectors → 「+」→ Add custom connectorで、URL に
https://api.shiftyasan.com/mcp を入れるだけです。
API キーの準備は要りません。
- ブラウザでシフト屋さんのログイン画面が開きます(メールアドレス/パスワード、または Google)
- どのアカウントで接続するか・接続先のホストが表示されるので、確認して「許可する」
- 接続完了。API キーは自動で用意されます(既にお持ちの場合はそれを使います)
npm パッケージを使う方法(従来どおり利用できます)
上のリモート接続を推奨します。 npm 版はローカルで動かす方式のため Node.js 20 以上が必要で、更新も各自で行う必要があります。 すでにお使いの設定はそのまま動きます。
claude mcp add shiftyasan -e SHIFTYASAN_API_KEY=sk_live_... -- npx -y @shiftyasan/mcp-server
設定後、「9月の第1週、早番・遅番・夜勤で4人のシフトを組んで。夜勤明けは休みにして、
夜勤は公平に分担して」のように話しかけると、エージェントが
validate_shift_input(無料)→ solve_shift を呼んでシフト表を返します。
クイックスタート(ChatGPT)
Plugins から https://api.shiftyasan.com/mcp を追加します(Authentication は OAuth)。
Claude.ai と同じく、ブラウザでシフト屋さんにログインして許可するだけで、
API キーの準備は要りません。
Custom GPT の Actions を使う方法(従来どおり利用できます)
上のプラグイン接続を推奨します。 Actions は API キーを GPT の中に保存する方式で、キーの管理と共有範囲に注意が必要です。
- My GPTs → Create a GPT → Configure → Actions → Import from URL で
https://api.shiftyasan.com/v1/public/openapi.jsonを取り込む - Authentication → API Key → Bearer で
sk_live_...を設定 - 取り込むと
validate_shift_input/solve_shift/get_solve_job/get_usageの4つが使えるようになります。 Instructions に「solve_shiftの前に必ずvalidate_shift_inputを呼ぶ」 「202 と job_id が返ったらget_solve_jobを約15秒間隔でポーリングする」 と書いておくと自律的に動きます
クイックスタート(HTTP API 直接)
スキーマ検証は無料・認証不要です:
curl -X POST "https://api.shiftyasan.com/v1/public/solve/validate" \
-H 'Content-Type: application/json' \
--data @request.json
solve は API キーが必要です(1回あたり数 units を消費・残量は GET /v1/public/usage):
curl -X POST "https://api.shiftyasan.com/v1/public/solve" \
-H "Authorization: Bearer $SHIFTYASAN_API_KEY" \
-H 'Content-Type: application/json' \
--data @request.json
大規模な問題(概ね25人超の規模)は同期では返らず、202 と job_id が返ります。
GET https://api.shiftyasan.com/v1/public/solve/jobs/{job_id} を約15秒間隔でポーリングしてください
(通常2〜7分で完了します)。
リクエスト/レスポンスの完全なスキーマは
GET https://api.shiftyasan.com/v1/public/openapi.json(OpenAPI 3.1)で取得できます。
エラーは RFC 7807 (problem+json) 形式で、フィールド単位の指摘を返すため
AI エージェントが自己修正しやすい設計です。
対応している制約(公開 API・現在)
| 制約 | 指定方法 | 種別 |
|---|---|---|
| シフト別・日別の必要人数(下限/上限) | shifts[].staffing_demand | 下限 hard / 上限 soft |
| 業務別の必要人数(シフト×日) | duties[].staffing_demand_by_shift | 下限 hard / 上限 soft |
| 従業員ごとの勤務可能シフト | employees[].assignable_shift_ids | hard |
| スキルレベル(0 = その業務に就けない) | employees[].skill_levels | hard |
| 休み希望・シフト希望 | employees[].preferences | soft(尊重を強く加点) |
| 固定割当(この日はこのシフト、と確定) | employees[].fixed_assignments | hard |
| 月間勤務日数の下限/上限 | employees[].working_days_per_month | soft+hard |
| 週間勤務日数 | employees[].working_days_per_week | soft |
| 連続勤務日数の上限 ※未指定でも既定でハード6日・ソフト5日が適用されます(無制限ではありません) | constraints.max_consecutive_working_days | soft+hard |
| シフト遷移の禁止/強制(例: 夜勤→明けは必ず休み) | constraints.shift_transitions | hard / soft 選択可 |
| 従業員ペアの同時配置禁止 | constraints.employee_pairings(exclude) | hard |
| 負担シフトの公平な分担(独立グループ最大4件・回数の均し・重み調整可) | constraints.fairness_groups | soft(penalty_weight 調整可) |
| 責任者の配置人数(シフト×日ごと) | shifts[].manager_demand | 下限 hard / 上限 soft |
| 週間勤務時間の上限(シフト時刻から自動計算) | employees[].weekly_working_hours_limit | soft / hard 選択可 |
| スキルサポート(初心者に熟練者を同席) | constraints.skill_support | soft / hard 選択可 |
| シフト横断の合計人数(時間帯需要。夜間帯をまたぐ人数保証等) | constraints.cross_shift_demands | 下限 hard / 上限 soft |
| 曜日単位の出勤可否(火・木だけ出勤等。日跨ぎは開始日の曜日で判定) | employees[].available_weekdays | hard |
| シフト種別ごとの回数上限・下限(夜勤は月4回まで等) | employees[].shift_count_limits | hard |
| 休業日 | schedule_period.holidays | hard |
解が存在しない場合は原因を自動診断します。制約を1つずつ外した
検証を短時間で再実行し、「どの制約を緩めると組めるようになるか」を
diagnosis.causes[](原因の種類・該当フィールド・緩和の提案)として
返すので、エージェントがそのまま利用者に改善案を提示できます。
人手不足はエラーにせず、不足マーカーつきの解として返します
(現実の「人が足りない週」でも表は出ます)。
最近追加した制約
- 複数の公平性グループの独立指定(
constraints.fairness_groups最大4件。夜勤の公平性と土日の公平性を別々に均等化等)/ シフト種別ごとの回数上限・下限 / 曜日単位の出勤可否
料金
ベータ期間中は無料です。キーごとに無料利用枠(units)が付与され、
solve 呼び出しごとに消費します。枠が尽きたらメールで追加をリクエストできます。
正式リリース後の料金は準備中で、ベータ利用者には事前にお知らせします。
リンク
- API キー管理ダッシュボード(ログイン / 新規登録 / キー発行・無効化 / 残り利用枠)
- MCP サーバー: GitHub / npm @shiftyasan/mcp-server
- API スキーマ:
GET https://api.shiftyasan.com/v1/public/openapi.json - 本体サービス(Web 版シフト屋さん): shiftyasan.com
- お問い合わせ / キー発行: [email protected]
Shiftyasan Public API & MCP Server
The shift-scheduling engine behind Shiftyasan (mathematical optimization by a constraint-optimization engine), exposed as a public HTTP API and an MCP server. AI agents such as Claude and ChatGPT can build and optimize shift schedules conversationally.
Get an API key (free beta — log in / sign up)
Quickstart (MCP — use from Claude)
The endpoint is https://api.shiftyasan.com/mcp. Server-side updates reach you
automatically, so there is no package to keep up to date.
Claude Code
Connects over HTTP directly, so you do not need Node.js on your machine.
export SHIFTYASAN_API_KEY=sk_live_...
claude mcp add --transport http shiftyasan https://api.shiftyasan.com/mcp \
--header "Authorization: Bearer $SHIFTYASAN_API_KEY"
The key is read from the environment, because putting it straight on the command line
leaves it in your shell history and in ps output. The export lands
in history too, so keep it in your shell profile or your usual secret manager.
Claude Desktop
Claude Desktop cannot connect to a remote MCP server directly yet, so bridge it with
mcp-remote. This route is the one that does need Node.js 20+
on your machine (claude_desktop_config.json):
{
"mcpServers": {
"shiftyasan": {
"command": "npx",
"args": [
"-y", "mcp-remote",
"https://api.shiftyasan.com/mcp",
"--header", "Authorization: Bearer sk_live_..."
]
}
}
}
Claude.ai (web)
Customize → Connectors → "+" → Add custom connector, and enter
https://api.shiftyasan.com/mcp. No API key needed.
- A Shiftyasan sign-in page opens in your browser (email/password, or Google)
- You are shown which account is connecting and where the connection goes — confirm and approve
- Done. An API key is provisioned for you automatically (an existing one is reused)
Using the npm package (still supported)
The remote connection above is recommended. The npm package runs locally, so it requires Node.js 20+ and you update it yourself. Existing setups keep working.
claude mcp add shiftyasan -e SHIFTYASAN_API_KEY=sk_live_... -- npx -y @shiftyasan/mcp-server
Then just ask something like: "Schedule 4 people across early, late and night shifts for the
first week of September. Give a day off after each night shift, and share night shifts fairly."
The agent calls validate_shift_input (free) and then solve_shift
and returns the schedule.
Quickstart (ChatGPT)
Add https://api.shiftyasan.com/mcp from Plugins, with Authentication set to OAuth.
As with Claude.ai, you just
sign in to Shiftyasan in the browser and approve — no API key needed.
Using a Custom GPT with Actions (still supported)
The plugin connection above is recommended. Actions store the API key inside the GPT, so you have to be careful about key management and who you share that GPT with.
- My GPTs → Create a GPT → Configure → Actions → Import from URL
with
https://api.shiftyasan.com/v1/public/openapi.json - Authentication → API Key → Bearer → paste your
sk_live_...token - You get four actions:
validate_shift_input,solve_shift,get_solve_jobandget_usage. Add to Instructions: "Always call validate_shift_input before solve_shift. If solve_shift returns 202 with a job_id, poll get_solve_job every ~15 seconds until it completes."
Quickstart (HTTP API)
Schema validation is free and requires no auth:
curl -X POST "https://api.shiftyasan.com/v1/public/solve/validate" \
-H 'Content-Type: application/json' \
--data @request.json
Solving requires an API key (consumes a few units per call; check the balance with GET /v1/public/usage):
curl -X POST "https://api.shiftyasan.com/v1/public/solve" \
-H "Authorization: Bearer $SHIFTYASAN_API_KEY" \
-H 'Content-Type: application/json' \
--data @request.json
Large problems (roughly 25+ employees) do not return synchronously: you get
202 with a job_id. Poll
GET https://api.shiftyasan.com/v1/public/solve/jobs/{job_id} every ~15 seconds
(typically done in 2–7 minutes).
The full request/response schema is served at
GET https://api.shiftyasan.com/v1/public/openapi.json (OpenAPI 3.1).
Errors follow RFC 7807 (problem+json) with field-level details, so AI agents can self-correct.
Supported constraints (public API, today)
| Constraint | Where | Kind |
|---|---|---|
| Staffing demand per shift per day (min/max) | shifts[].staffing_demand | min hard / max soft |
| Staffing demand per duty (shift × day) | duties[].staffing_demand_by_shift | min hard / max soft |
| Assignable shifts per employee | employees[].assignable_shift_ids | hard |
| Skill levels (0 = cannot do the duty) | employees[].skill_levels | hard |
| Day-off / shift preferences | employees[].preferences | soft (strongly rewarded) |
| Fixed assignments | employees[].fixed_assignments | hard |
| Working days per month (min/max) | employees[].working_days_per_month | soft+hard |
| Working days per week | employees[].working_days_per_week | soft |
| Max consecutive working days Note: omitting this is not "unlimited" — the default is a hard cap of 6 (soft 5) | constraints.max_consecutive_working_days | soft+hard |
| Forbid/require shift transitions (e.g. rest after night shift) | constraints.shift_transitions | hard or soft |
| Keep employee pairs apart | constraints.employee_pairings (exclude) | hard |
| Fair distribution of burdensome shifts (up to 4 independent groups, count-balanced, weight tunable) | constraints.fairness_groups | soft (penalty_weight) |
| Manager headcount per shift per day | shifts[].manager_demand | min hard / max soft |
| Weekly working-hours cap (derived from shift times) | employees[].weekly_working_hours_limit | soft or hard |
| Skill support (pair beginners with seniors) | constraints.skill_support | soft or hard |
| Cross-shift headcount (time-band style demand, e.g. overnight coverage) | constraints.cross_shift_demands | min hard / max soft |
| Weekday availability (e.g. Tue/Thu only; overnight shifts count by start date) | employees[].available_weekdays | hard |
| Per-shift assignment count bounds (e.g. at most 4 night shifts) | employees[].shift_count_limits | hard |
| Business holidays | schedule_period.holidays | hard |
When no solution exists, the API diagnoses the cause automatically: it
re-solves quick probe variants with one hard constraint removed at a time and returns
diagnosis.causes[] (cause type, offending field, suggested relaxation), so your
agent can tell the user exactly which constraint to relax. Understaffing is not an error:
the solver returns a schedule with shortage markers, so you still get a usable roster in a
short-staffed week.
Recently added constraints
- Multiple independent fairness groups (
constraints.fairness_groups, up to 4 — e.g. balance nights and weekends separately) / per-employee shift-type count bounds (e.g. max 4 night shifts) / weekday availability (employees[].available_weekdays)
Pricing
The open beta is free. Each key comes with a free usage quota (units) consumed
per solve call. Email us when you run out. Post-beta pricing is in preparation and
beta users will be notified in advance.
Links
- API key dashboard (log in / sign up / issue & disable keys / remaining quota)
- MCP server: GitHub / npm @shiftyasan/mcp-server
- API schema:
GET https://api.shiftyasan.com/v1/public/openapi.json - The Shiftyasan web app: shiftyasan.com
- Contact / key requests: [email protected]