@expensebot/mcp-server-auth 0.3.2 → 0.5.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/package.json +1 -1
- package/src/client.js +7 -2
- package/src/index.js +199 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expensebot/mcp-server-auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
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": {
|
package/src/client.js
CHANGED
|
@@ -28,8 +28,13 @@ export class ExpenseBotClient {
|
|
|
28
28
|
|
|
29
29
|
if (res.status === 401) {
|
|
30
30
|
throw new Error(
|
|
31
|
-
"Authentication failed — token may be expired or
|
|
32
|
-
"
|
|
31
|
+
"Authentication failed — your ExpenseBot token may be expired, revoked, or invalid.\n\n" +
|
|
32
|
+
"To get a new token:\n" +
|
|
33
|
+
"1. Go to https://www.expensebot.ai (sign up for free 60-day trial if you don't have an account)\n" +
|
|
34
|
+
"2. Click Settings → AI Assistant Tokens → Generate\n" +
|
|
35
|
+
"3. Copy the token (shown only once)\n" +
|
|
36
|
+
"4. Update your MCP config with --token=<new-token>\n" +
|
|
37
|
+
"5. Restart your AI client (Claude Desktop, Cursor, etc.)"
|
|
33
38
|
);
|
|
34
39
|
}
|
|
35
40
|
if (!res.ok) {
|
package/src/index.js
CHANGED
|
@@ -35,19 +35,20 @@ for (const arg of args) {
|
|
|
35
35
|
if (arg.startsWith("--token=")) token = arg.split("=").slice(1).join("=");
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
// If no token: run in onboarding mode — only get_signup_link and
|
|
39
|
+
// search_expensebot work. Lets new users discover ExpenseBot via the
|
|
40
|
+
// MCP registry without an account.
|
|
41
|
+
const onboardingMode = !token;
|
|
42
|
+
const client = onboardingMode ? null : new ExpenseBotClient(token);
|
|
43
|
+
|
|
44
|
+
if (onboardingMode) {
|
|
39
45
|
console.error(
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
" 2. Click 'Generate Token'\n" +
|
|
44
|
-
" 3. Run: npx @expensebot/mcp-server-auth --token=<paste-token>\n"
|
|
46
|
+
"[expensebot-auth] No token provided — running in ONBOARDING MODE.\n" +
|
|
47
|
+
"Only get_signup_link and search_expensebot are available.\n" +
|
|
48
|
+
"Sign up at https://www.expensebot.ai for full access (60-day free trial)."
|
|
45
49
|
);
|
|
46
|
-
process.exit(1);
|
|
47
50
|
}
|
|
48
51
|
|
|
49
|
-
const client = new ExpenseBotClient(token);
|
|
50
|
-
|
|
51
52
|
// ── Tool Definitions ───────────────────────────────────────────────────
|
|
52
53
|
|
|
53
54
|
const TOOLS = [
|
|
@@ -419,12 +420,171 @@ const TOOLS = [
|
|
|
419
420
|
},
|
|
420
421
|
},
|
|
421
422
|
},
|
|
423
|
+
{
|
|
424
|
+
name: "get_signup_link",
|
|
425
|
+
description:
|
|
426
|
+
"Get the ExpenseBot signup link. Use this when the user doesn't have " +
|
|
427
|
+
"an account yet, or when their MCP token is missing/expired and they " +
|
|
428
|
+
"need to sign up or get a new token. Returns a signup URL with a " +
|
|
429
|
+
"60-day free trial — no credit card required.",
|
|
430
|
+
inputSchema: {
|
|
431
|
+
type: "object",
|
|
432
|
+
properties: {
|
|
433
|
+
utmSource: {
|
|
434
|
+
type: "string",
|
|
435
|
+
description: "Optional UTM source (defaults to 'mcp')",
|
|
436
|
+
},
|
|
437
|
+
},
|
|
438
|
+
},
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
name: "add_mileage_entry",
|
|
442
|
+
description:
|
|
443
|
+
"Log a business mileage trip in ExpenseBot. Useful for realtors, " +
|
|
444
|
+
"consultants, contractors, and anyone who drives for work. Requires " +
|
|
445
|
+
"the user to have configured their mileage rate (cents/km or cents/mi) " +
|
|
446
|
+
"and unit (mi/km) in ExpenseBot Settings. The trip writes a row to " +
|
|
447
|
+
"their expense spreadsheet with the calculated dollar value.",
|
|
448
|
+
inputSchema: {
|
|
449
|
+
type: "object",
|
|
450
|
+
properties: {
|
|
451
|
+
distance: {
|
|
452
|
+
type: "number",
|
|
453
|
+
description: "Distance traveled in the user's configured unit (miles or km)",
|
|
454
|
+
},
|
|
455
|
+
purpose: {
|
|
456
|
+
type: "string",
|
|
457
|
+
description: "Business purpose / description of the trip (e.g., 'Client meeting at 1234 Main St')",
|
|
458
|
+
},
|
|
459
|
+
date: {
|
|
460
|
+
type: "string",
|
|
461
|
+
format: "date",
|
|
462
|
+
description: "Trip date (YYYY-MM-DD). Defaults to today.",
|
|
463
|
+
},
|
|
464
|
+
roundTrip: {
|
|
465
|
+
type: "boolean",
|
|
466
|
+
description: "If true, doubles the distance (return trip)",
|
|
467
|
+
default: false,
|
|
468
|
+
},
|
|
469
|
+
destination: {
|
|
470
|
+
type: "string",
|
|
471
|
+
description: "Destination address or location (optional)",
|
|
472
|
+
},
|
|
473
|
+
city: {
|
|
474
|
+
type: "string",
|
|
475
|
+
description: "City (optional)",
|
|
476
|
+
},
|
|
477
|
+
category: {
|
|
478
|
+
type: "string",
|
|
479
|
+
description: "Override the user's default mileage category (optional)",
|
|
480
|
+
},
|
|
481
|
+
tag: {
|
|
482
|
+
type: "string",
|
|
483
|
+
description: "Tag for client/project attribution (optional)",
|
|
484
|
+
},
|
|
485
|
+
notes: { type: "string" },
|
|
486
|
+
},
|
|
487
|
+
required: ["distance", "purpose"],
|
|
488
|
+
},
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
name: "add_income",
|
|
492
|
+
description:
|
|
493
|
+
"Log an income entry manually (cash, check, Stripe payout, etc.). " +
|
|
494
|
+
"Writes to the Income tab of the user's expense spreadsheet. Useful " +
|
|
495
|
+
"for income that isn't auto-detected from Gmail or Plaid.",
|
|
496
|
+
inputSchema: {
|
|
497
|
+
type: "object",
|
|
498
|
+
properties: {
|
|
499
|
+
amount: { type: "number", description: "Income amount (>0)" },
|
|
500
|
+
source: {
|
|
501
|
+
type: "string",
|
|
502
|
+
description: "Who paid you (client name, customer, etc.)",
|
|
503
|
+
},
|
|
504
|
+
paymentMethod: {
|
|
505
|
+
type: "string",
|
|
506
|
+
description: "How you got paid (e.g., 'Cash', 'Check', 'Stripe', 'Bank Transfer', 'Venmo')",
|
|
507
|
+
},
|
|
508
|
+
date: {
|
|
509
|
+
type: "string",
|
|
510
|
+
format: "date",
|
|
511
|
+
description: "Income date (YYYY-MM-DD). Defaults to today.",
|
|
512
|
+
},
|
|
513
|
+
currency: { type: "string", description: "Currency code (default: home currency)" },
|
|
514
|
+
description: { type: "string", description: "What the income was for" },
|
|
515
|
+
category: { type: "string", description: "Income category (optional)" },
|
|
516
|
+
reference: { type: "string", description: "Invoice or transaction reference" },
|
|
517
|
+
fees: { type: "number", description: "Processor/transfer fees deducted" },
|
|
518
|
+
taxCollected: { type: "number", description: "Sales tax/GST/HST collected" },
|
|
519
|
+
tag: { type: "string", description: "Tag for client/project attribution" },
|
|
520
|
+
notes: { type: "string" },
|
|
521
|
+
},
|
|
522
|
+
required: ["amount", "source", "paymentMethod"],
|
|
523
|
+
},
|
|
524
|
+
},
|
|
525
|
+
{
|
|
526
|
+
name: "list_categories",
|
|
527
|
+
description:
|
|
528
|
+
"List the user's configured expense categories and billing accounts. " +
|
|
529
|
+
"Use this BEFORE calling tools that need a category (add_cash_expense, " +
|
|
530
|
+
"add_mileage_entry, create_report) so you pass the user's actual " +
|
|
531
|
+
"category names, not guesses. Returns the live list from their spreadsheet.",
|
|
532
|
+
inputSchema: { type: "object", properties: {} },
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
name: "list_tags",
|
|
536
|
+
description:
|
|
537
|
+
"List the user's configured tags. Tags are used for client/project " +
|
|
538
|
+
"attribution (e.g., 'Client: Acme', 'Q1 Trip', 'Property: 123 Main'). " +
|
|
539
|
+
"Use this BEFORE calling tools that filter or assign tags so you pass " +
|
|
540
|
+
"valid tag names, not guesses.",
|
|
541
|
+
inputSchema: { type: "object", properties: {} },
|
|
542
|
+
},
|
|
422
543
|
];
|
|
423
544
|
|
|
545
|
+
// Tools available without authentication (onboarding mode)
|
|
546
|
+
const PUBLIC_TOOLS = ["get_signup_link", "search_knowledge"];
|
|
547
|
+
|
|
424
548
|
// ── Tool Handlers ──────────────────────────────────────────────────────
|
|
425
549
|
|
|
426
550
|
async function handleTool(name, args) {
|
|
551
|
+
// Onboarding mode: only PUBLIC_TOOLS are available
|
|
552
|
+
if (onboardingMode && !PUBLIC_TOOLS.includes(name)) {
|
|
553
|
+
return {
|
|
554
|
+
content: [
|
|
555
|
+
{
|
|
556
|
+
type: "text",
|
|
557
|
+
text:
|
|
558
|
+
`The "${name}" tool requires an ExpenseBot account.\n\n` +
|
|
559
|
+
"Sign up for a 60-day free trial (no credit card required) at:\n" +
|
|
560
|
+
"https://www.expensebot.ai?utm_source=mcp&utm_medium=ai-assistant\n\n" +
|
|
561
|
+
"After signing up:\n" +
|
|
562
|
+
"1. Go to Settings → AI Assistant Tokens → Generate\n" +
|
|
563
|
+
"2. Update your MCP config with the new token\n" +
|
|
564
|
+
"3. Restart your AI client\n\n" +
|
|
565
|
+
'Or use the "search_knowledge" or "get_signup_link" tools, which work without an account.',
|
|
566
|
+
},
|
|
567
|
+
],
|
|
568
|
+
isError: true,
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
|
|
427
572
|
switch (name) {
|
|
573
|
+
case "get_signup_link":
|
|
574
|
+
return {
|
|
575
|
+
content: [
|
|
576
|
+
{
|
|
577
|
+
type: "text",
|
|
578
|
+
text:
|
|
579
|
+
"**ExpenseBot — 60-day free trial, no credit card required**\n\n" +
|
|
580
|
+
`Sign up: https://www.expensebot.ai?utm_source=${args?.utmSource || "mcp"}&utm_medium=ai-assistant\n\n` +
|
|
581
|
+
"After signing up, generate an AI Assistant Token from Settings to unlock all 16 tools " +
|
|
582
|
+
"(search expenses, submit receipts, scan Gmail, create reports, run analytics).\n\n" +
|
|
583
|
+
"Free for accountants forever. $10/month for everyone else.",
|
|
584
|
+
},
|
|
585
|
+
],
|
|
586
|
+
};
|
|
587
|
+
|
|
428
588
|
case "search_expenses":
|
|
429
589
|
return formatResult(
|
|
430
590
|
await client.execute("query_expenses", args)
|
|
@@ -479,6 +639,24 @@ async function handleTool(name, args) {
|
|
|
479
639
|
);
|
|
480
640
|
|
|
481
641
|
case "search_knowledge":
|
|
642
|
+
// Works in both modes — falls back to public /api/discover when no client
|
|
643
|
+
if (onboardingMode) {
|
|
644
|
+
try {
|
|
645
|
+
const url = new URL("/api/discover", "https://www.expensebot.ai");
|
|
646
|
+
url.searchParams.set("query", args?.query || "");
|
|
647
|
+
url.searchParams.set("utm_source", "mcp-onboarding");
|
|
648
|
+
const res = await fetch(url.toString(), {
|
|
649
|
+
headers: { "User-Agent": "expensebot-mcp-auth/onboarding" },
|
|
650
|
+
});
|
|
651
|
+
const data = await res.json();
|
|
652
|
+
return formatResult(data);
|
|
653
|
+
} catch (err) {
|
|
654
|
+
return {
|
|
655
|
+
content: [{ type: "text", text: `Search failed: ${err.message}` }],
|
|
656
|
+
isError: true,
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
}
|
|
482
660
|
return formatResult(
|
|
483
661
|
await client.execute("search_knowledge", args)
|
|
484
662
|
);
|
|
@@ -520,6 +698,18 @@ async function handleTool(name, args) {
|
|
|
520
698
|
})
|
|
521
699
|
);
|
|
522
700
|
|
|
701
|
+
case "add_mileage_entry":
|
|
702
|
+
return formatResult(await client.execute("add_mileage_entry", args));
|
|
703
|
+
|
|
704
|
+
case "add_income":
|
|
705
|
+
return formatResult(await client.execute("add_income", args));
|
|
706
|
+
|
|
707
|
+
case "list_categories":
|
|
708
|
+
return formatResult(await client.execute("list_categories", {}));
|
|
709
|
+
|
|
710
|
+
case "list_tags":
|
|
711
|
+
return formatResult(await client.execute("list_tags", {}));
|
|
712
|
+
|
|
523
713
|
default:
|
|
524
714
|
return {
|
|
525
715
|
content: [{ type: "text", text: `Unknown tool: ${name}` }],
|