@chrischall/pickuppatrol-mcp 1.0.2 → 1.1.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-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +19 -2
- package/dist/bundle.js +545 -73
- package/dist/tools/_confirm.d.ts +31 -7
- package/dist/tools/_confirm.js +24 -15
- package/dist/tools/defaults.js +48 -15
- package/dist/tools/plans.js +19 -9
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/server.json +2 -2
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
},
|
|
7
7
|
"metadata": {
|
|
8
8
|
"description": "PickUp Patrol school-dismissal tools for Claude Code",
|
|
9
|
-
"version": "1.0
|
|
9
|
+
"version": "1.1.0"
|
|
10
10
|
},
|
|
11
11
|
"plugins": [
|
|
12
12
|
{
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"displayName": "PickUp Patrol",
|
|
15
15
|
"source": "./",
|
|
16
16
|
"description": "Read and change your children's school dismissal plans in PickUp Patrol — defaults, day-by-day changes and school cutoff times — via MCP",
|
|
17
|
-
"version": "1.0
|
|
17
|
+
"version": "1.1.0",
|
|
18
18
|
"author": {
|
|
19
19
|
"name": "Chris Chall"
|
|
20
20
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pickuppatrol",
|
|
3
3
|
"displayName": "PickUp Patrol",
|
|
4
|
-
"version": "1.0
|
|
4
|
+
"version": "1.1.0",
|
|
5
5
|
"description": "Read and change your children's school dismissal plans in PickUp Patrol — defaults, day-by-day changes and school cutoff times — via MCP",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Chris Chall"
|
package/README.md
CHANGED
|
@@ -60,8 +60,11 @@ and only reports the configuration error on the first tool call.
|
|
|
60
60
|
| `pup_list_car_numbers` | Car numbers the school issued to this account |
|
|
61
61
|
| `pup_healthcheck` | Credentials sign in and the API answers |
|
|
62
62
|
|
|
63
|
-
**Writes** — every one
|
|
64
|
-
|
|
63
|
+
**Writes** — every one asks you to confirm first. A client that can show a
|
|
64
|
+
confirmation prompt (Claude Code) shows one. Otherwise the first call makes no
|
|
65
|
+
change and returns a preview of the exact payload it would send plus a
|
|
66
|
+
`confirmToken`, and only a repeat call with that token makes the change — see
|
|
67
|
+
[Confirmations](#confirmations).
|
|
65
68
|
|
|
66
69
|
| Tool | What it changes |
|
|
67
70
|
|---|---|
|
|
@@ -69,6 +72,20 @@ change and returns a dry-run of the exact payload it would send.
|
|
|
69
72
|
| `pup_set_default_plans` | The weekly default plan, or clears every default |
|
|
70
73
|
| `pup_mark_defaults_reviewed` | The school's "defaults need review" prompt |
|
|
71
74
|
|
|
75
|
+
### Confirmations
|
|
76
|
+
|
|
77
|
+
| variable | default | |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| `MCP_CONFIRM_MODE` | `ask-user` | What a write does on a client that cannot show a confirmation prompt (claude.ai, Claude Desktop). `ask-user`: two steps — the first call does nothing and returns a preview plus a token, and the model must get your approval in chat before calling again with it. `auto`: the same two steps, but the model may use the token after reviewing the preview itself. `refuse`: writes are refused on such clients. A client that can show prompts (Claude Code) always gets the real prompt. An unrecognised value is treated as `refuse`. |
|
|
80
|
+
| `MCP_CONFIRM_TTL_SECONDS` | `600` | How long a token stays valid. |
|
|
81
|
+
| `MCP_CONFIRM_SECRET` | random per process | Signing key; set it only if tokens must survive a server restart. |
|
|
82
|
+
|
|
83
|
+
A token is single-use and bound to the exact payload. The second call re-reads
|
|
84
|
+
the student and rebuilds the payload, so if anything moved between the preview
|
|
85
|
+
and the approval — a different date or option, or (for default plans, which
|
|
86
|
+
round-trip the whole student record) a change made to the record meanwhile —
|
|
87
|
+
nothing is sent and you get `DRAFT_CHANGED` with a fresh preview.
|
|
88
|
+
|
|
72
89
|
### Two things the tools do that the API does not
|
|
73
90
|
|
|
74
91
|
**Rules are enforced before anything is sent.** Each dismissal option carries its
|
package/dist/bundle.js
CHANGED
|
@@ -23315,6 +23315,33 @@ var storage2 = new AsyncLocalStorage2();
|
|
|
23315
23315
|
function withCallerCapabilities(capabilities, fn) {
|
|
23316
23316
|
return capabilities ? storage2.run(capabilities, fn) : fn();
|
|
23317
23317
|
}
|
|
23318
|
+
function currentCallerCapabilities() {
|
|
23319
|
+
return storage2.getStore();
|
|
23320
|
+
}
|
|
23321
|
+
var ENVELOPE_CAPABILITIES_KEY = "io.modelcontextprotocol/clientCapabilities";
|
|
23322
|
+
var ELICITATION_MODES = ["form", "url"];
|
|
23323
|
+
function isRecord(value) {
|
|
23324
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23325
|
+
}
|
|
23326
|
+
function callerCapabilities(ctx) {
|
|
23327
|
+
const envelope = isRecord(ctx) && isRecord(ctx.mcpReq) ? ctx.mcpReq.envelope : void 0;
|
|
23328
|
+
if (isRecord(envelope)) {
|
|
23329
|
+
const declared = envelope[ENVELOPE_CAPABILITIES_KEY];
|
|
23330
|
+
if (isRecord(declared))
|
|
23331
|
+
return declared;
|
|
23332
|
+
}
|
|
23333
|
+
return currentCallerCapabilities();
|
|
23334
|
+
}
|
|
23335
|
+
function callerAcceptsFormElicitation(ctx) {
|
|
23336
|
+
const capabilities = callerCapabilities(ctx);
|
|
23337
|
+
if (!capabilities)
|
|
23338
|
+
return void 0;
|
|
23339
|
+
const elicitation = capabilities.elicitation;
|
|
23340
|
+
if (!isRecord(elicitation))
|
|
23341
|
+
return false;
|
|
23342
|
+
const namedModes = ELICITATION_MODES.filter((mode) => mode in elicitation);
|
|
23343
|
+
return namedModes.length === 0 || namedModes.includes("form");
|
|
23344
|
+
}
|
|
23318
23345
|
|
|
23319
23346
|
// node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs
|
|
23320
23347
|
var __create2 = Object.create;
|
|
@@ -27713,6 +27740,37 @@ var inputRequired = Object.assign(buildInputRequired, {
|
|
|
27713
27740
|
return { method: "roots/list" };
|
|
27714
27741
|
}
|
|
27715
27742
|
});
|
|
27743
|
+
function acceptedContent(responses, key, schema) {
|
|
27744
|
+
const view = inputResponse(responses, key);
|
|
27745
|
+
if (view.kind !== "elicit" || view.action !== "accept" || view.content === void 0) return void 0;
|
|
27746
|
+
if (schema === void 0) return view.content;
|
|
27747
|
+
const outcome = schema["~standard"].validate(view.content);
|
|
27748
|
+
if (outcome instanceof Promise) throw new TypeError("acceptedContent(responses, key, schema) requires a synchronously-validating schema");
|
|
27749
|
+
return outcome.issues === void 0 ? outcome.value : void 0;
|
|
27750
|
+
}
|
|
27751
|
+
function inputResponse(responses, key) {
|
|
27752
|
+
if (responses === void 0 || typeof responses !== "object" || responses === null) return { kind: "missing" };
|
|
27753
|
+
const entry = responses[key];
|
|
27754
|
+
if (entry === null || typeof entry !== "object" || Array.isArray(entry)) return { kind: "missing" };
|
|
27755
|
+
const candidate = entry;
|
|
27756
|
+
if (candidate["action"] === "accept" || candidate["action"] === "decline" || candidate["action"] === "cancel") {
|
|
27757
|
+
const content = candidate["content"];
|
|
27758
|
+
return {
|
|
27759
|
+
kind: "elicit",
|
|
27760
|
+
action: candidate["action"],
|
|
27761
|
+
...content !== null && typeof content === "object" && !Array.isArray(content) && { content }
|
|
27762
|
+
};
|
|
27763
|
+
}
|
|
27764
|
+
if (Array.isArray(candidate["roots"])) return {
|
|
27765
|
+
kind: "roots",
|
|
27766
|
+
roots: candidate["roots"]
|
|
27767
|
+
};
|
|
27768
|
+
if (typeof candidate["role"] === "string" && candidate["content"] !== void 0) return {
|
|
27769
|
+
kind: "sampling",
|
|
27770
|
+
result: candidate
|
|
27771
|
+
};
|
|
27772
|
+
return { kind: "missing" };
|
|
27773
|
+
}
|
|
27716
27774
|
var REQUEST_STATE_ONLY_LEG_PACING_MS = 250;
|
|
27717
27775
|
function inputRequiredRoundsExceededMessage(method, maxRounds) {
|
|
27718
27776
|
return `Multi-round-trip request '${method}' still required input after ${maxRounds} rounds (inputRequired.maxRounds)`;
|
|
@@ -37760,14 +37818,14 @@ function serveStdio(factory, options = {}) {
|
|
|
37760
37818
|
return false;
|
|
37761
37819
|
};
|
|
37762
37820
|
const answerLegacyRejection = (request, reason, requestedVersion) => {
|
|
37763
|
-
const
|
|
37821
|
+
const rejection3 = modernOnlyStrictRejection({
|
|
37764
37822
|
kind: "legacy",
|
|
37765
37823
|
reason,
|
|
37766
37824
|
...requestedVersion !== void 0 && { requestedVersion }
|
|
37767
37825
|
}, SUPPORTED_MODERN_PROTOCOL_VERSIONS);
|
|
37768
|
-
if (
|
|
37769
|
-
reportError(/* @__PURE__ */ new Error(`Rejected 2025-era request on a modern-only stdio connection (${
|
|
37770
|
-
return writeErrorResponse(request.id,
|
|
37826
|
+
if (rejection3 === void 0) return Promise.resolve();
|
|
37827
|
+
reportError(/* @__PURE__ */ new Error(`Rejected 2025-era request on a modern-only stdio connection (${rejection3.cell}): ${rejection3.message}`));
|
|
37828
|
+
return writeErrorResponse(request.id, rejection3.code, rejection3.message, rejection3.data);
|
|
37771
37829
|
};
|
|
37772
37830
|
const onInstanceClosed = (channel) => {
|
|
37773
37831
|
if (closing || channel === discarding) return;
|
|
@@ -57699,6 +57757,11 @@ var MEDIA_QUALIFIER = "(?:primary|secondary|main|default|cover|hero|profile|mast
|
|
|
57699
57757
|
var MEDIA_KEY = new RegExp(`^(?:(?:${MEDIA_QUALIFIER}|${MEDIA_NOUN})[_-]?)?${MEDIA_NOUN}s?(?:[_-]?(?:link|uri|url|src)s?)?$`, "i");
|
|
57700
57758
|
|
|
57701
57759
|
// node_modules/@chrischall/mcp-utils/dist/response/index.js
|
|
57760
|
+
function textResult(data) {
|
|
57761
|
+
return {
|
|
57762
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
|
|
57763
|
+
};
|
|
57764
|
+
}
|
|
57702
57765
|
function errorResult(message) {
|
|
57703
57766
|
return {
|
|
57704
57767
|
content: [{ type: "text", text: redactSecrets(message) }],
|
|
@@ -57706,6 +57769,407 @@ function errorResult(message) {
|
|
|
57706
57769
|
};
|
|
57707
57770
|
}
|
|
57708
57771
|
|
|
57772
|
+
// node_modules/@chrischall/mcp-utils/dist/server/confirmation.js
|
|
57773
|
+
import { createHash, createHmac, timingSafeEqual } from "node:crypto";
|
|
57774
|
+
|
|
57775
|
+
// node_modules/@chrischall/mcp-utils/dist/server/canonical.js
|
|
57776
|
+
function canonicalJson(value) {
|
|
57777
|
+
if (value === null || typeof value === "string" || typeof value === "boolean")
|
|
57778
|
+
return JSON.stringify(value);
|
|
57779
|
+
if (value === void 0)
|
|
57780
|
+
return "null";
|
|
57781
|
+
if (typeof value === "number")
|
|
57782
|
+
return Number.isFinite(value) ? JSON.stringify(value) : `{"$num":"${String(value)}"}`;
|
|
57783
|
+
if (typeof value === "bigint")
|
|
57784
|
+
return `{"$bigint":"${value.toString()}"}`;
|
|
57785
|
+
if (typeof value === "function" || typeof value === "symbol") {
|
|
57786
|
+
throw new TypeError(`confirmation: cannot bind a ${typeof value} argument value.`);
|
|
57787
|
+
}
|
|
57788
|
+
if (Array.isArray(value))
|
|
57789
|
+
return `[${value.map(canonicalJson).join(",")}]`;
|
|
57790
|
+
if (value instanceof Date) {
|
|
57791
|
+
return `{"$date":${JSON.stringify(Number.isNaN(value.getTime()) ? "Invalid Date" : value.toISOString())}}`;
|
|
57792
|
+
}
|
|
57793
|
+
if (ArrayBuffer.isView(value)) {
|
|
57794
|
+
const bytes = Buffer.from(value.buffer, value.byteOffset, value.byteLength);
|
|
57795
|
+
return `{"$bytes":${JSON.stringify(bytes.toString("base64"))}}`;
|
|
57796
|
+
}
|
|
57797
|
+
if (value instanceof ArrayBuffer)
|
|
57798
|
+
return `{"$bytes":${JSON.stringify(Buffer.from(value).toString("base64"))}}`;
|
|
57799
|
+
if (value instanceof Map) {
|
|
57800
|
+
const entries2 = [...value.entries()].map(([k, v]) => `[${canonicalJson(k)},${canonicalJson(v)}]`).sort();
|
|
57801
|
+
return `{"$map":[${entries2.join(",")}]}`;
|
|
57802
|
+
}
|
|
57803
|
+
if (value instanceof Set) {
|
|
57804
|
+
return `{"$set":[${[...value].map(canonicalJson).sort().join(",")}]}`;
|
|
57805
|
+
}
|
|
57806
|
+
const proto = Object.getPrototypeOf(value);
|
|
57807
|
+
if (proto !== Object.prototype && proto !== null) {
|
|
57808
|
+
throw new TypeError("confirmation: cannot bind a non-plain object argument value (class instance).");
|
|
57809
|
+
}
|
|
57810
|
+
const entries = Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
57811
|
+
return `{${entries.map(([k, v]) => `${JSON.stringify(escapeKey(k))}:${canonicalJson(v)}`).join(",")}}`;
|
|
57812
|
+
}
|
|
57813
|
+
function escapeKey(key) {
|
|
57814
|
+
return key.startsWith("$") ? `$${key}` : key;
|
|
57815
|
+
}
|
|
57816
|
+
|
|
57817
|
+
// node_modules/@chrischall/mcp-utils/dist/server/confirmation.js
|
|
57818
|
+
var DEFAULT_REQUEST_KEY = "confirmation";
|
|
57819
|
+
var DEFAULT_CONFIRMATION_LABEL = "Confirm this action should proceed.";
|
|
57820
|
+
var UNSUPPORTED_NOTE = "Nothing was done because this client cannot show a confirmation prompt (it declares no MCP elicitation capability), and this action is never taken without one";
|
|
57821
|
+
var STATE_PREFIX = "mcpu.confirm.v1.";
|
|
57822
|
+
function bindingKey(binding) {
|
|
57823
|
+
if (binding.ttlSeconds !== void 0 && !(Number.isFinite(binding.ttlSeconds) && binding.ttlSeconds > 0)) {
|
|
57824
|
+
throw new RangeError("requireConfirmation: binding.ttlSeconds must be a finite number greater than 0.");
|
|
57825
|
+
}
|
|
57826
|
+
const key = typeof binding.key === "string" ? Buffer.from(binding.key, "utf8") : Buffer.from(binding.key);
|
|
57827
|
+
if (key.length < 32) {
|
|
57828
|
+
throw new RangeError("requireConfirmation: binding.key must be at least 32 bytes.");
|
|
57829
|
+
}
|
|
57830
|
+
return key;
|
|
57831
|
+
}
|
|
57832
|
+
function commitment(action, args) {
|
|
57833
|
+
return createHash("sha256").update(`${action}\0${canonicalJson(args)}`).digest("base64url");
|
|
57834
|
+
}
|
|
57835
|
+
function mintState(key, action, binding) {
|
|
57836
|
+
const exp = Math.floor(Date.now() / 1e3) + (binding.ttlSeconds ?? 600);
|
|
57837
|
+
const body = Buffer.from(JSON.stringify({ c: commitment(action, binding.args), exp })).toString("base64url");
|
|
57838
|
+
const mac3 = createHmac("sha256", key).update(`${STATE_PREFIX}${body}`).digest("base64url");
|
|
57839
|
+
return `${STATE_PREFIX}${body}.${mac3}`;
|
|
57840
|
+
}
|
|
57841
|
+
function verifyState(key, action, binding, state) {
|
|
57842
|
+
if (typeof state !== "string" || !state.startsWith(STATE_PREFIX))
|
|
57843
|
+
return false;
|
|
57844
|
+
const rest = state.slice(STATE_PREFIX.length);
|
|
57845
|
+
const dot = rest.indexOf(".");
|
|
57846
|
+
if (dot < 0)
|
|
57847
|
+
return false;
|
|
57848
|
+
const body = rest.slice(0, dot);
|
|
57849
|
+
const mac3 = Buffer.from(rest.slice(dot + 1), "base64url");
|
|
57850
|
+
const expected = createHmac("sha256", key).update(`${STATE_PREFIX}${body}`).digest();
|
|
57851
|
+
if (mac3.length !== expected.length || !timingSafeEqual(mac3, expected))
|
|
57852
|
+
return false;
|
|
57853
|
+
let payload;
|
|
57854
|
+
try {
|
|
57855
|
+
payload = JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
|
|
57856
|
+
} catch {
|
|
57857
|
+
return false;
|
|
57858
|
+
}
|
|
57859
|
+
if (typeof payload.exp !== "number" || payload.exp * 1e3 <= Date.now())
|
|
57860
|
+
return false;
|
|
57861
|
+
const want = Buffer.from(commitment(action, binding.args));
|
|
57862
|
+
const got = Buffer.from(typeof payload.c === "string" ? payload.c : "");
|
|
57863
|
+
return got.length === want.length && timingSafeEqual(got, want);
|
|
57864
|
+
}
|
|
57865
|
+
function echoedState(ctx) {
|
|
57866
|
+
const accessor = ctx.mcpReq.requestState;
|
|
57867
|
+
return typeof accessor === "function" ? accessor() : void 0;
|
|
57868
|
+
}
|
|
57869
|
+
function requireConfirmation(ctx, options) {
|
|
57870
|
+
const requestKey = options.requestKey ?? DEFAULT_REQUEST_KEY;
|
|
57871
|
+
const key = options.binding ? bindingKey(options.binding) : void 0;
|
|
57872
|
+
const confirmationSchema = external_exports.object({
|
|
57873
|
+
confirmed: external_exports.boolean().describe(options.confirmationLabel ?? DEFAULT_CONFIRMATION_LABEL)
|
|
57874
|
+
});
|
|
57875
|
+
const ask = () => {
|
|
57876
|
+
const preview = {
|
|
57877
|
+
action: options.action,
|
|
57878
|
+
...options.details === void 0 ? {} : { details: options.details }
|
|
57879
|
+
};
|
|
57880
|
+
return inputRequired({
|
|
57881
|
+
inputRequests: {
|
|
57882
|
+
[requestKey]: inputRequired.elicit({
|
|
57883
|
+
message: `${options.message}
|
|
57884
|
+
${JSON.stringify(preview, null, 2)}`,
|
|
57885
|
+
requestedSchema: confirmationSchema
|
|
57886
|
+
})
|
|
57887
|
+
},
|
|
57888
|
+
...key && options.binding ? { requestState: mintState(key, options.action, options.binding) } : {}
|
|
57889
|
+
});
|
|
57890
|
+
};
|
|
57891
|
+
const response = inputResponse(ctx.mcpReq.inputResponses, requestKey);
|
|
57892
|
+
const accepted = acceptedContent(ctx.mcpReq.inputResponses, requestKey, confirmationSchema);
|
|
57893
|
+
if (response.kind === "missing") {
|
|
57894
|
+
if (callerAcceptsFormElicitation(ctx) === false) {
|
|
57895
|
+
return textResult({
|
|
57896
|
+
confirmed: false,
|
|
57897
|
+
dispatched: false,
|
|
57898
|
+
action: options.action,
|
|
57899
|
+
reason: "confirmation-unsupported",
|
|
57900
|
+
note: options.unsupportedNote ? `${UNSUPPORTED_NOTE}. ${options.unsupportedNote}` : `${UNSUPPORTED_NOTE}.`
|
|
57901
|
+
});
|
|
57902
|
+
}
|
|
57903
|
+
return ask();
|
|
57904
|
+
}
|
|
57905
|
+
if (response.kind === "elicit" && response.action === "accept" && accepted?.confirmed === true) {
|
|
57906
|
+
if (key && options.binding) {
|
|
57907
|
+
const state = echoedState(ctx);
|
|
57908
|
+
if (state === void 0 || state === null) {
|
|
57909
|
+
return errorResult(`Confirmation for ${options.action} was accepted, but the retry carried no requestState, so it cannot be checked against the prompt that was shown. Nothing was done. The likely cause is that the MCP client or host does not round-trip requestState (it must echo the requestState from the input_required result back on the retry); asking again would loop.`);
|
|
57910
|
+
}
|
|
57911
|
+
if (!verifyState(key, options.action, options.binding, state))
|
|
57912
|
+
return ask();
|
|
57913
|
+
}
|
|
57914
|
+
return void 0;
|
|
57915
|
+
}
|
|
57916
|
+
return textResult({
|
|
57917
|
+
confirmed: false,
|
|
57918
|
+
cancelled: true,
|
|
57919
|
+
action: options.action,
|
|
57920
|
+
note: "Nothing was changed because the confirmation was declined, cancelled, or left unchecked."
|
|
57921
|
+
});
|
|
57922
|
+
}
|
|
57923
|
+
|
|
57924
|
+
// node_modules/@chrischall/mcp-utils/dist/server/confirm-token.js
|
|
57925
|
+
import { createHash as createHash2, createHmac as createHmac2, randomBytes, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
|
|
57926
|
+
function createSpentTokenStore() {
|
|
57927
|
+
const spent = /* @__PURE__ */ new Map();
|
|
57928
|
+
return {
|
|
57929
|
+
has: (nonce) => spent.has(nonce),
|
|
57930
|
+
add: (nonce, exp) => {
|
|
57931
|
+
spent.set(nonce, exp);
|
|
57932
|
+
},
|
|
57933
|
+
prune: (now) => {
|
|
57934
|
+
for (const [nonce, exp] of spent)
|
|
57935
|
+
if (exp < now)
|
|
57936
|
+
spent.delete(nonce);
|
|
57937
|
+
},
|
|
57938
|
+
clear: () => spent.clear(),
|
|
57939
|
+
get size() {
|
|
57940
|
+
return spent.size;
|
|
57941
|
+
}
|
|
57942
|
+
};
|
|
57943
|
+
}
|
|
57944
|
+
var PROCESS_SPENT = createSpentTokenStore();
|
|
57945
|
+
var PREFIX = "mcpu.token.v1.";
|
|
57946
|
+
var DEFAULT_TTL_SECONDS = 600;
|
|
57947
|
+
function tokenKey(key) {
|
|
57948
|
+
const bytes = typeof key === "string" ? Buffer.from(key, "utf8") : Buffer.from(key);
|
|
57949
|
+
if (bytes.length < 32)
|
|
57950
|
+
throw new RangeError("confirm token: key must be at least 32 bytes.");
|
|
57951
|
+
return bytes;
|
|
57952
|
+
}
|
|
57953
|
+
function ttlOf(ttlSeconds) {
|
|
57954
|
+
if (ttlSeconds === void 0)
|
|
57955
|
+
return DEFAULT_TTL_SECONDS;
|
|
57956
|
+
if (!(Number.isFinite(ttlSeconds) && ttlSeconds > 0)) {
|
|
57957
|
+
throw new RangeError("confirm token: ttlSeconds must be a finite number greater than 0.");
|
|
57958
|
+
}
|
|
57959
|
+
return ttlSeconds;
|
|
57960
|
+
}
|
|
57961
|
+
function sign(key, body) {
|
|
57962
|
+
return createHmac2("sha256", key).update(`${PREFIX}${body}`).digest();
|
|
57963
|
+
}
|
|
57964
|
+
function hashConfirmPayload(payload) {
|
|
57965
|
+
return createHash2("sha256").update(canonicalJson(payload)).digest("base64url");
|
|
57966
|
+
}
|
|
57967
|
+
function issueConfirmToken(key, binding, options = {}) {
|
|
57968
|
+
const k = tokenKey(key);
|
|
57969
|
+
const now = options.now ?? Date.now();
|
|
57970
|
+
const exp = now + ttlOf(options.ttlSeconds) * 1e3;
|
|
57971
|
+
const claims = {
|
|
57972
|
+
t: binding.tool,
|
|
57973
|
+
...binding.account === void 0 ? {} : { a: binding.account },
|
|
57974
|
+
g: binding.target,
|
|
57975
|
+
...binding.revision === void 0 ? {} : { r: binding.revision },
|
|
57976
|
+
h: binding.payloadHash,
|
|
57977
|
+
exp,
|
|
57978
|
+
n: randomBytes(16).toString("base64url")
|
|
57979
|
+
};
|
|
57980
|
+
const body = Buffer.from(JSON.stringify(claims), "utf8").toString("base64url");
|
|
57981
|
+
return { token: `${PREFIX}${body}.${sign(k, body).toString("base64url")}`, expiresAt: new Date(exp).toISOString() };
|
|
57982
|
+
}
|
|
57983
|
+
function parseClaims(body) {
|
|
57984
|
+
try {
|
|
57985
|
+
const claims = JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
|
|
57986
|
+
return claims && typeof claims === "object" ? claims : void 0;
|
|
57987
|
+
} catch {
|
|
57988
|
+
return void 0;
|
|
57989
|
+
}
|
|
57990
|
+
}
|
|
57991
|
+
function verifyConfirmToken(key, token, binding, options = {}) {
|
|
57992
|
+
const k = tokenKey(key);
|
|
57993
|
+
const now = options.now ?? Date.now();
|
|
57994
|
+
const spent = options.spent ?? PROCESS_SPENT;
|
|
57995
|
+
spent.prune(now);
|
|
57996
|
+
if (!token.startsWith(PREFIX))
|
|
57997
|
+
return { ok: false, error: "TOKEN_INVALID" };
|
|
57998
|
+
const rest = token.slice(PREFIX.length);
|
|
57999
|
+
const dot = rest.indexOf(".");
|
|
58000
|
+
const body = dot < 0 ? "" : rest.slice(0, dot);
|
|
58001
|
+
const mac3 = Buffer.from(dot < 0 ? "" : rest.slice(dot + 1), "base64url");
|
|
58002
|
+
const expected = sign(k, body);
|
|
58003
|
+
if (!body || mac3.length !== expected.length || !timingSafeEqual2(mac3, expected))
|
|
58004
|
+
return { ok: false, error: "TOKEN_INVALID" };
|
|
58005
|
+
const claims = parseClaims(body);
|
|
58006
|
+
if (!claims)
|
|
58007
|
+
return { ok: false, error: "TOKEN_INVALID" };
|
|
58008
|
+
if (claims.t !== binding.tool || claims.a !== binding.account || claims.g !== binding.target) {
|
|
58009
|
+
return { ok: false, error: "TOKEN_INVALID" };
|
|
58010
|
+
}
|
|
58011
|
+
if (spent.has(claims.n))
|
|
58012
|
+
return { ok: false, error: "TOKEN_REUSED" };
|
|
58013
|
+
if (now > claims.exp)
|
|
58014
|
+
return { ok: false, error: "TOKEN_EXPIRED" };
|
|
58015
|
+
if (claims.r !== binding.revision)
|
|
58016
|
+
return { ok: false, error: "DRAFT_CHANGED", reason: "revision-changed" };
|
|
58017
|
+
if (claims.h !== binding.payloadHash)
|
|
58018
|
+
return { ok: false, error: "DRAFT_CHANGED", reason: "payload-changed" };
|
|
58019
|
+
spent.add(claims.n, claims.exp);
|
|
58020
|
+
return { ok: true };
|
|
58021
|
+
}
|
|
58022
|
+
var CONFIRM_TOKEN_INSTRUCTION = "Show this preview to the user verbatim and proceed only after they explicitly approve in chat. Then call again with confirmToken.";
|
|
58023
|
+
var confirmTokenParam = external_exports.string().optional().describe(`ONLY for the two-step confirmation fallback (a client without MCP elicitation). The confirmToken from this same tool's phase-1 "confirmation-required" response, passed back ONLY after the user has seen that preview and explicitly approved it in chat \u2014 never on the first call, never invented, never reused. Call again with the same arguments. Ignored when the client supports elicitation.`);
|
|
58024
|
+
var TOKEN_ERROR_NOTE = {
|
|
58025
|
+
TOKEN_EXPIRED: "Nothing was sent or changed: the confirmToken expired. Call again WITHOUT confirmToken for a fresh preview, and ask the user to approve it again.",
|
|
58026
|
+
TOKEN_REUSED: "Nothing was sent or changed by this call: this confirmToken was already used, and one approval acts once. If doing it again is really intended, call again WITHOUT confirmToken and get a new approval.",
|
|
58027
|
+
TOKEN_INVALID: "Nothing was sent or changed: this confirmToken was not issued by this server for this tool, account and target (or the server has restarted since). Call again WITHOUT confirmToken for a fresh preview and approval."
|
|
58028
|
+
};
|
|
58029
|
+
var CHANGED_NOTE = {
|
|
58030
|
+
"revision-changed": "Nothing was sent or changed: the target was edited since the user approved it (its version rotated), so what would happen is not what they saw.",
|
|
58031
|
+
"payload-changed": "Nothing was sent or changed: what would happen no longer matches what the user approved."
|
|
58032
|
+
};
|
|
58033
|
+
function isToolResult(value) {
|
|
58034
|
+
return Array.isArray(value.content);
|
|
58035
|
+
}
|
|
58036
|
+
function rejection2(data) {
|
|
58037
|
+
return { ...textResult({ status: "confirmation-rejected", confirmed: false, dispatched: false, ...data }), isError: true };
|
|
58038
|
+
}
|
|
58039
|
+
async function tokenConfirmation(action, fb) {
|
|
58040
|
+
const subject = await fb.subject();
|
|
58041
|
+
if (isToolResult(subject))
|
|
58042
|
+
return subject;
|
|
58043
|
+
const binding = {
|
|
58044
|
+
tool: fb.tool,
|
|
58045
|
+
...fb.account === void 0 ? {} : { account: fb.account },
|
|
58046
|
+
target: subject.target,
|
|
58047
|
+
...subject.revision === void 0 ? {} : { revision: subject.revision },
|
|
58048
|
+
payloadHash: hashConfirmPayload(subject.payload)
|
|
58049
|
+
};
|
|
58050
|
+
const phaseOne = () => {
|
|
58051
|
+
const { token, expiresAt } = issueConfirmToken(fb.key, binding, { ttlSeconds: fb.ttlSeconds });
|
|
58052
|
+
return {
|
|
58053
|
+
action,
|
|
58054
|
+
preview: subject.preview,
|
|
58055
|
+
confirmToken: token,
|
|
58056
|
+
expiresAt,
|
|
58057
|
+
ttlSeconds: ttlOf(fb.ttlSeconds),
|
|
58058
|
+
instruction: fb.instruction ?? CONFIRM_TOKEN_INSTRUCTION
|
|
58059
|
+
};
|
|
58060
|
+
};
|
|
58061
|
+
if (!fb.confirmToken) {
|
|
58062
|
+
return textResult({ status: "confirmation-required", confirmed: false, dispatched: false, ...phaseOne() });
|
|
58063
|
+
}
|
|
58064
|
+
const verdict = verifyConfirmToken(fb.key, fb.confirmToken, binding, { spent: fb.spent });
|
|
58065
|
+
if (verdict.ok)
|
|
58066
|
+
return void 0;
|
|
58067
|
+
if (verdict.error === "DRAFT_CHANGED") {
|
|
58068
|
+
return rejection2({
|
|
58069
|
+
error: "DRAFT_CHANGED",
|
|
58070
|
+
reason: verdict.reason,
|
|
58071
|
+
note: `${CHANGED_NOTE[verdict.reason]} The current preview and a fresh confirmToken are below.`,
|
|
58072
|
+
...phaseOne()
|
|
58073
|
+
});
|
|
58074
|
+
}
|
|
58075
|
+
return rejection2({ error: verdict.error, action, note: TOKEN_ERROR_NOTE[verdict.error] });
|
|
58076
|
+
}
|
|
58077
|
+
async function requireConfirmationWithFallback(ctx, options) {
|
|
58078
|
+
const { tokenFallback, ...confirmation } = options;
|
|
58079
|
+
if (tokenFallback && callerAcceptsFormElicitation(ctx) === false) {
|
|
58080
|
+
return tokenConfirmation(options.action, tokenFallback);
|
|
58081
|
+
}
|
|
58082
|
+
return requireConfirmation(ctx, confirmation);
|
|
58083
|
+
}
|
|
58084
|
+
|
|
58085
|
+
// node_modules/@chrischall/mcp-utils/dist/server/confirm-env.js
|
|
58086
|
+
import { createHash as createHash3, randomBytes as randomBytes2 } from "node:crypto";
|
|
58087
|
+
|
|
58088
|
+
// node_modules/@chrischall/mcp-utils/dist/config/index.js
|
|
58089
|
+
var PLACEHOLDER_RE = /^\$\{[^}]*\}$/;
|
|
58090
|
+
function readEnvVar(key, opts = {}) {
|
|
58091
|
+
const env = opts.env ?? process.env;
|
|
58092
|
+
const raw = env[key];
|
|
58093
|
+
if (typeof raw === "string") {
|
|
58094
|
+
const trimmed = raw.trim();
|
|
58095
|
+
if (trimmed.length > 0 && trimmed !== "undefined" && trimmed !== "null" && !PLACEHOLDER_RE.test(trimmed)) {
|
|
58096
|
+
return trimmed;
|
|
58097
|
+
}
|
|
58098
|
+
}
|
|
58099
|
+
return opts.default;
|
|
58100
|
+
}
|
|
58101
|
+
async function loadDotenvSafely(opts = {}) {
|
|
58102
|
+
try {
|
|
58103
|
+
const mod = await import(
|
|
58104
|
+
/* @vite-ignore */
|
|
58105
|
+
"dotenv"
|
|
58106
|
+
);
|
|
58107
|
+
const result = mod.config({
|
|
58108
|
+
...opts.path !== void 0 ? { path: opts.path } : {},
|
|
58109
|
+
override: opts.override ?? false,
|
|
58110
|
+
quiet: true
|
|
58111
|
+
});
|
|
58112
|
+
return result.error === void 0;
|
|
58113
|
+
} catch {
|
|
58114
|
+
return false;
|
|
58115
|
+
}
|
|
58116
|
+
}
|
|
58117
|
+
|
|
58118
|
+
// node_modules/@chrischall/mcp-utils/dist/server/confirm-env.js
|
|
58119
|
+
var MODES = /* @__PURE__ */ new Set(["ask-user", "auto", "refuse"]);
|
|
58120
|
+
var DEFAULT_TTL_SECONDS2 = 600;
|
|
58121
|
+
var warned = /* @__PURE__ */ new Set();
|
|
58122
|
+
function readConfirmMode(env = process.env) {
|
|
58123
|
+
const raw = readEnvVar("MCP_CONFIRM_MODE", { env })?.trim().toLowerCase();
|
|
58124
|
+
if (!raw)
|
|
58125
|
+
return "ask-user";
|
|
58126
|
+
if (MODES.has(raw))
|
|
58127
|
+
return raw;
|
|
58128
|
+
if (!warned.has(raw)) {
|
|
58129
|
+
warned.add(raw);
|
|
58130
|
+
process.stderr.write(`MCP_CONFIRM_MODE="${raw}" is not one of ask-user, auto, refuse; treating it as refuse.
|
|
58131
|
+
`);
|
|
58132
|
+
}
|
|
58133
|
+
return "refuse";
|
|
58134
|
+
}
|
|
58135
|
+
function confirmTtlFromEnv(env = process.env) {
|
|
58136
|
+
const raw = readEnvVar("MCP_CONFIRM_TTL_SECONDS", { env })?.trim();
|
|
58137
|
+
return raw && /^[1-9]\d*$/.test(raw) ? Number(raw) : DEFAULT_TTL_SECONDS2;
|
|
58138
|
+
}
|
|
58139
|
+
var processKey;
|
|
58140
|
+
function confirmKeyFromEnv(env = process.env) {
|
|
58141
|
+
const secret = readEnvVar("MCP_CONFIRM_SECRET", { env });
|
|
58142
|
+
if (secret)
|
|
58143
|
+
return createHash3("sha256").update(secret, "utf8").digest();
|
|
58144
|
+
processKey ??= randomBytes2(32);
|
|
58145
|
+
return processKey;
|
|
58146
|
+
}
|
|
58147
|
+
var CONFIRM_TOKEN_AUTO_INSTRUCTION = "Nothing has been done yet. Review this preview; if it is what was intended, call again with the same arguments plus confirmToken. (This server runs with MCP_CONFIRM_MODE=auto, so the user's approval in chat is not required.)";
|
|
58148
|
+
var REFUSE_HINT = "Set MCP_CONFIRM_MODE=ask-user on the server to allow two-step confirmation instead.";
|
|
58149
|
+
function confirmationFromEnv(options) {
|
|
58150
|
+
const { tool, account, confirmToken, subject, instruction, spent, env = process.env, ...confirmation } = options;
|
|
58151
|
+
const mode = readConfirmMode(env);
|
|
58152
|
+
if (mode === "refuse") {
|
|
58153
|
+
return {
|
|
58154
|
+
...confirmation,
|
|
58155
|
+
unsupportedNote: confirmation.unsupportedNote ? `${confirmation.unsupportedNote} ${REFUSE_HINT}` : REFUSE_HINT
|
|
58156
|
+
};
|
|
58157
|
+
}
|
|
58158
|
+
return {
|
|
58159
|
+
...confirmation,
|
|
58160
|
+
tokenFallback: {
|
|
58161
|
+
key: confirmKeyFromEnv(env),
|
|
58162
|
+
tool,
|
|
58163
|
+
...account === void 0 ? {} : { account },
|
|
58164
|
+
...confirmToken === void 0 ? {} : { confirmToken },
|
|
58165
|
+
subject,
|
|
58166
|
+
ttlSeconds: confirmTtlFromEnv(env),
|
|
58167
|
+
instruction: mode === "auto" ? CONFIRM_TOKEN_AUTO_INSTRUCTION : instruction ?? CONFIRM_TOKEN_INSTRUCTION,
|
|
58168
|
+
...spent === void 0 ? {} : { spent }
|
|
58169
|
+
}
|
|
58170
|
+
};
|
|
58171
|
+
}
|
|
58172
|
+
|
|
57709
58173
|
// node_modules/@chrischall/mcp-utils/dist/server/index.js
|
|
57710
58174
|
var SERVER_PROTOCOL_VERSIONS = Object.freeze([
|
|
57711
58175
|
"2026-07-28",
|
|
@@ -57881,36 +58345,6 @@ function runMcp(opts) {
|
|
|
57881
58345
|
return handle;
|
|
57882
58346
|
}
|
|
57883
58347
|
|
|
57884
|
-
// node_modules/@chrischall/mcp-utils/dist/config/index.js
|
|
57885
|
-
var PLACEHOLDER_RE = /^\$\{[^}]*\}$/;
|
|
57886
|
-
function readEnvVar(key, opts = {}) {
|
|
57887
|
-
const env = opts.env ?? process.env;
|
|
57888
|
-
const raw = env[key];
|
|
57889
|
-
if (typeof raw === "string") {
|
|
57890
|
-
const trimmed = raw.trim();
|
|
57891
|
-
if (trimmed.length > 0 && trimmed !== "undefined" && trimmed !== "null" && !PLACEHOLDER_RE.test(trimmed)) {
|
|
57892
|
-
return trimmed;
|
|
57893
|
-
}
|
|
57894
|
-
}
|
|
57895
|
-
return opts.default;
|
|
57896
|
-
}
|
|
57897
|
-
async function loadDotenvSafely(opts = {}) {
|
|
57898
|
-
try {
|
|
57899
|
-
const mod = await import(
|
|
57900
|
-
/* @vite-ignore */
|
|
57901
|
-
"dotenv"
|
|
57902
|
-
);
|
|
57903
|
-
const result = mod.config({
|
|
57904
|
-
...opts.path !== void 0 ? { path: opts.path } : {},
|
|
57905
|
-
override: opts.override ?? false,
|
|
57906
|
-
quiet: true
|
|
57907
|
-
});
|
|
57908
|
-
return result.error === void 0;
|
|
57909
|
-
} catch {
|
|
57910
|
-
return false;
|
|
57911
|
-
}
|
|
57912
|
-
}
|
|
57913
|
-
|
|
57914
58348
|
// node_modules/@chrischall/mcp-utils/dist/http/index.js
|
|
57915
58349
|
function buildQueryString(params) {
|
|
57916
58350
|
const parts = [];
|
|
@@ -58316,7 +58750,7 @@ var PickUpPatrolClient = class {
|
|
|
58316
58750
|
var client = new PickUpPatrolClient();
|
|
58317
58751
|
|
|
58318
58752
|
// src/version.ts
|
|
58319
|
-
var VERSION = "1.0
|
|
58753
|
+
var VERSION = "1.1.0";
|
|
58320
58754
|
|
|
58321
58755
|
// src/dates.ts
|
|
58322
58756
|
var WEEKDAY_NAMES = [
|
|
@@ -58662,16 +59096,26 @@ function clearDefaultPlans(student) {
|
|
|
58662
59096
|
}
|
|
58663
59097
|
|
|
58664
59098
|
// src/tools/_confirm.ts
|
|
58665
|
-
|
|
58666
|
-
|
|
58667
|
-
|
|
58668
|
-
|
|
58669
|
-
|
|
58670
|
-
|
|
58671
|
-
|
|
58672
|
-
|
|
58673
|
-
|
|
58674
|
-
|
|
59099
|
+
var CONFIRM_FLOW = "Asks the user to confirm first: a confirmation prompt where the client supports one; otherwise the first call returns a preview and a confirmToken, and only a repeat call with that token proceeds (see MCP_CONFIRM_MODE).";
|
|
59100
|
+
function confirmWrite(ctx, options) {
|
|
59101
|
+
const { tool, action, summary, method, dto, target, revision, payload, willSend, confirmToken } = options;
|
|
59102
|
+
const preview = { action: summary, method, dto, willSend: willSend ?? payload };
|
|
59103
|
+
return requireConfirmationWithFallback(
|
|
59104
|
+
ctx,
|
|
59105
|
+
confirmationFromEnv({
|
|
59106
|
+
action,
|
|
59107
|
+
message: `Review and confirm this change: ${summary}`,
|
|
59108
|
+
details: preview,
|
|
59109
|
+
tool,
|
|
59110
|
+
confirmToken,
|
|
59111
|
+
subject: () => ({
|
|
59112
|
+
target,
|
|
59113
|
+
...revision ? { revision } : {},
|
|
59114
|
+
payload,
|
|
59115
|
+
preview
|
|
59116
|
+
})
|
|
59117
|
+
})
|
|
59118
|
+
);
|
|
58675
59119
|
}
|
|
58676
59120
|
|
|
58677
59121
|
// src/tools/plans.ts
|
|
@@ -58738,7 +59182,7 @@ function registerPlanTools(server, client2) {
|
|
|
58738
59182
|
server.registerTool(
|
|
58739
59183
|
"pup_set_plan",
|
|
58740
59184
|
{
|
|
58741
|
-
description:
|
|
59185
|
+
description: `Change how a student is dismissed on one or more specific dates, or clear those dates back to the student's weekly default. This changes how a child actually leaves school. ${CONFIRM_FLOW} The preview shows the exact payload. Read pup_list_transportations first \u2014 options differ in whether they require a note, a car number or an early-dismissal time.`,
|
|
58742
59186
|
inputSchema: external_exports.object({
|
|
58743
59187
|
student_id: external_exports.number().int().describe("Student id, from pup_list_students"),
|
|
58744
59188
|
dates: external_exports.array(external_exports.string()).min(1).describe("One or more YYYY-MM-DD dates to apply this plan to"),
|
|
@@ -58748,10 +59192,10 @@ function registerPlanTools(server, client2) {
|
|
|
58748
59192
|
note: external_exports.string().optional().describe("Note for the school; required by some options"),
|
|
58749
59193
|
early_dismissal_time: external_exports.string().optional().describe("HH:MM, required when the option is an early dismissal"),
|
|
58750
59194
|
car_number: external_exports.string().optional().describe("Car number, for options where usesCarNumbers is true"),
|
|
58751
|
-
|
|
59195
|
+
confirmToken: confirmTokenParam
|
|
58752
59196
|
})
|
|
58753
59197
|
},
|
|
58754
|
-
(async ({ student_id, dates, transportation_id, note, early_dismissal_time, car_number,
|
|
59198
|
+
(async ({ student_id, dates, transportation_id, note, early_dismissal_time, car_number, confirmToken }, ctx) => {
|
|
58755
59199
|
const student = await client2.getStudent(student_id);
|
|
58756
59200
|
const transportation = transportation_id === null ? null : await resolveTransportation(client2, student.SchoolId, transportation_id);
|
|
58757
59201
|
const plans = buildPlanUpdates({
|
|
@@ -58763,7 +59207,16 @@ function registerPlanTools(server, client2) {
|
|
|
58763
59207
|
carNumber: car_number
|
|
58764
59208
|
});
|
|
58765
59209
|
const action = transportation === null ? `Clear ${dates.length} date(s) back to ${student.FirstName ?? "the student"}'s default plan` : `Set ${dates.length} date(s) for ${student.FirstName ?? "the student"} to "${transportation.Name}"`;
|
|
58766
|
-
const gate =
|
|
59210
|
+
const gate = await confirmWrite(ctx, {
|
|
59211
|
+
tool: "pup_set_plan",
|
|
59212
|
+
action: "plans.set",
|
|
59213
|
+
summary: action,
|
|
59214
|
+
method: "PUT",
|
|
59215
|
+
dto: "UpdatePlans",
|
|
59216
|
+
target: String(student_id),
|
|
59217
|
+
payload: { Plans: plans },
|
|
59218
|
+
confirmToken
|
|
59219
|
+
});
|
|
58767
59220
|
if (gate) return gate;
|
|
58768
59221
|
await client2.updatePlans(plans);
|
|
58769
59222
|
const expected = expectedPlanState({
|
|
@@ -58857,7 +59310,7 @@ function registerDefaultPlanTools(server, client2) {
|
|
|
58857
59310
|
server.registerTool(
|
|
58858
59311
|
"pup_set_default_plans",
|
|
58859
59312
|
{
|
|
58860
|
-
description:
|
|
59313
|
+
description: `Change a student's weekly default dismissal plan for one or more weekdays, or clear every default. This is how the child leaves school on any date without a specific plan. ${CONFIRM_FLOW} Read pup_list_transportations first.`,
|
|
58861
59314
|
inputSchema: external_exports.object({
|
|
58862
59315
|
student_id: external_exports.number().int().describe("Student id, from pup_list_students"),
|
|
58863
59316
|
days: external_exports.array(external_exports.union([external_exports.string(), external_exports.number().int()])).optional().describe('Weekdays to change, as names ("Monday") or ids (1 = Sunday \u2026 7 = Saturday)'),
|
|
@@ -58865,20 +59318,25 @@ function registerDefaultPlanTools(server, client2) {
|
|
|
58865
59318
|
note: external_exports.string().optional().describe("Note for the school; required by some options"),
|
|
58866
59319
|
early_dismissal_time: external_exports.string().optional().describe("HH:MM, required when the option is an early dismissal"),
|
|
58867
59320
|
clear_all: external_exports.boolean().optional().describe("Remove every weekday default instead of setting one (days is ignored)"),
|
|
58868
|
-
|
|
59321
|
+
confirmToken: confirmTokenParam
|
|
58869
59322
|
})
|
|
58870
59323
|
},
|
|
58871
|
-
(async ({ student_id, days, transportation_id, note, early_dismissal_time, clear_all,
|
|
59324
|
+
(async ({ student_id, days, transportation_id, note, early_dismissal_time, clear_all, confirmToken }, ctx) => {
|
|
58872
59325
|
const student = await client2.getStudent(student_id);
|
|
58873
59326
|
if (clear_all === true) {
|
|
58874
59327
|
const payload2 = clearDefaultPlans(student);
|
|
58875
|
-
const gate2 =
|
|
58876
|
-
|
|
58877
|
-
|
|
58878
|
-
"
|
|
58879
|
-
"
|
|
58880
|
-
|
|
58881
|
-
|
|
59328
|
+
const gate2 = await confirmWrite(ctx, {
|
|
59329
|
+
tool: "pup_set_default_plans",
|
|
59330
|
+
action: "default_plans.clear",
|
|
59331
|
+
summary: `Clear every weekday default for ${student.FirstName ?? "the student"}`,
|
|
59332
|
+
method: "PUT",
|
|
59333
|
+
dto: "Student",
|
|
59334
|
+
target: String(student_id),
|
|
59335
|
+
revision: student.ModifiedDate,
|
|
59336
|
+
payload: payload2,
|
|
59337
|
+
willSend: { StudentId: student.StudentId, DefaultPlans: [] },
|
|
59338
|
+
confirmToken
|
|
59339
|
+
});
|
|
58882
59340
|
if (gate2) return gate2;
|
|
58883
59341
|
await client2.updateStudent(payload2);
|
|
58884
59342
|
const after2 = await client2.getStudent(student_id);
|
|
@@ -58910,10 +59368,21 @@ function registerDefaultPlanTools(server, client2) {
|
|
|
58910
59368
|
});
|
|
58911
59369
|
const dayNames = dayIds.map((id) => dayIdToName(id)).join(", ");
|
|
58912
59370
|
const action = `Set ${student.FirstName ?? "the student"}'s default plan on ${dayNames} to "${transportation.Name}"`;
|
|
58913
|
-
const gate =
|
|
58914
|
-
|
|
58915
|
-
|
|
58916
|
-
|
|
59371
|
+
const gate = await confirmWrite(ctx, {
|
|
59372
|
+
tool: "pup_set_default_plans",
|
|
59373
|
+
action: "default_plans.set",
|
|
59374
|
+
summary: action,
|
|
59375
|
+
method: "PUT",
|
|
59376
|
+
dto: "Student",
|
|
59377
|
+
target: String(student_id),
|
|
59378
|
+
revision: student.ModifiedDate,
|
|
59379
|
+
payload,
|
|
59380
|
+
willSend: {
|
|
59381
|
+
StudentId: student.StudentId,
|
|
59382
|
+
DefaultPlans: payload.DefaultPlans,
|
|
59383
|
+
note: "The whole student record is sent back with only DefaultPlans changed."
|
|
59384
|
+
},
|
|
59385
|
+
confirmToken
|
|
58917
59386
|
});
|
|
58918
59387
|
if (gate) return gate;
|
|
58919
59388
|
await client2.updateStudent(payload);
|
|
@@ -58949,22 +59418,25 @@ function registerDefaultPlanTools(server, client2) {
|
|
|
58949
59418
|
server.registerTool(
|
|
58950
59419
|
"pup_mark_defaults_reviewed",
|
|
58951
59420
|
{
|
|
58952
|
-
description:
|
|
59421
|
+
description: `Mark a student's default plans as reviewed, clearing the school's 'needs review' prompt. ${CONFIRM_FLOW}`,
|
|
58953
59422
|
inputSchema: external_exports.object({
|
|
58954
59423
|
student_id: external_exports.number().int().describe("Student id, from pup_list_students"),
|
|
58955
59424
|
reviewed: external_exports.boolean().optional().describe("Defaults to true"),
|
|
58956
|
-
|
|
59425
|
+
confirmToken: confirmTokenParam
|
|
58957
59426
|
})
|
|
58958
59427
|
},
|
|
58959
|
-
async ({ student_id, reviewed,
|
|
59428
|
+
async ({ student_id, reviewed, confirmToken }, ctx) => {
|
|
58960
59429
|
const value = reviewed ?? true;
|
|
58961
|
-
const gate =
|
|
58962
|
-
|
|
58963
|
-
|
|
58964
|
-
"
|
|
58965
|
-
"
|
|
58966
|
-
|
|
58967
|
-
|
|
59430
|
+
const gate = await confirmWrite(ctx, {
|
|
59431
|
+
tool: "pup_mark_defaults_reviewed",
|
|
59432
|
+
action: "default_plans.mark_reviewed",
|
|
59433
|
+
summary: `Mark student ${student_id}'s defaults as ${value ? "reviewed" : "not reviewed"}`,
|
|
59434
|
+
method: "PUT",
|
|
59435
|
+
dto: "SetDefaultsReviewed",
|
|
59436
|
+
target: String(student_id),
|
|
59437
|
+
payload: { StudentId: student_id, Reviewed: value },
|
|
59438
|
+
confirmToken
|
|
59439
|
+
});
|
|
58968
59440
|
if (gate) return gate;
|
|
58969
59441
|
await client2.setDefaultsReviewed(student_id, value);
|
|
58970
59442
|
const review = await client2.getDefaultPlansReviewNeeded();
|
package/dist/tools/_confirm.d.ts
CHANGED
|
@@ -1,13 +1,37 @@
|
|
|
1
|
-
import type { CallToolResult } from '@modelcontextprotocol/server';
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
1
|
+
import type { CallToolResult, InputRequiredResult, ServerContext } from '@modelcontextprotocol/server';
|
|
2
|
+
import { confirmTokenParam } from '@chrischall/mcp-utils';
|
|
3
|
+
export { confirmTokenParam };
|
|
4
|
+
/** What every gated tool's description says about the confirmation step. */
|
|
5
|
+
export declare const CONFIRM_FLOW = "Asks the user to confirm first: a confirmation prompt where the client supports one; otherwise the first call returns a preview and a confirmToken, and only a repeat call with that token proceeds (see MCP_CONFIRM_MODE).";
|
|
6
|
+
export interface ConfirmWriteOptions {
|
|
7
|
+
/** The tool name the token is bound to. */
|
|
8
|
+
tool: string;
|
|
9
|
+
/** `<service>.<verb>` identifier for the operation. */
|
|
10
|
+
action: string;
|
|
11
|
+
/** Human-readable sentence describing what will change. */
|
|
12
|
+
summary: string;
|
|
13
|
+
method: string;
|
|
14
|
+
dto: string;
|
|
15
|
+
/** The primary id acted on. */
|
|
16
|
+
target: string;
|
|
17
|
+
/** A version of the target that rotates on edit, when the API has one. */
|
|
18
|
+
revision?: string | null | undefined;
|
|
19
|
+
/** EXACTLY what the write will send — hashed into the token. */
|
|
20
|
+
payload: unknown;
|
|
21
|
+
/** What the preview shows as `willSend`; defaults to `payload`. */
|
|
22
|
+
willSend?: unknown;
|
|
23
|
+
/** The phase-2 token from the tool's input. */
|
|
24
|
+
confirmToken: string | undefined;
|
|
25
|
+
}
|
|
4
26
|
/**
|
|
5
|
-
* Confirm-gate for a mutating tool
|
|
6
|
-
*
|
|
7
|
-
* preview
|
|
27
|
+
* Confirm-gate for a mutating tool. A client that can show a prompt gets one;
|
|
28
|
+
* one that cannot gets the two-step token flow (MCP_CONFIRM_MODE): phase 1
|
|
29
|
+
* makes **no** write and returns the preview plus a token, phase 2 proceeds
|
|
30
|
+
* only if the freshly rebuilt payload still matches what was previewed.
|
|
31
|
+
* `undefined` means proceed; anything else is the result to return.
|
|
8
32
|
*
|
|
9
33
|
* The gate matters more here than in most of the fleet: these writes change
|
|
10
34
|
* how a child leaves school. A hallucinated call must not silently put a
|
|
11
35
|
* student on a different bus.
|
|
12
36
|
*/
|
|
13
|
-
export declare function
|
|
37
|
+
export declare function confirmWrite(ctx: ServerContext, options: ConfirmWriteOptions): Promise<InputRequiredResult | CallToolResult | undefined>;
|
package/dist/tools/_confirm.js
CHANGED
|
@@ -1,23 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { confirmationFromEnv, confirmTokenParam, requireConfirmationWithFallback, } from '@chrischall/mcp-utils';
|
|
2
|
+
export { confirmTokenParam };
|
|
3
|
+
/** What every gated tool's description says about the confirmation step. */
|
|
4
|
+
export const CONFIRM_FLOW = 'Asks the user to confirm first: a confirmation prompt where the client supports one; otherwise the first call returns a preview and a confirmToken, and only a repeat call with that token proceeds (see MCP_CONFIRM_MODE).';
|
|
3
5
|
/**
|
|
4
|
-
* Confirm-gate for a mutating tool
|
|
5
|
-
*
|
|
6
|
-
* preview
|
|
6
|
+
* Confirm-gate for a mutating tool. A client that can show a prompt gets one;
|
|
7
|
+
* one that cannot gets the two-step token flow (MCP_CONFIRM_MODE): phase 1
|
|
8
|
+
* makes **no** write and returns the preview plus a token, phase 2 proceeds
|
|
9
|
+
* only if the freshly rebuilt payload still matches what was previewed.
|
|
10
|
+
* `undefined` means proceed; anything else is the result to return.
|
|
7
11
|
*
|
|
8
12
|
* The gate matters more here than in most of the fleet: these writes change
|
|
9
13
|
* how a child leaves school. A hallucinated call must not silently put a
|
|
10
14
|
* student on a different bus.
|
|
11
15
|
*/
|
|
12
|
-
export function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return
|
|
16
|
-
dryRun: true,
|
|
16
|
+
export function confirmWrite(ctx, options) {
|
|
17
|
+
const { tool, action, summary, method, dto, target, revision, payload, willSend, confirmToken } = options;
|
|
18
|
+
const preview = { action: summary, method, dto, willSend: willSend ?? payload };
|
|
19
|
+
return requireConfirmationWithFallback(ctx, confirmationFromEnv({
|
|
17
20
|
action,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
message: `Review and confirm this change: ${summary}`,
|
|
22
|
+
details: preview,
|
|
23
|
+
tool,
|
|
24
|
+
confirmToken,
|
|
25
|
+
subject: () => ({
|
|
26
|
+
target,
|
|
27
|
+
...(revision ? { revision } : {}),
|
|
28
|
+
payload,
|
|
29
|
+
preview,
|
|
30
|
+
}),
|
|
31
|
+
}));
|
|
23
32
|
}
|
package/dist/tools/defaults.js
CHANGED
|
@@ -4,7 +4,7 @@ import { applyDefaultPlans, clearDefaultPlans } from '../plans.js';
|
|
|
4
4
|
import { dayIdToName, nameToDayId } from '../dates.js';
|
|
5
5
|
import { summarizeDefaultPlans } from './account.js';
|
|
6
6
|
import { proofsMatch, resolveTransportation } from './plans.js';
|
|
7
|
-
import {
|
|
7
|
+
import { CONFIRM_FLOW, confirmTokenParam, confirmWrite } from './_confirm.js';
|
|
8
8
|
/**
|
|
9
9
|
* Accept weekdays as names ("Monday") or ids (1 = Sunday … 7 = Saturday).
|
|
10
10
|
* A name that is not a weekday is rejected rather than coerced — silently
|
|
@@ -54,7 +54,7 @@ export function registerDefaultPlanTools(server, client) {
|
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
56
|
server.registerTool('pup_set_default_plans', {
|
|
57
|
-
description:
|
|
57
|
+
description: `Change a student's weekly default dismissal plan for one or more weekdays, or clear every default. This is how the child leaves school on any date without a specific plan. ${CONFIRM_FLOW} Read pup_list_transportations first.`,
|
|
58
58
|
inputSchema: z.object({
|
|
59
59
|
student_id: z.number().int().describe('Student id, from pup_list_students'),
|
|
60
60
|
days: z
|
|
@@ -75,17 +75,30 @@ export function registerDefaultPlanTools(server, client) {
|
|
|
75
75
|
.boolean()
|
|
76
76
|
.optional()
|
|
77
77
|
.describe('Remove every weekday default instead of setting one (days is ignored)'),
|
|
78
|
-
|
|
78
|
+
confirmToken: confirmTokenParam,
|
|
79
79
|
}),
|
|
80
|
-
}, (async ({ student_id, days, transportation_id, note, early_dismissal_time, clear_all,
|
|
80
|
+
}, (async ({ student_id, days, transportation_id, note, early_dismissal_time, clear_all, confirmToken }, ctx) => {
|
|
81
81
|
// Read-modify-write: PickUp Patrol has no default-plans endpoint, so the
|
|
82
82
|
// whole student record round-trips. Reading it here (before the confirm
|
|
83
|
-
// gate) is what makes the
|
|
84
|
-
// nothing.
|
|
83
|
+
// gate, on every call) is what makes the preview show the real payload;
|
|
84
|
+
// it mutates nothing. The whole record is the token's payload, so a
|
|
85
|
+
// change to it between preview and approval — which this write would
|
|
86
|
+
// otherwise silently overwrite — is refused as DRAFT_CHANGED.
|
|
85
87
|
const student = await client.getStudent(student_id);
|
|
86
88
|
if (clear_all === true) {
|
|
87
89
|
const payload = clearDefaultPlans(student);
|
|
88
|
-
const gate =
|
|
90
|
+
const gate = await confirmWrite(ctx, {
|
|
91
|
+
tool: 'pup_set_default_plans',
|
|
92
|
+
action: 'default_plans.clear',
|
|
93
|
+
summary: `Clear every weekday default for ${student.FirstName ?? 'the student'}`,
|
|
94
|
+
method: 'PUT',
|
|
95
|
+
dto: 'Student',
|
|
96
|
+
target: String(student_id),
|
|
97
|
+
revision: student.ModifiedDate,
|
|
98
|
+
payload,
|
|
99
|
+
willSend: { StudentId: student.StudentId, DefaultPlans: [] },
|
|
100
|
+
confirmToken,
|
|
101
|
+
});
|
|
89
102
|
if (gate)
|
|
90
103
|
return gate;
|
|
91
104
|
await client.updateStudent(payload);
|
|
@@ -116,10 +129,21 @@ export function registerDefaultPlanTools(server, client) {
|
|
|
116
129
|
});
|
|
117
130
|
const dayNames = dayIds.map((id) => dayIdToName(id)).join(', ');
|
|
118
131
|
const action = `Set ${student.FirstName ?? 'the student'}'s default plan on ${dayNames} to "${transportation.Name}"`;
|
|
119
|
-
const gate =
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
132
|
+
const gate = await confirmWrite(ctx, {
|
|
133
|
+
tool: 'pup_set_default_plans',
|
|
134
|
+
action: 'default_plans.set',
|
|
135
|
+
summary: action,
|
|
136
|
+
method: 'PUT',
|
|
137
|
+
dto: 'Student',
|
|
138
|
+
target: String(student_id),
|
|
139
|
+
revision: student.ModifiedDate,
|
|
140
|
+
payload,
|
|
141
|
+
willSend: {
|
|
142
|
+
StudentId: student.StudentId,
|
|
143
|
+
DefaultPlans: payload.DefaultPlans,
|
|
144
|
+
note: 'The whole student record is sent back with only DefaultPlans changed.',
|
|
145
|
+
},
|
|
146
|
+
confirmToken,
|
|
123
147
|
});
|
|
124
148
|
if (gate)
|
|
125
149
|
return gate;
|
|
@@ -161,15 +185,24 @@ export function registerDefaultPlanTools(server, client) {
|
|
|
161
185
|
});
|
|
162
186
|
}));
|
|
163
187
|
server.registerTool('pup_mark_defaults_reviewed', {
|
|
164
|
-
description:
|
|
188
|
+
description: `Mark a student's default plans as reviewed, clearing the school's 'needs review' prompt. ${CONFIRM_FLOW}`,
|
|
165
189
|
inputSchema: z.object({
|
|
166
190
|
student_id: z.number().int().describe('Student id, from pup_list_students'),
|
|
167
191
|
reviewed: z.boolean().optional().describe('Defaults to true'),
|
|
168
|
-
|
|
192
|
+
confirmToken: confirmTokenParam,
|
|
169
193
|
}),
|
|
170
|
-
}, async ({ student_id, reviewed,
|
|
194
|
+
}, async ({ student_id, reviewed, confirmToken }, ctx) => {
|
|
171
195
|
const value = reviewed ?? true;
|
|
172
|
-
const gate =
|
|
196
|
+
const gate = await confirmWrite(ctx, {
|
|
197
|
+
tool: 'pup_mark_defaults_reviewed',
|
|
198
|
+
action: 'default_plans.mark_reviewed',
|
|
199
|
+
summary: `Mark student ${student_id}'s defaults as ${value ? 'reviewed' : 'not reviewed'}`,
|
|
200
|
+
method: 'PUT',
|
|
201
|
+
dto: 'SetDefaultsReviewed',
|
|
202
|
+
target: String(student_id),
|
|
203
|
+
payload: { StudentId: student_id, Reviewed: value },
|
|
204
|
+
confirmToken,
|
|
205
|
+
});
|
|
173
206
|
if (gate)
|
|
174
207
|
return gate;
|
|
175
208
|
await client.setDefaultsReviewed(student_id, value);
|
package/dist/tools/plans.js
CHANGED
|
@@ -2,7 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { McpToolError, minifiedResult } from '@chrischall/mcp-utils';
|
|
3
3
|
import { buildPlanUpdates } from '../plans.js';
|
|
4
4
|
import { weekdayOf } from '../dates.js';
|
|
5
|
-
import {
|
|
5
|
+
import { CONFIRM_FLOW, confirmTokenParam, confirmWrite } from './_confirm.js';
|
|
6
6
|
/**
|
|
7
7
|
* Reduce a time of day to `HH:MM:SS` so a read-back can be compared with what
|
|
8
8
|
* was sent. Accepts `H:MM`, `HH:MM:SS`, an ISO date-time, and the XSD duration
|
|
@@ -90,7 +90,7 @@ export function registerPlanTools(server, client) {
|
|
|
90
90
|
}),
|
|
91
91
|
}, async ({ student_id, date }) => minifiedResult(await client.getPlanEdit(date, student_id)));
|
|
92
92
|
server.registerTool('pup_set_plan', {
|
|
93
|
-
description:
|
|
93
|
+
description: `Change how a student is dismissed on one or more specific dates, or clear those dates back to the student's weekly default. This changes how a child actually leaves school. ${CONFIRM_FLOW} The preview shows the exact payload. Read pup_list_transportations first — options differ in whether they require a note, a car number or an early-dismissal time.`,
|
|
94
94
|
inputSchema: z.object({
|
|
95
95
|
student_id: z.number().int().describe('Student id, from pup_list_students'),
|
|
96
96
|
dates: z
|
|
@@ -111,14 +111,15 @@ export function registerPlanTools(server, client) {
|
|
|
111
111
|
.string()
|
|
112
112
|
.optional()
|
|
113
113
|
.describe('Car number, for options where usesCarNumbers is true'),
|
|
114
|
-
|
|
114
|
+
confirmToken: confirmTokenParam,
|
|
115
115
|
}),
|
|
116
|
-
}, (async ({ student_id, dates, transportation_id, note, early_dismissal_time, car_number,
|
|
116
|
+
}, (async ({ student_id, dates, transportation_id, note, early_dismissal_time, car_number, confirmToken }, ctx) => {
|
|
117
117
|
// The reads below resolve and validate the payload; they mutate nothing.
|
|
118
|
-
// Running them before the confirm gate
|
|
119
|
-
//
|
|
120
|
-
// against this school's rules,
|
|
121
|
-
//
|
|
118
|
+
// Running them before the confirm gate — on every call, both phases — is
|
|
119
|
+
// deliberate: it makes the preview show the exact bytes that would be
|
|
120
|
+
// sent, already checked against this school's rules, and phase 2 hashes
|
|
121
|
+
// a freshly rebuilt payload, so anything that moved since the preview is
|
|
122
|
+
// refused as DRAFT_CHANGED.
|
|
122
123
|
const student = await client.getStudent(student_id);
|
|
123
124
|
const transportation = transportation_id === null
|
|
124
125
|
? null
|
|
@@ -134,7 +135,16 @@ export function registerPlanTools(server, client) {
|
|
|
134
135
|
const action = transportation === null
|
|
135
136
|
? `Clear ${dates.length} date(s) back to ${student.FirstName ?? 'the student'}'s default plan`
|
|
136
137
|
: `Set ${dates.length} date(s) for ${student.FirstName ?? 'the student'} to "${transportation.Name}"`;
|
|
137
|
-
const gate =
|
|
138
|
+
const gate = await confirmWrite(ctx, {
|
|
139
|
+
tool: 'pup_set_plan',
|
|
140
|
+
action: 'plans.set',
|
|
141
|
+
summary: action,
|
|
142
|
+
method: 'PUT',
|
|
143
|
+
dto: 'UpdatePlans',
|
|
144
|
+
target: String(student_id),
|
|
145
|
+
payload: { Plans: plans },
|
|
146
|
+
confirmToken,
|
|
147
|
+
});
|
|
138
148
|
if (gate)
|
|
139
149
|
return gate;
|
|
140
150
|
await client.updatePlans(plans);
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chrischall/pickuppatrol-mcp",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"mcpName": "io.github.chrischall/pickuppatrol-mcp",
|
|
6
6
|
"description": "PickUp Patrol MCP server for Claude — developed and maintained by AI (Claude Code)",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"test:watch": "vitest"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@chrischall/mcp-utils": "^2.
|
|
60
|
+
"@chrischall/mcp-utils": "^2.6.0",
|
|
61
61
|
"@modelcontextprotocol/server": "^2.0.0",
|
|
62
62
|
"dotenv": "^17.4.0",
|
|
63
63
|
"zod": "^4.6.5"
|
package/server.json
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"url": "https://github.com/chrischall/pickuppatrol-mcp",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "1.0
|
|
9
|
+
"version": "1.1.0",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "@chrischall/pickuppatrol-mcp",
|
|
14
|
-
"version": "1.0
|
|
14
|
+
"version": "1.1.0",
|
|
15
15
|
"transport": {
|
|
16
16
|
"type": "stdio"
|
|
17
17
|
}
|