qbo-mcp-ts
Version:
TypeScript QuickBooks Online MCP Server with enhanced features and dual transport support
419 lines • 11.6 kB
TypeScript
/**
* Core TypeScript type definitions for QBOMCP-TS
*/
import { z } from 'zod';
export interface QBOConfig {
clientId: string;
clientSecret: string;
companyId: string;
refreshToken: string;
environment: 'sandbox' | 'production';
redirectUri?: string;
}
export interface QBOTokens {
accessToken: string;
refreshToken: string;
expiresAt: Date;
}
export interface QBOCustomer {
Id: string;
DisplayName: string;
GivenName?: string;
FamilyName?: string;
CompanyName?: string;
PrimaryEmailAddr?: {
Address: string;
};
PrimaryPhone?: {
FreeFormNumber: string;
};
Balance?: number;
Active?: boolean;
MetaData?: {
CreateTime: string;
LastUpdatedTime: string;
};
}
export interface QBOInvoice {
Id: string;
DocNumber?: string;
TxnDate: string;
DueDate?: string;
CustomerRef: {
value: string;
name?: string;
};
Line: QBOLineItem[];
TotalAmt: number;
Balance?: number;
EmailStatus?: 'NotSet' | 'NeedToSend' | 'EmailSent';
MetaData?: {
CreateTime: string;
LastUpdatedTime: string;
};
}
export interface QBOLineItem {
Id?: string;
LineNum?: number;
Description?: string;
Amount: number;
DetailType: 'SalesItemLineDetail' | 'DiscountLineDetail' | 'SubTotalLineDetail';
SalesItemLineDetail?: {
ItemRef?: {
value: string;
name?: string;
};
UnitPrice?: number;
Qty?: number;
TaxCodeRef?: {
value: string;
};
};
}
export interface QBOExpense {
Id: string;
PaymentType?: 'Cash' | 'Check' | 'CreditCard' | 'Bank';
EntityRef?: {
value: string;
name?: string;
type: 'Vendor' | 'Customer' | 'Employee';
};
AccountRef: {
value: string;
name?: string;
};
TxnDate: string;
TotalAmt: number;
Line: QBOExpenseLine[];
MetaData?: {
CreateTime: string;
LastUpdatedTime: string;
};
}
export interface QBOExpenseLine {
Id?: string;
Amount: number;
DetailType: 'AccountBasedExpenseLineDetail' | 'ItemBasedExpenseLineDetail';
AccountBasedExpenseLineDetail?: {
AccountRef: {
value: string;
name?: string;
};
};
Description?: string;
}
export interface QBOAccount {
Id: string;
Name: string;
AcctNum?: string;
AccountType: string;
AccountSubType?: string;
CurrentBalance?: number;
Active?: boolean;
SubAccount?: boolean;
ParentRef?: {
value: string;
name?: string;
};
}
export interface QBOReport {
Header: {
Time: string;
ReportName: string;
ReportBasis?: 'Cash' | 'Accrual';
StartPeriod?: string;
EndPeriod?: string;
SummarizeColumnsBy?: string;
Currency?: string;
};
Columns?: {
Column: Array<{
ColTitle?: string;
ColType?: string;
MetaData?: any;
}>;
};
Rows?: {
Row?: Array<QBOReportRow>;
};
}
export interface QBOReportRow {
type?: string;
group?: string;
ColData?: Array<{
value?: string;
id?: string;
}>;
Rows?: {
Row?: Array<QBOReportRow>;
};
Summary?: {
ColData?: Array<{
value?: string;
}>;
};
}
export declare const GetInvoicesSchema: z.ZodObject<{
status: z.ZodOptional<z.ZodEnum<{
unpaid: "unpaid";
paid: "paid";
overdue: "overdue";
all: "all";
}>>;
customerName: z.ZodOptional<z.ZodString>;
dateFrom: z.ZodOptional<z.ZodString>;
dateTo: z.ZodOptional<z.ZodString>;
minAmount: z.ZodOptional<z.ZodNumber>;
maxAmount: z.ZodOptional<z.ZodNumber>;
limit: z.ZodOptional<z.ZodNumber>;
}, z.core.$strip>;
export declare const CreateInvoiceSchema: z.ZodObject<{
customerName: z.ZodString;
items: z.ZodArray<z.ZodObject<{
description: z.ZodString;
amount: z.ZodNumber;
quantity: z.ZodOptional<z.ZodNumber>;
unitPrice: z.ZodOptional<z.ZodNumber>;
}, z.core.$strip>>;
dueDate: z.ZodOptional<z.ZodString>;
memo: z.ZodOptional<z.ZodString>;
emailToCustomer: z.ZodOptional<z.ZodBoolean>;
}, z.core.$strip>;
export declare const SendInvoiceSchema: z.ZodObject<{
invoiceId: z.ZodString;
email: z.ZodOptional<z.ZodString>;
subject: z.ZodOptional<z.ZodString>;
message: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
export declare const CreateExpenseSchema: z.ZodObject<{
vendorName: z.ZodString;
amount: z.ZodNumber;
accountName: z.ZodString;
paymentMethod: z.ZodOptional<z.ZodEnum<{
Cash: "Cash";
Check: "Check";
Bank: "Bank";
"Credit Card": "Credit Card";
}>>;
description: z.ZodOptional<z.ZodString>;
date: z.ZodOptional<z.ZodString>;
referenceNumber: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
export declare const GetExpensesSchema: z.ZodObject<{
dateFrom: z.ZodOptional<z.ZodString>;
dateTo: z.ZodOptional<z.ZodString>;
vendorName: z.ZodOptional<z.ZodString>;
minAmount: z.ZodOptional<z.ZodNumber>;
maxAmount: z.ZodOptional<z.ZodNumber>;
accountName: z.ZodOptional<z.ZodString>;
limit: z.ZodOptional<z.ZodNumber>;
}, z.core.$strip>;
export declare const ProfitAndLossSchema: z.ZodObject<{
startDate: z.ZodOptional<z.ZodString>;
endDate: z.ZodOptional<z.ZodString>;
summarizeBy: z.ZodOptional<z.ZodEnum<{
Total: "Total";
Month: "Month";
Quarter: "Quarter";
Year: "Year";
}>>;
accountingMethod: z.ZodOptional<z.ZodEnum<{
Cash: "Cash";
Accrual: "Accrual";
}>>;
}, z.core.$strip>;
export declare const BalanceSheetSchema: z.ZodObject<{
asOfDate: z.ZodOptional<z.ZodString>;
summarizeBy: z.ZodOptional<z.ZodEnum<{
Total: "Total";
Month: "Month";
Quarter: "Quarter";
}>>;
accountingMethod: z.ZodOptional<z.ZodEnum<{
Cash: "Cash";
Accrual: "Accrual";
}>>;
}, z.core.$strip>;
export declare const CashFlowSchema: z.ZodObject<{
startDate: z.ZodOptional<z.ZodString>;
endDate: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
export declare const AgingReportSchema: z.ZodObject<{
reportType: z.ZodEnum<{
receivables: "receivables";
payables: "payables";
}>;
asOfDate: z.ZodOptional<z.ZodString>;
agingPeriod: z.ZodDefault<z.ZodNumber>;
}, z.core.$strip>;
export declare const GetCustomersSchema: z.ZodObject<{
active: z.ZodOptional<z.ZodBoolean>;
withBalance: z.ZodOptional<z.ZodBoolean>;
nameContains: z.ZodOptional<z.ZodString>;
limit: z.ZodOptional<z.ZodNumber>;
}, z.core.$strip>;
export declare const CreateCustomerSchema: z.ZodObject<{
displayName: z.ZodString;
givenName: z.ZodOptional<z.ZodString>;
familyName: z.ZodOptional<z.ZodString>;
companyName: z.ZodOptional<z.ZodString>;
email: z.ZodOptional<z.ZodString>;
phone: z.ZodOptional<z.ZodString>;
billingAddress: z.ZodOptional<z.ZodObject<{
line1: z.ZodOptional<z.ZodString>;
city: z.ZodOptional<z.ZodString>;
countrySubDivisionCode: z.ZodOptional<z.ZodString>;
postalCode: z.ZodOptional<z.ZodString>;
}, z.core.$strip>>;
}, z.core.$strip>;
export declare const CustomerBalanceSchema: z.ZodObject<{
customerName: z.ZodString;
}, z.core.$strip>;
export declare const ChartOfAccountsSchema: z.ZodObject<{
accountType: z.ZodOptional<z.ZodEnum<{
Asset: "Asset";
Liability: "Liability";
Equity: "Equity";
Income: "Income";
Expense: "Expense";
}>>;
active: z.ZodOptional<z.ZodBoolean>;
}, z.core.$strip>;
export declare const JournalEntrySchema: z.ZodObject<{
date: z.ZodString;
entries: z.ZodArray<z.ZodObject<{
accountName: z.ZodString;
debit: z.ZodOptional<z.ZodNumber>;
credit: z.ZodOptional<z.ZodNumber>;
description: z.ZodOptional<z.ZodString>;
}, z.core.$strip>>;
memo: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
export interface MCPToolResponse<T = any> {
success: boolean;
data?: T;
error?: string;
suggestion?: string;
metadata?: {
timestamp: string;
requestId: string;
apiCalls?: number;
cached?: boolean;
};
}
export interface InvoiceListResponse {
summary: string;
count: number;
totalAmount: number;
invoices: Array<{
invoiceNumber: string;
customer: string;
date: string;
dueDate: string;
total: string;
balance: string;
status: 'Paid' | 'Unpaid' | 'Overdue';
id: string;
}>;
}
export interface ExpenseListResponse {
summary: string;
count: number;
total: string;
expenses: Array<{
date: string;
vendor: string;
amount: string;
paymentMethod: string;
account: string;
description?: string;
id: string;
}>;
}
export interface CustomerListResponse {
summary: string;
count: number;
customers: Array<{
name: string;
balance: string;
email: string;
phone: string;
active: boolean;
id: string;
}>;
}
export interface ReportResponse {
report: string;
generated: string;
period?: string;
data: any;
summary?: {
totalIncome?: number;
totalExpenses?: number;
netIncome?: number;
totalAssets?: number;
totalLiabilities?: number;
totalEquity?: number;
};
nextSteps?: string[];
}
export interface ICacheService {
get<T>(key: string): Promise<T | null>;
set<T>(key: string, value: T, ttl?: number): Promise<void>;
delete(key: string): Promise<void>;
clear(): Promise<void>;
}
export interface IQueueService {
add<T>(task: () => Promise<T>, priority?: number): Promise<T>;
pause(): void;
resume(): void;
clear(): void;
size(): number;
pending(): number;
}
export interface ILoggerService {
info(message: string, meta?: any): void;
warn(message: string, meta?: any): void;
error(message: string, error?: Error, meta?: any): void;
debug(message: string, meta?: any): void;
http(message: string, meta?: any): void;
}
export type TransportType = 'stdio' | 'sse';
export interface TransportConfig {
type: TransportType;
port?: number;
host?: string;
cors?: {
origin: string | string[];
credentials?: boolean;
};
rateLimit?: {
windowMs: number;
max: number;
};
healthCheckPath?: string;
}
export declare class QBOError extends Error {
code: string;
statusCode?: number | undefined;
details?: any | undefined;
constructor(message: string, code: string, statusCode?: number | undefined, details?: any | undefined);
}
export declare class AuthenticationError extends QBOError {
constructor(message: string, details?: any);
}
export declare class ValidationError extends QBOError {
constructor(message: string, details?: any);
}
export declare class RateLimitError extends QBOError {
constructor(message: string, retryAfter?: number);
}
export declare class NetworkError extends QBOError {
constructor(message: string, details?: any);
}
export type DeepPartial<T> = T extends object ? {
[P in keyof T]?: DeepPartial<T[P]>;
} : T;
export type Awaitable<T> = T | Promise<T>;
export type ValueOf<T> = T[keyof T];
//# sourceMappingURL=index.d.ts.map