@nannykeeper/mcp-server 1.10.1 → 1.14.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.
package/CLAUDE.md CHANGED
@@ -10,9 +10,9 @@ Calculate nanny taxes for all 50 US states.
10
10
  - `run_payroll` — End-to-end payroll: create, approve, and process (or schedule) in a single call. Finalized response reflects real status (`processing` / `pending_funding` / `completed` / **`scheduled`** as of 1.5.0). No UI intervention needed. (Starter+ required)
11
11
  - `get_autopilot` — Read Autopilot (recurring auto-run payroll) status for an employee, or list an employer's active enrollments (Plus/Professional, `ach` scope)
12
12
  - `manage_autopilot` — Pause / resume / skip / disable an existing enrollment. **Enrolling is NOT exposed** — it captures a standing recurring ACH authorization that must be employer-driven in-app. (Plus/Professional, `ach` scope) — added 1.9.0
13
- - `get_state_filing_status` — The employer's state agency accounts (UC, withholding, SDI) per state, last-four only. Each account has a status: `registered`, `pending`, `required`, or `not_required`. ⛔ `not_required` means this household genuinely does not owe that registration — most often because they and their employee agreed not to withhold state income tax — so never tell them to go register for it. A registration URL is returned only where there is still something to open or finish. Takes an optional `employer_id` (NK-695) — omit it for a single-household customer; ⚠️ a **test-mode key must pass one**, because a key's default household is always the user's REAL one and the endpoint enforces the test/live boundary.
13
+ - `get_state_filing_status` — The employer's state agency accounts (UC, withholding, SDI) per state, last-four only. Each account has a status: `registered`, `pending`, `required`, or `not_required`. ⛔ `not_required` means this household genuinely does not owe that registration — most often because they and their employee agreed not to withhold state income tax — so never tell them to go register for it. A registration URL is returned only where there is still something to open or finish. Takes an optional `employer_id` — omit it for a single-household account; a **test-mode key must pass one**, because a key's default household is always the real one and the endpoint enforces the test/live boundary.
14
14
 
15
- ⛔ **Declare tool parameters in `index.ts`, never in the tool descriptor.** `server.tool()` takes its own zod shape, so a `inputSchema` on the exported descriptor is read by NOTHING. That is the same trap as the inline tool DESCRIPTION that `index.ts` used to restate: on NK-395/NK-695 a second copy turned out to be the dead one **five times**, including a rewritten description that reached zero agents. Import the descriptor's `name`/`description`; put parameters in the zod shape.
15
+ **Declare tool parameters in `server.ts`, never in the tool descriptor.** `server.tool()` takes its own zod shape, so an `inputSchema` on the exported descriptor is read by nothing. The same applies to the tool description: `server.ts` must import the descriptor's `name` and `description` rather than restating them, or the copy an agent actually reads can drift from the one being edited. `index.ts` only starts the stdio transport. Hosted callers pass request-scoped credentials to the same server factory.
16
16
 
17
17
  ## Autopilot (get_autopilot, manage_autopilot)
18
18
  Autopilot auto-runs each period's payroll onto the existing scheduled-fire path so a household never misses a paycheck. The MCP surface is **manage-only**: read status/enrollments and pause/resume/skip/disable. Turning it ON must happen in the app (standing ACH authorization = employer-driven consent), so there is no enroll tool — `POST /api/v1/autopilot/enroll` returns 403 pointing back to the app. `skip` with `through_date` skips every period up to that date (vacation). Confirm any management action with the user before calling.
@@ -0,0 +1,7 @@
1
+ /** A hosted request supplies its own credentials. Never change process.env per user. */
2
+ export interface ToolContext {
3
+ apiKey: string;
4
+ apiBase: string;
5
+ publicConnection?: boolean;
6
+ }
7
+ export declare function getToolContext(context?: ToolContext): ToolContext;
@@ -0,0 +1,6 @@
1
+ export function getToolContext(context) {
2
+ return context ?? {
3
+ apiKey: process.env.NANNYKEEPER_API_KEY ?? "",
4
+ apiBase: process.env.NANNYKEEPER_API_URL || "https://www.nannykeeper.com",
5
+ };
6
+ }
package/dist/index.d.ts CHANGED
@@ -1,18 +1,2 @@
1
1
  #!/usr/bin/env node
2
- /**
3
- * NannyKeeper MCP Server
4
- *
5
- * Model Context Protocol server for calculating US household employer
6
- * (nanny) taxes. Provides these tools:
7
- * - calculate_nanny_taxes: Full tax breakdown for any US state
8
- * - check_threshold: Whether wages trigger employer obligations
9
- * - preview_payroll: Dry-run payroll calc (no record created)
10
- * - run_payroll: Run payroll with YTD tracking and DB persistence
11
- * - get_state_filing_status: State agency account numbers (last-four)
12
- * - get_autopilot: Read recurring auto-run payroll status/enrollments
13
- * - manage_autopilot: Pause/resume/skip/disable an existing enrollment
14
- *
15
- * Requires NANNYKEEPER_API_KEY environment variable.
16
- * Get a free key at: https://www.nannykeeper.com/developers/keys
17
- */
18
2
  export {};
package/dist/index.js CHANGED
@@ -1,317 +1,10 @@
1
1
  #!/usr/bin/env node
2
- /**
3
- * NannyKeeper MCP Server
4
- *
5
- * Model Context Protocol server for calculating US household employer
6
- * (nanny) taxes. Provides these tools:
7
- * - calculate_nanny_taxes: Full tax breakdown for any US state
8
- * - check_threshold: Whether wages trigger employer obligations
9
- * - preview_payroll: Dry-run payroll calc (no record created)
10
- * - run_payroll: Run payroll with YTD tracking and DB persistence
11
- * - get_state_filing_status: State agency account numbers (last-four)
12
- * - get_autopilot: Read recurring auto-run payroll status/enrollments
13
- * - manage_autopilot: Pause/resume/skip/disable an existing enrollment
14
- *
15
- * Requires NANNYKEEPER_API_KEY environment variable.
16
- * Get a free key at: https://www.nannykeeper.com/developers/keys
17
- */
18
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
19
2
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
20
3
  import { createRequire } from "node:module";
