splitwise-mcp 3.1.1 → 3.2.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 +12 -1
- package/dist/bundle.js +681 -179
- package/dist/client.js +35 -1
- 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/user.js +21 -11
- package/dist/tools/utilities.js +26 -9
- package/package.json +2 -2
- 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";
|
|
@@ -98340,6 +98774,25 @@ function redactAssetQuery(err, search) {
|
|
|
98340
98774
|
if (message === err.message) return err;
|
|
98341
98775
|
return err instanceof ApiError ? new ApiError(err.status, message) : new Error(message);
|
|
98342
98776
|
}
|
|
98777
|
+
function flattenErrors(errors) {
|
|
98778
|
+
if (errors == null) return [];
|
|
98779
|
+
if (typeof errors === "string") return errors ? [errors] : [];
|
|
98780
|
+
if (Array.isArray(errors)) return errors.flatMap((e2) => flattenErrors(e2));
|
|
98781
|
+
if (typeof errors === "object") {
|
|
98782
|
+
return Object.entries(errors).flatMap(
|
|
98783
|
+
([field, value]) => flattenErrors(value).map((msg) => field === "base" ? msg : `${field}: ${msg}`)
|
|
98784
|
+
);
|
|
98785
|
+
}
|
|
98786
|
+
return [String(errors)];
|
|
98787
|
+
}
|
|
98788
|
+
function assertWriteSucceeded(data) {
|
|
98789
|
+
if (data === null || typeof data !== "object" || Array.isArray(data)) return;
|
|
98790
|
+
const record4 = data;
|
|
98791
|
+
const messages = flattenErrors(record4.errors);
|
|
98792
|
+
if (messages.length === 0 && record4.success !== false) return;
|
|
98793
|
+
const detail = messages.length > 0 ? messages.join("; ") : "success: false with no error detail";
|
|
98794
|
+
throw new Error(`Splitwise rejected the request: ${detail}`);
|
|
98795
|
+
}
|
|
98343
98796
|
var SplitwiseClient = class {
|
|
98344
98797
|
apiKey;
|
|
98345
98798
|
/** Which source supplied the API key — a LABEL, never the value. */
|
|
@@ -98404,7 +98857,9 @@ var SplitwiseClient = class {
|
|
|
98404
98857
|
return this.apiKey;
|
|
98405
98858
|
}
|
|
98406
98859
|
async request(method, path, body) {
|
|
98407
|
-
|
|
98860
|
+
const data = await this.api.fetchJson(method, path, body !== void 0 ? { body } : {});
|
|
98861
|
+
if (method.toUpperCase() !== "GET") assertWriteSucceeded(data);
|
|
98862
|
+
return data;
|
|
98408
98863
|
}
|
|
98409
98864
|
/**
|
|
98410
98865
|
* Fetch the raw bytes behind an absolute asset URL the API handed back (an
|
|
@@ -98542,16 +98997,25 @@ function viewGeneric(view, payload) {
|
|
|
98542
98997
|
}
|
|
98543
98998
|
|
|
98544
98999
|
// src/tools/_confirm.ts
|
|
98545
|
-
|
|
98546
|
-
|
|
98547
|
-
|
|
98548
|
-
|
|
98549
|
-
|
|
98550
|
-
|
|
98551
|
-
|
|
98552
|
-
|
|
98553
|
-
|
|
98554
|
-
|
|
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
|
+
);
|
|
98555
99019
|
}
|
|
98556
99020
|
|
|
98557
99021
|
// src/tools/user.ts
|
|
@@ -98588,35 +99052,40 @@ function registerUserTools(server, client2) {
|
|
|
98588
99052
|
server.registerTool(
|
|
98589
99053
|
"sw_update_user",
|
|
98590
99054
|
{
|
|
98591
|
-
description: "Update the current user's profile fields. id must be the current user's id.",
|
|
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,
|
|
99056
|
+
annotations: { readOnlyHint: false, destructiveHint: true },
|
|
99057
|
+
// No `email` / `password`: changing the login email is an account
|
|
99058
|
+
// takeover primitive (a password reset to the new address follows), and
|
|
99059
|
+
// the only gate would be a model-driven confirmation that injected text from
|
|
99060
|
+
// comments, notifications or receipts could talk it into (fleet-audit
|
|
99061
|
+
// #250). z.object strips unknown keys, so a caller passing them anyway
|
|
99062
|
+
// has them dropped before the request is built.
|
|
98592
99063
|
inputSchema: external_exports.object({
|
|
98593
99064
|
id: external_exports.number().describe("User ID (must be the current user's id)"),
|
|
98594
99065
|
first_name: external_exports.string().optional(),
|
|
98595
99066
|
last_name: external_exports.string().optional(),
|
|
98596
|
-
email: external_exports.string().optional(),
|
|
98597
|
-
password: external_exports.string().optional(),
|
|
98598
99067
|
locale: external_exports.string().optional(),
|
|
98599
99068
|
default_currency: external_exports.string().optional(),
|
|
98600
|
-
|
|
99069
|
+
confirmToken: confirmTokenParam
|
|
98601
99070
|
})
|
|
98602
99071
|
},
|
|
98603
|
-
async ({ id, first_name, last_name,
|
|
99072
|
+
async ({ id, first_name, last_name, locale, default_currency, confirmToken }, ctx) => {
|
|
98604
99073
|
const body = pruneUndefined({
|
|
98605
99074
|
first_name,
|
|
98606
99075
|
last_name,
|
|
98607
|
-
email: email4,
|
|
98608
|
-
password,
|
|
98609
99076
|
locale,
|
|
98610
99077
|
default_currency
|
|
98611
99078
|
});
|
|
98612
|
-
const
|
|
98613
|
-
|
|
98614
|
-
|
|
98615
|
-
`Update current Splitwise user ${id} profile`,
|
|
98616
|
-
"POST",
|
|
98617
|
-
`/update_user/${id}`,
|
|
98618
|
-
|
|
98619
|
-
|
|
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
|
+
});
|
|
98620
99089
|
if (gate) return gate;
|
|
98621
99090
|
const data = await client2.request("POST", `/update_user/${id}`, body);
|
|
98622
99091
|
return minifiedResult(data);
|
|
@@ -98827,24 +99296,27 @@ function registerGroupTools(server, client2) {
|
|
|
98827
99296
|
server.registerTool(
|
|
98828
99297
|
"sw_create_group",
|
|
98829
99298
|
{
|
|
98830
|
-
description:
|
|
99299
|
+
description: `Create a new Splitwise group. ${CONFIRM_NOTE}`,
|
|
98831
99300
|
annotations: { destructiveHint: true },
|
|
98832
99301
|
inputSchema: external_exports.object({
|
|
98833
99302
|
name: external_exports.string().describe("Group name"),
|
|
98834
99303
|
group_type: external_exports.enum(["apartment", "house", "trip", "other"]).describe("Type of group").optional(),
|
|
98835
99304
|
simplify_by_default: external_exports.boolean().describe("Whether to simplify debts by default").optional(),
|
|
98836
|
-
|
|
99305
|
+
confirmToken: confirmTokenParam
|
|
98837
99306
|
})
|
|
98838
99307
|
},
|
|
98839
|
-
async ({ name, group_type, simplify_by_default,
|
|
99308
|
+
async ({ name, group_type, simplify_by_default, confirmToken }, ctx) => {
|
|
98840
99309
|
const body = pruneUndefined({ name, group_type, simplify_by_default });
|
|
98841
|
-
const gate =
|
|
98842
|
-
|
|
98843
|
-
|
|
98844
|
-
"
|
|
98845
|
-
"
|
|
98846
|
-
|
|
98847
|
-
|
|
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
|
+
});
|
|
98848
99320
|
if (gate) return gate;
|
|
98849
99321
|
const data = await client2.request("POST", "/create_group", body);
|
|
98850
99322
|
return minifiedResult(data);
|
|
@@ -98853,17 +99325,17 @@ function registerGroupTools(server, client2) {
|
|
|
98853
99325
|
server.registerTool(
|
|
98854
99326
|
"sw_add_user_to_group",
|
|
98855
99327
|
{
|
|
98856
|
-
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}`,
|
|
98857
99329
|
inputSchema: external_exports.object({
|
|
98858
99330
|
group_id: external_exports.number().describe("Group ID"),
|
|
98859
99331
|
user_id: external_exports.number().describe("User ID (preferred)").optional(),
|
|
98860
99332
|
first_name: external_exports.string().optional(),
|
|
98861
99333
|
last_name: external_exports.string().optional(),
|
|
98862
99334
|
email: external_exports.string().optional(),
|
|
98863
|
-
|
|
99335
|
+
confirmToken: confirmTokenParam
|
|
98864
99336
|
})
|
|
98865
99337
|
},
|
|
98866
|
-
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) => {
|
|
98867
99339
|
let body;
|
|
98868
99340
|
if (user_id !== void 0) {
|
|
98869
99341
|
body = { group_id, user_id };
|
|
@@ -98875,13 +99347,16 @@ function registerGroupTools(server, client2) {
|
|
|
98875
99347
|
}
|
|
98876
99348
|
body = { group_id, first_name, last_name, email: email4 };
|
|
98877
99349
|
}
|
|
98878
|
-
const gate =
|
|
98879
|
-
|
|
98880
|
-
|
|
98881
|
-
|
|
98882
|
-
"
|
|
98883
|
-
|
|
98884
|
-
|
|
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
|
+
});
|
|
98885
99360
|
if (gate) return gate;
|
|
98886
99361
|
const data = await client2.request("POST", "/add_user_to_group", body);
|
|
98887
99362
|
return minifiedResult(data);
|
|
@@ -98890,22 +99365,25 @@ function registerGroupTools(server, client2) {
|
|
|
98890
99365
|
server.registerTool(
|
|
98891
99366
|
"sw_remove_user_from_group",
|
|
98892
99367
|
{
|
|
98893
|
-
description:
|
|
99368
|
+
description: `Remove a user from a Splitwise group. ${CONFIRM_NOTE}`,
|
|
98894
99369
|
annotations: { destructiveHint: true },
|
|
98895
99370
|
inputSchema: external_exports.object({
|
|
98896
99371
|
group_id: external_exports.number().describe("Group ID"),
|
|
98897
99372
|
user_id: external_exports.number().describe("User ID to remove"),
|
|
98898
|
-
|
|
99373
|
+
confirmToken: confirmTokenParam
|
|
98899
99374
|
})
|
|
98900
99375
|
},
|
|
98901
|
-
async ({ group_id, user_id,
|
|
98902
|
-
const gate =
|
|
98903
|
-
|
|
98904
|
-
|
|
98905
|
-
|
|
98906
|
-
"
|
|
98907
|
-
|
|
98908
|
-
|
|
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
|
+
});
|
|
98909
99387
|
if (gate) return gate;
|
|
98910
99388
|
const data = await client2.request("POST", "/remove_user_from_group", { group_id, user_id });
|
|
98911
99389
|
return minifiedResult(data);
|
|
@@ -98914,20 +99392,23 @@ function registerGroupTools(server, client2) {
|
|
|
98914
99392
|
server.registerTool(
|
|
98915
99393
|
"sw_delete_group",
|
|
98916
99394
|
{
|
|
98917
|
-
description:
|
|
99395
|
+
description: `Soft-delete a Splitwise group. ${CONFIRM_NOTE}`,
|
|
98918
99396
|
annotations: { destructiveHint: true },
|
|
98919
99397
|
inputSchema: external_exports.object({
|
|
98920
99398
|
id: external_exports.number().describe("Group ID to delete"),
|
|
98921
|
-
|
|
99399
|
+
confirmToken: confirmTokenParam
|
|
98922
99400
|
})
|
|
98923
99401
|
},
|
|
98924
|
-
async ({ id,
|
|
98925
|
-
const gate =
|
|
98926
|
-
|
|
98927
|
-
|
|
98928
|
-
|
|
98929
|
-
|
|
98930
|
-
|
|
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
|
+
});
|
|
98931
99412
|
if (gate) return gate;
|
|
98932
99413
|
const data = await client2.request("POST", `/delete_group/${id}`);
|
|
98933
99414
|
return minifiedResult(data);
|
|
@@ -98967,24 +99448,27 @@ function registerFriendTools(server, client2) {
|
|
|
98967
99448
|
server.registerTool(
|
|
98968
99449
|
"sw_create_friend",
|
|
98969
99450
|
{
|
|
98970
|
-
description:
|
|
99451
|
+
description: `Add a Splitwise friend by email (sends them an invite). ${CONFIRM_NOTE}`,
|
|
98971
99452
|
annotations: { destructiveHint: true },
|
|
98972
99453
|
inputSchema: external_exports.object({
|
|
98973
99454
|
user_email: external_exports.string().describe("Email of the user to add as a friend"),
|
|
98974
99455
|
user_first_name: external_exports.string().describe("First name of the user").optional(),
|
|
98975
99456
|
user_last_name: external_exports.string().describe("Last name of the user").optional(),
|
|
98976
|
-
|
|
99457
|
+
confirmToken: confirmTokenParam
|
|
98977
99458
|
})
|
|
98978
99459
|
},
|
|
98979
|
-
async ({ user_email, user_first_name, user_last_name,
|
|
99460
|
+
async ({ user_email, user_first_name, user_last_name, confirmToken }, ctx) => {
|
|
98980
99461
|
const body = pruneUndefined({ user_email, user_first_name, user_last_name });
|
|
98981
|
-
const gate =
|
|
98982
|
-
|
|
98983
|
-
|
|
98984
|
-
|
|
98985
|
-
"
|
|
98986
|
-
|
|
98987
|
-
|
|
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
|
+
});
|
|
98988
99472
|
if (gate) return gate;
|
|
98989
99473
|
const data = await client2.request("POST", "/create_friend", body);
|
|
98990
99474
|
return minifiedResult(data);
|
|
@@ -98993,20 +99477,23 @@ function registerFriendTools(server, client2) {
|
|
|
98993
99477
|
server.registerTool(
|
|
98994
99478
|
"sw_delete_friend",
|
|
98995
99479
|
{
|
|
98996
|
-
description:
|
|
99480
|
+
description: `Remove a Splitwise friendship by user id. ${CONFIRM_NOTE}`,
|
|
98997
99481
|
annotations: { destructiveHint: true },
|
|
98998
99482
|
inputSchema: external_exports.object({
|
|
98999
99483
|
id: external_exports.number().describe("User ID of the friend to remove"),
|
|
99000
|
-
|
|
99484
|
+
confirmToken: confirmTokenParam
|
|
99001
99485
|
})
|
|
99002
99486
|
},
|
|
99003
|
-
async ({ id,
|
|
99004
|
-
const gate =
|
|
99005
|
-
|
|
99006
|
-
|
|
99007
|
-
|
|
99008
|
-
|
|
99009
|
-
|
|
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
|
+
});
|
|
99010
99497
|
if (gate) return gate;
|
|
99011
99498
|
const data = await client2.request("POST", `/delete_friend/${id}`);
|
|
99012
99499
|
return minifiedResult(data);
|
|
@@ -99029,7 +99516,7 @@ function buildExpenseBody(args) {
|
|
|
99029
99516
|
split_equally,
|
|
99030
99517
|
users,
|
|
99031
99518
|
expense_id: _id,
|
|
99032
|
-
|
|
99519
|
+
confirmToken: _confirmToken,
|
|
99033
99520
|
...rest
|
|
99034
99521
|
} = args;
|
|
99035
99522
|
if (split_equally && users) {
|
|
@@ -99103,7 +99590,7 @@ function registerExpenseTools(server, client2) {
|
|
|
99103
99590
|
server.registerTool(
|
|
99104
99591
|
"sw_create_expense",
|
|
99105
99592
|
{
|
|
99106
|
-
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}`,
|
|
99107
99594
|
inputSchema: external_exports.object({
|
|
99108
99595
|
group_id: external_exports.number().describe("Group to add expense to (use 0 for no group)"),
|
|
99109
99596
|
description: external_exports.string().describe("Short description of the expense"),
|
|
@@ -99116,18 +99603,21 @@ function registerExpenseTools(server, client2) {
|
|
|
99116
99603
|
date: external_exports.string().describe("ISO 8601 datetime").optional(),
|
|
99117
99604
|
category_id: external_exports.number().describe("Category id from sw_get_categories").optional(),
|
|
99118
99605
|
details: external_exports.string().describe("Notes").optional(),
|
|
99119
|
-
|
|
99606
|
+
confirmToken: confirmTokenParam
|
|
99120
99607
|
})
|
|
99121
99608
|
},
|
|
99122
|
-
async (args) => {
|
|
99609
|
+
async (args, ctx) => {
|
|
99123
99610
|
const body = buildExpenseBody(args);
|
|
99124
|
-
const gate =
|
|
99125
|
-
|
|
99126
|
-
|
|
99127
|
-
"
|
|
99128
|
-
"
|
|
99129
|
-
|
|
99130
|
-
|
|
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
|
+
});
|
|
99131
99621
|
if (gate) return gate;
|
|
99132
99622
|
const data = await client2.request("POST", "/create_expense", body);
|
|
99133
99623
|
return minifiedResult(data);
|
|
@@ -99136,7 +99626,7 @@ function registerExpenseTools(server, client2) {
|
|
|
99136
99626
|
server.registerTool(
|
|
99137
99627
|
"sw_update_expense",
|
|
99138
99628
|
{
|
|
99139
|
-
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}`,
|
|
99140
99630
|
inputSchema: external_exports.object({
|
|
99141
99631
|
expense_id: external_exports.number().describe("ID of the expense to update"),
|
|
99142
99632
|
description: external_exports.string().optional(),
|
|
@@ -99149,19 +99639,22 @@ function registerExpenseTools(server, client2) {
|
|
|
99149
99639
|
date: external_exports.string().optional(),
|
|
99150
99640
|
category_id: external_exports.number().optional(),
|
|
99151
99641
|
details: external_exports.string().optional(),
|
|
99152
|
-
|
|
99642
|
+
confirmToken: confirmTokenParam
|
|
99153
99643
|
})
|
|
99154
99644
|
},
|
|
99155
|
-
async (args) => {
|
|
99645
|
+
async (args, ctx) => {
|
|
99156
99646
|
const { expense_id } = args;
|
|
99157
99647
|
const body = buildExpenseBody(args);
|
|
99158
|
-
const gate =
|
|
99159
|
-
|
|
99160
|
-
|
|
99161
|
-
|
|
99162
|
-
|
|
99163
|
-
|
|
99164
|
-
|
|
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
|
+
});
|
|
99165
99658
|
if (gate) return gate;
|
|
99166
99659
|
const data = await client2.request("POST", `/update_expense/${expense_id}`, body);
|
|
99167
99660
|
return minifiedResult(data);
|
|
@@ -99170,20 +99663,23 @@ function registerExpenseTools(server, client2) {
|
|
|
99170
99663
|
server.registerTool(
|
|
99171
99664
|
"sw_delete_expense",
|
|
99172
99665
|
{
|
|
99173
|
-
description:
|
|
99666
|
+
description: `Soft-delete a Splitwise expense by id. Returns {success: true} on success. Use sw_undelete_expense to restore. ${CONFIRM_NOTE}`,
|
|
99174
99667
|
annotations: { destructiveHint: true },
|
|
99175
99668
|
inputSchema: external_exports.object({
|
|
99176
99669
|
id: external_exports.number().describe("Expense ID to delete"),
|
|
99177
|
-
|
|
99670
|
+
confirmToken: confirmTokenParam
|
|
99178
99671
|
})
|
|
99179
99672
|
},
|
|
99180
|
-
async ({ id,
|
|
99181
|
-
const gate =
|
|
99182
|
-
|
|
99183
|
-
|
|
99184
|
-
|
|
99185
|
-
|
|
99186
|
-
|
|
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
|
+
});
|
|
99187
99683
|
if (gate) return gate;
|
|
99188
99684
|
const data = await client2.request("POST", `/delete_expense/${id}`);
|
|
99189
99685
|
return minifiedResult(data);
|
|
@@ -99439,22 +99935,25 @@ function registerUtilityTools(server, client2) {
|
|
|
99439
99935
|
server.registerTool(
|
|
99440
99936
|
"sw_create_comment",
|
|
99441
99937
|
{
|
|
99442
|
-
description:
|
|
99938
|
+
description: `Add a comment to a Splitwise expense (visible to other participants). ${CONFIRM_NOTE}`,
|
|
99443
99939
|
annotations: { destructiveHint: true },
|
|
99444
99940
|
inputSchema: external_exports.object({
|
|
99445
99941
|
expense_id: external_exports.number().describe("Expense ID to comment on"),
|
|
99446
99942
|
content: external_exports.string().describe("Comment text"),
|
|
99447
|
-
|
|
99943
|
+
confirmToken: confirmTokenParam
|
|
99448
99944
|
})
|
|
99449
99945
|
},
|
|
99450
|
-
async ({ expense_id, content,
|
|
99451
|
-
const gate =
|
|
99452
|
-
|
|
99453
|
-
|
|
99454
|
-
|
|
99455
|
-
"
|
|
99456
|
-
|
|
99457
|
-
|
|
99946
|
+
async ({ expense_id, content, confirmToken }, ctx) => {
|
|
99947
|
+
const gate = await confirmWrite(ctx, {
|
|
99948
|
+
tool: "sw_create_comment",
|
|
99949
|
+
action: "comment.create",
|
|
99950
|
+
summary: `Comment on Splitwise expense ${expense_id} (visible to participants)`,
|
|
99951
|
+
method: "POST",
|
|
99952
|
+
path: "/create_comment",
|
|
99953
|
+
body: { expense_id, content },
|
|
99954
|
+
target: expense_id,
|
|
99955
|
+
confirmToken
|
|
99956
|
+
});
|
|
99458
99957
|
if (gate) return gate;
|
|
99459
99958
|
const data = await client2.request("POST", "/create_comment", { expense_id, content });
|
|
99460
99959
|
return minifiedResult(data);
|
|
@@ -99463,20 +99962,23 @@ function registerUtilityTools(server, client2) {
|
|
|
99463
99962
|
server.registerTool(
|
|
99464
99963
|
"sw_delete_comment",
|
|
99465
99964
|
{
|
|
99466
|
-
description:
|
|
99965
|
+
description: `Delete a comment by id. ${CONFIRM_NOTE}`,
|
|
99467
99966
|
annotations: { destructiveHint: true },
|
|
99468
99967
|
inputSchema: external_exports.object({
|
|
99469
99968
|
id: external_exports.number().describe("Comment ID to delete"),
|
|
99470
|
-
|
|
99969
|
+
confirmToken: confirmTokenParam
|
|
99471
99970
|
})
|
|
99472
99971
|
},
|
|
99473
|
-
async ({ id,
|
|
99474
|
-
const gate =
|
|
99475
|
-
|
|
99476
|
-
|
|
99477
|
-
|
|
99478
|
-
|
|
99479
|
-
|
|
99972
|
+
async ({ id, confirmToken }, ctx) => {
|
|
99973
|
+
const gate = await confirmWrite(ctx, {
|
|
99974
|
+
tool: "sw_delete_comment",
|
|
99975
|
+
action: "comment.delete",
|
|
99976
|
+
summary: `Delete Splitwise comment ${id}`,
|
|
99977
|
+
method: "POST",
|
|
99978
|
+
path: `/delete_comment/${id}`,
|
|
99979
|
+
target: id,
|
|
99980
|
+
confirmToken
|
|
99981
|
+
});
|
|
99480
99982
|
if (gate) return gate;
|
|
99481
99983
|
const data = await client2.request("POST", `/delete_comment/${id}`);
|
|
99482
99984
|
return minifiedResult(data);
|
|
@@ -99487,7 +99989,7 @@ function registerUtilityTools(server, client2) {
|
|
|
99487
99989
|
// src/index.ts
|
|
99488
99990
|
await runMcp({
|
|
99489
99991
|
name: "splitwise-mcp",
|
|
99490
|
-
version: "3.
|
|
99992
|
+
version: "3.2.0",
|
|
99491
99993
|
// x-release-please-version
|
|
99492
99994
|
deps: client,
|
|
99493
99995
|
banner: "[splitwise-mcp] This project was developed and is maintained by AI (Claude Sonnet 4.6). Use at your own discretion.",
|