splitwise-mcp 3.1.2 → 3.2.1
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 +12 -1
- package/dist/bundle.js +658 -176
- package/dist/index.js +1 -1
- package/dist/tools/_confirm.js +28 -18
- package/dist/tools/expenses.js +41 -15
- package/dist/tools/friends.js +26 -9
- package/dist/tools/groups.js +52 -17
- package/dist/tools/receipts.js +10 -3
- package/dist/tools/user.js +15 -6
- package/dist/tools/utilities.js +26 -9
- package/package.json +3 -3
- package/server.json +2 -2
- package/skills/splitwise-mcp/SKILL.md +1 -0
package/dist/bundle.js
CHANGED
|
@@ -63223,6 +63223,33 @@ var storage2 = new AsyncLocalStorage2();
|
|
|
63223
63223
|
function withCallerCapabilities(capabilities, fn2) {
|
|
63224
63224
|
return capabilities ? storage2.run(capabilities, fn2) : fn2();
|
|
63225
63225
|
}
|
|
63226
|
+
function currentCallerCapabilities() {
|
|
63227
|
+
return storage2.getStore();
|
|
63228
|
+
}
|
|
63229
|
+
var ENVELOPE_CAPABILITIES_KEY = "io.modelcontextprotocol/clientCapabilities";
|
|
63230
|
+
var ELICITATION_MODES = ["form", "url"];
|
|
63231
|
+
function isRecord(value) {
|
|
63232
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
63233
|
+
}
|
|
63234
|
+
function callerCapabilities(ctx) {
|
|
63235
|
+
const envelope = isRecord(ctx) && isRecord(ctx.mcpReq) ? ctx.mcpReq.envelope : void 0;
|
|
63236
|
+
if (isRecord(envelope)) {
|
|
63237
|
+
const declared = envelope[ENVELOPE_CAPABILITIES_KEY];
|
|
63238
|
+
if (isRecord(declared))
|
|
63239
|
+
return declared;
|
|
63240
|
+
}
|
|
63241
|
+
return currentCallerCapabilities();
|
|
63242
|
+
}
|
|
63243
|
+
function callerAcceptsFormElicitation(ctx) {
|
|
63244
|
+
const capabilities = callerCapabilities(ctx);
|
|
63245
|
+
if (!capabilities)
|
|
63246
|
+
return void 0;
|
|
63247
|
+
const elicitation = capabilities.elicitation;
|
|
63248
|
+
if (!isRecord(elicitation))
|
|
63249
|
+
return false;
|
|
63250
|
+
const namedModes = ELICITATION_MODES.filter((mode) => mode in elicitation);
|
|
63251
|
+
return namedModes.length === 0 || namedModes.includes("form");
|
|
63252
|
+
}
|
|
63226
63253
|
|
|
63227
63254
|
// node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs
|
|
63228
63255
|
var __create2 = Object.create;
|
|
@@ -67621,6 +67648,37 @@ var inputRequired = Object.assign(buildInputRequired, {
|
|
|
67621
67648
|
return { method: "roots/list" };
|
|
67622
67649
|
}
|
|
67623
67650
|
});
|
|
67651
|
+
function acceptedContent(responses, key, schema) {
|
|
67652
|
+
const view = inputResponse(responses, key);
|
|
67653
|
+
if (view.kind !== "elicit" || view.action !== "accept" || view.content === void 0) return void 0;
|
|
67654
|
+
if (schema === void 0) return view.content;
|
|
67655
|
+
const outcome = schema["~standard"].validate(view.content);
|
|
67656
|
+
if (outcome instanceof Promise) throw new TypeError("acceptedContent(responses, key, schema) requires a synchronously-validating schema");
|
|
67657
|
+
return outcome.issues === void 0 ? outcome.value : void 0;
|
|
67658
|
+
}
|
|
67659
|
+
function inputResponse(responses, key) {
|
|
67660
|
+
if (responses === void 0 || typeof responses !== "object" || responses === null) return { kind: "missing" };
|
|
67661
|
+
const entry = responses[key];
|
|
67662
|
+
if (entry === null || typeof entry !== "object" || Array.isArray(entry)) return { kind: "missing" };
|
|
67663
|
+
const candidate = entry;
|
|
67664
|
+
if (candidate["action"] === "accept" || candidate["action"] === "decline" || candidate["action"] === "cancel") {
|
|
67665
|
+
const content = candidate["content"];
|
|
67666
|
+
return {
|
|
67667
|
+
kind: "elicit",
|
|
67668
|
+
action: candidate["action"],
|
|
67669
|
+
...content !== null && typeof content === "object" && !Array.isArray(content) && { content }
|
|
67670
|
+
};
|
|
67671
|
+
}
|
|
67672
|
+
if (Array.isArray(candidate["roots"])) return {
|
|
67673
|
+
kind: "roots",
|
|
67674
|
+
roots: candidate["roots"]
|
|
67675
|
+
};
|
|
67676
|
+
if (typeof candidate["role"] === "string" && candidate["content"] !== void 0) return {
|
|
67677
|
+
kind: "sampling",
|
|
67678
|
+
result: candidate
|
|
67679
|
+
};
|
|
67680
|
+
return { kind: "missing" };
|
|
67681
|
+
}
|
|
67624
67682
|
var REQUEST_STATE_ONLY_LEG_PACING_MS = 250;
|
|
67625
67683
|
function inputRequiredRoundsExceededMessage(method, maxRounds) {
|
|
67626
67684
|
return `Multi-round-trip request '${method}' still required input after ${maxRounds} rounds (inputRequired.maxRounds)`;
|
|
@@ -77668,14 +77726,14 @@ function serveStdio(factory, options = {}) {
|
|
|
77668
77726
|
return false;
|
|
77669
77727
|
};
|
|
77670
77728
|
const answerLegacyRejection = (request, reason, requestedVersion) => {
|
|
77671
|
-
const
|
|
77729
|
+
const rejection3 = modernOnlyStrictRejection({
|
|
77672
77730
|
kind: "legacy",
|
|
77673
77731
|
reason,
|
|
77674
77732
|
...requestedVersion !== void 0 && { requestedVersion }
|
|
77675
77733
|
}, SUPPORTED_MODERN_PROTOCOL_VERSIONS);
|
|
77676
|
-
if (
|
|
77677
|
-
reportError(/* @__PURE__ */ new Error(`Rejected 2025-era request on a modern-only stdio connection (${
|
|
77678
|
-
return writeErrorResponse(request.id,
|
|
77734
|
+
if (rejection3 === void 0) return Promise.resolve();
|
|
77735
|
+
reportError(/* @__PURE__ */ new Error(`Rejected 2025-era request on a modern-only stdio connection (${rejection3.cell}): ${rejection3.message}`));
|
|
77736
|
+
return writeErrorResponse(request.id, rejection3.code, rejection3.message, rejection3.data);
|
|
77679
77737
|
};
|
|
77680
77738
|
const onInstanceClosed = (channel) => {
|
|
77681
77739
|
if (closing || channel === discarding) return;
|
|
@@ -97696,6 +97754,11 @@ function walk(value, keep, drop) {
|
|
|
97696
97754
|
}
|
|
97697
97755
|
|
|
97698
97756
|
// node_modules/@chrischall/mcp-utils/dist/response/index.js
|
|
97757
|
+
function textResult(data) {
|
|
97758
|
+
return {
|
|
97759
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
|
|
97760
|
+
};
|
|
97761
|
+
}
|
|
97699
97762
|
function imageResult(base643, mimeType) {
|
|
97700
97763
|
return {
|
|
97701
97764
|
content: [{ type: "image", data: base643, mimeType }]
|
|
@@ -97716,6 +97779,418 @@ function pruneUndefined(obj) {
|
|
|
97716
97779
|
return out;
|
|
97717
97780
|
}
|
|
97718
97781
|
|
|
97782
|
+
// node_modules/@chrischall/mcp-utils/dist/server/confirmation.js
|
|
97783
|
+
import { createHash, createHmac, timingSafeEqual } from "node:crypto";
|
|
97784
|
+
|
|
97785
|
+
// node_modules/@chrischall/mcp-utils/dist/server/canonical.js
|
|
97786
|
+
function canonicalJson(value) {
|
|
97787
|
+
if (value === null || typeof value === "string" || typeof value === "boolean")
|
|
97788
|
+
return JSON.stringify(value);
|
|
97789
|
+
if (value === void 0)
|
|
97790
|
+
return "null";
|
|
97791
|
+
if (typeof value === "number")
|
|
97792
|
+
return Number.isFinite(value) ? JSON.stringify(value) : `{"$num":"${String(value)}"}`;
|
|
97793
|
+
if (typeof value === "bigint")
|
|
97794
|
+
return `{"$bigint":"${value.toString()}"}`;
|
|
97795
|
+
if (typeof value === "function" || typeof value === "symbol") {
|
|
97796
|
+
throw new TypeError(`confirmation: cannot bind a ${typeof value} argument value.`);
|
|
97797
|
+
}
|
|
97798
|
+
if (Array.isArray(value))
|
|
97799
|
+
return `[${value.map(canonicalJson).join(",")}]`;
|
|
97800
|
+
if (value instanceof Date) {
|
|
97801
|
+
return `{"$date":${JSON.stringify(Number.isNaN(value.getTime()) ? "Invalid Date" : value.toISOString())}}`;
|
|
97802
|
+
}
|
|
97803
|
+
if (ArrayBuffer.isView(value)) {
|
|
97804
|
+
const bytes = Buffer.from(value.buffer, value.byteOffset, value.byteLength);
|
|
97805
|
+
return `{"$bytes":${JSON.stringify(bytes.toString("base64"))}}`;
|
|
97806
|
+
}
|
|
97807
|
+
if (value instanceof ArrayBuffer)
|
|
97808
|
+
return `{"$bytes":${JSON.stringify(Buffer.from(value).toString("base64"))}}`;
|
|
97809
|
+
if (value instanceof Map) {
|
|
97810
|
+
const entries2 = [...value.entries()].map(([k2, v2]) => `[${canonicalJson(k2)},${canonicalJson(v2)}]`).sort();
|
|
97811
|
+
return `{"$map":[${entries2.join(",")}]}`;
|
|
97812
|
+
}
|
|
97813
|
+
if (value instanceof Set) {
|
|
97814
|
+
return `{"$set":[${[...value].map(canonicalJson).sort().join(",")}]}`;
|
|
97815
|
+
}
|
|
97816
|
+
const proto = Object.getPrototypeOf(value);
|
|
97817
|
+
if (proto !== Object.prototype && proto !== null) {
|
|
97818
|
+
throw new TypeError("confirmation: cannot bind a non-plain object argument value (class instance).");
|
|
97819
|
+
}
|
|
97820
|
+
const entries = Object.entries(value).filter(([, v2]) => v2 !== void 0).sort(([a2], [b2]) => a2 < b2 ? -1 : a2 > b2 ? 1 : 0);
|
|
97821
|
+
return `{${entries.map(([k2, v2]) => `${JSON.stringify(escapeKey(k2))}:${canonicalJson(v2)}`).join(",")}}`;
|
|
97822
|
+
}
|
|
97823
|
+
function escapeKey(key) {
|
|
97824
|
+
return key.startsWith("$") ? `$${key}` : key;
|
|
97825
|
+
}
|
|
97826
|
+
|
|
97827
|
+
// node_modules/@chrischall/mcp-utils/dist/server/confirmation.js
|
|
97828
|
+
var DEFAULT_REQUEST_KEY = "confirmation";
|
|
97829
|
+
var DEFAULT_CONFIRMATION_LABEL = "Confirm this action should proceed.";
|
|
97830
|
+
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";
|
|
97831
|
+
var STATE_PREFIX = "mcpu.confirm.v1.";
|
|
97832
|
+
function bindingKey(binding) {
|
|
97833
|
+
if (binding.ttlSeconds !== void 0 && !(Number.isFinite(binding.ttlSeconds) && binding.ttlSeconds > 0)) {
|
|
97834
|
+
throw new RangeError("requireConfirmation: binding.ttlSeconds must be a finite number greater than 0.");
|
|
97835
|
+
}
|
|
97836
|
+
const key = typeof binding.key === "string" ? Buffer.from(binding.key, "utf8") : Buffer.from(binding.key);
|
|
97837
|
+
if (key.length < 32) {
|
|
97838
|
+
throw new RangeError("requireConfirmation: binding.key must be at least 32 bytes.");
|
|
97839
|
+
}
|
|
97840
|
+
return key;
|
|
97841
|
+
}
|
|
97842
|
+
function commitment(action, args) {
|
|
97843
|
+
return createHash("sha256").update(`${action}\0${canonicalJson(args)}`).digest("base64url");
|
|
97844
|
+
}
|
|
97845
|
+
function mintState(key, action, binding) {
|
|
97846
|
+
const exp = Math.floor(Date.now() / 1e3) + (binding.ttlSeconds ?? 600);
|
|
97847
|
+
const body = Buffer.from(JSON.stringify({ c: commitment(action, binding.args), exp })).toString("base64url");
|
|
97848
|
+
const mac3 = createHmac("sha256", key).update(`${STATE_PREFIX}${body}`).digest("base64url");
|
|
97849
|
+
return `${STATE_PREFIX}${body}.${mac3}`;
|
|
97850
|
+
}
|
|
97851
|
+
function verifyState(key, action, binding, state) {
|
|
97852
|
+
if (typeof state !== "string" || !state.startsWith(STATE_PREFIX))
|
|
97853
|
+
return false;
|
|
97854
|
+
const rest = state.slice(STATE_PREFIX.length);
|
|
97855
|
+
const dot = rest.indexOf(".");
|
|
97856
|
+
if (dot < 0)
|
|
97857
|
+
return false;
|
|
97858
|
+
const body = rest.slice(0, dot);
|
|
97859
|
+
const mac3 = Buffer.from(rest.slice(dot + 1), "base64url");
|
|
97860
|
+
const expected = createHmac("sha256", key).update(`${STATE_PREFIX}${body}`).digest();
|
|
97861
|
+
if (mac3.length !== expected.length || !timingSafeEqual(mac3, expected))
|
|
97862
|
+
return false;
|
|
97863
|
+
let payload;
|
|
97864
|
+
try {
|
|
97865
|
+
payload = JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
|
|
97866
|
+
} catch {
|
|
97867
|
+
return false;
|
|
97868
|
+
}
|
|
97869
|
+
if (typeof payload.exp !== "number" || payload.exp * 1e3 <= Date.now())
|
|
97870
|
+
return false;
|
|
97871
|
+
const want = Buffer.from(commitment(action, binding.args));
|
|
97872
|
+
const got = Buffer.from(typeof payload.c === "string" ? payload.c : "");
|
|
97873
|
+
return got.length === want.length && timingSafeEqual(got, want);
|
|
97874
|
+
}
|
|
97875
|
+
function echoedState(ctx) {
|
|
97876
|
+
const accessor = ctx.mcpReq.requestState;
|
|
97877
|
+
return typeof accessor === "function" ? accessor() : void 0;
|
|
97878
|
+
}
|
|
97879
|
+
function requireConfirmation(ctx, options) {
|
|
97880
|
+
const requestKey = options.requestKey ?? DEFAULT_REQUEST_KEY;
|
|
97881
|
+
const key = options.binding ? bindingKey(options.binding) : void 0;
|
|
97882
|
+
const confirmationSchema = external_exports.object({
|
|
97883
|
+
confirmed: external_exports.boolean().describe(options.confirmationLabel ?? DEFAULT_CONFIRMATION_LABEL)
|
|
97884
|
+
});
|
|
97885
|
+
const ask = () => {
|
|
97886
|
+
const preview = {
|
|
97887
|
+
action: options.action,
|
|
97888
|
+
...options.details === void 0 ? {} : { details: options.details }
|
|
97889
|
+
};
|
|
97890
|
+
return inputRequired({
|
|
97891
|
+
inputRequests: {
|
|
97892
|
+
[requestKey]: inputRequired.elicit({
|
|
97893
|
+
message: `${options.message}
|
|
97894
|
+
${JSON.stringify(preview, null, 2)}`,
|
|
97895
|
+
requestedSchema: confirmationSchema
|
|
97896
|
+
})
|
|
97897
|
+
},
|
|
97898
|
+
...key && options.binding ? { requestState: mintState(key, options.action, options.binding) } : {}
|
|
97899
|
+
});
|
|
97900
|
+
};
|
|
97901
|
+
const response = inputResponse(ctx.mcpReq.inputResponses, requestKey);
|
|
97902
|
+
const accepted = acceptedContent(ctx.mcpReq.inputResponses, requestKey, confirmationSchema);
|
|
97903
|
+
if (response.kind === "missing") {
|
|
97904
|
+
if (callerAcceptsFormElicitation(ctx) === false) {
|
|
97905
|
+
return textResult({
|
|
97906
|
+
confirmed: false,
|
|
97907
|
+
dispatched: false,
|
|
97908
|
+
action: options.action,
|
|
97909
|
+
reason: "confirmation-unsupported",
|
|
97910
|
+
note: options.unsupportedNote ? `${UNSUPPORTED_NOTE}. ${options.unsupportedNote}` : `${UNSUPPORTED_NOTE}.`
|
|
97911
|
+
});
|
|
97912
|
+
}
|
|
97913
|
+
return ask();
|
|
97914
|
+
}
|
|
97915
|
+
if (response.kind === "elicit" && response.action === "accept" && accepted?.confirmed === true) {
|
|
97916
|
+
if (key && options.binding) {
|
|
97917
|
+
const state = echoedState(ctx);
|
|
97918
|
+
if (state === void 0 || state === null) {
|
|
97919
|
+
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.`);
|
|
97920
|
+
}
|
|
97921
|
+
if (!verifyState(key, options.action, options.binding, state))
|
|
97922
|
+
return ask();
|
|
97923
|
+
}
|
|
97924
|
+
return void 0;
|
|
97925
|
+
}
|
|
97926
|
+
return textResult({
|
|
97927
|
+
confirmed: false,
|
|
97928
|
+
cancelled: true,
|
|
97929
|
+
action: options.action,
|
|
97930
|
+
note: "Nothing was changed because the confirmation was declined, cancelled, or left unchecked."
|
|
97931
|
+
});
|
|
97932
|
+
}
|
|
97933
|
+
|
|
97934
|
+
// node_modules/@chrischall/mcp-utils/dist/server/confirm-token.js
|
|
97935
|
+
import { createHash as createHash2, createHmac as createHmac2, randomBytes, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
|
|
97936
|
+
function createSpentTokenStore() {
|
|
97937
|
+
const spent = /* @__PURE__ */ new Map();
|
|
97938
|
+
return {
|
|
97939
|
+
has: (nonce) => spent.has(nonce),
|
|
97940
|
+
add: (nonce, exp) => {
|
|
97941
|
+
spent.set(nonce, exp);
|
|
97942
|
+
},
|
|
97943
|
+
prune: (now) => {
|
|
97944
|
+
for (const [nonce, exp] of spent)
|
|
97945
|
+
if (exp < now)
|
|
97946
|
+
spent.delete(nonce);
|
|
97947
|
+
},
|
|
97948
|
+
clear: () => spent.clear(),
|
|
97949
|
+
get size() {
|
|
97950
|
+
return spent.size;
|
|
97951
|
+
}
|
|
97952
|
+
};
|
|
97953
|
+
}
|
|
97954
|
+
var PROCESS_SPENT = createSpentTokenStore();
|
|
97955
|
+
var PREFIX = "mcpu.token.v1.";
|
|
97956
|
+
var DEFAULT_TTL_SECONDS = 600;
|
|
97957
|
+
function tokenKey(key) {
|
|
97958
|
+
const bytes = typeof key === "string" ? Buffer.from(key, "utf8") : Buffer.from(key);
|
|
97959
|
+
if (bytes.length < 32)
|
|
97960
|
+
throw new RangeError("confirm token: key must be at least 32 bytes.");
|
|
97961
|
+
return bytes;
|
|
97962
|
+
}
|
|
97963
|
+
function ttlOf(ttlSeconds) {
|
|
97964
|
+
if (ttlSeconds === void 0)
|
|
97965
|
+
return DEFAULT_TTL_SECONDS;
|
|
97966
|
+
if (!(Number.isFinite(ttlSeconds) && ttlSeconds > 0)) {
|
|
97967
|
+
throw new RangeError("confirm token: ttlSeconds must be a finite number greater than 0.");
|
|
97968
|
+
}
|
|
97969
|
+
return ttlSeconds;
|
|
97970
|
+
}
|
|
97971
|
+
function sign(key, body) {
|
|
97972
|
+
return createHmac2("sha256", key).update(`${PREFIX}${body}`).digest();
|
|
97973
|
+
}
|
|
97974
|
+
function hashConfirmPayload(payload) {
|
|
97975
|
+
return createHash2("sha256").update(canonicalJson(payload)).digest("base64url");
|
|
97976
|
+
}
|
|
97977
|
+
function issueConfirmToken(key, binding, options = {}) {
|
|
97978
|
+
const k2 = tokenKey(key);
|
|
97979
|
+
const now = options.now ?? Date.now();
|
|
97980
|
+
const exp = now + ttlOf(options.ttlSeconds) * 1e3;
|
|
97981
|
+
const claims = {
|
|
97982
|
+
t: binding.tool,
|
|
97983
|
+
...binding.account === void 0 ? {} : { a: binding.account },
|
|
97984
|
+
g: binding.target,
|
|
97985
|
+
...binding.revision === void 0 ? {} : { r: binding.revision },
|
|
97986
|
+
h: binding.payloadHash,
|
|
97987
|
+
exp,
|
|
97988
|
+
n: randomBytes(16).toString("base64url")
|
|
97989
|
+
};
|
|
97990
|
+
const body = Buffer.from(JSON.stringify(claims), "utf8").toString("base64url");
|
|
97991
|
+
return { token: `${PREFIX}${body}.${sign(k2, body).toString("base64url")}`, expiresAt: new Date(exp).toISOString() };
|
|
97992
|
+
}
|
|
97993
|
+
function parseClaims(body) {
|
|
97994
|
+
try {
|
|
97995
|
+
const claims = JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
|
|
97996
|
+
return claims && typeof claims === "object" ? claims : void 0;
|
|
97997
|
+
} catch {
|
|
97998
|
+
return void 0;
|
|
97999
|
+
}
|
|
98000
|
+
}
|
|
98001
|
+
function verifyConfirmToken(key, token, binding, options = {}) {
|
|
98002
|
+
const k2 = tokenKey(key);
|
|
98003
|
+
const now = options.now ?? Date.now();
|
|
98004
|
+
const spent = options.spent ?? PROCESS_SPENT;
|
|
98005
|
+
spent.prune(now);
|
|
98006
|
+
if (!token.startsWith(PREFIX))
|
|
98007
|
+
return { ok: false, error: "TOKEN_INVALID" };
|
|
98008
|
+
const rest = token.slice(PREFIX.length);
|
|
98009
|
+
const dot = rest.indexOf(".");
|
|
98010
|
+
const body = dot < 0 ? "" : rest.slice(0, dot);
|
|
98011
|
+
const mac3 = Buffer.from(dot < 0 ? "" : rest.slice(dot + 1), "base64url");
|
|
98012
|
+
const expected = sign(k2, body);
|
|
98013
|
+
if (!body || mac3.length !== expected.length || !timingSafeEqual2(mac3, expected))
|
|
98014
|
+
return { ok: false, error: "TOKEN_INVALID" };
|
|
98015
|
+
const claims = parseClaims(body);
|
|
98016
|
+
if (!claims)
|
|
98017
|
+
return { ok: false, error: "TOKEN_INVALID" };
|
|
98018
|
+
if (claims.t !== binding.tool || claims.a !== binding.account || claims.g !== binding.target) {
|
|
98019
|
+
return { ok: false, error: "TOKEN_INVALID" };
|
|
98020
|
+
}
|
|
98021
|
+
if (spent.has(claims.n))
|
|
98022
|
+
return { ok: false, error: "TOKEN_REUSED" };
|
|
98023
|
+
if (now > claims.exp)
|
|
98024
|
+
return { ok: false, error: "TOKEN_EXPIRED" };
|
|
98025
|
+
if (claims.r !== binding.revision)
|
|
98026
|
+
return { ok: false, error: "DRAFT_CHANGED", reason: "revision-changed" };
|
|
98027
|
+
if (claims.h !== binding.payloadHash)
|
|
98028
|
+
return { ok: false, error: "DRAFT_CHANGED", reason: "payload-changed" };
|
|
98029
|
+
spent.add(claims.n, claims.exp);
|
|
98030
|
+
return { ok: true };
|
|
98031
|
+
}
|
|
98032
|
+
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.";
|
|
98033
|
+
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.`);
|
|
98034
|
+
var TOKEN_ERROR_NOTE = {
|
|
98035
|
+
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.",
|
|
98036
|
+
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.",
|
|
98037
|
+
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."
|
|
98038
|
+
};
|
|
98039
|
+
var CHANGED_NOTE = {
|
|
98040
|
+
"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.",
|
|
98041
|
+
"payload-changed": "Nothing was sent or changed: what would happen no longer matches what the user approved."
|
|
98042
|
+
};
|
|
98043
|
+
function isToolResult(value) {
|
|
98044
|
+
return Array.isArray(value.content);
|
|
98045
|
+
}
|
|
98046
|
+
function rejection2(data) {
|
|
98047
|
+
return { ...textResult({ status: "confirmation-rejected", confirmed: false, dispatched: false, ...data }), isError: true };
|
|
98048
|
+
}
|
|
98049
|
+
async function tokenConfirmation(action, fb) {
|
|
98050
|
+
const subject = await fb.subject();
|
|
98051
|
+
if (isToolResult(subject))
|
|
98052
|
+
return subject;
|
|
98053
|
+
const binding = {
|
|
98054
|
+
tool: fb.tool,
|
|
98055
|
+
...fb.account === void 0 ? {} : { account: fb.account },
|
|
98056
|
+
target: subject.target,
|
|
98057
|
+
...subject.revision === void 0 ? {} : { revision: subject.revision },
|
|
98058
|
+
payloadHash: hashConfirmPayload(subject.payload)
|
|
98059
|
+
};
|
|
98060
|
+
const phaseOne = () => {
|
|
98061
|
+
const { token, expiresAt } = issueConfirmToken(fb.key, binding, { ttlSeconds: fb.ttlSeconds });
|
|
98062
|
+
return {
|
|
98063
|
+
action,
|
|
98064
|
+
preview: subject.preview,
|
|
98065
|
+
confirmToken: token,
|
|
98066
|
+
expiresAt,
|
|
98067
|
+
ttlSeconds: ttlOf(fb.ttlSeconds),
|
|
98068
|
+
instruction: fb.instruction ?? CONFIRM_TOKEN_INSTRUCTION
|
|
98069
|
+
};
|
|
98070
|
+
};
|
|
98071
|
+
if (!fb.confirmToken) {
|
|
98072
|
+
return textResult({ status: "confirmation-required", confirmed: false, dispatched: false, ...phaseOne() });
|
|
98073
|
+
}
|
|
98074
|
+
const verdict = verifyConfirmToken(fb.key, fb.confirmToken, binding, { spent: fb.spent });
|
|
98075
|
+
if (verdict.ok)
|
|
98076
|
+
return void 0;
|
|
98077
|
+
if (verdict.error === "DRAFT_CHANGED") {
|
|
98078
|
+
return rejection2({
|
|
98079
|
+
error: "DRAFT_CHANGED",
|
|
98080
|
+
reason: verdict.reason,
|
|
98081
|
+
note: `${CHANGED_NOTE[verdict.reason]} The current preview and a fresh confirmToken are below.`,
|
|
98082
|
+
...phaseOne()
|
|
98083
|
+
});
|
|
98084
|
+
}
|
|
98085
|
+
return rejection2({ error: verdict.error, action, note: TOKEN_ERROR_NOTE[verdict.error] });
|
|
98086
|
+
}
|
|
98087
|
+
async function requireConfirmationWithFallback(ctx, options) {
|
|
98088
|
+
const { tokenFallback, ...confirmation } = options;
|
|
98089
|
+
if (tokenFallback && callerAcceptsFormElicitation(ctx) === false) {
|
|
98090
|
+
return tokenConfirmation(options.action, tokenFallback);
|
|
98091
|
+
}
|
|
98092
|
+
return requireConfirmation(ctx, confirmation);
|
|
98093
|
+
}
|
|
98094
|
+
|
|
98095
|
+
// node_modules/@chrischall/mcp-utils/dist/server/confirm-env.js
|
|
98096
|
+
import { createHash as createHash3, randomBytes as randomBytes2 } from "node:crypto";
|
|
98097
|
+
|
|
98098
|
+
// node_modules/@chrischall/mcp-utils/dist/config/index.js
|
|
98099
|
+
import { homedir } from "node:os";
|
|
98100
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
98101
|
+
var PLACEHOLDER_RE = /^\$\{[^}]*\}$/;
|
|
98102
|
+
function readEnvVar(key, opts = {}) {
|
|
98103
|
+
const env = opts.env ?? process.env;
|
|
98104
|
+
const raw = env[key];
|
|
98105
|
+
if (typeof raw === "string") {
|
|
98106
|
+
const trimmed = raw.trim();
|
|
98107
|
+
if (trimmed.length > 0 && trimmed !== "undefined" && trimmed !== "null" && !PLACEHOLDER_RE.test(trimmed)) {
|
|
98108
|
+
return trimmed;
|
|
98109
|
+
}
|
|
98110
|
+
}
|
|
98111
|
+
return opts.default;
|
|
98112
|
+
}
|
|
98113
|
+
function expandPath(p2) {
|
|
98114
|
+
let expanded = p2;
|
|
98115
|
+
if (p2 === "~") {
|
|
98116
|
+
expanded = homedir();
|
|
98117
|
+
} else if (p2.startsWith("~/")) {
|
|
98118
|
+
expanded = join(homedir(), p2.slice(2));
|
|
98119
|
+
}
|
|
98120
|
+
return isAbsolute(expanded) ? expanded : resolve(expanded);
|
|
98121
|
+
}
|
|
98122
|
+
async function loadDotenvSafely(opts = {}) {
|
|
98123
|
+
try {
|
|
98124
|
+
const mod = await import(
|
|
98125
|
+
/* @vite-ignore */
|
|
98126
|
+
"dotenv"
|
|
98127
|
+
);
|
|
98128
|
+
const result = mod.config({
|
|
98129
|
+
...opts.path !== void 0 ? { path: opts.path } : {},
|
|
98130
|
+
override: opts.override ?? false,
|
|
98131
|
+
quiet: true
|
|
98132
|
+
});
|
|
98133
|
+
return result.error === void 0;
|
|
98134
|
+
} catch {
|
|
98135
|
+
return false;
|
|
98136
|
+
}
|
|
98137
|
+
}
|
|
98138
|
+
|
|
98139
|
+
// node_modules/@chrischall/mcp-utils/dist/server/confirm-env.js
|
|
98140
|
+
var MODES = /* @__PURE__ */ new Set(["ask-user", "auto", "refuse"]);
|
|
98141
|
+
var DEFAULT_TTL_SECONDS2 = 600;
|
|
98142
|
+
var warned = /* @__PURE__ */ new Set();
|
|
98143
|
+
function readConfirmMode(env = process.env) {
|
|
98144
|
+
const raw = readEnvVar("MCP_CONFIRM_MODE", { env })?.trim().toLowerCase();
|
|
98145
|
+
if (!raw)
|
|
98146
|
+
return "ask-user";
|
|
98147
|
+
if (MODES.has(raw))
|
|
98148
|
+
return raw;
|
|
98149
|
+
if (!warned.has(raw)) {
|
|
98150
|
+
warned.add(raw);
|
|
98151
|
+
process.stderr.write(`MCP_CONFIRM_MODE="${raw}" is not one of ask-user, auto, refuse; treating it as refuse.
|
|
98152
|
+
`);
|
|
98153
|
+
}
|
|
98154
|
+
return "refuse";
|
|
98155
|
+
}
|
|
98156
|
+
function confirmTtlFromEnv(env = process.env) {
|
|
98157
|
+
const raw = readEnvVar("MCP_CONFIRM_TTL_SECONDS", { env })?.trim();
|
|
98158
|
+
return raw && /^[1-9]\d*$/.test(raw) ? Number(raw) : DEFAULT_TTL_SECONDS2;
|
|
98159
|
+
}
|
|
98160
|
+
var processKey;
|
|
98161
|
+
function confirmKeyFromEnv(env = process.env) {
|
|
98162
|
+
const secret = readEnvVar("MCP_CONFIRM_SECRET", { env });
|
|
98163
|
+
if (secret)
|
|
98164
|
+
return createHash3("sha256").update(secret, "utf8").digest();
|
|
98165
|
+
processKey ??= randomBytes2(32);
|
|
98166
|
+
return processKey;
|
|
98167
|
+
}
|
|
98168
|
+
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.)";
|
|
98169
|
+
var REFUSE_HINT = "Set MCP_CONFIRM_MODE=ask-user on the server to allow two-step confirmation instead.";
|
|
98170
|
+
function confirmationFromEnv(options) {
|
|
98171
|
+
const { tool, account, confirmToken, subject, instruction, spent, env = process.env, ...confirmation } = options;
|
|
98172
|
+
const mode = readConfirmMode(env);
|
|
98173
|
+
if (mode === "refuse") {
|
|
98174
|
+
return {
|
|
98175
|
+
...confirmation,
|
|
98176
|
+
unsupportedNote: confirmation.unsupportedNote ? `${confirmation.unsupportedNote} ${REFUSE_HINT}` : REFUSE_HINT
|
|
98177
|
+
};
|
|
98178
|
+
}
|
|
98179
|
+
return {
|
|
98180
|
+
...confirmation,
|
|
98181
|
+
tokenFallback: {
|
|
98182
|
+
key: confirmKeyFromEnv(env),
|
|
98183
|
+
tool,
|
|
98184
|
+
...account === void 0 ? {} : { account },
|
|
98185
|
+
...confirmToken === void 0 ? {} : { confirmToken },
|
|
98186
|
+
subject,
|
|
98187
|
+
ttlSeconds: confirmTtlFromEnv(env),
|
|
98188
|
+
instruction: mode === "auto" ? CONFIRM_TOKEN_AUTO_INSTRUCTION : instruction ?? CONFIRM_TOKEN_INSTRUCTION,
|
|
98189
|
+
...spent === void 0 ? {} : { spent }
|
|
98190
|
+
}
|
|
98191
|
+
};
|
|
98192
|
+
}
|
|
98193
|
+
|
|
97719
98194
|
// node_modules/@chrischall/mcp-utils/dist/server/index.js
|
|
97720
98195
|
var SERVER_PROTOCOL_VERSIONS = Object.freeze([
|
|
97721
98196
|
"2026-07-28",
|
|
@@ -97891,47 +98366,6 @@ function runMcp(opts) {
|
|
|
97891
98366
|
return handle;
|
|
97892
98367
|
}
|
|
97893
98368
|
|
|
97894
|
-
// node_modules/@chrischall/mcp-utils/dist/config/index.js
|
|
97895
|
-
import { homedir } from "node:os";
|
|
97896
|
-
import { isAbsolute, join, resolve } from "node:path";
|
|
97897
|
-
var PLACEHOLDER_RE = /^\$\{[^}]*\}$/;
|
|
97898
|
-
function readEnvVar(key, opts = {}) {
|
|
97899
|
-
const env = opts.env ?? process.env;
|
|
97900
|
-
const raw = env[key];
|
|
97901
|
-
if (typeof raw === "string") {
|
|
97902
|
-
const trimmed = raw.trim();
|
|
97903
|
-
if (trimmed.length > 0 && trimmed !== "undefined" && trimmed !== "null" && !PLACEHOLDER_RE.test(trimmed)) {
|
|
97904
|
-
return trimmed;
|
|
97905
|
-
}
|
|
97906
|
-
}
|
|
97907
|
-
return opts.default;
|
|
97908
|
-
}
|
|
97909
|
-
function expandPath(p2) {
|
|
97910
|
-
let expanded = p2;
|
|
97911
|
-
if (p2 === "~") {
|
|
97912
|
-
expanded = homedir();
|
|
97913
|
-
} else if (p2.startsWith("~/")) {
|
|
97914
|
-
expanded = join(homedir(), p2.slice(2));
|
|
97915
|
-
}
|
|
97916
|
-
return isAbsolute(expanded) ? expanded : resolve(expanded);
|
|
97917
|
-
}
|
|
97918
|
-
async function loadDotenvSafely(opts = {}) {
|
|
97919
|
-
try {
|
|
97920
|
-
const mod = await import(
|
|
97921
|
-
/* @vite-ignore */
|
|
97922
|
-
"dotenv"
|
|
97923
|
-
);
|
|
97924
|
-
const result = mod.config({
|
|
97925
|
-
...opts.path !== void 0 ? { path: opts.path } : {},
|
|
97926
|
-
override: opts.override ?? false,
|
|
97927
|
-
quiet: true
|
|
97928
|
-
});
|
|
97929
|
-
return result.error === void 0;
|
|
97930
|
-
} catch {
|
|
97931
|
-
return false;
|
|
97932
|
-
}
|
|
97933
|
-
}
|
|
97934
|
-
|
|
97935
98369
|
// node_modules/@chrischall/mcp-utils/dist/fs/confine.js
|
|
97936
98370
|
import { existsSync, realpathSync } from "node:fs";
|
|
97937
98371
|
import { dirname, isAbsolute as isAbsolute2, relative, resolve as resolve2, sep } from "node:path";
|
|
@@ -98563,16 +98997,25 @@ function viewGeneric(view, payload) {
|
|
|
98563
98997
|
}
|
|
98564
98998
|
|
|
98565
98999
|
// src/tools/_confirm.ts
|
|
98566
|
-
|
|
98567
|
-
|
|
98568
|
-
|
|
98569
|
-
|
|
98570
|
-
|
|
98571
|
-
|
|
98572
|
-
|
|
98573
|
-
|
|
98574
|
-
|
|
98575
|
-
|
|
99000
|
+
var CONFIRM_NOTE = "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).";
|
|
99001
|
+
function confirmWrite(ctx, gate) {
|
|
99002
|
+
const request = {
|
|
99003
|
+
method: gate.method,
|
|
99004
|
+
path: gate.path,
|
|
99005
|
+
...gate.body !== void 0 ? { willSend: gate.body } : {}
|
|
99006
|
+
};
|
|
99007
|
+
const preview = { action: gate.summary, ...request };
|
|
99008
|
+
return requireConfirmationWithFallback(
|
|
99009
|
+
ctx,
|
|
99010
|
+
confirmationFromEnv({
|
|
99011
|
+
action: gate.action,
|
|
99012
|
+
message: `Review and confirm: ${gate.summary}`,
|
|
99013
|
+
details: preview,
|
|
99014
|
+
tool: gate.tool,
|
|
99015
|
+
confirmToken: gate.confirmToken,
|
|
99016
|
+
subject: () => ({ target: String(gate.target), payload: request, preview })
|
|
99017
|
+
})
|
|
99018
|
+
);
|
|
98576
99019
|
}
|
|
98577
99020
|
|
|
98578
99021
|
// src/tools/user.ts
|
|
@@ -98609,11 +99052,11 @@ function registerUserTools(server, client2) {
|
|
|
98609
99052
|
server.registerTool(
|
|
98610
99053
|
"sw_update_user",
|
|
98611
99054
|
{
|
|
98612
|
-
description: "Update the current user's profile fields: name, locale and default currency. id must be the current user's id. The login email and password are deliberately not settable here \u2014 account credentials are changed in the Splitwise app, not by an assistant.",
|
|
99055
|
+
description: "Update the current user's profile fields: name, locale and default currency. id must be the current user's id. The login email and password are deliberately not settable here \u2014 account credentials are changed in the Splitwise app, not by an assistant. " + CONFIRM_NOTE,
|
|
98613
99056
|
annotations: { readOnlyHint: false, destructiveHint: true },
|
|
98614
99057
|
// No `email` / `password`: changing the login email is an account
|
|
98615
99058
|
// takeover primitive (a password reset to the new address follows), and
|
|
98616
|
-
// the only gate would be a model-
|
|
99059
|
+
// the only gate would be a model-driven confirmation that injected text from
|
|
98617
99060
|
// comments, notifications or receipts could talk it into (fleet-audit
|
|
98618
99061
|
// #250). z.object strips unknown keys, so a caller passing them anyway
|
|
98619
99062
|
// has them dropped before the request is built.
|
|
@@ -98623,23 +99066,26 @@ function registerUserTools(server, client2) {
|
|
|
98623
99066
|
last_name: external_exports.string().optional(),
|
|
98624
99067
|
locale: external_exports.string().optional(),
|
|
98625
99068
|
default_currency: external_exports.string().optional(),
|
|
98626
|
-
|
|
99069
|
+
confirmToken: confirmTokenParam
|
|
98627
99070
|
})
|
|
98628
99071
|
},
|
|
98629
|
-
async ({ id, first_name, last_name, locale, default_currency,
|
|
99072
|
+
async ({ id, first_name, last_name, locale, default_currency, confirmToken }, ctx) => {
|
|
98630
99073
|
const body = pruneUndefined({
|
|
98631
99074
|
first_name,
|
|
98632
99075
|
last_name,
|
|
98633
99076
|
locale,
|
|
98634
99077
|
default_currency
|
|
98635
99078
|
});
|
|
98636
|
-
const gate =
|
|
98637
|
-
|
|
98638
|
-
|
|
98639
|
-
|
|
98640
|
-
|
|
98641
|
-
|
|
98642
|
-
|
|
99079
|
+
const gate = await confirmWrite(ctx, {
|
|
99080
|
+
tool: "sw_update_user",
|
|
99081
|
+
action: "user.update",
|
|
99082
|
+
summary: `Update current Splitwise user ${id} profile`,
|
|
99083
|
+
method: "POST",
|
|
99084
|
+
path: `/update_user/${id}`,
|
|
99085
|
+
body,
|
|
99086
|
+
target: id,
|
|
99087
|
+
confirmToken
|
|
99088
|
+
});
|
|
98643
99089
|
if (gate) return gate;
|
|
98644
99090
|
const data = await client2.request("POST", `/update_user/${id}`, body);
|
|
98645
99091
|
return minifiedResult(data);
|
|
@@ -98850,24 +99296,27 @@ function registerGroupTools(server, client2) {
|
|
|
98850
99296
|
server.registerTool(
|
|
98851
99297
|
"sw_create_group",
|
|
98852
99298
|
{
|
|
98853
|
-
description:
|
|
99299
|
+
description: `Create a new Splitwise group. ${CONFIRM_NOTE}`,
|
|
98854
99300
|
annotations: { destructiveHint: true },
|
|
98855
99301
|
inputSchema: external_exports.object({
|
|
98856
99302
|
name: external_exports.string().describe("Group name"),
|
|
98857
99303
|
group_type: external_exports.enum(["apartment", "house", "trip", "other"]).describe("Type of group").optional(),
|
|
98858
99304
|
simplify_by_default: external_exports.boolean().describe("Whether to simplify debts by default").optional(),
|
|
98859
|
-
|
|
99305
|
+
confirmToken: confirmTokenParam
|
|
98860
99306
|
})
|
|
98861
99307
|
},
|
|
98862
|
-
async ({ name, group_type, simplify_by_default,
|
|
99308
|
+
async ({ name, group_type, simplify_by_default, confirmToken }, ctx) => {
|
|
98863
99309
|
const body = pruneUndefined({ name, group_type, simplify_by_default });
|
|
98864
|
-
const gate =
|
|
98865
|
-
|
|
98866
|
-
|
|
98867
|
-
"
|
|
98868
|
-
"
|
|
98869
|
-
|
|
98870
|
-
|
|
99310
|
+
const gate = await confirmWrite(ctx, {
|
|
99311
|
+
tool: "sw_create_group",
|
|
99312
|
+
action: "group.create",
|
|
99313
|
+
summary: `Create Splitwise group "${name}"`,
|
|
99314
|
+
method: "POST",
|
|
99315
|
+
path: "/create_group",
|
|
99316
|
+
body,
|
|
99317
|
+
target: "",
|
|
99318
|
+
confirmToken
|
|
99319
|
+
});
|
|
98871
99320
|
if (gate) return gate;
|
|
98872
99321
|
const data = await client2.request("POST", "/create_group", body);
|
|
98873
99322
|
return minifiedResult(data);
|
|
@@ -98876,17 +99325,17 @@ function registerGroupTools(server, client2) {
|
|
|
98876
99325
|
server.registerTool(
|
|
98877
99326
|
"sw_add_user_to_group",
|
|
98878
99327
|
{
|
|
98879
|
-
description:
|
|
99328
|
+
description: `Add a user to a Splitwise group. Provide user_id (preferred, use sw_list_friends to resolve a name) or first_name + last_name + email to invite by email. ${CONFIRM_NOTE}`,
|
|
98880
99329
|
inputSchema: external_exports.object({
|
|
98881
99330
|
group_id: external_exports.number().describe("Group ID"),
|
|
98882
99331
|
user_id: external_exports.number().describe("User ID (preferred)").optional(),
|
|
98883
99332
|
first_name: external_exports.string().optional(),
|
|
98884
99333
|
last_name: external_exports.string().optional(),
|
|
98885
99334
|
email: external_exports.string().optional(),
|
|
98886
|
-
|
|
99335
|
+
confirmToken: confirmTokenParam
|
|
98887
99336
|
})
|
|
98888
99337
|
},
|
|
98889
|
-
async ({ group_id, user_id, first_name, last_name, email: email4,
|
|
99338
|
+
async ({ group_id, user_id, first_name, last_name, email: email4, confirmToken }, ctx) => {
|
|
98890
99339
|
let body;
|
|
98891
99340
|
if (user_id !== void 0) {
|
|
98892
99341
|
body = { group_id, user_id };
|
|
@@ -98898,13 +99347,16 @@ function registerGroupTools(server, client2) {
|
|
|
98898
99347
|
}
|
|
98899
99348
|
body = { group_id, first_name, last_name, email: email4 };
|
|
98900
99349
|
}
|
|
98901
|
-
const gate =
|
|
98902
|
-
|
|
98903
|
-
|
|
98904
|
-
|
|
98905
|
-
"
|
|
98906
|
-
|
|
98907
|
-
|
|
99350
|
+
const gate = await confirmWrite(ctx, {
|
|
99351
|
+
tool: "sw_add_user_to_group",
|
|
99352
|
+
action: "group.add_user",
|
|
99353
|
+
summary: `Add a user to Splitwise group ${group_id} (may send an invite email)`,
|
|
99354
|
+
method: "POST",
|
|
99355
|
+
path: "/add_user_to_group",
|
|
99356
|
+
body,
|
|
99357
|
+
target: group_id,
|
|
99358
|
+
confirmToken
|
|
99359
|
+
});
|
|
98908
99360
|
if (gate) return gate;
|
|
98909
99361
|
const data = await client2.request("POST", "/add_user_to_group", body);
|
|
98910
99362
|
return minifiedResult(data);
|
|
@@ -98913,22 +99365,25 @@ function registerGroupTools(server, client2) {
|
|
|
98913
99365
|
server.registerTool(
|
|
98914
99366
|
"sw_remove_user_from_group",
|
|
98915
99367
|
{
|
|
98916
|
-
description:
|
|
99368
|
+
description: `Remove a user from a Splitwise group. ${CONFIRM_NOTE}`,
|
|
98917
99369
|
annotations: { destructiveHint: true },
|
|
98918
99370
|
inputSchema: external_exports.object({
|
|
98919
99371
|
group_id: external_exports.number().describe("Group ID"),
|
|
98920
99372
|
user_id: external_exports.number().describe("User ID to remove"),
|
|
98921
|
-
|
|
99373
|
+
confirmToken: confirmTokenParam
|
|
98922
99374
|
})
|
|
98923
99375
|
},
|
|
98924
|
-
async ({ group_id, user_id,
|
|
98925
|
-
const gate =
|
|
98926
|
-
|
|
98927
|
-
|
|
98928
|
-
|
|
98929
|
-
"
|
|
98930
|
-
|
|
98931
|
-
|
|
99376
|
+
async ({ group_id, user_id, confirmToken }, ctx) => {
|
|
99377
|
+
const gate = await confirmWrite(ctx, {
|
|
99378
|
+
tool: "sw_remove_user_from_group",
|
|
99379
|
+
action: "group.remove_user",
|
|
99380
|
+
summary: `Remove user ${user_id} from Splitwise group ${group_id}`,
|
|
99381
|
+
method: "POST",
|
|
99382
|
+
path: "/remove_user_from_group",
|
|
99383
|
+
body: { group_id, user_id },
|
|
99384
|
+
target: group_id,
|
|
99385
|
+
confirmToken
|
|
99386
|
+
});
|
|
98932
99387
|
if (gate) return gate;
|
|
98933
99388
|
const data = await client2.request("POST", "/remove_user_from_group", { group_id, user_id });
|
|
98934
99389
|
return minifiedResult(data);
|
|
@@ -98937,20 +99392,23 @@ function registerGroupTools(server, client2) {
|
|
|
98937
99392
|
server.registerTool(
|
|
98938
99393
|
"sw_delete_group",
|
|
98939
99394
|
{
|
|
98940
|
-
description:
|
|
99395
|
+
description: `Soft-delete a Splitwise group. ${CONFIRM_NOTE}`,
|
|
98941
99396
|
annotations: { destructiveHint: true },
|
|
98942
99397
|
inputSchema: external_exports.object({
|
|
98943
99398
|
id: external_exports.number().describe("Group ID to delete"),
|
|
98944
|
-
|
|
99399
|
+
confirmToken: confirmTokenParam
|
|
98945
99400
|
})
|
|
98946
99401
|
},
|
|
98947
|
-
async ({ id,
|
|
98948
|
-
const gate =
|
|
98949
|
-
|
|
98950
|
-
|
|
98951
|
-
|
|
98952
|
-
|
|
98953
|
-
|
|
99402
|
+
async ({ id, confirmToken }, ctx) => {
|
|
99403
|
+
const gate = await confirmWrite(ctx, {
|
|
99404
|
+
tool: "sw_delete_group",
|
|
99405
|
+
action: "group.delete",
|
|
99406
|
+
summary: `Soft-delete Splitwise group ${id}`,
|
|
99407
|
+
method: "POST",
|
|
99408
|
+
path: `/delete_group/${id}`,
|
|
99409
|
+
target: id,
|
|
99410
|
+
confirmToken
|
|
99411
|
+
});
|
|
98954
99412
|
if (gate) return gate;
|
|
98955
99413
|
const data = await client2.request("POST", `/delete_group/${id}`);
|
|
98956
99414
|
return minifiedResult(data);
|
|
@@ -98990,24 +99448,27 @@ function registerFriendTools(server, client2) {
|
|
|
98990
99448
|
server.registerTool(
|
|
98991
99449
|
"sw_create_friend",
|
|
98992
99450
|
{
|
|
98993
|
-
description:
|
|
99451
|
+
description: `Add a Splitwise friend by email (sends them an invite). ${CONFIRM_NOTE}`,
|
|
98994
99452
|
annotations: { destructiveHint: true },
|
|
98995
99453
|
inputSchema: external_exports.object({
|
|
98996
99454
|
user_email: external_exports.string().describe("Email of the user to add as a friend"),
|
|
98997
99455
|
user_first_name: external_exports.string().describe("First name of the user").optional(),
|
|
98998
99456
|
user_last_name: external_exports.string().describe("Last name of the user").optional(),
|
|
98999
|
-
|
|
99457
|
+
confirmToken: confirmTokenParam
|
|
99000
99458
|
})
|
|
99001
99459
|
},
|
|
99002
|
-
async ({ user_email, user_first_name, user_last_name,
|
|
99460
|
+
async ({ user_email, user_first_name, user_last_name, confirmToken }, ctx) => {
|
|
99003
99461
|
const body = pruneUndefined({ user_email, user_first_name, user_last_name });
|
|
99004
|
-
const gate =
|
|
99005
|
-
|
|
99006
|
-
|
|
99007
|
-
|
|
99008
|
-
"
|
|
99009
|
-
|
|
99010
|
-
|
|
99462
|
+
const gate = await confirmWrite(ctx, {
|
|
99463
|
+
tool: "sw_create_friend",
|
|
99464
|
+
action: "friend.create",
|
|
99465
|
+
summary: `Add ${user_email} as a Splitwise friend`,
|
|
99466
|
+
method: "POST",
|
|
99467
|
+
path: "/create_friend",
|
|
99468
|
+
body,
|
|
99469
|
+
target: user_email,
|
|
99470
|
+
confirmToken
|
|
99471
|
+
});
|
|
99011
99472
|
if (gate) return gate;
|
|
99012
99473
|
const data = await client2.request("POST", "/create_friend", body);
|
|
99013
99474
|
return minifiedResult(data);
|
|
@@ -99016,20 +99477,23 @@ function registerFriendTools(server, client2) {
|
|
|
99016
99477
|
server.registerTool(
|
|
99017
99478
|
"sw_delete_friend",
|
|
99018
99479
|
{
|
|
99019
|
-
description:
|
|
99480
|
+
description: `Remove a Splitwise friendship by user id. ${CONFIRM_NOTE}`,
|
|
99020
99481
|
annotations: { destructiveHint: true },
|
|
99021
99482
|
inputSchema: external_exports.object({
|
|
99022
99483
|
id: external_exports.number().describe("User ID of the friend to remove"),
|
|
99023
|
-
|
|
99484
|
+
confirmToken: confirmTokenParam
|
|
99024
99485
|
})
|
|
99025
99486
|
},
|
|
99026
|
-
async ({ id,
|
|
99027
|
-
const gate =
|
|
99028
|
-
|
|
99029
|
-
|
|
99030
|
-
|
|
99031
|
-
|
|
99032
|
-
|
|
99487
|
+
async ({ id, confirmToken }, ctx) => {
|
|
99488
|
+
const gate = await confirmWrite(ctx, {
|
|
99489
|
+
tool: "sw_delete_friend",
|
|
99490
|
+
action: "friend.delete",
|
|
99491
|
+
summary: `Remove Splitwise friendship with user ${id}`,
|
|
99492
|
+
method: "POST",
|
|
99493
|
+
path: `/delete_friend/${id}`,
|
|
99494
|
+
target: id,
|
|
99495
|
+
confirmToken
|
|
99496
|
+
});
|
|
99033
99497
|
if (gate) return gate;
|
|
99034
99498
|
const data = await client2.request("POST", `/delete_friend/${id}`);
|
|
99035
99499
|
return minifiedResult(data);
|
|
@@ -99052,7 +99516,7 @@ function buildExpenseBody(args) {
|
|
|
99052
99516
|
split_equally,
|
|
99053
99517
|
users,
|
|
99054
99518
|
expense_id: _id,
|
|
99055
|
-
|
|
99519
|
+
confirmToken: _confirmToken,
|
|
99056
99520
|
...rest
|
|
99057
99521
|
} = args;
|
|
99058
99522
|
if (split_equally && users) {
|
|
@@ -99126,7 +99590,7 @@ function registerExpenseTools(server, client2) {
|
|
|
99126
99590
|
server.registerTool(
|
|
99127
99591
|
"sw_create_expense",
|
|
99128
99592
|
{
|
|
99129
|
-
description:
|
|
99593
|
+
description: `Create a Splitwise expense. Use split_equally:true to split evenly among group members, or provide a users array for custom per-person splits (paid_share and owed_share as decimal strings like "25.00"). cost must be a decimal string. ${CONFIRM_NOTE}`,
|
|
99130
99594
|
inputSchema: external_exports.object({
|
|
99131
99595
|
group_id: external_exports.number().describe("Group to add expense to (use 0 for no group)"),
|
|
99132
99596
|
description: external_exports.string().describe("Short description of the expense"),
|
|
@@ -99139,18 +99603,21 @@ function registerExpenseTools(server, client2) {
|
|
|
99139
99603
|
date: external_exports.string().describe("ISO 8601 datetime").optional(),
|
|
99140
99604
|
category_id: external_exports.number().describe("Category id from sw_get_categories").optional(),
|
|
99141
99605
|
details: external_exports.string().describe("Notes").optional(),
|
|
99142
|
-
|
|
99606
|
+
confirmToken: confirmTokenParam
|
|
99143
99607
|
})
|
|
99144
99608
|
},
|
|
99145
|
-
async (args) => {
|
|
99609
|
+
async (args, ctx) => {
|
|
99146
99610
|
const body = buildExpenseBody(args);
|
|
99147
|
-
const gate =
|
|
99148
|
-
|
|
99149
|
-
|
|
99150
|
-
"
|
|
99151
|
-
"
|
|
99152
|
-
|
|
99153
|
-
|
|
99611
|
+
const gate = await confirmWrite(ctx, {
|
|
99612
|
+
tool: "sw_create_expense",
|
|
99613
|
+
action: "expense.create",
|
|
99614
|
+
summary: `Create a Splitwise expense "${args.description}" (${args.cost}) \u2014 notifies group members`,
|
|
99615
|
+
method: "POST",
|
|
99616
|
+
path: "/create_expense",
|
|
99617
|
+
body,
|
|
99618
|
+
target: args.group_id,
|
|
99619
|
+
confirmToken: args.confirmToken
|
|
99620
|
+
});
|
|
99154
99621
|
if (gate) return gate;
|
|
99155
99622
|
const data = await client2.request("POST", "/create_expense", body);
|
|
99156
99623
|
return minifiedResult(data);
|
|
@@ -99159,7 +99626,7 @@ function registerExpenseTools(server, client2) {
|
|
|
99159
99626
|
server.registerTool(
|
|
99160
99627
|
"sw_update_expense",
|
|
99161
99628
|
{
|
|
99162
|
-
description:
|
|
99629
|
+
description: `Edit an existing Splitwise expense. Provide expense_id and any fields to change. For custom split updates, the full users array must be provided (the API replaces the entire split). ${CONFIRM_NOTE}`,
|
|
99163
99630
|
inputSchema: external_exports.object({
|
|
99164
99631
|
expense_id: external_exports.number().describe("ID of the expense to update"),
|
|
99165
99632
|
description: external_exports.string().optional(),
|
|
@@ -99172,19 +99639,22 @@ function registerExpenseTools(server, client2) {
|
|
|
99172
99639
|
date: external_exports.string().optional(),
|
|
99173
99640
|
category_id: external_exports.number().optional(),
|
|
99174
99641
|
details: external_exports.string().optional(),
|
|
99175
|
-
|
|
99642
|
+
confirmToken: confirmTokenParam
|
|
99176
99643
|
})
|
|
99177
99644
|
},
|
|
99178
|
-
async (args) => {
|
|
99645
|
+
async (args, ctx) => {
|
|
99179
99646
|
const { expense_id } = args;
|
|
99180
99647
|
const body = buildExpenseBody(args);
|
|
99181
|
-
const gate =
|
|
99182
|
-
|
|
99183
|
-
|
|
99184
|
-
|
|
99185
|
-
|
|
99186
|
-
|
|
99187
|
-
|
|
99648
|
+
const gate = await confirmWrite(ctx, {
|
|
99649
|
+
tool: "sw_update_expense",
|
|
99650
|
+
action: "expense.update",
|
|
99651
|
+
summary: `Update Splitwise expense ${expense_id} \u2014 notifies group members`,
|
|
99652
|
+
method: "POST",
|
|
99653
|
+
path: `/update_expense/${expense_id}`,
|
|
99654
|
+
body,
|
|
99655
|
+
target: expense_id,
|
|
99656
|
+
confirmToken: args.confirmToken
|
|
99657
|
+
});
|
|
99188
99658
|
if (gate) return gate;
|
|
99189
99659
|
const data = await client2.request("POST", `/update_expense/${expense_id}`, body);
|
|
99190
99660
|
return minifiedResult(data);
|
|
@@ -99193,20 +99663,23 @@ function registerExpenseTools(server, client2) {
|
|
|
99193
99663
|
server.registerTool(
|
|
99194
99664
|
"sw_delete_expense",
|
|
99195
99665
|
{
|
|
99196
|
-
description:
|
|
99666
|
+
description: `Soft-delete a Splitwise expense by id. Returns {success: true} on success. Use sw_undelete_expense to restore. ${CONFIRM_NOTE}`,
|
|
99197
99667
|
annotations: { destructiveHint: true },
|
|
99198
99668
|
inputSchema: external_exports.object({
|
|
99199
99669
|
id: external_exports.number().describe("Expense ID to delete"),
|
|
99200
|
-
|
|
99670
|
+
confirmToken: confirmTokenParam
|
|
99201
99671
|
})
|
|
99202
99672
|
},
|
|
99203
|
-
async ({ id,
|
|
99204
|
-
const gate =
|
|
99205
|
-
|
|
99206
|
-
|
|
99207
|
-
|
|
99208
|
-
|
|
99209
|
-
|
|
99673
|
+
async ({ id, confirmToken }, ctx) => {
|
|
99674
|
+
const gate = await confirmWrite(ctx, {
|
|
99675
|
+
tool: "sw_delete_expense",
|
|
99676
|
+
action: "expense.delete",
|
|
99677
|
+
summary: `Soft-delete Splitwise expense ${id}`,
|
|
99678
|
+
method: "POST",
|
|
99679
|
+
path: `/delete_expense/${id}`,
|
|
99680
|
+
target: id,
|
|
99681
|
+
confirmToken
|
|
99682
|
+
});
|
|
99210
99683
|
if (gate) return gate;
|
|
99211
99684
|
const data = await client2.request("POST", `/delete_expense/${id}`);
|
|
99212
99685
|
return minifiedResult(data);
|
|
@@ -99285,7 +99758,7 @@ function registerReceiptTools(server, client2) {
|
|
|
99285
99758
|
"Also return the PDF's text layer as `text`. Ideal for looking up line items or totals without transferring the file. PDFs only; a scanned receipt has no text layer to extract."
|
|
99286
99759
|
).optional(),
|
|
99287
99760
|
output_dir: external_exports.string().describe(
|
|
99288
|
-
"Directory to write the receipt into. Defaults to $SPLITWISE_OUTPUT_DIR, else the current working directory."
|
|
99761
|
+
"Directory to write the receipt into. Defaults to $SPLITWISE_OUTPUT_DIR, else the current working directory. When SPLITWISE_OUTPUT_DIR is set, this must be inside it."
|
|
99289
99762
|
).optional(),
|
|
99290
99763
|
write: external_exports.boolean().describe(
|
|
99291
99764
|
"Write the receipt to disk. Defaults to true. Pass false when the caller cannot reach this server's filesystem, or when the server runs read-only."
|
|
@@ -99312,8 +99785,11 @@ function registerReceiptTools(server, client2) {
|
|
|
99312
99785
|
let writeError;
|
|
99313
99786
|
if (write !== false) {
|
|
99314
99787
|
try {
|
|
99788
|
+
const configuredDir = readEnvVar("SPLITWISE_OUTPUT_DIR");
|
|
99315
99789
|
path = writeBinaryOutput({
|
|
99316
|
-
dir: resolveOutputDir(output_dir, "SPLITWISE_OUTPUT_DIR"
|
|
99790
|
+
dir: resolveOutputDir(output_dir, "SPLITWISE_OUTPUT_DIR", {
|
|
99791
|
+
...configuredDir ? { allowedRoots: [configuredDir] } : {}
|
|
99792
|
+
}),
|
|
99317
99793
|
baseName: `splitwise-receipt-${id}`,
|
|
99318
99794
|
base64: base643,
|
|
99319
99795
|
extension: extensionFor(mimeType, url4)
|
|
@@ -99462,22 +99938,25 @@ function registerUtilityTools(server, client2) {
|
|
|
99462
99938
|
server.registerTool(
|
|
99463
99939
|
"sw_create_comment",
|
|
99464
99940
|
{
|
|
99465
|
-
description:
|
|
99941
|
+
description: `Add a comment to a Splitwise expense (visible to other participants). ${CONFIRM_NOTE}`,
|
|
99466
99942
|
annotations: { destructiveHint: true },
|
|
99467
99943
|
inputSchema: external_exports.object({
|
|
99468
99944
|
expense_id: external_exports.number().describe("Expense ID to comment on"),
|
|
99469
99945
|
content: external_exports.string().describe("Comment text"),
|
|
99470
|
-
|
|
99946
|
+
confirmToken: confirmTokenParam
|
|
99471
99947
|
})
|
|
99472
99948
|
},
|
|
99473
|
-
async ({ expense_id, content,
|
|
99474
|
-
const gate =
|
|
99475
|
-
|
|
99476
|
-
|
|
99477
|
-
|
|
99478
|
-
"
|
|
99479
|
-
|
|
99480
|
-
|
|
99949
|
+
async ({ expense_id, content, confirmToken }, ctx) => {
|
|
99950
|
+
const gate = await confirmWrite(ctx, {
|
|
99951
|
+
tool: "sw_create_comment",
|
|
99952
|
+
action: "comment.create",
|
|
99953
|
+
summary: `Comment on Splitwise expense ${expense_id} (visible to participants)`,
|
|
99954
|
+
method: "POST",
|
|
99955
|
+
path: "/create_comment",
|
|
99956
|
+
body: { expense_id, content },
|
|
99957
|
+
target: expense_id,
|
|
99958
|
+
confirmToken
|
|
99959
|
+
});
|
|
99481
99960
|
if (gate) return gate;
|
|
99482
99961
|
const data = await client2.request("POST", "/create_comment", { expense_id, content });
|
|
99483
99962
|
return minifiedResult(data);
|
|
@@ -99486,20 +99965,23 @@ function registerUtilityTools(server, client2) {
|
|
|
99486
99965
|
server.registerTool(
|
|
99487
99966
|
"sw_delete_comment",
|
|
99488
99967
|
{
|
|
99489
|
-
description:
|
|
99968
|
+
description: `Delete a comment by id. ${CONFIRM_NOTE}`,
|
|
99490
99969
|
annotations: { destructiveHint: true },
|
|
99491
99970
|
inputSchema: external_exports.object({
|
|
99492
99971
|
id: external_exports.number().describe("Comment ID to delete"),
|
|
99493
|
-
|
|
99972
|
+
confirmToken: confirmTokenParam
|
|
99494
99973
|
})
|
|
99495
99974
|
},
|
|
99496
|
-
async ({ id,
|
|
99497
|
-
const gate =
|
|
99498
|
-
|
|
99499
|
-
|
|
99500
|
-
|
|
99501
|
-
|
|
99502
|
-
|
|
99975
|
+
async ({ id, confirmToken }, ctx) => {
|
|
99976
|
+
const gate = await confirmWrite(ctx, {
|
|
99977
|
+
tool: "sw_delete_comment",
|
|
99978
|
+
action: "comment.delete",
|
|
99979
|
+
summary: `Delete Splitwise comment ${id}`,
|
|
99980
|
+
method: "POST",
|
|
99981
|
+
path: `/delete_comment/${id}`,
|
|
99982
|
+
target: id,
|
|
99983
|
+
confirmToken
|
|
99984
|
+
});
|
|
99503
99985
|
if (gate) return gate;
|
|
99504
99986
|
const data = await client2.request("POST", `/delete_comment/${id}`);
|
|
99505
99987
|
return minifiedResult(data);
|
|
@@ -99510,7 +99992,7 @@ function registerUtilityTools(server, client2) {
|
|
|
99510
99992
|
// src/index.ts
|
|
99511
99993
|
await runMcp({
|
|
99512
99994
|
name: "splitwise-mcp",
|
|
99513
|
-
version: "3.1
|
|
99995
|
+
version: "3.2.1",
|
|
99514
99996
|
// x-release-please-version
|
|
99515
99997
|
deps: client,
|
|
99516
99998
|
banner: "[splitwise-mcp] This project was developed and is maintained by AI (Claude Sonnet 4.6). Use at your own discretion.",
|