21
- import { z } from "zod";
22
- import { executeCalculate } from "./tools/calculate.js";
23
- import { executeThreshold } from "./tools/threshold.js";
24
- import { executePreviewPayroll } from "./tools/preview-payroll.js";
25
- import { executeRunPayroll } from "./tools/run-payroll.js";
26
- import { executeStateFilingStatus, stateFilingStatusTool, } from "./tools/state-filing-status.js";
27
- import { executeGetAutopilot, executeManageAutopilot } from "./tools/autopilot.js";
28
- /**
29
- * ⛔ DERIVED, never hardcoded. This is the version the client sees in the
30
- * `initialize` handshake — the one an MCP host displays and the first thing
31
- * anyone reads when asking "which version am I running?".
32
- *
33
- * It was a literal, and it drifted: it sat at "1.9.0" from the Autopilot commit
34
- * while package.json, manifest.json and server.json all moved to 1.10.0. The
35
- * release runbook's "version has to bump in all three files" checklist did not
36
- * list it, so nothing bumped it and nothing noticed — the published 1.10.0
37
- * introduced itself as 1.9.0 (NK-696).
38
- *
39
- * `createRequire` rather than an import attribute: this package targets Node
40
- * >=18, where `with { type: "json" }` is still behind a flag on the older
41
- * runtimes in that range. npm always ships package.json, and `dist/index.js`
42
- * sits one level down, so `../package.json` resolves in the published layout.
43
- */
44
- const { version: SERVER_VERSION } = createRequire(import.meta.url)("../package.json");
45
- const server = new McpServer({
46
- name: "nannykeeper",
47
- version: SERVER_VERSION,
48
- });
49
- /**
50
- * Authority: SSA Contribution and Benefit Base; IRS Pubs. 15 and 926 (2026).
51
- * Fact: the 2026 Social Security wage base is $184,500; Social Security is
52
- * 6.2% for both employer and employee; Medicare is 1.45% for each with no cap.
53
- * Sources: https://www.ssa.gov/oact/COLA/cbb.html
54
- * https://www.irs.gov/publications/p15
55
- * https://www.irs.gov/publications/p926
56
- * Accessed: 2026-08-25.
57
- * Reasoning: the compiled tool description is shipped inside the MCPB and is
58
- * independently customer-visible, so its tax facts require the same source
59
- * provenance as the application calculators.
60
- */
61
- // Register calculate tool
62
- server.tool("calculate_nanny_taxes", "Calculate employer and employee tax obligations for a household employee (nanny, caregiver, housekeeper) in any US state. " +
63
- "Returns Social Security, Medicare, FUTA, state unemployment, and income tax breakdown. " +
64
- "State income-tax reciprocity: if the employee LIVES in a different state than they work (e.g., lives in Kentucky, works in Indiana), " +
65
- "pass residence_state — for reciprocal pairs the response includes a `reciprocity` block naming the exemption certificate; " +
66
- "pass reciprocity_certificate_on_file=true to suppress the work state's income tax (local taxes and SUI are unaffected). " +
67
- "Important: These are single-period estimates assuming zero year-to-date wages. " +
68
- "Mid-year calculations may overstate Social Security (which caps at the $184,500 wage base) and FUTA (which caps at $7,000). " +
69
- "For accurate ongoing calculations with automatic YTD tracking, pay stubs, W-2s, and direct deposit, " +
70
- "the user needs a NannyKeeper account (free to start, $10/mo for full payroll). Use the signup_url in the response.", {
71
- state: z.string().describe("2-letter US state code where the employee WORKS (e.g., CA, NY, TX, FL)"),
72
- annual_wages: z.number().describe("Annual wages paid to the household employee"),
73
- pay_frequency: z
74
- .enum(["weekly", "biweekly", "semimonthly", "monthly"])
75
- .optional()
76
- .describe("How often the employee is paid (default: biweekly)"),
77
- residence_state: z
78
- .string()
79
- .optional()
80
- .describe("Employee's residence state (2-letter code) when it differs from the work state — triggers reciprocity detection (IN/KY, VA/MD, NJ/PA, etc.)"),
81
- reciprocity_certificate_on_file: z
82
- .boolean()
83
- .optional()
84
- .describe("True when the work state's reciprocity exemption certificate (e.g., Indiana WH-47) is on file with the employer — suppresses the work state's income tax for reciprocal pairs"),
85
- }, {
86
- title: "Calculate Nanny Taxes",
87
- readOnlyHint: true,
88
- destructiveHint: false,
89
- idempotentHint: true,
90
- openWorldHint: true,
91
- }, async (args) => {
92
- const result = await executeCalculate(args);
93
- return { content: [{ type: "text", text: result }] };
94
- });
95
- // Register threshold tool
96
- server.tool("check_threshold", "Check whether one household employee's annual wages cross the IRS Social Security and Medicare threshold " +
97
- "($3,000 for 2026). The response discloses, but cannot assess, household-wide quarterly FUTA and state thresholds " +
98
- "because this tool does not receive quarterly wages for every employee. It also cannot assess family-employee exemptions " +
99
- "because it has no relationship input. Never interpret the result as a complete tax-obligation decision.", {
100
- state: z.string().describe("2-letter US state code (e.g., CA, NY, TX)"),
101
- annual_wages: z.number().describe("Annual wages paid (or planned) to the household employee"),
102
- tax_year: z.number().min(2024).max(2026).optional().describe("Supported tax year to check (2024-2026; default: current year)"),
103
- }, {
104
- title: "Check Tax Threshold",
105
- readOnlyHint: true,
106
- destructiveHint: false,
107
- idempotentHint: true,
108
- openWorldHint: true,
109
- }, async (args) => {
110
- const result = await executeThreshold(args);
111
- return { content: [{ type: "text", text: result }] };
112
- });
113
- // Register preview_payroll tool
114
- server.tool("preview_payroll", "Preview payroll for a household employee WITHOUT creating a record. " +
115
- "Returns the full tax breakdown (federal, state, FICA, FUTA), net pay, and employer costs. " +
116
- "Cross-state employees: each employee's result includes a `reciprocity` field when their " +
117
- "work/residence states have a reciprocal agreement — applied=true means the work state's income " +
118
- "tax was suppressed under the employer's certificate attestation (set up in the NannyKeeper app " +
119
- "on the employee's profile); applied=false names the certificate still to collect. " +
120
- "Use this to validate your request before calling run_payroll. " +
121
- "Same parameters as run_payroll. Requires a Starter+ subscription. " +
122
- "pay_date is optional — when omitted, the server picks the earliest valid pay date " +
123
- "based on ACH submission lead time and echoes it back in the response. " +
124
- "v1.5.0: if pay_date is more than 5 business days in the future, the response includes " +
125
- "is_estimated=true — those numbers will be recomputed at fire time if the user schedules. " +
126
- "To get your employer_id and employee_id, call the NannyKeeper API: " +
127
- "GET /api/v1/employees?employer_id=YOUR_ID (employer_id is visible in your dashboard URL).", {
128
- employer_id: z.string().uuid().describe("Employer UUID — visible in your NannyKeeper dashboard URL or from GET /api/v1/employees"),
129
- employee_id: z.string().uuid().describe("Employee UUID — from GET /api/v1/employees response"),
130
- pay_period_start: z.string().describe("Start of pay period in YYYY-MM-DD format (e.g., 2026-04-07)"),
131
- pay_period_end: z.string().describe("End of pay period in YYYY-MM-DD format (e.g., 2026-04-13)"),
132
- pay_date: z.string().optional().describe("Date employee is paid (YYYY-MM-DD). Optional — server picks the earliest valid date if omitted."),
133
- pay_frequency: z
134
- .enum(["weekly", "biweekly", "semimonthly", "monthly"])
135
- .describe("How often the employee is paid"),
136
- regular_hours: z.number().optional().describe("Regular hours worked this period (e.g., 40 for a full week)"),
137
- overtime_hours: z.number().optional().describe("Overtime hours worked this period"),
138
- bonus: z.number().optional().describe("Bonus amount in dollars for this period"),
139
- other_earnings: z.number().optional().describe("Other earnings in dollars for this period"),
140
- voluntary_set_aside: z
141
- .object({
142
- skip: z.boolean().optional().describe("Skip the active set-aside rule for this paycheck only"),
143
- amount: z.number().min(0).max(9999).optional().describe("Override the rule's computed amount for this paycheck only"),
144
- })
145
- .optional()
146
- .describe("Override or skip the employee's voluntary post-tax set-aside rule for this paycheck only. The recurring rule itself is configured via the dashboard. Omit this field to apply the rule normally."),
147
- }, {
148
- title: "Preview Payroll",
149
- readOnlyHint: true,
150
- destructiveHint: false,
151
- idempotentHint: true,
152
- openWorldHint: true,
153
- }, async (args) => {
154
- const result = await executePreviewPayroll(args);
155
- return { content: [{ type: "text", text: result }] };
156
- });
157
- // Register run_payroll tool
158
- server.tool("run_payroll", "Run payroll for a household employee end-to-end in a single call. Creates the " +
159
- "record, runs all tax calculations (federal, state, FICA, FUTA) with year-to-date " +
160
- "tracking, approves the payroll, and kicks off payment processing. " +
161
- "Returns the finalized status (processing/pending_funding/completed/scheduled) plus full tax breakdown, " +
162
- "net pay, employer costs, and the payroll ID for reference. " +
163
- "Requires a Starter+ subscription. " +
164
- "Plans cap active employees per employer (Starter 1, Plus 5, Professional 5 included, expandable " +
165
- "to 25 at $6/mo each); if the roster exceeds the plan's count, the API returns 403 with guidance — " +
166
- "the user adds employees at Settings → Billing in the dashboard (never billed implicitly via API), then retry. " +
167
- "pay_date is optional — when omitted, the server picks the earliest valid pay date " +
168
- "based on ACH submission lead time and echoes it back. If supplied and past the " +
169
- "submission deadline, the request is rejected with next_valid_pay_date in the error. " +
170
- "If pay_date is more than 5 business days in the future on a DD payroll, status=scheduled " +
171
- "and the payroll will auto-fire at scheduled_send_at (5 biz days before pay_date). " +
172
- "Scheduled responses include is_estimated=true — numbers may shift slightly at fire time " +
173
- "if YTD or rate configs change between approve and fire. " +
174
- "Direct deposit callers: set confirm_large_payroll=true for totals >$5,000 or any single " +
175
- "net pay >$3,000; set confirm_ach_debit=true for first-time DD or if no DD in 30 days. " +
176
- "Tip: use preview_payroll first to validate your request and see results before committing. " +
177
- "To get your employer_id and employee_id, call the NannyKeeper API: " +
178
- "GET /api/v1/employees?employer_id=YOUR_ID (employer_id is visible in your dashboard URL).", {
179
- employer_id: z.string().uuid().describe("Employer UUID — visible in your NannyKeeper dashboard URL or from GET /api/v1/employees"),
180
- employee_id: z.string().uuid().describe("Employee UUID — from GET /api/v1/employees response"),
181
- pay_period_start: z.string().describe("Start of pay period in YYYY-MM-DD format (e.g., 2026-04-07)"),
182
- pay_period_end: z.string().describe("End of pay period in YYYY-MM-DD format (e.g., 2026-04-13)"),
183
- pay_date: z.string().optional().describe("Date employee is paid (YYYY-MM-DD). Optional — server picks the earliest valid date if omitted."),
184
- pay_frequency: z
185
- .enum(["weekly", "biweekly", "semimonthly", "monthly"])
186
- .describe("How often the employee is paid"),
187
- regular_hours: z.number().optional().describe("Regular hours worked this period (e.g., 40 for a full week)"),
188
- overtime_hours: z.number().optional().describe("Overtime hours worked this period"),
189
- bonus: z.number().optional().describe("Bonus amount in dollars for this period"),
190
- other_earnings: z.number().optional().describe("Other earnings in dollars for this period"),
191
- payment_method: z
192
- .enum(["direct_deposit", "check", "cash"])
193
- .optional()
194
- .describe("How the employee is paid (default: check)"),
195
- notes: z.string().optional().describe("Notes (use 'catch-up' for retroactive payrolls that auto-complete)"),
196
- confirm_large_payroll: z
197
- .boolean()
198
- .optional()
199
- .describe("Required for direct-deposit payrolls with total net pay >$5,000 or any single net pay >$3,000."),
200
- confirm_ach_debit: z
201
- .boolean()
202
- .optional()
203
- .describe("Required for first-time direct-deposit payroll or when the last DD authorization is >30 days old."),
204
- off_cycle: z
205
- .boolean()
206
- .optional()
207
- .describe("Deprecated and ignored. Runs for an Autopilot-covered employee are classified by pay period: a past/current period Autopilot has NOT scheduled runs normally; a period Autopilot already scheduled returns 409 with error code 'autopilot_run_scheduled' (it must be replaced in the NannyKeeper app, or Autopilot turned off first); a period beyond Autopilot's next run returns 409 'period_ahead_of_anchor'. Do NOT retry with off_cycle=true — there is no additive off-cycle run. On a 409, surface the message to the user rather than retrying."),
208
- voluntary_set_aside: z
209
- .object({
210
- skip: z.boolean().optional().describe("Skip the active set-aside rule for this paycheck only"),
211
- amount: z.number().min(0).max(9999).optional().describe("Override the rule's computed amount for this paycheck only"),
212
- })
213
- .optional()
214
- .describe("Override or skip the employee's voluntary post-tax set-aside rule for this paycheck only. The recurring rule itself is configured via the dashboard. Omit this field to apply the rule normally."),
215
- idempotency_key: z
216
- .string()
217
- .optional()
218
- .describe("Unique key to prevent duplicate payroll creation (e.g., 'payroll-2026-04-07-emp123')"),
219
- }, {
220
- title: "Run Payroll",
221
- readOnlyHint: false,
222
- destructiveHint: false,
223
- idempotentHint: false,
224
- openWorldHint: true,
225
- }, async (args) => {
226
- const result = await executeRunPayroll(args);
227
- return { content: [{ type: "text", text: result }] };
228
- });
229
- // Register get_state_filing_status tool
230
- server.tool(stateFilingStatusTool.name,
231
- // ⛔ IMPORTED, not restated. The inline copy that used to sit here was the
232
- // one agents actually read, and it drifted out of date the moment NK-395
233
- // edited the exported descriptor instead — promising "a registration URL for
234
- // any that are missing" long after that stopped being true.
235
- stateFilingStatusTool.description, {
236
- // ⛔ THIS is the shape agents actually see — the `{}` that used to sit here
237
- // is why the descriptor's own `inputSchema` was read by nothing and has now
238
- // been deleted rather than extended (NK-695). Declaring a parameter there
239
- // would have reached zero agents, which is the fifth time on this issue
240
- // that a second copy turned out to be the dead one.
241
- employer_id: z
242
- .string()
243
- .uuid()
244
- .optional()
245
- .describe("Optional. The household to read, when the account has more than one. " +
246
- "Defaults to the household this API key belongs to — leave unset for " +
247
- "a single-household customer. Needed for a test-mode (nk_test_) key, " +
248
- "whose default household is the REAL one: pass the sandbox id."),
249
- }, {
250
- title: "Get State Filing Status",
251
- readOnlyHint: true,
252
- destructiveHint: false,
253
- idempotentHint: true,
254
- openWorldHint: true,
255
- }, async ({ employer_id }) => {
256
- const result = await executeStateFilingStatus({ employer_id });
257
- return { content: [{ type: "text", text: result }] };
258
- });
259
- // Register get_autopilot tool (read)
260
- server.tool("get_autopilot", "Read Autopilot status (recurring auto-run payroll). With employee_id: the live enrollment " +
261
- "(status, standard hours, expected net, next pay date) plus eligibility and a 3-payday schedule " +
262
- "preview — or, if not enrolled, WHY (the eligibility reason, e.g. not_plus / insufficient_history). " +
263
- "Without employee_id: the list of the employer's active enrollments. Read-only. " +
264
- "Requires a Plus/Professional key. To get employer_id/employee_id: GET /api/v1/employees?employer_id=YOUR_ID.", {
265
- employer_id: z.string().uuid().describe("Employer UUID — visible in your NannyKeeper dashboard URL"),
266
- employee_id: z
267
- .string()
268
- .uuid()
269
- .optional()
270
- .describe("Employee UUID — omit to list all active enrollments for the employer"),
271
- }, {
272
- title: "Get Autopilot Status",
273
- readOnlyHint: true,
274
- destructiveHint: false,
275
- idempotentHint: true,
276
- openWorldHint: true,
277
- }, async (args) => {
278
- const result = await executeGetAutopilot(args);
279
- return { content: [{ type: "text", text: result }] };
280
- });
281
- // Register manage_autopilot tool (pause/resume/skip/disable)
282
- server.tool("manage_autopilot", "Manage an EXISTING Autopilot enrollment for a household employee. Actions: " +
283
- "`pause` (stop new generation — an already-scheduled run still fires unless voided from the payroll page), " +
284
- "`resume` (re-checks eligibility + clears the failure counter), " +
285
- "`skip` (skip the next period; with through_date, skip every period up to that date for a vacation), " +
286
- "`disable` (turn Autopilot off — soft-deleted so the ledger + ACH authorization are retained; the employee can re-enroll in-app). " +
287
- "Turning Autopilot ON is NOT available here — it captures a standing recurring ACH authorization that must be " +
288
- "done by the employer in the app. Requires a Plus/Professional key. Confirm the action with the user before calling.", {
289
- employer_id: z.string().uuid().describe("Employer UUID"),
290
- employee_id: z.string().uuid().describe("Employee UUID whose enrollment to manage"),
291
- action: z
292
- .enum(["pause", "resume", "skip", "disable"])
293
- .describe("What to do: pause | resume | skip | disable"),
294
- through_date: z
295
- .string()
296
- .regex(/^\d{4}-\d{2}-\d{2}$/)
297
- .optional()
298
- .describe("skip only: skip every upcoming period up to this date (YYYY-MM-DD) for a multi-week vacation"),
299
- }, {
300
- title: "Manage Autopilot",
301
- readOnlyHint: false,
302
- destructiveHint: false,
303
- idempotentHint: false,
304
- openWorldHint: true,
305
- }, async (args) => {
306
- const result = await executeManageAutopilot(args);
307
- return { content: [{ type: "text", text: result }] };
308
- });
309
- // Start server
310
- async function main() {
311
- const transport = new StdioServerTransport();
312
- await server.connect(transport);
313
- }
314
- main().catch((error) => {
4
+ import { createNannyKeeperServer } from "./server.js";
5
+ const { version } = createRequire(import.meta.url)("../package.json");
6
+ const server = createNannyKeeperServer(version);
7
+ server.connect(new StdioServerTransport()).catch((error) => {
315
8
  console.error("Failed to start NannyKeeper MCP server:", error);
316
9
  process.exit(1);
317
10
  });
@@ -0,0 +1,9 @@
1
+ /** Public listing copy avoids pricing prompts and delegates tax facts to the API. */
2
+ export declare const publicDescriptions: Record<string, string>;
3
+ export declare function toolResult(text: string, publicConnection?: boolean): {
4
+ isError?: boolean | undefined;
5
+ content: {
6
+ type: "text";
7
+ text: string;
8
+ }[];
9
+ };
@@ -0,0 +1,26 @@
1
+ /** Public listing copy avoids pricing prompts and delegates tax facts to the API. */
2
+ export const publicDescriptions = {
3
+ calculate_nanny_taxes: "Estimate household payroll taxes using the NannyKeeper calculator. Provide work state, annual wages, and pay frequency; include residence state when different. These estimates do not incorporate an existing employee's year-to-date payroll. Use preview_payroll for an existing employee. Preserve any limitations or unassessed items returned by the API.",
4
+ check_threshold: "Check the supported annual wage threshold assessment for one household employee. This tool has no household-wide quarterly wages or family-relationship input. Preserve the API's limitations and unassessed items; do not present its result as a complete determination of obligations.",
5
+ preview_payroll: "Preview payroll for an existing household employee without creating a payroll record. Review the returned pay date, gross and net pay, employer costs, warnings, and any estimated status with the user before running payroll. The account must already have access to payroll. Ask for missing employer and employee IDs; never invent them.",
6
+ run_payroll: "Create, approve, and process payroll for an existing household employee. Check and cash record payments the employer handles themselves. Direct deposit initiates or schedules NannyKeeper processing through Stripe. First preview the same inputs and obtain explicit confirmation of the employee, period, pay date, amounts, and payment method. Set debit or large-payroll confirmation flags only after the user explicitly authorizes the corresponding action. Use one idempotency_key per approved payroll and reuse it on a retry with identical inputs. Do not retry a rejected payroll with changed dates, payment method, confirmation flags, or off_cycle to bypass a safeguard. Report the exact returned status; scheduled or processing does not mean paid.",
7
+ get_state_filing_status: "Read masked state agency account status for the connected household. Use employer_id to select an authorized household when needed. Present returned registered, pending, required, and not_required states faithfully. This tool does not register an account or submit a filing. Do not infer that missing or unassessed information means no obligation.",
8
+ get_autopilot: "Read existing recurring payroll enrollment status for a household, optionally for one employee. Returns status and available schedule information; it does not enroll anyone or change payroll.",
9
+ manage_autopilot: "Pause, resume, skip, or disable an existing recurring payroll enrollment. Confirm the employee and exact action before calling. Resume can restart future payroll generation and Stripe processing. Pausing does not cancel a payroll that is already scheduled. To cancel an existing payroll, use NannyKeeper. Initial enrollment and its standing authorization happen in NannyKeeper.",
10
+ };
11
+ export function toolResult(text, publicConnection = false) {
12
+ let data;
13
+ try {
14
+ data = JSON.parse(text);
15
+ }
16
+ catch {
17
+ data = null;
18
+ }
19
+ const isError = !!data && typeof data === "object" && "error" in data;
20
+ if (publicConnection && data && typeof data === "object") {
21
+ // API acquisition prompts are useful in the standalone developer package,
22
+ // but public plugins provide access to existing accounts without selling plans.
23
+ text = JSON.stringify(data, (key, value) => ["signup_url", "upgrade_url", "continue_url", "next_actions"].includes(key) ? undefined : value);
24
+ }
25
+ return { content: [{ type: "text", text }], ...(isError ? { isError: true } : {}) };
26
+ }
@@ -0,0 +1,4 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import type { ToolContext } from "./context.ts";
3
+ /** A fresh server and credential closure for each hosted request. */
4
+ export declare function createNannyKeeperServer(version: string, context?: ToolContext): McpServer;
package/dist/server.js ADDED
@@ -0,0 +1,271 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { z } from "zod";
3
+ import { executeCalculate } from "./tools/calculate.js";
4
+ import { executeThreshold } from "./tools/threshold.js";
5
+ import { executePreviewPayroll } from "./tools/preview-payroll.js";
6
+ import { executeRunPayroll } from "./tools/run-payroll.js";
7
+ import { executeStateFilingStatus, stateFilingStatusTool, } from "./tools/state-filing-status.js";
8
+ import { executeGetAutopilot, executeManageAutopilot } from "./tools/autopilot.js";
9
+ import { publicDescriptions, toolResult } from "./public-profile.js";
10
+ /** A fresh server and credential closure for each hosted request. */
11
+ export function createNannyKeeperServer(version, context) {
12
+ const server = new McpServer({ name: "nannykeeper", version });
13
+ /**
14
+ * Authority: SSA Contribution and Benefit Base; IRS Pubs. 15 and 926 (2026).
15
+ * Fact: the 2026 Social Security wage base is $184,500; Social Security is
16
+ * 6.2% for both employer and employee; Medicare is 1.45% for each with no cap.
17
+ * Sources: https://www.ssa.gov/oact/COLA/cbb.html
18
+ * https://www.irs.gov/publications/p15
19
+ * https://www.irs.gov/publications/p926
20
+ * Accessed: 2026-08-25.
21
+ * Reasoning: the compiled tool description is shipped inside the MCPB and is
22
+ * independently customer-visible, so its tax facts require the same source
23
+ * provenance as the application calculators.
24
+ */
25
+ // Register calculate tool
26
+ server.tool("calculate_nanny_taxes", context?.publicConnection ? publicDescriptions.calculate_nanny_taxes : ("Calculate employer and employee tax obligations for a household employee (nanny, caregiver, housekeeper) in any US state. " +
27
+ "Returns Social Security, Medicare, FUTA, state unemployment, and income tax breakdown. " +
28
+ "State income-tax reciprocity: if the employee LIVES in a different state than they work (e.g., lives in Kentucky, works in Indiana), " +
29
+ "pass residence_state — for reciprocal pairs the response includes a `reciprocity` block naming the exemption certificate; " +
30
+ "pass reciprocity_certificate_on_file=true to suppress the work state's income tax (local taxes and SUI are unaffected). " +
31
+ "Important: These are annual estimates from annual_wages, with derived per-paycheck amounts. " +
32
+ "They do not read an existing employee's year-to-date payroll records; use preview_payroll for an existing employee. " +
33
+ "For accurate ongoing calculations with automatic YTD tracking, pay stubs, W-2s, and direct deposit, " +
34
+ "the user needs a NannyKeeper account (free to start, $10/mo for full payroll). Use the signup_url in the response."), {
35
+ state: z.string().describe("2-letter US state code where the employee WORKS (e.g., CA, NY, TX, FL)"),
36
+ annual_wages: z.number().describe("Annual wages paid to the household employee"),
37
+ pay_frequency: z
38
+ .enum(["weekly", "biweekly", "semimonthly", "monthly"])
39
+ .optional()
40
+ .describe("How often the employee is paid (default: biweekly)"),
41
+ residence_state: z
42
+ .string()
43
+ .optional()
44
+ .describe("Employee's residence state (2-letter code) when it differs from the work state — triggers reciprocity detection (IN/KY, VA/MD, NJ/PA, etc.)"),
45
+ reciprocity_certificate_on_file: z
46
+ .boolean()
47
+ .optional()
48
+ .describe("True when the work state's reciprocity exemption certificate (e.g., Indiana WH-47) is on file with the employer — suppresses the work state's income tax for reciprocal pairs"),
49
+ }, {
50
+ title: "Calculate Nanny Taxes",
51
+ readOnlyHint: true,
52
+ destructiveHint: false,
53
+ idempotentHint: true,
54
+ openWorldHint: true,
55
+ }, async (args) => {
56
+ const result = await executeCalculate(args, context);
57
+ return toolResult(result, context?.publicConnection);
58
+ });
59
+ // Register threshold tool
60
+ server.tool("check_threshold", context?.publicConnection ? publicDescriptions.check_threshold : ("Check whether one household employee's annual wages cross the IRS Social Security and Medicare threshold " +
61
+ "($3,000 for 2026). The response discloses, but cannot assess, household-wide quarterly FUTA and state thresholds " +
62
+ "because this tool does not receive quarterly wages for every employee. It also cannot assess family-employee exemptions " +
63
+ "because it has no relationship input. Never interpret the result as a complete tax-obligation decision."), {
64
+ state: z.string().describe("2-letter US state code (e.g., CA, NY, TX)"),
65
+ annual_wages: z.number().describe("Annual wages paid (or planned) to the household employee"),
66
+ tax_year: z.number().min(2024).max(2026).optional().describe("Supported tax year to check (2024-2026; default: current year)"),
67
+ }, {
68
+ title: "Check Tax Threshold",
69
+ readOnlyHint: true,
70
+ destructiveHint: false,
71
+ idempotentHint: true,
72
+ openWorldHint: true,
73
+ }, async (args) => {
74
+ const result = await executeThreshold(args, context);
75
+ return toolResult(result, context?.publicConnection);
76
+ });
77
+ // Register preview_payroll tool
78
+ server.tool("preview_payroll", context?.publicConnection ? publicDescriptions.preview_payroll : ("Preview payroll for a household employee WITHOUT creating a record. " +
79
+ "Returns the full tax breakdown (federal, state, FICA, FUTA), net pay, and employer costs. " +
80
+ "Cross-state employees: each employee's result includes a `reciprocity` field when their " +
81
+ "work/residence states have a reciprocal agreement — applied=true means the work state's income " +
82
+ "tax was suppressed under the employer's certificate attestation (set up in the NannyKeeper app " +
83
+ "on the employee's profile); applied=false names the certificate still to collect. " +
84
+ "Use this to validate your request before calling run_payroll. " +
85
+ "Same parameters as run_payroll. Requires a Starter+ subscription. " +
86
+ "pay_date is optional — when omitted, the server picks the earliest valid pay date " +
87
+ "based on ACH submission lead time and echoes it back in the response. " +
88
+ "v1.5.0: if pay_date is more than 5 business days in the future, the response includes " +
89
+ "is_estimated=true — those numbers will be recomputed at fire time if the user schedules. " +
90
+ "To get your employer_id and employee_id, call the NannyKeeper API: " +
91
+ "GET /api/v1/employees?employer_id=YOUR_ID (employer_id is visible in your dashboard URL)."), {
92
+ employer_id: z.string().uuid().describe("Employer UUID — visible in your NannyKeeper dashboard URL or from GET /api/v1/employees"),
93
+ employee_id: z.string().uuid().describe("Employee UUID — from GET /api/v1/employees response"),
94
+ pay_period_start: z.string().describe("Start of pay period in YYYY-MM-DD format (e.g., 2026-04-07)"),
95
+ pay_period_end: z.string().describe("End of pay period in YYYY-MM-DD format (e.g., 2026-04-13)"),
96
+ pay_date: z.string().optional().describe("Date employee is paid (YYYY-MM-DD). Optional — server picks the earliest valid date if omitted."),
97
+ pay_frequency: z
98
+ .enum(["weekly", "biweekly", "semimonthly", "monthly"])
99
+ .describe("How often the employee is paid"),
100
+ regular_hours: z.number().optional().describe("Regular hours worked this period (e.g., 40 for a full week)"),
101
+ overtime_hours: z.number().optional().describe("Overtime hours worked this period"),
102
+ bonus: z.number().optional().describe("Bonus amount in dollars for this period"),
103
+ other_earnings: z.number().optional().describe("Other earnings in dollars for this period"),
104
+ voluntary_set_aside: z
105
+ .object({
106
+ skip: z.boolean().optional().describe("Skip the active set-aside rule for this paycheck only"),
107
+ amount: z.number().min(0).max(9999).optional().describe("Override the rule's computed amount for this paycheck only"),
108
+ })
109
+ .optional()
110
+ .describe("Override or skip the employee's voluntary post-tax set-aside rule for this paycheck only. The recurring rule itself is configured via the dashboard. Omit this field to apply the rule normally."),
111
+ }, {
112
+ title: "Preview Payroll",
113
+ readOnlyHint: true,
114
+ destructiveHint: false,
115
+ idempotentHint: true,
116
+ openWorldHint: true,
117
+ }, async (args) => {
118
+ const result = await executePreviewPayroll(args, context);
119
+ return toolResult(result, context?.publicConnection);
120
+ });
121
+ // Register run_payroll tool
122
+ server.tool("run_payroll", context?.publicConnection ? publicDescriptions.run_payroll : ("Run payroll for a household employee end-to-end in a single call. Creates the " +
123
+ "record, runs all tax calculations (federal, state, FICA, FUTA) with year-to-date " +
124
+ "tracking, approves the payroll, and kicks off payment processing. " +
125
+ "Returns the finalized status (processing/pending_funding/completed/scheduled) plus full tax breakdown, " +
126
+ "net pay, employer costs, and the payroll ID for reference. " +
127
+ "Requires a Starter+ subscription. " +
128
+ "Plans cap active employees per employer (Starter 1, Plus 5, Professional 5 included, expandable " +
129
+ "to 25 at $6/mo each); if the roster exceeds the plan's count, the API returns 403 with guidance — " +
130
+ "the user adds employees at Settings → Billing in the dashboard (never billed implicitly via API), then retry. " +
131
+ "pay_date is optional — when omitted, the server picks the earliest valid pay date " +
132
+ "based on ACH submission lead time and echoes it back. If supplied and past the " +
133
+ "submission deadline, the request is rejected with next_valid_pay_date in the error. " +
134
+ "If pay_date is more than 5 business days in the future on a DD payroll, status=scheduled " +
135
+ "and the payroll will auto-fire at scheduled_send_at (5 biz days before pay_date). " +
136
+ "Scheduled responses include is_estimated=true — numbers may shift slightly at fire time " +
137
+ "if YTD or rate configs change between approve and fire. " +
138
+ "Direct deposit callers: set confirm_large_payroll=true for totals >$5,000 or any single " +
139
+ "net pay >$3,000; set confirm_ach_debit=true for first-time DD or if no DD in 30 days. " +
140
+ "Tip: use preview_payroll first to validate your request and see results before committing. " +
141
+ "To get your employer_id and employee_id, call the NannyKeeper API: " +
142
+ "GET /api/v1/employees?employer_id=YOUR_ID (employer_id is visible in your dashboard URL)."), {
143
+ employer_id: z.string().uuid().describe("Employer UUID — visible in your NannyKeeper dashboard URL or from GET /api/v1/employees"),
144
+ employee_id: z.string().uuid().describe("Employee UUID — from GET /api/v1/employees response"),
145
+ pay_period_start: z.string().describe("Start of pay period in YYYY-MM-DD format (e.g., 2026-04-07)"),
146
+ pay_period_end: z.string().describe("End of pay period in YYYY-MM-DD format (e.g., 2026-04-13)"),
147
+ pay_date: z.string().optional().describe("Date employee is paid (YYYY-MM-DD). Optional — server picks the earliest valid date if omitted."),
148
+ pay_frequency: z
149
+ .enum(["weekly", "biweekly", "semimonthly", "monthly"])
150
+ .describe("How often the employee is paid"),
151
+ regular_hours: z.number().optional().describe("Regular hours worked this period (e.g., 40 for a full week)"),
152
+ overtime_hours: z.number().optional().describe("Overtime hours worked this period"),
153
+ bonus: z.number().optional().describe("Bonus amount in dollars for this period"),
154
+ other_earnings: z.number().optional().describe("Other earnings in dollars for this period"),
155
+ payment_method: z
156
+ .enum(["direct_deposit", "check", "cash"])
157
+ .optional()
158
+ .describe("How the employee is paid (default: check)"),
159
+ notes: z.string().optional().describe("Notes (use 'catch-up' for retroactive payrolls that auto-complete)"),
160
+ confirm_large_payroll: z
161
+ .boolean()
162
+ .optional()
163
+ .describe("Required for direct-deposit payrolls with total net pay >$5,000 or any single net pay >$3,000."),
164
+ confirm_ach_debit: z
165
+ .boolean()
166
+ .optional()
167
+ .describe("Required for first-time direct-deposit payroll or when the last DD authorization is >30 days old."),
168
+ off_cycle: z
169
+ .boolean()
170
+ .optional()
171
+ .describe("Deprecated and ignored. Runs for an Autopilot-covered employee are classified by pay period: a past/current period Autopilot has NOT scheduled runs normally; a period Autopilot already scheduled returns 409 with error code 'autopilot_run_scheduled' (it must be replaced in the NannyKeeper app, or Autopilot turned off first); a period beyond Autopilot's next run returns 409 'period_ahead_of_anchor'. Do NOT retry with off_cycle=true — there is no additive off-cycle run. On a 409, surface the message to the user rather than retrying."),
172
+ voluntary_set_aside: z
173
+ .object({
174
+ skip: z.boolean().optional().describe("Skip the active set-aside rule for this paycheck only"),
175
+ amount: z.number().min(0).max(9999).optional().describe("Override the rule's computed amount for this paycheck only"),
176
+ })
177
+ .optional()
178
+ .describe("Override or skip the employee's voluntary post-tax set-aside rule for this paycheck only. The recurring rule itself is configured via the dashboard. Omit this field to apply the rule normally."),
179
+ idempotency_key: context?.publicConnection ? z.string().trim().min(1).max(255).describe("Unique key for this approved payroll. Reuse the same key with identical inputs when retrying.") : z
180
+ .string()
181
+ .optional()
182
+ .describe("Unique key to prevent duplicate payroll creation (e.g., 'payroll-2026-04-07-emp123')"),
183
+ }, {
184
+ title: "Run Payroll",
185
+ readOnlyHint: false,
186
+ destructiveHint: true,
187
+ idempotentHint: false,
188
+ openWorldHint: true,
189
+ }, async (args) => {
190
+ const result = await executeRunPayroll(args, context);
191
+ return toolResult(result, context?.publicConnection);
192
+ });
193
+ // Register get_state_filing_status tool
194
+ server.tool(stateFilingStatusTool.name,
195
+ // Imported, not restated. An inline copy here is the one agents actually
196
+ // read, so it silently diverges the moment someone edits the exported
197
+ // descriptor instead.
198
+ context?.publicConnection ? publicDescriptions.get_state_filing_status : stateFilingStatusTool.description, {
199
+ // This is the parameter shape agents actually see. Declare parameters
200
+ // here — an `inputSchema` on the exported descriptor is read by nothing,
201
+ // which is why the descriptor no longer carries one.
202
+ employer_id: z
203
+ .string()
204
+ .uuid()
205
+ .optional()
206
+ .describe("Optional. The household to read, when the account has more than one. " +
207
+ "Defaults to the household this API key belongs to — leave unset for " +
208
+ "a single-household customer. Needed for a test-mode (nk_test_) key, " +
209
+ "whose default household is the REAL one: pass the sandbox id."),
210
+ }, {
211
+ title: "Get State Filing Status",
212
+ readOnlyHint: true,
213
+ destructiveHint: false,
214
+ idempotentHint: true,
215
+ openWorldHint: true,
216
+ }, async ({ employer_id }) => {
217
+ const result = await executeStateFilingStatus({ employer_id }, context);
218
+ return toolResult(result, context?.publicConnection);
219
+ });
220
+ // Register get_autopilot tool (read)
221
+ server.tool("get_autopilot", context?.publicConnection ? publicDescriptions.get_autopilot : ("Read Autopilot status (recurring auto-run payroll). With employee_id: the live enrollment " +
222
+ "(status, standard hours, expected net, next pay date) plus eligibility and a 3-payday schedule " +
223
+ "preview — or, if not enrolled, WHY (the eligibility reason, e.g. not_plus / insufficient_history). " +
224
+ "Without employee_id: the list of the employer's active enrollments. Read-only. " +
225
+ "Requires a Plus/Professional key. To get employer_id/employee_id: GET /api/v1/employees?employer_id=YOUR_ID."), {
226
+ employer_id: z.string().uuid().describe("Employer UUID — visible in your NannyKeeper dashboard URL"),
227
+ employee_id: z
228
+ .string()
229
+ .uuid()
230
+ .optional()
231
+ .describe("Employee UUID — omit to list all active enrollments for the employer"),
232
+ }, {
233
+ title: "Get Autopilot Status",
234
+ readOnlyHint: true,
235
+ destructiveHint: false,
236
+ idempotentHint: true,
237
+ openWorldHint: true,
238
+ }, async (args) => {
239
+ const result = await executeGetAutopilot(args, context);
240
+ return toolResult(result, context?.publicConnection);
241
+ });
242
+ // Register manage_autopilot tool (pause/resume/skip/disable)
243
+ server.tool("manage_autopilot", context?.publicConnection ? publicDescriptions.manage_autopilot : ("Manage an EXISTING Autopilot enrollment for a household employee. Actions: " +
244
+ "`pause` (stop new generation — an already-scheduled run still fires unless voided from the payroll page), " +
245
+ "`resume` (re-checks eligibility + clears the failure counter), " +
246
+ "`skip` (skip the next period; with through_date, skip every period up to that date for a vacation), " +
247
+ "`disable` (turn Autopilot off — soft-deleted so the ledger + ACH authorization are retained; the employee can re-enroll in-app). " +
248
+ "Turning Autopilot ON is NOT available here — it captures a standing recurring ACH authorization that must be " +
249
+ "done by the employer in the app. Requires a Plus/Professional key. Confirm the action with the user before calling."), {
250
+ employer_id: z.string().uuid().describe("Employer UUID"),
251
+ employee_id: z.string().uuid().describe("Employee UUID whose enrollment to manage"),
252
+ action: z
253
+ .enum(["pause", "resume", "skip", "disable"])
254
+ .describe("What to do: pause | resume | skip | disable"),
255
+ through_date: z
256
+ .string()
257
+ .regex(/^\d{4}-\d{2}-\d{2}$/)
258
+ .optional()
259
+ .describe("skip only: skip every upcoming period up to this date (YYYY-MM-DD) for a multi-week vacation"),
260
+ }, {
261
+ title: "Manage Autopilot",
262
+ readOnlyHint: false,
263
+ destructiveHint: true,
264
+ idempotentHint: false,
265
+ openWorldHint: true,
266
+ }, async (args) => {
267
+ const result = await executeManageAutopilot(args, context);
268
+ return toolResult(result, context?.publicConnection);
269
+ });
270
+ return server;
271
+ }
@@ -7,15 +7,16 @@
7
7
  * on captures a standing recurring ACH authorization that must be employer-
8
8
  * driven in the app. Requires a Plus/Professional key (the `ach` scope).
9
9
  */
10
+ import { type ToolContext } from "../context.ts";
10
11
  /** Read Autopilot status for one employee, or list the employer's active enrollments. */
11
12
  export declare function executeGetAutopilot(args: {
12
13
  employer_id: string;
13
14
  employee_id?: string;
14
- }): Promise<string>;
15
+ }, context?: ToolContext): Promise<string>;
15
16
  /** Manage an existing enrollment: pause / resume / skip / disable. */
