@crscreditapi/finstack-mcp-server 0.1.0-1b9ede0 → 0.1.0-a04547f
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.
|
@@ -55,3 +55,22 @@ export interface CustomerSearchResult {
|
|
|
55
55
|
message?: string;
|
|
56
56
|
}
|
|
57
57
|
export declare function searchCustomers(client: ApiClient, query: string, threshold?: number): Promise<CustomerSearchResult>;
|
|
58
|
+
export type RevenuePeriodType = 'day' | 'week' | 'month' | 'quarter' | 'year';
|
|
59
|
+
export interface RevenuePeriod {
|
|
60
|
+
period: string;
|
|
61
|
+
revenue: number;
|
|
62
|
+
}
|
|
63
|
+
export interface CustomerRevenue {
|
|
64
|
+
customer_code: string;
|
|
65
|
+
type: RevenuePeriodType;
|
|
66
|
+
start_date: string;
|
|
67
|
+
end_date: string;
|
|
68
|
+
periods: RevenuePeriod[];
|
|
69
|
+
total: number;
|
|
70
|
+
}
|
|
71
|
+
export declare function getCustomerRevenue(client: ApiClient, args: {
|
|
72
|
+
customerCode: string;
|
|
73
|
+
type: RevenuePeriodType;
|
|
74
|
+
startDate: string;
|
|
75
|
+
endDate: string;
|
|
76
|
+
}): Promise<CustomerRevenue>;
|
package/dist/api/customer.api.js
CHANGED
|
@@ -29,3 +29,20 @@ export async function searchCustomers(client, query, threshold) {
|
|
|
29
29
|
message: response.message,
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
+
export async function getCustomerRevenue(client, args) {
|
|
33
|
+
const secret = process.env.FINSTACK_CHATBASE_SECRET;
|
|
34
|
+
if (!secret) {
|
|
35
|
+
throw new Error('FINSTACK_CHATBASE_SECRET must be set');
|
|
36
|
+
}
|
|
37
|
+
const params = new URLSearchParams({
|
|
38
|
+
customer_code: args.customerCode,
|
|
39
|
+
type: args.type,
|
|
40
|
+
start_date: args.startDate,
|
|
41
|
+
end_date: args.endDate,
|
|
42
|
+
});
|
|
43
|
+
const response = await client.get(`/api/v1/chatbase/customer_revenue?${params}`, { 'X-Chatbase-Secret': secret });
|
|
44
|
+
if (response.status !== 'success' || !response.data) {
|
|
45
|
+
throw new Error(response.message || 'Failed to fetch customer revenue');
|
|
46
|
+
}
|
|
47
|
+
return response.data;
|
|
48
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type RevenuePeriodType } from '../api/customer.api.js';
|
|
1
2
|
interface GetCustomerSummaryArgs {
|
|
2
3
|
customer_code: string;
|
|
3
4
|
environment?: string;
|
|
@@ -9,4 +10,12 @@ interface SearchCustomerArgs {
|
|
|
9
10
|
environment?: string;
|
|
10
11
|
}
|
|
11
12
|
export declare function handleSearchCustomer(args: SearchCustomerArgs): Promise<unknown>;
|
|
13
|
+
interface GetCustomerRevenueArgs {
|
|
14
|
+
customer_code: string;
|
|
15
|
+
type: RevenuePeriodType;
|
|
16
|
+
start_date: string;
|
|
17
|
+
end_date: string;
|
|
18
|
+
environment?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function handleGetCustomerRevenue(args: GetCustomerRevenueArgs): Promise<unknown>;
|
|
12
21
|
export {};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Customer tool handlers
|
|
3
3
|
*/
|
|
4
4
|
import { getClient } from '../api/client.js';
|
|
5
|
-
import { getCustomerSummary, searchCustomers } from '../api/customer.api.js';
|
|
5
|
+
import { getCustomerRevenue, getCustomerSummary, searchCustomers, } from '../api/customer.api.js';
|
|
6
6
|
export async function handleGetCustomerSummary(args) {
|
|
7
7
|
const client = getClient(args.environment ?? 'prod');
|
|
8
8
|
return getCustomerSummary(client, args.customer_code);
|
|
@@ -11,3 +11,12 @@ export async function handleSearchCustomer(args) {
|
|
|
11
11
|
const client = getClient(args.environment ?? 'prod');
|
|
12
12
|
return searchCustomers(client, args.q, args.threshold);
|
|
13
13
|
}
|
|
14
|
+
export async function handleGetCustomerRevenue(args) {
|
|
15
|
+
const client = getClient(args.environment ?? 'prod');
|
|
16
|
+
return getCustomerRevenue(client, {
|
|
17
|
+
customerCode: args.customer_code,
|
|
18
|
+
type: args.type,
|
|
19
|
+
startDate: args.start_date,
|
|
20
|
+
endDate: args.end_date,
|
|
21
|
+
});
|
|
22
|
+
}
|
package/dist/handlers/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { handleGetCustomerSummary, handleSearchCustomer, } from './customer.handler.js';
|
|
1
|
+
import { handleGetCustomerRevenue, handleGetCustomerSummary, handleSearchCustomer, } from './customer.handler.js';
|
|
2
2
|
const wrap = (fn) => {
|
|
3
3
|
return async (args) => fn(args);
|
|
4
4
|
};
|
|
5
5
|
export const handlers = {
|
|
6
6
|
finstack_get_customer_summary: wrap(handleGetCustomerSummary),
|
|
7
7
|
finstack_search_customer: wrap(handleSearchCustomer),
|
|
8
|
+
finstack_get_customer_revenue: wrap(handleGetCustomerRevenue),
|
|
8
9
|
};
|
|
@@ -44,4 +44,36 @@ export const customerTools = [
|
|
|
44
44
|
required: ['q'],
|
|
45
45
|
},
|
|
46
46
|
},
|
|
47
|
+
{
|
|
48
|
+
name: 'finstack_get_customer_revenue',
|
|
49
|
+
description: 'Fetch revenue for a B2B customer over a date range, bucketed by period (day/week/month/quarter/year). Use when the user asks how much a customer paid, revenue trends, MRR/ARR-style figures, or billing over time. Returns periods[{period,revenue}] plus a total. Max range: day=92d, week=2y, month/quarter=10y, year=50y; pick the coarsest type that covers the range.',
|
|
50
|
+
inputSchema: {
|
|
51
|
+
type: 'object',
|
|
52
|
+
properties: {
|
|
53
|
+
customer_code: {
|
|
54
|
+
type: 'string',
|
|
55
|
+
description: 'Customer code (CID) — e.g. "CID18068"',
|
|
56
|
+
},
|
|
57
|
+
type: {
|
|
58
|
+
type: 'string',
|
|
59
|
+
enum: ['day', 'week', 'month', 'quarter', 'year'],
|
|
60
|
+
description: 'Bucketing granularity for the returned periods',
|
|
61
|
+
},
|
|
62
|
+
start_date: {
|
|
63
|
+
type: 'string',
|
|
64
|
+
description: 'Start date (inclusive), format YYYY-MM-DD',
|
|
65
|
+
},
|
|
66
|
+
end_date: {
|
|
67
|
+
type: 'string',
|
|
68
|
+
description: 'End date (inclusive), format YYYY-MM-DD. Must be >= start_date.',
|
|
69
|
+
},
|
|
70
|
+
environment: {
|
|
71
|
+
type: 'string',
|
|
72
|
+
description: 'Target environment: "prod" (default) or "dev"',
|
|
73
|
+
enum: ['dev', 'prod'],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
required: ['customer_code', 'type', 'start_date', 'end_date'],
|
|
77
|
+
},
|
|
78
|
+
},
|
|
47
79
|
];
|