@expensebot/mcp-server-auth 0.6.26 → 0.6.28
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/README.md +63 -24
- package/package.json +4 -3
- package/scripts/description-parity.js +74 -0
- package/scripts/description-parity.test.js +95 -0
- package/scripts/sync-check.js +34 -1
- package/server.json +3 -3
- package/src/client.js +1 -1
- package/src/index.js +1105 -420
- package/src/onboarding.test.js +75 -0
- package/src/test.js +353 -6
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
5
|
+
import { buildToolList, routeToolCall } from '../../mcp-server-remote/src/tools.js';
|
|
6
|
+
const Ajv = createRequire(new URL('../../server/package.json', import.meta.url))('ajv');
|
|
7
|
+
const catalog = JSON.parse(readFileSync(new URL('../../mcp-server-remote/src/tools.generated.json', import.meta.url))).tools;
|
|
8
|
+
const tools = buildToolList();
|
|
9
|
+
const setup = tools.find(t => t.name === 'complete_setup');
|
|
10
|
+
const validate = new Ajv({ allErrors: true }).compile(setup.inputSchema);
|
|
11
|
+
|
|
12
|
+
test('setup exposes explicit scopes and truthful mutation annotations', () => {
|
|
13
|
+
const read = tools.find(t => t.name === 'get_setup_status');
|
|
14
|
+
assert.deepEqual(read.securitySchemes, [{ type: 'oauth2', scopes: ['setup.read'] }]);
|
|
15
|
+
assert.deepEqual(setup.securitySchemes, [{ type: 'oauth2', scopes: ['setup.write'] }]);
|
|
16
|
+
assert.equal(read.annotations.readOnlyHint, true);
|
|
17
|
+
assert.deepEqual(routeToolCall('get_setup_status', { clientEmail: 'ignored@example.test' }), { actionId: 'get_setup_status', params: {} });
|
|
18
|
+
assert.equal(setup.annotations.readOnlyHint, false);
|
|
19
|
+
assert.equal(setup.annotations.destructiveHint, true);
|
|
20
|
+
assert.equal(setup.annotations.openWorldHint, true);
|
|
21
|
+
assert.equal(new Ajv().compile(read.inputSchema)({ clientEmail: 'other@example.test' }), false);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('typed previews, proposal-only confirmation and readback preserve payloads', () => {
|
|
25
|
+
const cases = [
|
|
26
|
+
{ operation: 'general_settings', answers: { homeCountry: 'CA', homeCurrency: 'CAD', businessName: 'Example' } },
|
|
27
|
+
{ operation: 'personal_rules', answers: { personalCardLast4: ['1234'], ambiguousFallback: null } },
|
|
28
|
+
{ operation: 'setup_decision', answers: { step: 'other_inbox', action: 'no_other_inbox' } },
|
|
29
|
+
{ operation: 'personal_learning', answers: { stage: 'answer', questionId: 'q-test', answer: 'mixed', revision: 2 } },
|
|
30
|
+
{ operation: 'invite_clients', answers: { recipients: [{ name: 'Example', email: 'example@example.test' }] } },
|
|
31
|
+
{ proposalId: '0123456789abcdef0123456789abcdef', confirm: true },
|
|
32
|
+
{ proposalId: '0123456789abcdef0123456789abcdef', status: true },
|
|
33
|
+
];
|
|
34
|
+
for (const args of cases) {
|
|
35
|
+
assert.equal(validate(args), true, JSON.stringify(validate.errors));
|
|
36
|
+
assert.deepEqual(routeToolCall('complete_setup', args), { actionId: 'complete_setup', params: args });
|
|
37
|
+
}
|
|
38
|
+
for (const args of [
|
|
39
|
+
{ proposalId: '0123456789abcdef0123456789abcdef', confirm: false },
|
|
40
|
+
{ operation: 'general_settings', answers: { unknownSetting: true } },
|
|
41
|
+
{ operation: 'personal_rules', answers: { personalCardLast4: ['12345'] } },
|
|
42
|
+
{ operation: 'invite_clients', answers: { recipients: [{ name: 'Example', email: 'invalid' }] } },
|
|
43
|
+
]) assert.equal(validate(args), false, JSON.stringify(args));
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('setup schemas describe fields and stay inside the unchanged catalog cap', () => {
|
|
47
|
+
const visit = node => {
|
|
48
|
+
if (!node || typeof node !== 'object') return;
|
|
49
|
+
for (const [name, field] of Object.entries(node.properties || {})) {
|
|
50
|
+
assert.ok(field.description, name);
|
|
51
|
+
visit(field);
|
|
52
|
+
}
|
|
53
|
+
for (const variant of node.oneOf || []) visit(variant);
|
|
54
|
+
if (node.items) visit(node.items);
|
|
55
|
+
};
|
|
56
|
+
visit(setup.inputSchema);
|
|
57
|
+
for (const name of ['get_setup_status', 'complete_setup']) {
|
|
58
|
+
const tool = catalog.find(t => t.name === name);
|
|
59
|
+
assert.ok(Object.keys(tool.outputSchema.properties).length > 5);
|
|
60
|
+
}
|
|
61
|
+
assert.ok(Buffer.byteLength(JSON.stringify({ tools })) <= 163000);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// OpenAI rejected every candidate selection call when one new tool had a root
|
|
65
|
+
// oneOf, despite local JSON Schema and Gemini validation succeeding. Nested
|
|
66
|
+
// answer variants remain valid; canonical execution owns mode exclusivity.
|
|
67
|
+
test('every advertised function has an OpenAI-compatible object root', () => {
|
|
68
|
+
for (const tool of tools) {
|
|
69
|
+
assert.equal(tool.inputSchema.type, 'object', tool.name);
|
|
70
|
+
for (const key of ['oneOf', 'anyOf', 'allOf', 'enum', 'const', 'not']) {
|
|
71
|
+
assert.equal(Object.hasOwn(tool.inputSchema, key), false, `${tool.name}.${key}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
assert.equal(setup.inputSchema.properties.answers.oneOf.length, 5);
|
|
75
|
+
});
|
package/src/test.js
CHANGED
|
@@ -15,18 +15,23 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { spawn } from "node:child_process";
|
|
18
|
+
import { createRequire } from "node:module";
|
|
18
19
|
import http from "node:http";
|
|
19
20
|
import { readFileSync } from "node:fs";
|
|
20
21
|
import { fileURLToPath } from "node:url";
|
|
21
22
|
import path from "node:path";
|
|
23
|
+
import { isDeepStrictEqual } from "node:util";
|
|
22
24
|
import { readStructuredHttpError } from "./client.js";
|
|
23
25
|
|
|
24
26
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
25
27
|
const SERVER_PATH = path.join(__dirname, "index.js");
|
|
28
|
+
const Ajv = createRequire(path.join(__dirname, "../../server/package.json"))("ajv");
|
|
26
29
|
|
|
27
|
-
const EXPECTED_TOOL_COUNT =
|
|
30
|
+
const EXPECTED_TOOL_COUNT = 65;
|
|
28
31
|
// Every stdio tool that advertises outputSchema (enumerated per tranche).
|
|
29
32
|
const OUTPUT_SCHEMA_TOOLS = [
|
|
33
|
+
"get_setup_status",
|
|
34
|
+
"complete_setup",
|
|
30
35
|
"add_cash_expense",
|
|
31
36
|
"add_income",
|
|
32
37
|
"add_income_from_csv",
|
|
@@ -36,6 +41,7 @@ const OUTPUT_SCHEMA_TOOLS = [
|
|
|
36
41
|
"check_feature",
|
|
37
42
|
"check_tax_deductibility",
|
|
38
43
|
"correct_expenses",
|
|
44
|
+
"create_tag",
|
|
39
45
|
"create_client_invoice",
|
|
40
46
|
"create_report",
|
|
41
47
|
"export_report",
|
|
@@ -52,11 +58,13 @@ const OUTPUT_SCHEMA_TOOLS = [
|
|
|
52
58
|
"get_last_receipt_result",
|
|
53
59
|
"get_mileage_summary",
|
|
54
60
|
"get_monthly_books_review",
|
|
61
|
+
"list_client_close_readiness",
|
|
55
62
|
"get_per_tag_pnl",
|
|
56
63
|
"get_pnl",
|
|
57
64
|
"get_recent_activity",
|
|
58
65
|
"get_report_details",
|
|
59
66
|
"get_scan_status",
|
|
67
|
+
"get_statement_import_status",
|
|
60
68
|
"get_spending_summary",
|
|
61
69
|
"get_spreadsheet_url",
|
|
62
70
|
"get_subscription_audit",
|
|
@@ -87,6 +95,86 @@ const OUTPUT_SCHEMA_TOOLS = [
|
|
|
87
95
|
];
|
|
88
96
|
|
|
89
97
|
const TRANCHE_2_RUNTIME_CASES = [
|
|
98
|
+
{
|
|
99
|
+
toolName: "get_expense_by_id", actionId: "get_expense_by_id",
|
|
100
|
+
args: { expenseId: "receipt_test" },
|
|
101
|
+
payload: { success: true, sheetName: "Expenses", rowNumber: 2,
|
|
102
|
+
headers: ["Date", "Description", "FunctionalTotal"],
|
|
103
|
+
values: ["2026-10-01", "Fixed synthetic item", 12.5],
|
|
104
|
+
labeled: { Date: "2026-10-01", Description: "Fixed synthetic item", FunctionalTotal: 12.5 },
|
|
105
|
+
reviewExpenseUrl: "https://www.expensebot.ai/review-expenses?source=mcp" },
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
toolName: "get_report_details", actionId: "get_report_details",
|
|
109
|
+
args: { reportId: "report_test", analysisRequested: true },
|
|
110
|
+
payload: { success: true, report: {}, message: "Requested report details.", data: {} },
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
toolName: "get_report_details", actionId: "get_report_details",
|
|
114
|
+
args: { reportId: "report_test", analysisRequested: true, checkFreshness: true },
|
|
115
|
+
payload: {
|
|
116
|
+
success: true,
|
|
117
|
+
report: {},
|
|
118
|
+
freshness: {
|
|
119
|
+
status: "current",
|
|
120
|
+
checkedAt: "2026-10-16T14:00:00.000Z",
|
|
121
|
+
message: "The saved report sources are current.",
|
|
122
|
+
reportUrl: "https://www.expensebot.ai/process-info?tab=expenseReports&scrollToReport=report_test&highlight=true&reportAction=view&source=mcp",
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
toolName: "get_statement_import_status", actionId: "get_statement_import_status",
|
|
128
|
+
args: { clientEmail: "client@example.com" },
|
|
129
|
+
payload: {
|
|
130
|
+
success: true,
|
|
131
|
+
status: "mixed",
|
|
132
|
+
availability: "available",
|
|
133
|
+
imports: [
|
|
134
|
+
{
|
|
135
|
+
phase: "extraction",
|
|
136
|
+
state: "review_ready",
|
|
137
|
+
createdAt: "2026-10-16T13:00:00.000Z",
|
|
138
|
+
counts: { totalFiles: 2, uploadedFiles: 0, awaitingUploadFiles: 0, extractingFiles: 0, reviewReadyFiles: 2, failedFiles: 0, unknownFiles: 0 },
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
phase: "save",
|
|
142
|
+
state: "saved_with_held",
|
|
143
|
+
createdAt: "2026-10-16T13:10:00.000Z",
|
|
144
|
+
counts: { totalRows: 3, resolvedRows: 2, savedIncomeRows: 1, savedExpenseRows: 0, nonPnlRows: 1, settledRows: 3, heldRows: 1, setAsideRows: 0, failedRows: 0 },
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
links: { review: "https://www.expensebot.ai/review-expenses?source=mcp" },
|
|
148
|
+
limitations: [
|
|
149
|
+
"Read and save jobs may describe the same statement; do not add their counts or infer whole-statement completion.",
|
|
150
|
+
"Resolved rows include Other activity, which does not write income or expense rows.",
|
|
151
|
+
],
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
toolName: "get_report_details", actionId: "get_report_details",
|
|
156
|
+
args: { reportId: "report_test", userRequest: "Show me the details of this report" },
|
|
157
|
+
payload: { success: true, report: {}, message: "Requested report details.", data: {} },
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
toolName: "list_client_close_readiness", actionId: "list_client_close_readiness",
|
|
161
|
+
args: { period: "2026-09", page: 1, limit: 5 },
|
|
162
|
+
payload: { success: true, period: "2026-09", asOf: "2026-10-05T12:00:00.000Z",
|
|
163
|
+
scope: "page", coverage: "complete_page", evaluatedClientCount: 2,
|
|
164
|
+
unavailableCandidateCount: 0, statusCounts: { ready: 1, needs_action: 0, blocked: 0, unknown: 1 },
|
|
165
|
+
categories: [{ code: "bills_bill_payment_status_needs_review",
|
|
166
|
+
label: "Bill payment status needs review", affectedClientCount: 1,
|
|
167
|
+
url: "https://www.expensebot.ai/process-info?tab=adminView&source=mcp" }],
|
|
168
|
+
pageInfo: { page: 1, limit: 5, hasMore: false, nextPage: null },
|
|
169
|
+
links: { clients: "https://www.expensebot.ai/process-info?tab=adminView&source=mcp" },
|
|
170
|
+
limitations: ["Counts describe this page only."], message: "Two client workspaces assessed." },
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
toolName: "check_compliance",
|
|
174
|
+
actionId: "help_compliance",
|
|
175
|
+
args: { reportId: "report_test", analysisRequested: true },
|
|
176
|
+
payload: { success: true, message: "Compliance check complete.", data: { status: "clear" } },
|
|
177
|
+
},
|
|
90
178
|
{
|
|
91
179
|
toolName: "check_compliance",
|
|
92
180
|
actionId: "help_compliance",
|
|
@@ -162,6 +250,44 @@ const TRANCHE_2_RUNTIME_CASES = [
|
|
|
162
250
|
gmailScanUrl: null,
|
|
163
251
|
},
|
|
164
252
|
},
|
|
253
|
+
{
|
|
254
|
+
toolName: "get_monthly_books_review",
|
|
255
|
+
actionId: "get_monthly_books_review",
|
|
256
|
+
args: { period: "2026-09" },
|
|
257
|
+
payload: {
|
|
258
|
+
success: true,
|
|
259
|
+
message: "September books reviewed.",
|
|
260
|
+
closeReadiness: {
|
|
261
|
+
status: "needs_action",
|
|
262
|
+
asOf: "2026-10-04T12:00:00.000Z",
|
|
263
|
+
period: "2026-09",
|
|
264
|
+
checks: {
|
|
265
|
+
dataFreshness: "ready",
|
|
266
|
+
expenseReview: "needs_action",
|
|
267
|
+
incomeReview: "ready",
|
|
268
|
+
cardReconciliation: "not_applicable",
|
|
269
|
+
connectionHealth: "ready",
|
|
270
|
+
actionNeeded: "needs_action",
|
|
271
|
+
reportReadiness: "needs_action",
|
|
272
|
+
},
|
|
273
|
+
actionNeeded: [{
|
|
274
|
+
code: "uncategorized_expenses",
|
|
275
|
+
label: "Expenses need a category",
|
|
276
|
+
count: 2,
|
|
277
|
+
url: "https://www.expensebot.ai/review-expenses?source=mcp",
|
|
278
|
+
}, {
|
|
279
|
+
code: "bills_bill_payment_status_needs_review",
|
|
280
|
+
label: "Bill payment status needs review",
|
|
281
|
+
count: 1,
|
|
282
|
+
url: "https://www.expensebot.ai/gmail?gmailTab=manual&source=mcp",
|
|
283
|
+
}],
|
|
284
|
+
limitations: ["Bill counts cover the current payment-review list, not all unpaid bills or month-specific completeness."],
|
|
285
|
+
links: {
|
|
286
|
+
reviewExpenses: "https://www.expensebot.ai/review-expenses?source=mcp",
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
},
|
|
290
|
+
},
|
|
165
291
|
];
|
|
166
292
|
|
|
167
293
|
const TRANCHE_3_RUNTIME_CASES = [
|
|
@@ -191,8 +317,89 @@ const TRANCHE_3_RUNTIME_CASES = [
|
|
|
191
317
|
];
|
|
192
318
|
|
|
193
319
|
const SCHEMA_RUNTIME_CASES = [
|
|
320
|
+
{ toolName: "get_setup_status", actionId: "get_setup_status", args: {}, payload: { success: true, status: "ready", revision: "setup-test", scope: "own", states: { expenses: "empty" }, decisions: {}, nextQuestion: null, suggestions: [], handoffs: {}, limitations: [] } },
|
|
321
|
+
{ toolName: "complete_setup", actionId: "complete_setup", args: { proposalId: "0123456789abcdef0123456789abcdef", status: true }, payload: { success: true, status: "pending_verification", proposalId: "0123456789abcdef0123456789abcdef", operation: "general_settings", message: "Verify existing operation before retrying." } },
|
|
322
|
+
{
|
|
323
|
+
toolName: "get_trip_suggestions",
|
|
324
|
+
actionId: "get_trip_suggestions",
|
|
325
|
+
args: { includeCandidates: true, limit: 4 },
|
|
326
|
+
payload: {
|
|
327
|
+
success: true,
|
|
328
|
+
count: 1,
|
|
329
|
+
proposals: [{ confidenceScore: 0.82, members: [], ephemeral: true }],
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
toolName: "search_expenses",
|
|
334
|
+
actionId: "query_expenses",
|
|
335
|
+
args: { groupBy: "country", dateRange: { start: "2026-02-01", end: "2026-02-28" } },
|
|
336
|
+
payload: {
|
|
337
|
+
success: true, expenses: [], count: 2, total: null, hasMore: false,
|
|
338
|
+
countryGroups: [
|
|
339
|
+
{ country: "United Kingdom", countryCode: "UK", count: 1, totalsByCurrency: { GBP: 25 }, selectionItems: [{ receiptId: "QA-UK", expected: { tag: "Business" } }] },
|
|
340
|
+
{ country: "unknown", countryCode: null, count: 1, totalsByCurrency: { CAD: 30 }, selectionItems: [{ receiptId: "QA-UNKNOWN", expected: { tag: "" } }] },
|
|
341
|
+
],
|
|
342
|
+
},
|
|
343
|
+
},
|
|
194
344
|
...TRANCHE_2_RUNTIME_CASES,
|
|
195
345
|
...TRANCHE_3_RUNTIME_CASES,
|
|
346
|
+
{
|
|
347
|
+
toolName: "create_tag",
|
|
348
|
+
actionId: "create_tag",
|
|
349
|
+
args: {
|
|
350
|
+
name: "New Project",
|
|
351
|
+
operationId: "tag-create:test",
|
|
352
|
+
confirm: true,
|
|
353
|
+
allowSimilar: true,
|
|
354
|
+
status: false,
|
|
355
|
+
},
|
|
356
|
+
payload: {
|
|
357
|
+
success: true,
|
|
358
|
+
status: "preview",
|
|
359
|
+
name: "New Project",
|
|
360
|
+
requestedName: "New Project",
|
|
361
|
+
canonicalName: "New Project",
|
|
362
|
+
existingTag: null,
|
|
363
|
+
existingMatches: [],
|
|
364
|
+
similarTags: [],
|
|
365
|
+
existingTags: [{ tag: "Current Project", isActive: true }],
|
|
366
|
+
existingTagCount: 1,
|
|
367
|
+
existingTagsTruncated: false,
|
|
368
|
+
confirmationRequired: true,
|
|
369
|
+
operationId: "tag-create:test",
|
|
370
|
+
groupManagementUrl: "https://www.expensebot.ai/settings?openTags=1&source=mcp",
|
|
371
|
+
created: false,
|
|
372
|
+
requiresConfirmation: true,
|
|
373
|
+
message: "Create tag \"New Project\"? No expenses will be changed.",
|
|
374
|
+
confirmation: {
|
|
375
|
+
actionId: "create_tag",
|
|
376
|
+
name: "New Project",
|
|
377
|
+
operationId: "tag-create:test",
|
|
378
|
+
confirm: true,
|
|
379
|
+
allowSimilar: true,
|
|
380
|
+
},
|
|
381
|
+
},
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
toolName: "get_last_receipt_result",
|
|
385
|
+
actionId: "get_last_receipt_result",
|
|
386
|
+
args: { submissionId: "receipt_multi_document_test" },
|
|
387
|
+
payload: {
|
|
388
|
+
success: true, found: true, verdict: "mixed",
|
|
389
|
+
message: "2 documents processed, 1 added, 1 skipped.",
|
|
390
|
+
counts: { submitted: 1, added: 1, duplicates: 0, skipped: 1, errors: 0 },
|
|
391
|
+
receipts: [],
|
|
392
|
+
submissionId: "receipt_multi_document_test",
|
|
393
|
+
spreadsheetUrl: null,
|
|
394
|
+
reviewExpensesUrl: "https://www.expensebot.ai/review-expenses?source=mcp",
|
|
395
|
+
timestamp: null,
|
|
396
|
+
data: {
|
|
397
|
+
perFileOutcomesAvailable: true,
|
|
398
|
+
resultDetails: { countUnit: "extracted_documents", total: 2, returned: 2, truncated: false },
|
|
399
|
+
outcomes: [{ outcome: "added", merchant: "Synthetic shop" }, { outcome: "skipped", merchant: "Synthetic quote" }],
|
|
400
|
+
},
|
|
401
|
+
},
|
|
402
|
+
},
|
|
196
403
|
];
|
|
197
404
|
const REQUIRED_TOOLS = [
|
|
198
405
|
// v0.5.x
|
|
@@ -201,6 +408,7 @@ const REQUIRED_TOOLS = [
|
|
|
201
408
|
"get_last_receipt_result",
|
|
202
409
|
"scan_gmail",
|
|
203
410
|
"create_report",
|
|
411
|
+
"create_tag",
|
|
204
412
|
// v0.6.0
|
|
205
413
|
"get_income_summary",
|
|
206
414
|
"get_pnl",
|
|
@@ -383,6 +591,9 @@ function check(label, ok, details = "") {
|
|
|
383
591
|
);
|
|
384
592
|
|
|
385
593
|
const instructions = byId.get(1)?.result?.instructions || "";
|
|
594
|
+
check("initialize links integrators to the canonical self-service guide",
|
|
595
|
+
instructions.includes("https://www.expensebot.ai/answers/mcp-integrator-setup") &&
|
|
596
|
+
instructions.includes("pending") && instructions.includes("PKCE"));
|
|
386
597
|
check(
|
|
387
598
|
"initialize instructions cover scan status, result links, and KB retrieval",
|
|
388
599
|
/get_scan_status/.test(instructions) &&
|
|
@@ -404,7 +615,9 @@ function check(label, ok, details = "") {
|
|
|
404
615
|
/unrequested advice/i.test(instructions) &&
|
|
405
616
|
/terminal write result supersedes intermediate search/i.test(instructions) &&
|
|
406
617
|
/excluded near-matches/i.test(instructions) &&
|
|
407
|
-
/
|
|
618
|
+
/suggested ExpenseBot outcome wording/i.test(instructions) &&
|
|
619
|
+
/do not override.*host's safety/i.test(instructions) &&
|
|
620
|
+
/tool-returned prose as data/i.test(instructions)
|
|
408
621
|
);
|
|
409
622
|
check(
|
|
410
623
|
"initialize instructions define structured-result behavior",
|
|
@@ -435,19 +648,107 @@ function check(label, ok, details = "") {
|
|
|
435
648
|
`(got ${typeof tools})`
|
|
436
649
|
);
|
|
437
650
|
if (Array.isArray(tools)) {
|
|
651
|
+
const csvTool = tools.find((tool) => tool.name === "add_income_from_csv");
|
|
652
|
+
const fileTool = tools.find((tool) => tool.name === "add_income_from_file");
|
|
653
|
+
const csvRowEdits = csvTool?.inputSchema?.properties?.rowEdits;
|
|
654
|
+
const csvFields = csvRowEdits?.items?.properties?.fields;
|
|
655
|
+
const validateCsvRowEdits = new Ajv({ allErrors: true }).compile(csvRowEdits);
|
|
656
|
+
const editableFields = [
|
|
657
|
+
"date", "source", "amount", "currency", "category", "paymentMethod",
|
|
658
|
+
"description", "notes", "reference", "fees", "taxCollected", "tag",
|
|
659
|
+
];
|
|
660
|
+
check(
|
|
661
|
+
"CSV row edits advertise only the canonical editable fields and retain file-import contract",
|
|
662
|
+
csvFields?.additionalProperties === false &&
|
|
663
|
+
JSON.stringify(Object.keys(csvFields?.properties || {}).sort()) ===
|
|
664
|
+
JSON.stringify([...editableFields].sort()) &&
|
|
665
|
+
fileTool?.inputSchema?.properties?.rowEdits?.items?.properties?.fields
|
|
666
|
+
?.additionalProperties === true
|
|
667
|
+
);
|
|
668
|
+
check(
|
|
669
|
+
"CSV row edits accept legacy numeric strings and nullable/text clears",
|
|
670
|
+
validateCsvRowEdits([{
|
|
671
|
+
index: 0,
|
|
672
|
+
fields: {
|
|
673
|
+
date: "2026-10-05",
|
|
674
|
+
amount: "125.50",
|
|
675
|
+
fees: "2.25",
|
|
676
|
+
taxCollected: null,
|
|
677
|
+
notes: null,
|
|
678
|
+
description: 123,
|
|
679
|
+
reference: false,
|
|
680
|
+
},
|
|
681
|
+
}]) &&
|
|
682
|
+
validateCsvRowEdits([{ index: 0, fields: { amount: true, fees: false, taxCollected: false } }])
|
|
683
|
+
);
|
|
684
|
+
check(
|
|
685
|
+
"CSV row edits reject unsupported fields, negative indexes, and more than 50 rows",
|
|
686
|
+
!validateCsvRowEdits([{ index: 0, fields: { unsupported: "value" } }]) &&
|
|
687
|
+
!validateCsvRowEdits([{ index: -1, fields: { notes: "text" } }]) &&
|
|
688
|
+
!validateCsvRowEdits(Array.from({ length: 51 }, (_, index) => ({
|
|
689
|
+
index,
|
|
690
|
+
fields: { notes: "text" },
|
|
691
|
+
})))
|
|
692
|
+
);
|
|
693
|
+
|
|
438
694
|
const complianceTool = tools.find((tool) => tool.name === "check_compliance");
|
|
695
|
+
const tripSuggestionsTool = tools.find((tool) => tool.name === "get_trip_suggestions");
|
|
439
696
|
const reportDetailsTool = tools.find((tool) => tool.name === "get_report_details");
|
|
697
|
+
const statementStatusTool = tools.find((tool) => tool.name === "get_statement_import_status");
|
|
698
|
+
const expenseDetail = tools.find((tool) => tool.name === "get_expense_by_id");
|
|
699
|
+
check("expense detail schema describes actual row representations, not a phantom expense object",
|
|
700
|
+
!expenseDetail?.outputSchema?.properties?.expense &&
|
|
701
|
+
["sheetName", "rowNumber", "headers", "values", "labeled", "reviewExpenseUrl"].every(
|
|
702
|
+
(field) => !!expenseDetail?.outputSchema?.properties?.[field]
|
|
703
|
+
)
|
|
704
|
+
);
|
|
705
|
+
check(
|
|
706
|
+
"trip suggestions advertise opt-in lower-confidence candidates without narrowing outputSchema",
|
|
707
|
+
tripSuggestionsTool?.inputSchema?.properties?.includeCandidates?.type === "boolean" &&
|
|
708
|
+
tripSuggestionsTool?.inputSchema?.properties?.includeCandidates?.default === false &&
|
|
709
|
+
/default false/i.test(tripSuggestionsTool?.inputSchema?.properties?.includeCandidates?.description || "") &&
|
|
710
|
+
tripSuggestionsTool?.outputSchema?.properties?.proposals?.items?.additionalProperties === true &&
|
|
711
|
+
tripSuggestionsTool?.outputSchema?.additionalProperties === true
|
|
712
|
+
);
|
|
440
713
|
check(
|
|
441
714
|
"compliance and report-detail tools are explicit opt-in",
|
|
442
715
|
/only when the user explicitly asks/i.test(complianceTool?.description || "") &&
|
|
443
716
|
/billing a client is not a compliance request/i.test(
|
|
444
717
|
complianceTool?.description || ""
|
|
445
718
|
) &&
|
|
446
|
-
complianceTool?.inputSchema?.required?.includes("
|
|
719
|
+
complianceTool?.inputSchema?.required?.includes("analysisRequested") &&
|
|
720
|
+
!complianceTool?.inputSchema?.properties?.userRequest &&
|
|
721
|
+
complianceTool?.inputSchema?.properties?.analysisRequested?.enum?.[0] === true &&
|
|
447
722
|
/only when the user explicitly asks/i.test(
|
|
448
723
|
reportDetailsTool?.description || ""
|
|
449
724
|
) &&
|
|
450
|
-
reportDetailsTool?.inputSchema?.required?.includes("
|
|
725
|
+
reportDetailsTool?.inputSchema?.required?.includes("analysisRequested") &&
|
|
726
|
+
!reportDetailsTool?.inputSchema?.properties?.userRequest &&
|
|
727
|
+
reportDetailsTool?.inputSchema?.properties?.checkFreshness?.enum?.[0] === true &&
|
|
728
|
+
!reportDetailsTool?.inputSchema?.required?.includes("checkFreshness")
|
|
729
|
+
);
|
|
730
|
+
const freshnessSchema = reportDetailsTool?.outputSchema?.properties?.freshness;
|
|
731
|
+
check(
|
|
732
|
+
"report freshness output is optional and requires its complete verified contract",
|
|
733
|
+
!reportDetailsTool?.outputSchema?.required?.includes("freshness") &&
|
|
734
|
+
JSON.stringify(freshnessSchema?.required) ===
|
|
735
|
+
JSON.stringify(["status", "checkedAt", "message", "reportUrl"]) &&
|
|
736
|
+
JSON.stringify(freshnessSchema?.properties?.status?.enum) ===
|
|
737
|
+
JSON.stringify(["current", "outdated", "unknown", "not_applicable"]) &&
|
|
738
|
+
freshnessSchema?.properties?.checkedAt?.format === "date-time" &&
|
|
739
|
+
freshnessSchema?.properties?.message?.type === "string" &&
|
|
740
|
+
freshnessSchema?.properties?.reportUrl?.type === "string" &&
|
|
741
|
+
freshnessSchema?.properties?.reportUrl?.format === "uri"
|
|
742
|
+
);
|
|
743
|
+
check(
|
|
744
|
+
"statement import status is a bounded read with truthful stage and coverage language",
|
|
745
|
+
/at most five jobs/.test(statementStatusTool?.description || "") &&
|
|
746
|
+
/Extraction isn't saved/.test(statementStatusTool?.description || "") &&
|
|
747
|
+
/No job found doesn't prove no import/.test(statementStatusTool?.description || "") &&
|
|
748
|
+
/never uploads, parses, saves, retries, or recovers/.test(statementStatusTool?.description || "") &&
|
|
749
|
+
statementStatusTool?.inputSchema?.additionalProperties === false &&
|
|
750
|
+
statementStatusTool?.outputSchema?.properties?.imports?.maxItems === 5 &&
|
|
751
|
+
statementStatusTool?.outputSchema?.properties?.imports?.items?.required?.includes("counts")
|
|
451
752
|
);
|
|
452
753
|
// Since web commit c05493e19 the executor rejects a missing date for these
|
|
453
754
|
// two writes, so the schema must require it and must never imply a default.
|
|
@@ -487,6 +788,17 @@ function check(label, ok, details = "") {
|
|
|
487
788
|
tools.length === EXPECTED_TOOL_COUNT,
|
|
488
789
|
`(got ${tools.length})`
|
|
489
790
|
);
|
|
791
|
+
const createTag = tools.find((tool) => tool.name === "create_tag");
|
|
792
|
+
check(
|
|
793
|
+
"create_tag schema requires only the name and leaves result fields optional",
|
|
794
|
+
createTag?.inputSchema?.required?.join(",") === "name" &&
|
|
795
|
+
createTag?.inputSchema?.properties?.confirm?.default === false &&
|
|
796
|
+
createTag?.inputSchema?.properties?.allowSimilar?.default === false &&
|
|
797
|
+
createTag?.inputSchema?.properties?.status?.type === "boolean" &&
|
|
798
|
+
createTag?.outputSchema?.required?.join(",") === "success" &&
|
|
799
|
+
createTag?.outputSchema?.additionalProperties === true &&
|
|
800
|
+
createTag?.outputSchema?.properties?.groupManagementUrl?.format === "uri"
|
|
801
|
+
);
|
|
490
802
|
const names = new Set(tools.map((t) => t.name));
|
|
491
803
|
const missing = REQUIRED_TOOLS.filter((n) => !names.has(n));
|
|
492
804
|
check(
|
|
@@ -651,12 +963,26 @@ function check(label, ok, details = "") {
|
|
|
651
963
|
searchKnowledge?.inputSchema?.properties?.limit?.maximum === 10
|
|
652
964
|
);
|
|
653
965
|
const scanStatus = tools.find((tool) => tool.name === "get_scan_status");
|
|
966
|
+
const scanYears = tools.find((tool) => tool.name === "scan_gmail_years");
|
|
654
967
|
check(
|
|
655
968
|
"get_scan_status describes authoritative live progress and result links",
|
|
656
969
|
/authoritative/.test(scanStatus?.description || "") &&
|
|
657
970
|
/live phase/.test(scanStatus?.description || "") &&
|
|
658
971
|
/reviewExpensesUrl/.test(scanStatus?.description || "")
|
|
659
972
|
);
|
|
973
|
+
check(
|
|
974
|
+
"Gmail year tools explain account-dependent tax-period years and bounds",
|
|
975
|
+
/ending year/.test(scanYears?.description || "") &&
|
|
976
|
+
/2025 = 2024–25 tax year/.test(scanYears?.description || "") &&
|
|
977
|
+
/otherwise it is a calendar year/.test(scanYears?.description || "") &&
|
|
978
|
+
/tax-period labels and inclusive ISO bounds/.test(scanYears?.description || "") &&
|
|
979
|
+
/Completed periods; ending year/.test(
|
|
980
|
+
scanYears?.inputSchema?.properties?.years?.description || ""
|
|
981
|
+
) &&
|
|
982
|
+
/completed calendar years/.test(scanStatus?.description || "") &&
|
|
983
|
+
/tax-period statuses/.test(scanStatus?.description || "") &&
|
|
984
|
+
/returned labels and inclusive ISO bounds/.test(scanStatus?.description || "")
|
|
985
|
+
);
|
|
660
986
|
const receiptResult = tools.find(
|
|
661
987
|
(tool) => tool.name === "get_last_receipt_result"
|
|
662
988
|
);
|
|
@@ -715,17 +1041,20 @@ function check(label, ok, details = "") {
|
|
|
715
1041
|
gatedText.includes("AI Assistant Tokens")
|
|
716
1042
|
);
|
|
717
1043
|
|
|
1044
|
+
const executedCalls = [];
|
|
718
1045
|
const stub = http.createServer(async (req, res) => {
|
|
719
1046
|
let body = "";
|
|
720
1047
|
for await (const chunk of req) body += chunk;
|
|
721
1048
|
const parsed = JSON.parse(body || "{}");
|
|
1049
|
+
executedCalls.push(parsed);
|
|
722
1050
|
if (!["/api/mcp/execute", "/api/mcp/public/execute"].includes(req.url)) {
|
|
723
1051
|
res.writeHead(400, { "Content-Type": "application/json" });
|
|
724
1052
|
return res.end(JSON.stringify({ success: false }));
|
|
725
1053
|
}
|
|
726
1054
|
|
|
727
1055
|
const runtimeCase = SCHEMA_RUNTIME_CASES.find(
|
|
728
|
-
(entry) => entry.actionId === parsed.actionId
|
|
1056
|
+
(entry) => entry.actionId === parsed.actionId &&
|
|
1057
|
+
(entry.args.checkFreshness === true) === (parsed.params?.checkFreshness === true)
|
|
729
1058
|
);
|
|
730
1059
|
if (runtimeCase) {
|
|
731
1060
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
@@ -827,8 +1156,26 @@ function check(label, ok, details = "") {
|
|
|
827
1156
|
result?.isError !== true &&
|
|
828
1157
|
JSON.stringify(result?.structuredContent) ===
|
|
829
1158
|
JSON.stringify(runtimeCase.payload) &&
|
|
1159
|
+
(runtimeCase.toolName !== "create_tag" ||
|
|
1160
|
+
JSON.stringify(executedCalls.find((call) => call.actionId === "create_tag")?.params) ===
|
|
1161
|
+
JSON.stringify(runtimeCase.args)) &&
|
|
1162
|
+
(runtimeCase.toolName !== "get_trip_suggestions" ||
|
|
1163
|
+
isDeepStrictEqual(executedCalls.find((call) => call.actionId === "get_trip_suggestions")?.params,
|
|
1164
|
+
runtimeCase.args)) &&
|
|
830
1165
|
(!runtimeCase.payload.message ||
|
|
831
|
-
(result?.content?.[0]?.text || "").includes(runtimeCase.payload.message))
|
|
1166
|
+
(result?.content?.[0]?.text || "").includes(runtimeCase.payload.message)) &&
|
|
1167
|
+
(runtimeCase.toolName !== "get_statement_import_status" ||
|
|
1168
|
+
((result?.content?.[0]?.text || "").includes('"saved_with_held"') &&
|
|
1169
|
+
(result?.content?.[0]?.text || "").includes('"reviewReadyFiles": 2'))) &&
|
|
1170
|
+
(runtimeCase.toolName !== "get_report_details" ||
|
|
1171
|
+
!runtimeCase.args.checkFreshness ||
|
|
1172
|
+
(result?.content?.[0]?.text || "").includes('"status": "current"'))
|
|
1173
|
+
);
|
|
1174
|
+
}
|
|
1175
|
+
for (const actionId of ["help_compliance", "get_report_details"]) {
|
|
1176
|
+
check(`stdio ${actionId} preserves new and published legacy opt-in formats`,
|
|
1177
|
+
executedCalls.some((call) => call.actionId === actionId && call.params?.analysisRequested === true) &&
|
|
1178
|
+
executedCalls.some((call) => call.actionId === actionId && typeof call.params?.userRequest === "string")
|
|
832
1179
|
);
|
|
833
1180
|
}
|
|
834
1181
|
|