16
17
  export declare function executeManageAutopilot(args: {
17
18
  employer_id: string;
18
19
  employee_id: string;
19
20
  action: "pause" | "resume" | "skip" | "disable";
20
21
  through_date?: string;
21
- }): Promise<string>;
22
+ }, context?: ToolContext): Promise<string>;
@@ -7,15 +7,15 @@
7
7
  * on captures a standing recurring ACH authorization that must be employer-
8
8
  * driven in the app. Requires a Plus/Professional key (the `ach` scope).
9
9
  */
10
- const API_BASE = process.env.NANNYKEEPER_API_URL || "https://www.nannykeeper.com";
10
+ import { getToolContext } from "../context.js";
11
11
  function missingKey() {
12
12
  return JSON.stringify({
13
13
  error: "NANNYKEEPER_API_KEY environment variable is not set. Autopilot management requires a Plus/Professional key: nannykeeper.com/developers/keys",
14
14
  });
15
15
  }
16
16
  /** Read Autopilot status for one employee, or list the employer's active enrollments. */
17
- export async function executeGetAutopilot(args) {
18
- const apiKey = process.env.NANNYKEEPER_API_KEY;
17
+ export async function executeGetAutopilot(args, context) {
18
+ const { apiKey, apiBase: API_BASE } = getToolContext(context);
19
19
  if (!apiKey)
20
20
  return missingKey();
21
21
  try {
@@ -38,8 +38,8 @@ export async function executeGetAutopilot(args) {
38
38
  }
39
39
  }
40
40
  /** Manage an existing enrollment: pause / resume / skip / disable. */
41
- export async function executeManageAutopilot(args) {
42
- const apiKey = process.env.NANNYKEEPER_API_KEY;
41
+ export async function executeManageAutopilot(args, context) {
42
+ const { apiKey, apiBase: API_BASE } = getToolContext(context);
43
43
  if (!apiKey)
44
44
  return missingKey();
45
45
  try {
@@ -3,16 +3,17 @@
3
3
  *
4
4
  * Calls the NannyKeeper API to calculate household employer taxes.
5
5
  */
6
+ import { type ToolContext } from "../context.ts";
6
7
  /**
7
8
  * ⛔ THE DESCRIPTOR CONST THAT USED TO LIVE HERE WAS DEAD AND HAS BEEN REMOVED.
8
9
  *
9
- * `index.ts` registers this tool with its own description, so the exported
10
+ * `server.ts` registers this tool with its own description, so the exported
10
11
  * const was imported by nothing — and had already drifted from the shipped
11
- * text in both directions. It cost NK-395 a HIGH on the sibling tool: a
12
+ * text in both directions. It has already bitten the sibling tool once: a
12
13
  * customer-facing prompt was rewritten in the dead copy while every agent kept
13
14
  * reading the stale live one.
14
15
  *
15
- * If you want a single definition here, export it AND import it in `index.ts`
16
+ * If you want a single definition here, export it AND import it in `server.ts`
16
17
  * (see `state-filing-status.ts`, which now does). A second copy nobody reads is
17
18
  * worse than no copy: it looks like the source of truth and silently is not.
18
19
  */
@@ -22,4 +23,4 @@ export declare function executeCalculate(args: {
22
23
  pay_frequency?: string;
23
24
  residence_state?: string;
24
25
  reciprocity_certificate_on_file?: boolean;
25
- }): Promise<string>;
26
+ }, context?: ToolContext): Promise<string>;
@@ -3,22 +3,22 @@
3
3
  *
4
4
  * Calls the NannyKeeper API to calculate household employer taxes.
5
5
  */
6
- const API_BASE = process.env.NANNYKEEPER_API_URL || "https://www.nannykeeper.com";
6
+ import { getToolContext } from "../context.js";
7
7
  /**
8
8
  * ⛔ THE DESCRIPTOR CONST THAT USED TO LIVE HERE WAS DEAD AND HAS BEEN REMOVED.
9
9
  *
10
- * `index.ts` registers this tool with its own description, so the exported
10
+ * `server.ts` registers this tool with its own description, so the exported
11
11
  * const was imported by nothing — and had already drifted from the shipped
12
- * text in both directions. It cost NK-395 a HIGH on the sibling tool: a
12
+ * text in both directions. It has already bitten the sibling tool once: a
13
13
  * customer-facing prompt was rewritten in the dead copy while every agent kept
14
14
  * reading the stale live one.
15
15
  *
16
- * If you want a single definition here, export it AND import it in `index.ts`
16
+ * If you want a single definition here, export it AND import it in `server.ts`
17
17
  * (see `state-filing-status.ts`, which now does). A second copy nobody reads is
18
18
  * worse than no copy: it looks like the source of truth and silently is not.
19
19
  */
20
- export async function executeCalculate(args) {
21
- const apiKey = process.env.NANNYKEEPER_API_KEY;
20
+ export async function executeCalculate(args, context) {
21
+ const { apiKey, apiBase: API_BASE } = getToolContext(context);
22
22
  if (!apiKey) {
23
23
  return JSON.stringify({
24
24
  error: "NANNYKEEPER_API_KEY environment variable is not set. Get a free key at nannykeeper.com/developers/keys",
@@ -47,7 +47,7 @@ export async function executeCalculate(args) {
47
47
  if (!response.ok) {
48
48
  if (response.status === 429) {
49
49
  return JSON.stringify({
50
- error: "Rate limit exceeded. Free tier allows 50 requests/day. Upgrade at nannykeeper.com/developers/pricing",
50
+ error: "Rate limit exceeded. Please wait before retrying.",
51
51
  });
52
52
  }
53
53
  return JSON.stringify({
@@ -4,6 +4,7 @@
4
4
  * Calls the NannyKeeper API to preview payroll without creating a record.
5
5
  * Returns full tax breakdown and net pay — use to validate before run_payroll.
6
6
  */
7
+ import { type ToolContext } from "../context.ts";
7
8
  export declare function executePreviewPayroll(args: {
8
9
  employer_id: string;
9
10
  employee_id: string;
@@ -19,4 +20,4 @@ export declare function executePreviewPayroll(args: {
19
20
  skip?: boolean;
20
21
  amount?: number;
21
22
  };
22
- }): Promise<string>;
23
+ }, context?: ToolContext): Promise<string>;
@@ -4,9 +4,9 @@
4
4
  * Calls the NannyKeeper API to preview payroll without creating a record.
5
5
  * Returns full tax breakdown and net pay — use to validate before run_payroll.
6
6
  */
7
- const API_BASE = process.env.NANNYKEEPER_API_URL || "https://www.nannykeeper.com";
8
- export async function executePreviewPayroll(args) {
9
- const apiKey = process.env.NANNYKEEPER_API_KEY;
7
+ import { getToolContext } from "../context.js";
8
+ export async function executePreviewPayroll(args, context) {
9
+ const { apiKey, apiBase: API_BASE } = getToolContext(context);
10
10
  if (!apiKey) {
11
11
  return JSON.stringify({
12
12
  error: "NANNYKEEPER_API_KEY environment variable is not set. Get a key at nannykeeper.com/developers/keys",
@@ -4,6 +4,7 @@
4
4
  * Calls the NannyKeeper API to run payroll for a household employee.
5
5
  * Creates a payroll record with full tax calculations and YTD tracking.
6
6
  */
7
+ import { type ToolContext } from "../context.ts";
7
8
  export declare function executeRunPayroll(args: {
8
9
  employer_id: string;
9
10
  employee_id: string;
@@ -25,4 +26,4 @@ export declare function executeRunPayroll(args: {
25
26
  };
26
27
  off_cycle?: boolean;
27
28
  idempotency_key?: string;
28
- }): Promise<string>;
29
+ }, context?: ToolContext): Promise<string>;
@@ -4,9 +4,9 @@
4
4
  * Calls the NannyKeeper API to run payroll for a household employee.
5
5
  * Creates a payroll record with full tax calculations and YTD tracking.
6
6
  */
7
- const API_BASE = process.env.NANNYKEEPER_API_URL || "https://www.nannykeeper.com";
8
- export async function executeRunPayroll(args) {
9
- const apiKey = process.env.NANNYKEEPER_API_KEY;
7
+ import { getToolContext } from "../context.js";
8
+ export async function executeRunPayroll(args, context) {
9
+ const { apiKey, apiBase: API_BASE } = getToolContext(context);
10
10
  if (!apiKey) {
11
11
  return JSON.stringify({
12
12
  error: "NANNYKEEPER_API_KEY environment variable is not set. Get a key at nannykeeper.com/developers/keys",
@@ -57,7 +57,7 @@ export async function executeRunPayroll(args) {
57
57
  if (!response.ok) {
58
58
  if (response.status === 429) {
59
59
  return JSON.stringify({
60
- error: "Rate limit exceeded. Upgrade at nannykeeper.com/developers/pricing",
60
+ error: "Rate limit exceeded. Please wait before retrying.",
61
61
  });
62
62
  }
63
63
  // Include example from error response if available (LLM self-correction)
@@ -18,39 +18,24 @@
18
18
  * via /settings/states or call the REST API explicitly with
19
19
  * confirmation context.
20
20
  */
21
+ import { type ToolContext } from "../context.ts";
21
22
  /**
22
- * ⛔ THE SINGLE DEFINITION, and `index.ts` now imports it.
23
- *
24
- * It did not. `index.ts` registered this tool with its OWN inline description
25
- * string, so this const was exported and imported by nothing — dead. NK-395
26
- * carefully rewrote it to define `not_required` and to say "never tell them to
27
- * go register for it", and none of that reached a single agent: the live
28
- * registration still promised "a registration URL for any that are missing",
29
- * which is now false, and the word `not_required` appeared in no prompt any
30
- * model would ever see.
31
- *
32
- * 🔑 That is the fourth time on this issue that a fix landed somewhere nothing
33
- * reads — after a guard keyed on an unbackfilled column, a parameter no caller
34
- * passed, and a tRPC option nothing forwarded. The pattern is the same every
35
- * time: **a second copy is the defect generator.** Two of the other tool
36
- * descriptors in this package are dead the same way and have already drifted
37
- * from what ships, which is what makes this worth removing rather than
38
- * policing. Import this; never restate it.
23
+ * The single definition of this tool's name and description. `server.ts` imports
24
+ * it rather than restating it: an inline copy there is the one agents actually
25
+ * read, so edits made here would never reach a model.
39
26
  */
40
27
  export declare const stateFilingStatusTool: {
41
28
  name: string;
42
29
  description: string;
43
30
  };
44
31
  /**
45
- * ⛔ The `employer_id` passthrough is not optional plumbing.
32
+ * The `employer_id` passthrough is required, not optional plumbing.
46
33
  *
47
- * `/api/v1/state-registrations` enforces the test/live boundary (NK-695), and
48
- * an API key's stamped household is always the user's REAL one. So a server
49
- * configured with a `nk_test_` key and no way to name a household would get a
50
- * permanent 403 here — the endpoint "enforced" by being unreachable, which is
51
- * the exact failure the route's own docblock argues against, just moved one
52
- * layer up into the tool that calls it. Found by `/code-review` on NK-695.
34
+ * `/api/v1/state-registrations` enforces the test/live boundary, and an API
35
+ * key's stored household is always the real one. A server configured with a
36
+ * `nk_test_` key and no way to name a household would therefore be refused on
37
+ * every call, with no way to reach the sandbox it is meant to work against.
53
38
  */
54
39
  export declare function executeStateFilingStatus(args?: {
55
40
  employer_id?: string;
56
- }): Promise<string>;
41
+ }, context?: ToolContext): Promise<string>;
@@ -18,25 +18,11 @@
18
18
  * via /settings/states or call the REST API explicitly with
19
19
  * confirmation context.
20
20
  */
21
- const API_BASE = process.env.NANNYKEEPER_API_URL || "https://www.nannykeeper.com";
21
+ import { getToolContext } from "../context.js";
22
22
  /**
23
- * ⛔ THE SINGLE DEFINITION, and `index.ts` now imports it.
24
- *
25
- * It did not. `index.ts` registered this tool with its OWN inline description
26
- * string, so this const was exported and imported by nothing — dead. NK-395
27
- * carefully rewrote it to define `not_required` and to say "never tell them to
28
- * go register for it", and none of that reached a single agent: the live
29
- * registration still promised "a registration URL for any that are missing",
30
- * which is now false, and the word `not_required` appeared in no prompt any
31
- * model would ever see.
32
- *
33
- * 🔑 That is the fourth time on this issue that a fix landed somewhere nothing
34
- * reads — after a guard keyed on an unbackfilled column, a parameter no caller
35
- * passed, and a tRPC option nothing forwarded. The pattern is the same every
36
- * time: **a second copy is the defect generator.** Two of the other tool
37
- * descriptors in this package are dead the same way and have already drifted
38
- * from what ships, which is what makes this worth removing rather than
39
- * policing. Import this; never restate it.
23
+ * The single definition of this tool's name and description. `server.ts` imports
24
+ * it rather than restating it: an inline copy there is the one agents actually
25
+ * read, so edits made here would never reach a model.
40
26
  */
41
27
  export const stateFilingStatusTool = {
42
28
  name: "get_state_filing_status",
@@ -52,25 +38,26 @@ export const stateFilingStatusTool = {
52
38
  "to go register for it. Use before generating " +
53
39
  "quarterly filing instructions, or when a customer asks 'do I have my " +
54
40
  "state account numbers set up?' Read-only — to update, use the REST " +
55
- "API or direct the customer to /settings/states.",
56
- // ⛔ No `inputSchema` here on purpose. There used to be one, and it was read
57
- // by NOTHING — `index.ts` passes its own zod shape to `server.tool()`, so the
58
- // declaration here reached zero agents exactly the way the inline description
59
- // above it did. Declare parameters in `index.ts`; a second copy is the defect
60
- // generator, and on this issue it has now been the dead one five times.
41
+ "API or direct the customer to /settings/states. The response also " +
42
+ "carries `obligations`: this household's FICA, FUTA and per-state " +
43
+ "unemployment status (started, not_started, exempt or unassessed), " +
44
+ "registration state, estimate, action and the agency's real due date. " +
45
+ "When `assessment` is incomplete or a status is unassessed, never tell " +
46
+ "the customer they owe nothing or are all set.",
47
+ // No `inputSchema` here on purpose: `server.ts` passes its own zod shape to
48
+ // `server.tool()`, so a declaration here would reach no agent. Declare
49
+ // parameters there.
61
50
  };
62
51
  /**
63
- * ⛔ The `employer_id` passthrough is not optional plumbing.
52
+ * The `employer_id` passthrough is required, not optional plumbing.
64
53
  *
65
- * `/api/v1/state-registrations` enforces the test/live boundary (NK-695), and
66
- * an API key's stamped household is always the user's REAL one. So a server
67
- * configured with a `nk_test_` key and no way to name a household would get a
68
- * permanent 403 here — the endpoint "enforced" by being unreachable, which is
69
- * the exact failure the route's own docblock argues against, just moved one
70
- * layer up into the tool that calls it. Found by `/code-review` on NK-695.
54
+ * `/api/v1/state-registrations` enforces the test/live boundary, and an API
55
+ * key's stored household is always the real one. A server configured with a
56
+ * `nk_test_` key and no way to name a household would therefore be refused on
57
+ * every call, with no way to reach the sandbox it is meant to work against.
71
58
  */
72
- export async function executeStateFilingStatus(args) {
73
- const apiKey = process.env.NANNYKEEPER_API_KEY;
59
+ export async function executeStateFilingStatus(args, context) {
60
+ const { apiKey, apiBase: API_BASE } = getToolContext(context);
74
61
  if (!apiKey) {
75
62
  return JSON.stringify({
76
63
  error: "NANNYKEEPER_API_KEY environment variable is not set. Get a key at nannykeeper.com/developers/keys",
@@ -107,7 +94,7 @@ export async function executeStateFilingStatus(args) {
107
94
  agency: r.agency,
108
95
  last_four: r.account_number_last_four,
109
96
  status: r.status,
110
- // ⛔ `not_required` joins `registered` here (NK-395). The upstream
97
+ // ⛔ `not_required` joins `registered` here. The upstream
111
98
  // route already nulls it, so this is belt-and-braces — but this tool
112
99
  // is what an agent actually reads, and handing it a URL for a
113
100
  // registration we just said is not required is how the agent ends up
@@ -3,16 +3,17 @@
3
3
  *
4
4
  * Calls the NannyKeeper API to check one worker's annual FICA threshold.
5
5
  */
6
+ import { type ToolContext } from "../context.ts";
6
7
  /**
7
8
  * ⛔ THE DESCRIPTOR CONST THAT USED TO LIVE HERE WAS DEAD AND HAS BEEN REMOVED.
8
9
  *
9
- * `index.ts` registers this tool with its own description, so the exported
10
+ * `server.ts` registers this tool with its own description, so the exported
10
11
  * const was imported by nothing — and had already drifted from the shipped
11
- * text in both directions. It cost NK-395 a HIGH on the sibling tool: a
12
+ * text in both directions. It has already bitten the sibling tool once: a
12
13
  * customer-facing prompt was rewritten in the dead copy while every agent kept
13
14
  * reading the stale live one.
14
15
  *
15
- * If you want a single definition here, export it AND import it in `index.ts`
16
+ * If you want a single definition here, export it AND import it in `server.ts`
16
17
  * (see `state-filing-status.ts`, which now does). A second copy nobody reads is
17
18
  * worse than no copy: it looks like the source of truth and silently is not.
18
19
  */
@@ -20,4 +21,4 @@ export declare function executeThreshold(args: {
20
21
  state: string;
21
22
  annual_wages: number;
22
23
  tax_year?: number;
23
- }): Promise<string>;
24
+ }, context?: ToolContext): Promise<string>;
@@ -3,22 +3,22 @@
3
3
  *
4
4
  * Calls the NannyKeeper API to check one worker's annual FICA threshold.
5
5
  */
6
- const API_BASE = process.env.NANNYKEEPER_API_URL || "https://www.nannykeeper.com";
6
+ import { getToolContext } from "../context.js";
7
7
  /**
8
8
  * ⛔ THE DESCRIPTOR CONST THAT USED TO LIVE HERE WAS DEAD AND HAS BEEN REMOVED.
9
9
  *
10
- * `index.ts` registers this tool with its own description, so the exported
10
+ * `server.ts` registers this tool with its own description, so the exported
11
11
  * const was imported by nothing — and had already drifted from the shipped
12
- * text in both directions. It cost NK-395 a HIGH on the sibling tool: a
12
+ * text in both directions. It has already bitten the sibling tool once: a
13
13
  * customer-facing prompt was rewritten in the dead copy while every agent kept
14
14
  * reading the stale live one.
15
15
  *
16
- * If you want a single definition here, export it AND import it in `index.ts`
16
+ * If you want a single definition here, export it AND import it in `server.ts`
17
17
  * (see `state-filing-status.ts`, which now does). A second copy nobody reads is
18
18
  * worse than no copy: it looks like the source of truth and silently is not.
19
19
  */
20
- export async function executeThreshold(args) {
21
- const apiKey = process.env.NANNYKEEPER_API_KEY;
20
+ export async function executeThreshold(args, context) {
21
+ const { apiKey, apiBase: API_BASE } = getToolContext(context);
22
22
  if (!apiKey) {
23
23
  return JSON.stringify({
24
24
  error: "NANNYKEEPER_API_KEY environment variable is not set. Get a free key at nannykeeper.com/developers/keys",
package/manifest.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": "0.3",
3
3
  "name": "nannykeeper",
4
- "version": "1.10.1",
4
+ "version": "1.14.0",
5
5
  "description": "Calculate US household employer (nanny) taxes for all 50 states. Preview and run payroll, list state agency account numbers, and manage existing Autopilot enrollments. 7 tools: calculate_nanny_taxes, check_threshold, preview_payroll, run_payroll, get_state_filing_status, get_autopilot, manage_autopilot.",
6
6
  "author": {
7
7
  "name": "nannykeeper",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nannykeeper/mcp-server",
3
- "version": "1.10.1",
3
+ "version": "1.14.0",
4
4
  "mcpName": "com.nannykeeper.www/mcp-server",
5
5
  "description": "MCP server for calculating US household employer (nanny) taxes. All 50 states. Works with Claude, ChatGPT, and any MCP-compatible AI agent.",
6
6
  "keywords": [
@@ -44,8 +44,8 @@
44
44
  "AGENTS.md"
45
45
  ],
46
46
  "scripts": {
47
- "_comment_prepublishOnly": "⛔ dist/ is gitignored, so it NEVER updates from a git pull — only from a build in that exact directory. 1.9.0 shipped from a checkout whose dist/ was 2.5 months old: no autopilot tools, no NK-395 description, no NK-695 employer_id. A version number said 1.9.0 over mid-June code, and npm versions are immutable, so the only remedy was to burn the number and cut 1.10.0. npm runs this hook in the publish directory immediately before packing, which is the one place a build cannot be in the wrong tree. Do not remove it (NK-696).",
48
- "prepublishOnly": "npm run build",
47
+ "_comment_prepack": "dist/ is gitignored, so it is refreshed only by a build in this directory. This hook runs immediately before packing (npm pack AND npm publish), in whatever directory the publish runs from, so the compiled output always matches the source being published. Do not remove it.",
48
+ "prepack": "npm run build",
49
49
  "build": "tsc",
50
50
  "dev": "tsc --watch",
51
51
  "start": "node dist/index.js",
@@ -64,4 +64,4 @@
64
64
  "engines": {
65
65
  "node": ">=18"
66
66
  }
67
- }
67
+ }