@expensebot/mcp-server-auth 0.3.1 → 0.4.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 +2 -2
- package/src/client.js +7 -2
- package/src/index.js +84 -9
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expensebot/mcp-server-auth",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"mcpName": "io.github.
|
|
3
|
+
"version": "0.4.0",
|
|
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
7
|
"expensebot-mcp-auth": "./src/index.js"
|
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,68 @@ 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
|
+
},
|
|
422
440
|
];
|
|
423
441
|
|
|
442
|
+
// Tools available without authentication (onboarding mode)
|
|
443
|
+
const PUBLIC_TOOLS = ["get_signup_link", "search_knowledge"];
|
|
444
|
+
|
|
424
445
|
// ── Tool Handlers ──────────────────────────────────────────────────────
|
|
425
446
|
|
|
426
447
|
async function handleTool(name, args) {
|
|
448
|
+
// Onboarding mode: only PUBLIC_TOOLS are available
|
|
449
|
+
if (onboardingMode && !PUBLIC_TOOLS.includes(name)) {
|
|
450
|
+
return {
|
|
451
|
+
content: [
|
|
452
|
+
{
|
|
453
|
+
type: "text",
|
|
454
|
+
text:
|
|
455
|
+
`The "${name}" tool requires an ExpenseBot account.\n\n` +
|
|
456
|
+
"Sign up for a 60-day free trial (no credit card required) at:\n" +
|
|
457
|
+
"https://www.expensebot.ai?utm_source=mcp&utm_medium=ai-assistant\n\n" +
|
|
458
|
+
"After signing up:\n" +
|
|
459
|
+
"1. Go to Settings → AI Assistant Tokens → Generate\n" +
|
|
460
|
+
"2. Update your MCP config with the new token\n" +
|
|
461
|
+
"3. Restart your AI client\n\n" +
|
|
462
|
+
'Or use the "search_knowledge" or "get_signup_link" tools, which work without an account.',
|
|
463
|
+
},
|
|
464
|
+
],
|
|
465
|
+
isError: true,
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
|
|
427
469
|
switch (name) {
|
|
470
|
+
case "get_signup_link":
|
|
471
|
+
return {
|
|
472
|
+
content: [
|
|
473
|
+
{
|
|
474
|
+
type: "text",
|
|
475
|
+
text:
|
|
476
|
+
"**ExpenseBot — 60-day free trial, no credit card required**\n\n" +
|
|
477
|
+
`Sign up: https://www.expensebot.ai?utm_source=${args?.utmSource || "mcp"}&utm_medium=ai-assistant\n\n` +
|
|
478
|
+
"After signing up, generate an AI Assistant Token from Settings to unlock all 16 tools " +
|
|
479
|
+
"(search expenses, submit receipts, scan Gmail, create reports, run analytics).\n\n" +
|
|
480
|
+
"Free for accountants forever. $10/month for everyone else.",
|
|
481
|
+
},
|
|
482
|
+
],
|
|
483
|
+
};
|
|
484
|
+
|
|
428
485
|
case "search_expenses":
|
|
429
486
|
return formatResult(
|
|
430
487
|
await client.execute("query_expenses", args)
|
|
@@ -479,6 +536,24 @@ async function handleTool(name, args) {
|
|
|
479
536
|
);
|
|
480
537
|
|
|
481
538
|
case "search_knowledge":
|
|
539
|
+
// Works in both modes — falls back to public /api/discover when no client
|
|
540
|
+
if (onboardingMode) {
|
|
541
|
+
try {
|
|
542
|
+
const url = new URL("/api/discover", "https://www.expensebot.ai");
|
|
543
|
+
url.searchParams.set("query", args?.query || "");
|
|
544
|
+
url.searchParams.set("utm_source", "mcp-onboarding");
|
|
545
|
+
const res = await fetch(url.toString(), {
|
|
546
|
+
headers: { "User-Agent": "expensebot-mcp-auth/onboarding" },
|
|
547
|
+
});
|
|
548
|
+
const data = await res.json();
|
|
549
|
+
return formatResult(data);
|
|
550
|
+
} catch (err) {
|
|
551
|
+
return {
|
|
552
|
+
content: [{ type: "text", text: `Search failed: ${err.message}` }],
|
|
553
|
+
isError: true,
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
}
|
|
482
557
|
return formatResult(
|
|
483
558
|
await client.execute("search_knowledge", args)
|
|
484
559
|
);
|