@expensebot/mcp-server-auth 0.6.7 → 0.6.9
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/package.json +2 -2
- package/src/client.js +32 -1
- package/src/index.js +13 -7
- package/src/test.js +17 -0
- package/scripts/descriptions.generated.json +0 -10
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expensebot/mcp-server-auth",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.9",
|
|
4
4
|
"mcpName": "io.github.TotesMagotes/mcp-server-auth",
|
|
5
5
|
"description": "Authenticated MCP server for ExpenseBot — lets Claude Desktop, Cursor, and other AI assistants search your expenses, create reports, and analyze spending using your actual ExpenseBot data.",
|
|
6
6
|
"bin": {
|
|
7
|
-
"expensebot-mcp-auth": "
|
|
7
|
+
"expensebot-mcp-auth": "src/index.js"
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
10
|
"main": "./src/index.js",
|
package/src/client.js
CHANGED
|
@@ -7,6 +7,32 @@ const DEFAULT_BASE = "https://www.expensebot.ai";
|
|
|
7
7
|
const POLL_INTERVAL_MS = 3000;
|
|
8
8
|
const POLL_TIMEOUT_MS = 60000;
|
|
9
9
|
|
|
10
|
+
async function readStructuredHttpError(res) {
|
|
11
|
+
const text = await res.text().catch(() => "");
|
|
12
|
+
let body = null;
|
|
13
|
+
try {
|
|
14
|
+
body = text ? JSON.parse(text) : null;
|
|
15
|
+
} catch (_) {}
|
|
16
|
+
const nested = body?.error;
|
|
17
|
+
const message =
|
|
18
|
+
(typeof nested === "string" && nested) ||
|
|
19
|
+
nested?.message ||
|
|
20
|
+
body?.message ||
|
|
21
|
+
`API error ${res.status}`;
|
|
22
|
+
const details = {};
|
|
23
|
+
if (Array.isArray(body?.rejected)) details.rejected = body.rejected;
|
|
24
|
+
if (Array.isArray(body?.accepted)) details.accepted = body.accepted;
|
|
25
|
+
return {
|
|
26
|
+
success: false,
|
|
27
|
+
error: {
|
|
28
|
+
code: body?.code || nested?.code || `http_${res.status}`,
|
|
29
|
+
message,
|
|
30
|
+
...(nested?.hint ? { hint: nested.hint } : {}),
|
|
31
|
+
...(Object.keys(details).length ? { details } : {}),
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
10
36
|
export class ExpenseBotClient {
|
|
11
37
|
constructor(token, baseUrl) {
|
|
12
38
|
this.token = token;
|
|
@@ -20,7 +46,7 @@ export class ExpenseBotClient {
|
|
|
20
46
|
headers: {
|
|
21
47
|
Authorization: `Bearer ${this.token}`,
|
|
22
48
|
"Content-Type": "application/json",
|
|
23
|
-
"User-Agent": "expensebot-mcp-auth/0.6.
|
|
49
|
+
"User-Agent": "expensebot-mcp-auth/0.6.9",
|
|
24
50
|
"X-ExpenseBot-MCP-Transport": "stdio",
|
|
25
51
|
...options.headers,
|
|
26
52
|
},
|
|
@@ -39,6 +65,9 @@ export class ExpenseBotClient {
|
|
|
39
65
|
);
|
|
40
66
|
}
|
|
41
67
|
if (!res.ok) {
|
|
68
|
+
if (path === "/api/mcp/execute") {
|
|
69
|
+
return readStructuredHttpError(res);
|
|
70
|
+
}
|
|
42
71
|
const text = await res.text().catch(() => "");
|
|
43
72
|
throw new Error(`API error ${res.status}: ${text.substring(0, 200)}`);
|
|
44
73
|
}
|
|
@@ -98,3 +127,5 @@ export class ExpenseBotClient {
|
|
|
98
127
|
};
|
|
99
128
|
}
|
|
100
129
|
}
|
|
130
|
+
|
|
131
|
+
export { readStructuredHttpError };
|
package/src/index.js
CHANGED
|
@@ -43,7 +43,7 @@ const client = onboardingMode ? null : new ExpenseBotClient(token);
|
|
|
43
43
|
|
|
44
44
|
const SERVER_INSTRUCTIONS = [
|
|
45
45
|
"ExpenseBot tracks the user's business expenses and income in a Google Sheet they own.",
|
|
46
|
-
"After submit_receipt returns a submissionId, call get_last_receipt_result with that exact ID
|
|
46
|
+
"After submit_receipt returns a submissionId, call get_last_receipt_result with that exact ID using the polling interval and time allowance returned by submit_receipt. A small batch allows at least 5 minutes and larger batches allow longer. A pending result is normal; never resubmit the same file because that creates a duplicate. Report the final counts, then show spreadsheetUrl and reviewExpensesUrl.",
|
|
47
47
|
"After another expense submission, show the returned spreadsheetUrl and reviewExpensesUrl.",
|
|
48
48
|
"For income writes, show spreadsheetUrl and reviewIncomeUrl.",
|
|
49
49
|
"For Gmail scan progress or completion, call get_scan_status. Report its authoritative status and live phase; on completion show spreadsheetUrl and reviewExpensesUrl, and when action is needed show gmailScanUrl.",
|
|
@@ -402,8 +402,9 @@ const TOOLS = [
|
|
|
402
402
|
"simply shares a photo of a receipt or invoice. The receipt image " +
|
|
403
403
|
"is validated, uploaded to cloud storage, and processed " +
|
|
404
404
|
"by AI to extract vendor, amount, date, tax, and category. The expense " +
|
|
405
|
-
"appears in the user's spreadsheet
|
|
406
|
-
"PDFs, mixed together in one
|
|
405
|
+
"appears in the user's spreadsheet in about 1-3 minutes, and longer for " +
|
|
406
|
+
"PDFs or large batches. Handles images and PDFs, mixed together in one " +
|
|
407
|
+
"batch.\n\n" +
|
|
407
408
|
"TO SEND FILES (preferred, and required for PDFs): call this tool with " +
|
|
408
409
|
"filesToUpload listing every file the user gave you. It returns one " +
|
|
409
410
|
"signed upload URL per file. Upload them ONE AT A TIME with an HTTP PUT, " +
|
|
@@ -511,9 +512,11 @@ const TOOLS = [
|
|
|
511
512
|
name: "get_last_receipt_result",
|
|
512
513
|
description:
|
|
513
514
|
"Check the authoritative final outcome of a receipt image/PDF batch submitted " +
|
|
514
|
-
"with submit_receipt. After submit_receipt returns submissionId,
|
|
515
|
-
"
|
|
516
|
-
"
|
|
515
|
+
"with submit_receipt. After submit_receipt returns submissionId, call this " +
|
|
516
|
+
"tool with that exact ID using the polling interval and time allowance in " +
|
|
517
|
+
"the submit_receipt response. A small batch allows at least 5 minutes; larger " +
|
|
518
|
+
"batches allow longer. A pending result is normal and must not trigger a " +
|
|
519
|
+
"duplicate resubmission. Returns added, duplicate, skipped, or " +
|
|
517
520
|
"errored verdicts with exact counts and up to 10 processed receipt summaries. " +
|
|
518
521
|
"On completion, tell the user what happened and show spreadsheetUrl plus " +
|
|
519
522
|
"reviewExpensesUrl. This is for uploaded receipts; use get_scan_status for " +
|
|
@@ -1856,6 +1859,9 @@ function formatResult(result) {
|
|
|
1856
1859
|
if (err && typeof err === "object" && err.message) {
|
|
1857
1860
|
errText = `Error (${err.code || "unknown"}): ${err.message}`;
|
|
1858
1861
|
if (err.hint) errText += `\n\nHint: ${err.hint}`;
|
|
1862
|
+
if (err.details) {
|
|
1863
|
+
errText += `\n\nDetails:\n${JSON.stringify(err.details, null, 2)}`;
|
|
1864
|
+
}
|
|
1859
1865
|
} else if (typeof err === "string") {
|
|
1860
1866
|
errText = `Error: ${err}`;
|
|
1861
1867
|
} else {
|
|
@@ -1904,7 +1910,7 @@ function formatResult(result) {
|
|
|
1904
1910
|
|
|
1905
1911
|
async function main() {
|
|
1906
1912
|
const server = new Server(
|
|
1907
|
-
{ name: "expensebot-auth", version: "0.6.
|
|
1913
|
+
{ name: "expensebot-auth", version: "0.6.9" },
|
|
1908
1914
|
{ capabilities: { tools: {} }, instructions: SERVER_INSTRUCTIONS }
|
|
1909
1915
|
);
|
|
1910
1916
|
|
package/src/test.js
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import { spawn } from "node:child_process";
|
|
18
18
|
import { fileURLToPath } from "node:url";
|
|
19
19
|
import path from "node:path";
|
|
20
|
+
import { readStructuredHttpError } from "./client.js";
|
|
20
21
|
|
|
21
22
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
22
23
|
const SERVER_PATH = path.join(__dirname, "index.js");
|
|
@@ -163,6 +164,22 @@ function check(label, ok, details = "") {
|
|
|
163
164
|
|
|
164
165
|
(async () => {
|
|
165
166
|
console.log("=== mcp-server-auth smoke test ===\n");
|
|
167
|
+
const structuredFailure = await readStructuredHttpError(
|
|
168
|
+
new Response(
|
|
169
|
+
JSON.stringify({
|
|
170
|
+
code: "upload_validation_failed",
|
|
171
|
+
error: "One file could not be accepted.",
|
|
172
|
+
rejected: [{ id: "2", code: "upload_unreadable", retryable: true }],
|
|
173
|
+
}),
|
|
174
|
+
{ status: 502, headers: { "Content-Type": "application/json" } }
|
|
175
|
+
)
|
|
176
|
+
);
|
|
177
|
+
check(
|
|
178
|
+
"structured upload failures preserve each concise per-file reason",
|
|
179
|
+
structuredFailure.error.code === "upload_validation_failed" &&
|
|
180
|
+
structuredFailure.error.details.rejected[0].code === "upload_unreadable" &&
|
|
181
|
+
structuredFailure.error.details.rejected[0].id === "2"
|
|
182
|
+
);
|
|
166
183
|
const responses = await runServer();
|
|
167
184
|
const byId = new Map(
|
|
168
185
|
responses.filter((r) => r.id != null).map((r) => [r.id, r])
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"_meta": {
|
|
3
|
-
"generatedAt": "2026-05-07T05:13:24.014Z",
|
|
4
|
-
"sourceKb": "../server/config/kb/entries/income-and-pnl-analytics.md",
|
|
5
|
-
"note": "Auto-generated from KB. Do NOT edit by hand — re-run `npm run gen-descriptions` after the KB changes."
|
|
6
|
-
},
|
|
7
|
-
"get_income_summary": "Get income totals and breakdowns from the Income tab — Schedule C / T2125 basis. Excludes Schedule B (interest, dividends), tax refunds, and security deposits (mirrors year-end report routing). Examples: \"How much income YTD?\", \"Income by source\", \"by month\", \"by payment method\".",
|
|
8
|
-
"get_pnl": "Compute Profit & Loss across the Income tab and expenses. Examples: \"Am I profitable this year?\", \"Net income last quarter\", \"What's my margin?\", \"P&L for Q1\".",
|
|
9
|
-
"get_per_tag_pnl": "Per-tag P&L — revenue, cost, profit, and margin grouped by tag. Requires both income AND expense rows to be tagged consistently. Examples: ."
|
|
10
|
-
}
|