@expensebot/mcp-server-auth 0.6.24 → 0.6.26

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/src/index.js CHANGED
@@ -586,6 +586,769 @@ const GET_SCAN_STATUS_OUTPUT_SCHEMA = {
586
586
  },
587
587
  };
588
588
 
589
+ // ── Tranche 3 output schemas (2026-09-09) — workflow and write tools ─────
590
+ // Successful writes may already have happened when a client validates the
591
+ // response. Keep required fields to proven invariants, and expose each
592
+ // preview/upload/queued/terminal discriminator so clients never infer a retry.
593
+
594
+ const CREATE_REPORT_OUTPUT_SCHEMA = {
595
+ type: "object",
596
+ required: ["success"],
597
+ additionalProperties: true,
598
+ properties: {
599
+ success: { type: "boolean" },
600
+ creationStatus: { type: "string" },
601
+ reportId: { type: "string" },
602
+ reportUrl: { type: "string" },
603
+ billClientUrl: { type: "string" },
604
+ accountingHandoffUrls: { type: "object", additionalProperties: true },
605
+ accountingSetupUrl: { type: "string" },
606
+ finalAnswer: { type: "string" },
607
+ responseGuidance: { type: "string" },
608
+ nextActions: { type: "array", items: { type: "object", additionalProperties: true } },
609
+ data: {
610
+ type: "object",
611
+ additionalProperties: true,
612
+ properties: {
613
+ creationStatus: { type: "string" },
614
+ reportId: { type: "string" },
615
+ title: { type: "string" },
616
+ receiptCount: { type: "integer", minimum: 0 },
617
+ functionalTotal: { type: "number" },
618
+ homeCurrency: { type: "string" },
619
+ appliedFilters: { type: "object", additionalProperties: true },
620
+ personalExcludedCount: { type: "integer", minimum: 0 },
621
+ link: { type: "string" },
622
+ appReportUrl: { type: "string" },
623
+ billClientUrl: { type: "string" },
624
+ },
625
+ },
626
+ },
627
+ };
628
+
629
+ const REQUEST_ACCOUNTING_INTEGRATION_OUTPUT_SCHEMA = {
630
+ type: "object",
631
+ required: ["success", "duplicate", "packageName", "message"],
632
+ additionalProperties: true,
633
+ properties: {
634
+ success: { type: "boolean" },
635
+ duplicate: { type: "boolean" },
636
+ packageName: { type: "string" },
637
+ message: { type: "string" },
638
+ },
639
+ };
640
+
641
+ const SHARE_REPORT_OUTPUT_SCHEMA = {
642
+ type: "object",
643
+ required: ["success", "message", "sharedWith", "recipientRole"],
644
+ additionalProperties: true,
645
+ properties: {
646
+ success: { type: "boolean" },
647
+ message: { type: "string" },
648
+ sharedWith: { type: "array", items: { type: "string", format: "email" } },
649
+ recipientRole: { type: "string" },
650
+ finalAnswer: { type: "string" },
651
+ responseGuidance: { type: "string" },
652
+ },
653
+ };
654
+
655
+ const SUBMIT_RECEIPT_OUTPUT_SCHEMA = {
656
+ type: "object",
657
+ required: ["success"],
658
+ additionalProperties: true,
659
+ properties: {
660
+ success: { type: "boolean" },
661
+ status: { type: "string" },
662
+ statusCode: { type: "integer" },
663
+ message: { type: "string" },
664
+ submissionId: { type: "string" },
665
+ fileCount: { type: "integer", minimum: 0 },
666
+ files: { type: "array", items: { type: "object", additionalProperties: true } },
667
+ spreadsheetUrl: { type: ["string", "null"] },
668
+ reviewExpensesUrl: { type: "string" },
669
+ data: {
670
+ type: "object",
671
+ additionalProperties: true,
672
+ properties: {
673
+ signedUrl: { type: "string" },
674
+ uploadRef: { type: "string" },
675
+ requiredHeaders: { type: "object", additionalProperties: { type: "string" } },
676
+ expiresInSeconds: { type: "integer", minimum: 1 },
677
+ files: {
678
+ type: "array",
679
+ items: {
680
+ type: "object",
681
+ additionalProperties: true,
682
+ properties: {
683
+ id: { type: "string" },
684
+ filename: { type: "string" },
685
+ mimeType: { type: "string" },
686
+ signedUrl: { type: "string" },
687
+ uploadRef: { type: "string" },
688
+ requiredHeaders: { type: "object", additionalProperties: { type: "string" } },
689
+ },
690
+ },
691
+ },
692
+ submissionId: { type: "string" },
693
+ spreadsheetUrl: { type: ["string", "null"] },
694
+ reviewExpensesUrl: { type: "string" },
695
+ },
696
+ },
697
+ },
698
+ allOf: [
699
+ {
700
+ if: { properties: { status: { const: "upload_required" } }, required: ["status"] },
701
+ then: { required: ["data"] },
702
+ },
703
+ ],
704
+ };
705
+
706
+ const ADD_CASH_EXPENSE_OUTPUT_SCHEMA = {
707
+ type: "object",
708
+ required: ["success", "message"],
709
+ additionalProperties: true,
710
+ properties: {
711
+ success: { type: "boolean" },
712
+ message: { type: "string" },
713
+ rowNumber: { type: "integer", minimum: 1 },
714
+ recordId: { type: "string" },
715
+ expense: {
716
+ type: "object",
717
+ additionalProperties: true,
718
+ properties: {
719
+ recordId: { type: "string" },
720
+ rowNumber: { type: "integer", minimum: 1 },
721
+ date: { type: "string", format: "date" },
722
+ merchant: { type: "string" },
723
+ category: { type: "string" },
724
+ total: { type: "number" },
725
+ receivedAmount: { type: "number" },
726
+ currency: { type: "string" },
727
+ tag: { type: "string" },
728
+ isClientAdvance: { type: "boolean" },
729
+ },
730
+ },
731
+ spreadsheetUrl: { type: ["string", "null"] },
732
+ reviewExpensesUrl: { type: "string" },
733
+ data: { type: "object", additionalProperties: true },
734
+ finalAnswer: { type: "string" },
735
+ responseGuidance: { type: "string" },
736
+ },
737
+ };
738
+
739
+ const PARSE_EXPENSE_OUTPUT_SCHEMA = {
740
+ type: "object",
741
+ required: ["success", "expenses", "validationErrors", "categoryNames"],
742
+ additionalProperties: true,
743
+ properties: {
744
+ success: { type: "boolean" },
745
+ expenses: {
746
+ type: "array",
747
+ items: {
748
+ type: "object",
749
+ additionalProperties: true,
750
+ properties: {
751
+ date: { type: "string", format: "date" },
752
+ merchant: { type: "string" },
753
+ category: { type: "string" },
754
+ amount: { type: "number" },
755
+ currency: { type: "string" },
756
+ },
757
+ },
758
+ },
759
+ validationErrors: { type: "array", items: {} },
760
+ categoryNames: { type: "array", items: { type: "string" } },
761
+ },
762
+ };
763
+
764
+ const PROCESS_GMAIL_RECEIPTS_OUTPUT_SCHEMA = {
765
+ type: "object",
766
+ required: ["success", "message"],
767
+ additionalProperties: true,
768
+ properties: {
769
+ success: { type: "boolean" },
770
+ message: { type: "string" },
771
+ error: { type: "string" },
772
+ emailCount: { type: "integer", minimum: 0 },
773
+ processedItems: { type: "array", items: { type: "object", additionalProperties: true } },
774
+ submissionId: { type: "string" },
775
+ processInfo: {
776
+ type: "object",
777
+ additionalProperties: true,
778
+ properties: {
779
+ processingCompleted: { type: "boolean" },
780
+ sessionId: { type: "string" },
781
+ status: { type: "string" },
782
+ },
783
+ },
784
+ spreadsheetUrl: { type: ["string", "null"] },
785
+ reviewExpensesUrl: { type: "string" },
786
+ data: { type: "object", additionalProperties: true },
787
+ },
788
+ };
789
+
790
+ const SCAN_GMAIL_OUTPUT_SCHEMA = {
791
+ type: "object",
792
+ required: ["success"],
793
+ additionalProperties: true,
794
+ properties: {
795
+ success: { type: "boolean" },
796
+ message: { type: "string" },
797
+ status: { type: "string" },
798
+ orchestrated: { type: "boolean" },
799
+ sessionId: { type: "string" },
800
+ submissionId: { type: "string" },
801
+ scanInProgress: { type: "boolean" },
802
+ spreadsheetUrl: { type: ["string", "null"] },
803
+ reviewExpensesUrl: { type: ["string", "null"] },
804
+ data: { type: "object", additionalProperties: true },
805
+ _metadata: { type: "object", additionalProperties: true },
806
+ },
807
+ };
808
+
809
+ const ADD_MILEAGE_ENTRY_OUTPUT_SCHEMA = {
810
+ type: "object",
811
+ required: ["success", "message"],
812
+ additionalProperties: true,
813
+ properties: {
814
+ success: { type: "boolean" },
815
+ message: { type: "string" },
816
+ rowNumber: { type: "integer", minimum: 1 },
817
+ settings: {
818
+ type: "object",
819
+ additionalProperties: true,
820
+ properties: {
821
+ unit: { type: "string" },
822
+ allowancePerUnit: { type: "number" },
823
+ },
824
+ },
825
+ spreadsheetUrl: { type: ["string", "null"] },
826
+ reviewExpensesUrl: { type: "string" },
827
+ data: { type: "object", additionalProperties: true },
828
+ finalAnswer: { type: "string" },
829
+ responseGuidance: { type: "string" },
830
+ },
831
+ };
832
+
833
+ const ADD_INCOME_OUTPUT_SCHEMA = {
834
+ type: "object",
835
+ required: ["success", "message"],
836
+ additionalProperties: true,
837
+ properties: {
838
+ success: { type: "boolean" },
839
+ message: { type: "string" },
840
+ deduped: { type: "boolean" },
841
+ rowNumber: { type: "integer", minimum: 1 },
842
+ tabCreated: { type: "boolean" },
843
+ recordId: { type: "string" },
844
+ matchedRow: {
845
+ type: "object",
846
+ additionalProperties: true,
847
+ properties: {
848
+ rowNumber: { type: "integer", minimum: 1 },
849
+ amount: { type: "number" },
850
+ date: { type: "string", format: "date" },
851
+ currency: { type: "string" },
852
+ },
853
+ },
854
+ destinations: { type: "object", additionalProperties: true },
855
+ data: { type: "object", additionalProperties: true },
856
+ finalAnswer: { type: "string" },
857
+ responseGuidance: { type: "string" },
858
+ },
859
+ };
860
+
861
+ const INCOME_IMPORT_OUTPUT_SCHEMA = {
862
+ type: "object",
863
+ required: ["success", "message"],
864
+ additionalProperties: true,
865
+ properties: {
866
+ success: { type: "boolean" },
867
+ message: { type: "string" },
868
+ preview: { type: "boolean" },
869
+ confirmed: { type: "boolean" },
870
+ tooLargeForChat: { type: "boolean" },
871
+ previewId: { type: "string" },
872
+ expiresAt: { type: "string", format: "date-time" },
873
+ expiresInMinutes: { type: "integer", minimum: 1 },
874
+ entryCount: { type: "integer", minimum: 0 },
875
+ maxChatEntries: { type: "integer", minimum: 1 },
876
+ totalsByCurrency: { type: "object", additionalProperties: { type: "number" } },
877
+ refundRowCount: { type: "integer", minimum: 0 },
878
+ duplicateCount: { type: "integer", minimum: 0 },
879
+ duplicates: { type: "array", items: { type: "object", additionalProperties: true } },
880
+ rejectedRows: { type: "array", items: { type: "object", additionalProperties: true } },
881
+ warnings: { type: "array", items: { type: "string" } },
882
+ entries: {
883
+ type: "array",
884
+ items: {
885
+ type: "object",
886
+ additionalProperties: true,
887
+ properties: {
888
+ index: { type: "integer", minimum: 0 },
889
+ date: { type: "string", format: "date" },
890
+ payer: { type: "string" },
891
+ amount: { type: "number" },
892
+ currency: { type: "string" },
893
+ duplicate: { type: "boolean" },
894
+ },
895
+ },
896
+ },
897
+ projectionTruncated: { type: "boolean" },
898
+ reviewImportUrl: { type: "string" },
899
+ confirmationContract: { type: "string" },
900
+ written: { type: "integer", minimum: 0 },
901
+ deduped: { type: "integer", minimum: 0 },
902
+ failed: { type: "integer", minimum: 0 },
903
+ unattempted: { type: "integer", minimum: 0 },
904
+ total: { type: "integer", minimum: 0 },
905
+ spreadsheetUrl: { type: ["string", "null"] },
906
+ reviewIncomeUrl: { type: "string" },
907
+ finalAnswer: { type: "string" },
908
+ responseGuidance: { type: "string" },
909
+ idempotentReplay: { type: "boolean" },
910
+ },
911
+ allOf: [
912
+ {
913
+ if: { properties: { preview: { const: true } }, required: ["preview"] },
914
+ then: { required: ["previewId", "expiresAt", "entryCount", "entries", "confirmationContract"] },
915
+ },
916
+ {
917
+ if: { properties: { confirmed: { const: true } }, required: ["confirmed"] },
918
+ then: { required: ["previewId", "written", "deduped", "failed", "unattempted", "total"] },
919
+ },
920
+ ],
921
+ };
922
+
923
+ const SEND_REPORT_TO_ACCOUNTING_OUTPUT_SCHEMA = {
924
+ type: "object",
925
+ required: ["success", "phase", "provider", "proposalId"],
926
+ additionalProperties: true,
927
+ properties: {
928
+ success: { type: "boolean" },
929
+ phase: { type: "string", enum: ["preview", "completed"] },
930
+ provider: { type: "string" },
931
+ proposalId: { type: "string" },
932
+ expiresAt: { type: "string", format: "date-time" },
933
+ organization: { type: "object", additionalProperties: true },
934
+ counts: { type: "object", additionalProperties: true },
935
+ units: { type: "array", items: { type: "object", additionalProperties: true } },
936
+ confirmationRequired: { type: "boolean" },
937
+ confirmationQuestion: { type: "string" },
938
+ confirmationContract: { type: "string" },
939
+ reportId: { type: "string" },
940
+ created: { type: "integer", minimum: 0 },
941
+ matchedExisting: { type: "integer", minimum: 0 },
942
+ skippedAlreadyPushed: { type: "integer", minimum: 0 },
943
+ omittedExpenses: { type: "integer", minimum: 0 },
944
+ reconciliationRequired: { type: "boolean" },
945
+ finalAnswer: { type: "string" },
946
+ responseGuidance: { type: "string" },
947
+ idempotentReplay: { type: "boolean" },
948
+ },
949
+ allOf: [
950
+ {
951
+ if: { properties: { phase: { const: "preview" } }, required: ["phase"] },
952
+ then: { required: ["expiresAt", "confirmationRequired", "confirmationQuestion", "confirmationContract"] },
953
+ },
954
+ {
955
+ if: { properties: { phase: { const: "completed" } }, required: ["phase"] },
956
+ then: { required: ["reportId", "finalAnswer", "responseGuidance"] },
957
+ },
958
+ ],
959
+ };
960
+
961
+ const TRACE_DOCUMENT_OUTPUT_SCHEMA = {
962
+ type: "object",
963
+ required: ["success", "type", "message", "data"],
964
+ additionalProperties: true,
965
+ properties: {
966
+ success: { type: "boolean" },
967
+ type: { type: "string", const: "lineage_trace" },
968
+ message: { type: "string" },
969
+ data: {
970
+ type: "object",
971
+ additionalProperties: true,
972
+ properties: {
973
+ searchLabel: { type: "string" },
974
+ summary: { type: "object", additionalProperties: true },
975
+ events: { type: "array", items: { type: "object", additionalProperties: true } },
976
+ filters: { type: "object", additionalProperties: true },
977
+ },
978
+ },
979
+ },
980
+ };
981
+
982
+ const EXPORT_REPORT_OUTPUT_SCHEMA = {
983
+ type: "object",
984
+ required: ["success", "report", "urls", "expiresAt", "availableInReport", "notes"],
985
+ additionalProperties: true,
986
+ properties: {
987
+ success: { type: "boolean" },
988
+ report: {
989
+ type: "object",
990
+ required: ["title", "spreadsheetId"],
991
+ additionalProperties: true,
992
+ properties: {
993
+ id: { type: "string" },
994
+ title: { type: "string" },
995
+ status: { type: "string" },
996
+ spreadsheetId: { type: "string" },
997
+ },
998
+ },
999
+ urls: {
1000
+ type: "object",
1001
+ required: ["view", "pdf", "report"],
1002
+ additionalProperties: true,
1003
+ properties: {
1004
+ view: { type: "string" },
1005
+ pdf: { type: "string" },
1006
+ report: { type: "string" },
1007
+ },
1008
+ },
1009
+ expiresAt: { type: "string", format: "date-time" },
1010
+ availableInReport: { type: "array", items: { type: "string" } },
1011
+ notes: { type: "string" },
1012
+ },
1013
+ };
1014
+
1015
+ const SCAN_GMAIL_YEARS_OUTPUT_SCHEMA = {
1016
+ type: "object",
1017
+ required: ["success", "message"],
1018
+ additionalProperties: true,
1019
+ properties: {
1020
+ success: { type: "boolean" },
1021
+ message: { type: "string" },
1022
+ preview: { type: "boolean" },
1023
+ account: { type: "string" },
1024
+ startedYear: { type: ["integer", "null"] },
1025
+ eligible: { type: "array", items: { type: "integer" } },
1026
+ queuedYears: { type: "array", items: { type: "integer" } },
1027
+ alreadyScanned: { type: "array", items: { type: "integer" } },
1028
+ alreadyQueued: { type: "array", items: { type: "integer" } },
1029
+ scanning: { type: "array", items: { type: "integer" } },
1030
+ notEligible: {
1031
+ type: "array",
1032
+ items: {
1033
+ type: "object",
1034
+ required: ["year", "reason"],
1035
+ additionalProperties: true,
1036
+ properties: {
1037
+ year: { type: "integer" },
1038
+ reason: { type: "string" },
1039
+ code: { type: "string" },
1040
+ },
1041
+ },
1042
+ },
1043
+ archiveThroughYear: { type: "integer" },
1044
+ gmailUrl: { type: "string" },
1045
+ },
1046
+ allOf: [
1047
+ {
1048
+ if: { properties: { preview: { const: true } }, required: ["preview"] },
1049
+ then: { required: ["account", "eligible", "alreadyScanned", "notEligible"] },
1050
+ },
1051
+ ],
1052
+ };
1053
+
1054
+ const PREPARE_CLIENT_INVOICE_OUTPUT_SCHEMA = {
1055
+ type: "object",
1056
+ required: ["success", "preparationId", "expiresAt", "preview"],
1057
+ additionalProperties: true,
1058
+ properties: {
1059
+ success: { type: "boolean" },
1060
+ preparationId: { type: "string" },
1061
+ expiresAt: { type: "string", format: "date-time" },
1062
+ preview: {
1063
+ type: "object",
1064
+ additionalProperties: true,
1065
+ properties: {
1066
+ reportId: { type: "string" },
1067
+ reportTitle: { type: "string" },
1068
+ invoiceNumber: { type: "string" },
1069
+ issueDate: { type: "string", format: "date" },
1070
+ dueDate: { type: "string", format: "date" },
1071
+ paymentTerms: { type: "string" },
1072
+ clientName: { type: "string" },
1073
+ clientTag: { type: "string" },
1074
+ currency: { type: "string" },
1075
+ expenseCount: { type: "integer", minimum: 0 },
1076
+ customLineCount: { type: "integer", minimum: 0 },
1077
+ subtotal: { type: "number" },
1078
+ markupPct: { type: "number" },
1079
+ markupAmount: { type: "number" },
1080
+ taxPct: { type: "number" },
1081
+ taxLabel: { type: "string" },
1082
+ taxAmount: { type: "number" },
1083
+ grandTotal: { type: "number" },
1084
+ advanceApplied: { type: "number" },
1085
+ balanceDue: { type: "number" },
1086
+ taxConfirmationRequired: { type: "boolean" },
1087
+ hasTaxRegistration: { type: "boolean" },
1088
+ },
1089
+ },
1090
+ },
1091
+ };
1092
+
1093
+ const CREATE_CLIENT_INVOICE_OUTPUT_SCHEMA = {
1094
+ type: "object",
1095
+ required: ["success"],
1096
+ additionalProperties: true,
1097
+ properties: {
1098
+ success: { type: "boolean" },
1099
+ recovered: { type: "boolean" },
1100
+ invoiceId: { type: ["string", "null"] },
1101
+ invoiceNumber: { type: ["string", "null"] },
1102
+ clientName: { type: ["string", "null"] },
1103
+ status: { type: "string" },
1104
+ total: { type: "number" },
1105
+ grandTotal: { type: "number" },
1106
+ advanceApplied: { type: "number" },
1107
+ currency: { type: "string" },
1108
+ issueDate: { type: ["string", "null"], format: "date" },
1109
+ dueDate: { type: ["string", "null"], format: "date" },
1110
+ documentUrl: { type: ["string", "null"] },
1111
+ pdfUrl: { type: ["string", "null"] },
1112
+ docxUrl: { type: ["string", "null"] },
1113
+ sourceReportId: { type: ["string", "null"] },
1114
+ artifactWarning: { type: "string" },
1115
+ },
1116
+ };
1117
+
1118
+ const MARK_CLIENT_INVOICE_PAID_OUTPUT_SCHEMA = {
1119
+ type: "object",
1120
+ required: ["success", "invoiceId", "status", "paidDate", "paidAmount", "paidVia", "incomeRowCreated", "message"],
1121
+ additionalProperties: true,
1122
+ properties: {
1123
+ success: { type: "boolean" },
1124
+ invoiceId: { type: "string" },
1125
+ invoiceNumber: { type: ["string", "null"] },
1126
+ status: { type: "string", const: "paid" },
1127
+ paidDate: { type: "string", format: "date" },
1128
+ paidAmount: { type: ["number", "null"] },
1129
+ paidVia: { type: "string" },
1130
+ incomeRowCreated: { type: "boolean", const: false },
1131
+ message: { type: "string" },
1132
+ },
1133
+ };
1134
+
1135
+ const GROUP_EXPENSES_OUTPUT_SCHEMA = {
1136
+ type: "object",
1137
+ required: ["success", "status"],
1138
+ additionalProperties: true,
1139
+ properties: {
1140
+ success: { type: "boolean" },
1141
+ status: { type: "string" },
1142
+ operationId: { type: "string" },
1143
+ group: { type: "object", additionalProperties: true },
1144
+ candidates: { type: "array", items: { type: "object", additionalProperties: true } },
1145
+ suggestedTag: { type: "string" },
1146
+ preview: { type: "object", additionalProperties: true },
1147
+ manifest: { type: "object", additionalProperties: true },
1148
+ requiresConfirmation: { type: "boolean" },
1149
+ requiresNewGroupApproval: { type: "boolean" },
1150
+ confirmation: { type: "object", additionalProperties: true },
1151
+ exclusions: { type: "object", additionalProperties: true },
1152
+ reviewExpensesUrl: { type: "string" },
1153
+ reportsUrl: { type: "string" },
1154
+ report: { type: "object", additionalProperties: true },
1155
+ undo: { type: "object", additionalProperties: true },
1156
+ creationStatus: { type: "string" },
1157
+ message: { type: "string" },
1158
+ finalAnswer: { type: "string" },
1159
+ responseGuidance: { type: "string" },
1160
+ },
1161
+ };
1162
+
1163
+ const UPDATE_EXPENSE_OUTPUT_SCHEMA = {
1164
+ type: "object",
1165
+ required: ["success", "message", "data"],
1166
+ additionalProperties: true,
1167
+ properties: {
1168
+ success: { type: "boolean" },
1169
+ message: { type: "string" },
1170
+ data: {
1171
+ type: "object",
1172
+ required: ["applied", "expenseId", "diff", "unmapped"],
1173
+ additionalProperties: true,
1174
+ properties: {
1175
+ applied: { type: "boolean" },
1176
+ preview: { type: "boolean" },
1177
+ dryRun: { type: "boolean" },
1178
+ expenseId: { type: "string" },
1179
+ diff: {
1180
+ type: "array",
1181
+ items: {
1182
+ type: "object",
1183
+ required: ["field", "from", "to"],
1184
+ additionalProperties: true,
1185
+ properties: {
1186
+ field: { type: "string" },
1187
+ column: { type: "string" },
1188
+ columnLetter: { type: "string" },
1189
+ from: {},
1190
+ to: {},
1191
+ },
1192
+ },
1193
+ },
1194
+ unmapped: { type: "array", items: { type: "string" } },
1195
+ reviewExpenseUrl: { type: "string" },
1196
+ },
1197
+ },
1198
+ finalAnswer: { type: "string" },
1199
+ responseGuidance: { type: "string" },
1200
+ },
1201
+ };
1202
+
1203
+ const CORRECT_EXPENSES_OUTPUT_SCHEMA = {
1204
+ type: "object",
1205
+ required: ["success", "status"],
1206
+ additionalProperties: true,
1207
+ properties: {
1208
+ success: { type: "boolean" },
1209
+ status: { type: "string" },
1210
+ operationId: { type: "string" },
1211
+ change: { type: "object", additionalProperties: true },
1212
+ preview: { type: "object", additionalProperties: true },
1213
+ manifest: { type: "object", additionalProperties: true },
1214
+ requiresConfirmation: { type: "boolean" },
1215
+ confirmation: { type: "object", additionalProperties: true },
1216
+ message: { type: "string" },
1217
+ finalAnswer: { type: "string" },
1218
+ reviewExpensesUrl: { type: "string" },
1219
+ responseGuidance: { type: "string" },
1220
+ undo: { type: "object", additionalProperties: true },
1221
+ },
1222
+ };
1223
+
1224
+ // `fix_compliance` is a compatibility entry point for the reviewed expense
1225
+ // correction workflow. Keep one input contract so the alias cannot drift back
1226
+ // to the legacy row-based batch writer.
1227
+ const REVIEWED_EXPENSE_CORRECTION_INPUT_SCHEMA = {
1228
+ type: "object",
1229
+ additionalProperties: false,
1230
+ properties: {
1231
+ change: {
1232
+ type: "object",
1233
+ additionalProperties: false,
1234
+ description:
1235
+ "Exactly one correction. The selected type determines which matching value field is required.",
1236
+ properties: {
1237
+ type: {
1238
+ type: "string",
1239
+ enum: ["category", "businessPurpose", "attendees"],
1240
+ description:
1241
+ "The one correction kind to apply to every exact selected expense.",
1242
+ },
1243
+ category: {
1244
+ type: "string",
1245
+ description:
1246
+ "Configured expense category to apply when type is category.",
1247
+ },
1248
+ businessPurpose: {
1249
+ type: "string",
1250
+ description:
1251
+ "User-supplied business purpose to apply when type is businessPurpose.",
1252
+ },
1253
+ attendees: {
1254
+ type: "array",
1255
+ minItems: 1,
1256
+ maxItems: 25,
1257
+ items: { type: "string" },
1258
+ description:
1259
+ "Attendee names explicitly supplied by the user when type is attendees; never infer names.",
1260
+ },
1261
+ attendeeMode: {
1262
+ type: "string",
1263
+ enum: ["add", "replace"],
1264
+ description:
1265
+ "Use add unless the user explicitly asks to replace existing attendees.",
1266
+ },
1267
+ },
1268
+ required: ["type"],
1269
+ oneOf: [
1270
+ {
1271
+ properties: { type: { const: "category" } },
1272
+ required: ["category"],
1273
+ },
1274
+ {
1275
+ properties: { type: { const: "businessPurpose" } },
1276
+ required: ["businessPurpose"],
1277
+ },
1278
+ {
1279
+ properties: { type: { const: "attendees" } },
1280
+ required: ["attendees"],
1281
+ },
1282
+ ],
1283
+ },
1284
+ selection: {
1285
+ type: "object",
1286
+ additionalProperties: false,
1287
+ description:
1288
+ "Exact expenses returned by search_expenses and approved for this bounded correction.",
1289
+ properties: {
1290
+ items: {
1291
+ type: "array",
1292
+ minItems: 1,
1293
+ maxItems: 100,
1294
+ description:
1295
+ "One exact receipt identity per selected expense; never broaden this list after preview.",
1296
+ items: {
1297
+ type: "object",
1298
+ additionalProperties: false,
1299
+ properties: {
1300
+ receiptId: {
1301
+ type: "string",
1302
+ description:
1303
+ "Exact full expenseId/Column-Q receipt identity from search_expenses.",
1304
+ },
1305
+ expected: {
1306
+ type: "object",
1307
+ additionalProperties: false,
1308
+ description:
1309
+ "Optional optimistic-concurrency values copied from the search result.",
1310
+ properties: {
1311
+ category: {
1312
+ type: "string",
1313
+ description:
1314
+ "Current category observed before preview for conflict detection.",
1315
+ },
1316
+ notes: {
1317
+ type: "string",
1318
+ description:
1319
+ "Current structured Notes value observed before preview for conflict detection.",
1320
+ },
1321
+ },
1322
+ },
1323
+ },
1324
+ required: ["receiptId"],
1325
+ },
1326
+ },
1327
+ },
1328
+ required: ["items"],
1329
+ },
1330
+ operationId: {
1331
+ type: "string",
1332
+ pattern: "^expense-bulk:[a-zA-Z0-9_-]{8,100}$",
1333
+ description:
1334
+ "Stable idempotency key generated once for preview and reused unchanged.",
1335
+ },
1336
+ confirm: {
1337
+ type: "boolean",
1338
+ description: "Omit/false for preview; true only after explicit approval.",
1339
+ },
1340
+ status: {
1341
+ type: "boolean",
1342
+ description: "Read operation status using operationId.",
1343
+ },
1344
+ undo: {
1345
+ type: "boolean",
1346
+ description: "Undo a completed correction within its Undo window.",
1347
+ },
1348
+ },
1349
+ required: ["operationId"],
1350
+ };
1351
+
589
1352
  // ── Tool Definitions ───────────────────────────────────────────────────
590
1353
 
591
1354
  // Output contracts for the first, highest-guess-cost tranche. `required`
@@ -682,8 +1445,10 @@ const GET_LAST_RECEIPT_RESULT_OUTPUT_SCHEMA = {
682
1445
  message: { type: "string" },
683
1446
  verdict: {
684
1447
  type: "string",
685
- enum: ["added", "duplicate", "skipped", "errored", "mixed", "unknown"],
686
- description: "Terminal branch only.",
1448
+ enum: ["added", "duplicate", "skipped", "errored", "mixed", "unknown", "held_for_review"],
1449
+ description:
1450
+ "Terminal branch only. held_for_review: every file was held for review, so none was added. " +
1451
+ "mixed also covers any batch that includes held files.",
687
1452
  },
688
1453
  counts: {
689
1454
  type: "object",
@@ -695,9 +1460,18 @@ const GET_LAST_RECEIPT_RESULT_OUTPUT_SCHEMA = {
695
1460
  duplicates: { type: "integer", minimum: 0 },
696
1461
  skipped: { type: "integer", minimum: 0 },
697
1462
  errors: { type: "integer", minimum: 0 },
1463
+ heldForReview: {
1464
+ type: "integer",
1465
+ minimum: 0,
1466
+ description: "Files held for review and not added. Present only when at least one.",
1467
+ },
698
1468
  },
699
1469
  },
700
- receipts: { type: "array", items: { type: "object", additionalProperties: true } },
1470
+ receipts: {
1471
+ type: "array",
1472
+ description: "Processed receipt summaries. Held files are not listed here; see data.outcomes.",
1473
+ items: { type: "object", additionalProperties: true },
1474
+ },
701
1475
  submissionId: { type: ["string", "null"] },
702
1476
  spreadsheetUrl: { type: ["string", "null"] },
703
1477
  reviewExpensesUrl: { type: "string" },
@@ -871,6 +1645,7 @@ const TOOLS = [
871
1645
  },
872
1646
  {
873
1647
  name: "create_report",
1648
+ outputSchema: CREATE_REPORT_OUTPUT_SCHEMA,
874
1649
  description:
875
1650
  "Create an expense report from a clear date, client, project, trip, " +
876
1651
  "category, or merchant request. Tags are ExpenseBot's grouping layer " +
@@ -973,6 +1748,7 @@ const TOOLS = [
973
1748
  },
974
1749
  {
975
1750
  name: "request_accounting_integration",
1751
+ outputSchema: REQUEST_ACCOUNTING_INTEGRATION_OUTPUT_SCHEMA,
976
1752
  description:
977
1753
  "Request support for an accounting package only after checking ExpenseBot's reviewed direct and import-file destinations and finding no matching package. Do not use this for a listed or Beta destination, a general compatibility question, or without the exact package name. This is a confirmation-gated write: after the user approves, it creates one deduplicated request bound to the authenticated ExpenseBot account and emails ExpenseBot's internal team. It does not create an integration or make the requested package immediately available. On accepted or previously recorded requests, tell the user ExpenseBot will email them within one week with an update.",
978
1754
  inputSchema: {
@@ -1011,6 +1787,7 @@ const TOOLS = [
1011
1787
  },
1012
1788
  {
1013
1789
  name: "share_report",
1790
+ outputSchema: SHARE_REPORT_OUTPUT_SCHEMA,
1014
1791
  description:
1015
1792
  "Share one existing expense report after confirmation. Default to reviewer: they can open and edit that report's Google Sheet, inspect receipts, comment, approve, or request changes, but cannot act for the owner or use accounting integrations. Use accountant only when the user explicitly asks for ongoing accounting access; it creates the established accountant relationship and broader report-management workflow.",
1016
1793
  inputSchema: {
@@ -1056,21 +1833,15 @@ const TOOLS = [
1056
1833
  },
1057
1834
  {
1058
1835
  name: "fix_compliance",
1836
+ outputSchema: CORRECT_EXPENSES_OUTPUT_SCHEMA,
1059
1837
  description:
1060
- "Bulk-fix compliance issues in a report (e.g., apply the same " +
1061
- "business purpose to all flagged expenses).",
1062
- inputSchema: {
1063
- type: "object",
1064
- properties: {
1065
- reportId: { type: "string" },
1066
- action: {
1067
- type: "string",
1068
- enum: ["add_purpose", "set_category", "add_tag"],
1069
- },
1070
- value: { type: "string", description: "The value to apply" },
1071
- },
1072
- required: ["reportId", "action", "value"],
1073
- },
1838
+ "Safely correct compliance issues on an exact bounded set of recorded expenses. " +
1839
+ "Use only after the user explicitly asks to fix issues found by check_compliance. " +
1840
+ "Use search_expenses to obtain each full expenseId, then pass those exact identities; never select every report row or infer a business purpose, category, or attendee. " +
1841
+ "This compatibility tool uses the same reviewed workflow as correct_expenses: the first call always prepares a grounded preview and makes no change, even if confirm:true arrives early. " +
1842
+ "Show the exact proposed changes and ask once for approval. Only after explicit approval repeat the same operationId, selection, and change with confirm:true. " +
1843
+ "The confirmed result reports applied/conflicted/failed counts and supports status and Undo. For tags/groups use group_expenses; for unsupported or more than 100-row cleanup open https://www.expensebot.ai/review-expenses?source=mcp.",
1844
+ inputSchema: REVIEWED_EXPENSE_CORRECTION_INPUT_SCHEMA,
1074
1845
  },
1075
1846
  {
1076
1847
  name: "check_tax_deductibility",
@@ -1133,6 +1904,7 @@ const TOOLS = [
1133
1904
  },
1134
1905
  {
1135
1906
  name: "submit_receipt",
1907
+ outputSchema: SUBMIT_RECEIPT_OUTPUT_SCHEMA,
1136
1908
  _meta: { "openai/fileParams": ["photo"] },
1137
1909
  description:
1138
1910
  "Submit a photo or PDF of a receipt for processing. Covers requests " +
@@ -1294,8 +2066,9 @@ const TOOLS = [
1294
2066
  "tool with that exact ID using the polling interval and time allowance in " +
1295
2067
  "the submit_receipt response. A small batch allows at least 5 minutes; larger " +
1296
2068
  "batches allow longer. A pending result is normal and must not trigger a " +
1297
- "duplicate resubmission. Returns added, duplicate, skipped, or " +
2069
+ "duplicate resubmission. Returns added, duplicate, skipped, held_for_review, or " +
1298
2070
  "errored verdicts with exact counts and up to 10 processed receipt summaries. " +
2071
+ "A held_for_review file (withheld for missing details or a possible duplicate) was not added; relay the next step in the message. " +
1299
2072
  "found:false is pending and has no terminal verdict; found:true is terminal. " +
1300
2073
  "On completion, tell the user what happened and show spreadsheetUrl plus " +
1301
2074
  "reviewExpensesUrl. This is for uploaded receipts; use get_scan_status for " +
@@ -1321,6 +2094,7 @@ const TOOLS = [
1321
2094
  },
1322
2095
  {
1323
2096
  name: "add_cash_expense",
2097
+ outputSchema: ADD_CASH_EXPENSE_OUTPUT_SCHEMA,
1324
2098
  description:
1325
2099
  "Add an expense without a receipt, or record money a client provided in advance for expenses. " +
1326
2100
  "Writes directly to the user's expense spreadsheet after confirmation. For an ordinary expense, " +
@@ -1376,6 +2150,7 @@ const TOOLS = [
1376
2150
  },
1377
2151
  {
1378
2152
  name: "parse_expense",
2153
+ outputSchema: PARSE_EXPENSE_OUTPUT_SCHEMA,
1379
2154
  description:
1380
2155
  "Parse a natural language expense description into structured fields. " +
1381
2156
  "Does NOT add the expense — just returns the parsed fields for review. " +
@@ -1394,6 +2169,7 @@ const TOOLS = [
1394
2169
  },
1395
2170
  {
1396
2171
  name: "process_gmail_receipts",
2172
+ outputSchema: PROCESS_GMAIL_RECEIPTS_OUTPUT_SCHEMA,
1397
2173
  description:
1398
2174
  "Process specific Gmail emails as receipts. Pass Gmail message IDs " +
1399
2175
  "and they'll be converted to PDF, extracted by AI, and added to the " +
@@ -1418,6 +2194,7 @@ const TOOLS = [
1418
2194
  },
1419
2195
  {
1420
2196
  name: "scan_gmail",
2197
+ outputSchema: SCAN_GMAIL_OUTPUT_SCHEMA,
1421
2198
  description:
1422
2199
  "Trigger a background Gmail scan to discover and process receipt " +
1423
2200
  "emails from the last ~60 days (default). Runs asynchronously — " +
@@ -1470,6 +2247,7 @@ const TOOLS = [
1470
2247
  },
1471
2248
  {
1472
2249
  name: "add_mileage_entry",
2250
+ outputSchema: ADD_MILEAGE_ENTRY_OUTPUT_SCHEMA,
1473
2251
  description:
1474
2252
  "Log a business mileage trip in ExpenseBot. Useful for realtors, " +
1475
2253
  "consultants, contractors, and anyone who drives for work. Requires " +
@@ -1493,7 +2271,9 @@ const TOOLS = [
1493
2271
  date: {
1494
2272
  type: "string",
1495
2273
  format: "date",
1496
- description: "Trip date (YYYY-MM-DD). Defaults to today.",
2274
+ description:
2275
+ "Trip date (YYYY-MM-DD). Required. Use the date the user gives; for \"today\" send " +
2276
+ "today's calendar date in their timezone. If no date was given, ask.",
1497
2277
  },
1498
2278
  roundTrip: {
1499
2279
  type: "boolean",
@@ -1521,13 +2301,17 @@ const TOOLS = [
1521
2301
  description: "Optional user-supplied context stored with the mileage entry.",
1522
2302
  },
1523
2303
  },
1524
- required: ["distance", "purpose"],
2304
+ required: ["distance", "purpose", "date"],
1525
2305
  },
1526
2306
  },
1527
2307
  {
1528
2308
  name: "add_income",
2309
+ outputSchema: ADD_INCOME_OUTPUT_SCHEMA,
1529
2310
  description:
1530
- "Log an income entry manually (cash, check, Stripe payout, etc.). " +
2311
+ "Log exactly one user-confirmed income payment manually (cash, check, Stripe payout, etc.). " +
2312
+ "Never loop this tool over a statement, export, table, or multi-row list. For two or more " +
2313
+ "payments, use add_income_from_csv for CSV/TSV/text or add_income_from_file for an image/PDF; " +
2314
+ "those tools stage a duplicate-checked preview and require confirmation before writing. " +
1531
2315
  "Writes to the Income tab of the user's expense spreadsheet. Useful " +
1532
2316
  "for income that isn't auto-detected from Gmail or Plaid. Call " +
1533
2317
  "list_income_categories first and use one of its fixed tax categories; " +
@@ -1547,7 +2331,9 @@ const TOOLS = [
1547
2331
  date: {
1548
2332
  type: "string",
1549
2333
  format: "date",
1550
- description: "Income date (YYYY-MM-DD). Defaults to today.",
2334
+ description:
2335
+ "Income date (YYYY-MM-DD). Required. Use the date the user gives; for \"today\" send " +
2336
+ "today's calendar date in their timezone. If no date was given, ask.",
1551
2337
  },
1552
2338
  currency: { type: "string", description: "Currency code (default: home currency)" },
1553
2339
  description: { type: "string", description: "What the income was for" },
@@ -1558,11 +2344,12 @@ const TOOLS = [
1558
2344
  tag: { type: "string", description: "Tag for client/project attribution" },
1559
2345
  notes: { type: "string" },
1560
2346
  },
1561
- required: ["amount", "source", "paymentMethod"],
2347
+ required: ["amount", "source", "paymentMethod", "date"],
1562
2348
  },
1563
2349
  },
1564
2350
  {
1565
2351
  name: "add_income_from_file",
2352
+ outputSchema: INCOME_IMPORT_OUTPUT_SCHEMA,
1566
2353
  _meta: { "openai/fileParams": ["photo"] },
1567
2354
  description:
1568
2355
  "Import income from an attached screenshot, image (JPEG, PNG, WebP, HEIC/HEIF), or PDF " +
@@ -1674,6 +2461,7 @@ const TOOLS = [
1674
2461
  },
1675
2462
  {
1676
2463
  name: "add_income_from_csv",
2464
+ outputSchema: INCOME_IMPORT_OUTPUT_SCHEMA,
1677
2465
  _meta: { "openai/fileParams": ["csvContent"] },
1678
2466
  description:
1679
2467
  "Import income from a CSV/TSV/text export (Stripe, PayPal, Square, Cash App, Venmo, " +
@@ -1800,6 +2588,7 @@ const TOOLS = [
1800
2588
  },
1801
2589
  {
1802
2590
  name: "send_report_to_accounting",
2591
+ outputSchema: SEND_REPORT_TO_ACCOUNTING_OUTPUT_SCHEMA,
1803
2592
  description:
1804
2593
  "Review and then post an ExpenseBot report to the owner's accounting destination. " +
1805
2594
  "STEP 1: call with provider, reportId, and optional mode/mappings, without confirm. The " +
@@ -2066,6 +2855,7 @@ const TOOLS = [
2066
2855
  },
2067
2856
  {
2068
2857
  name: "trace_document",
2858
+ outputSchema: TRACE_DOCUMENT_OUTPUT_SCHEMA,
2069
2859
  description:
2070
2860
  "Trace what happened to a specific receipt, invoice, forwarded email, Gmail receipt, or PDF in ExpenseBot processing. " +
2071
2861
  "Use when the user asks where a document went, why it did not show up, whether it was skipped, routed to income, deduped, or removed as a duplicate. " +
@@ -2203,6 +2993,7 @@ const TOOLS = [
2203
2993
  },
2204
2994
  {
2205
2995
  name: "export_report",
2996
+ outputSchema: EXPORT_REPORT_OUTPUT_SCHEMA,
2206
2997
  description:
2207
2998
  "Get a short-lived direct PDF download for one exact authorized expense " +
2208
2999
  "report, plus the exact highlighted in-app report link. Use the in-app " +
@@ -2263,7 +3054,7 @@ const TOOLS = [
2263
3054
  "anything is saved. " +
2264
3055
  "Team setup requests use the returned role-aware Team setup handoff: " +
2265
3056
  "eligible solo business owners open Add teammates, while existing team " +
2266
- "owners and co-admins open License Manager. If the handoff says owner " +
3057
+ "owners and co-admins open Team Management. If the handoff says owner " +
2267
3058
  "access is required, explain that instead of presenting a broken link. " +
2268
3059
  "Complex or visually reviewed report requests " +
2269
3060
  "use the returned Create report link. Read-only; this tool does " +
@@ -2390,6 +3181,7 @@ const TOOLS = [
2390
3181
  },
2391
3182
  {
2392
3183
  name: "scan_gmail_years",
3184
+ outputSchema: SCAN_GMAIL_YEARS_OUTPUT_SCHEMA,
2393
3185
  description:
2394
3186
  "Scan one or more COMPLETED PRIOR years of the user's Gmail for " +
2395
3187
  "receipts (e.g. years:[2023] or years:[2020,2021,2022]). Long-running " +
@@ -2493,6 +3285,7 @@ const TOOLS = [
2493
3285
  },
2494
3286
  {
2495
3287
  name: "prepare_client_invoice",
3288
+ outputSchema: PREPARE_CLIENT_INVOICE_OUTPUT_SCHEMA,
2496
3289
  description:
2497
3290
  "Prepare a client invoice from a saved ExpenseBot report without creating it. " +
2498
3291
  "Reads canonical report rows, allocates a unique invoice number, verifies the " +
@@ -2557,6 +3350,7 @@ const TOOLS = [
2557
3350
  },
2558
3351
  {
2559
3352
  name: "create_client_invoice",
3353
+ outputSchema: CREATE_CLIENT_INVOICE_OUTPUT_SCHEMA,
2560
3354
  description:
2561
3355
  "Create the exact invoice previously returned by prepare_client_invoice. This is " +
2562
3356
  "a confirmed write: it revalidates the report snapshot and client identity, creates " +
@@ -2599,6 +3393,7 @@ const TOOLS = [
2599
3393
  },
2600
3394
  {
2601
3395
  name: "mark_client_invoice_paid",
3396
+ outputSchema: MARK_CLIENT_INVOICE_PAID_OUTPUT_SCHEMA,
2602
3397
  description:
2603
3398
  "Mark an issued client invoice as paid after explicit confirmation. Requires " +
2604
3399
  "a strict calendar-valid paidDate in YYYY-MM-DD format. This updates the " +
@@ -2765,6 +3560,7 @@ const TOOLS = [
2765
3560
  },
2766
3561
  {
2767
3562
  name: "group_expenses",
3563
+ outputSchema: GROUP_EXPENSES_OUTPUT_SCHEMA,
2768
3564
  description:
2769
3565
  "Group an exact set of recorded expenses for a client, project, trip, job, or other user-named purpose. " +
2770
3566
  "Examples: 'group my Mexico meals for client Rob', 'put these Vegas expenses under the Vegas project', " +
@@ -2864,6 +3660,7 @@ const TOOLS = [
2864
3660
  },
2865
3661
  {
2866
3662
  name: "update_expense",
3663
+ outputSchema: UPDATE_EXPENSE_OUTPUT_SCHEMA,
2867
3664
  description:
2868
3665
  "Update a single existing expense row's category, tag, merchant, or " +
2869
3666
  "business purpose (e.g. 'recategorize expense X to Meals' or 'tag it " +
@@ -2873,6 +3670,9 @@ const TOOLS = [
2873
3670
  "Two-phase operation: calls with confirm omitted or false return a " +
2874
3671
  "preview of the current→proposed change and make no change. After user " +
2875
3672
  "confirmation, a call with confirm:true applies the proposed change. " +
3673
+ "If the expense is not found, search once for a current exact expenseId; never retry the " +
3674
+ "same stale ID. If a business-purpose update exceeds the Notes capacity, stop and send the " +
3675
+ "user to https://www.expensebot.ai/review-expenses?source=mcp instead of retrying. " +
2876
3676
  "Only category/tag/merchant/businessPurpose are " +
2877
3677
  "editable — amounts, dates, and notes are not editable via the " +
2878
3678
  "assistant. Does not create or delete rows.",
@@ -2902,6 +3702,7 @@ const TOOLS = [
2902
3702
  },
2903
3703
  {
2904
3704
  name: "correct_expenses",
3705
+ outputSchema: CORRECT_EXPENSES_OUTPUT_SCHEMA,
2905
3706
  description:
2906
3707
  "Safely correct the category, business purpose, or explicit attendees on an exact bounded set of recorded expenses. " +
2907
3708
  "Examples: 'categorize these as Travel', 'add Client kickoff dinner as the business purpose for these meals', or " +
@@ -2912,108 +3713,7 @@ const TOOLS = [
2912
3713
  "Business purpose and attendees preserve the structured Notes field, including card, description, inbox, and other typed segments. Formula Notes and changes that exceed the Notes limit are skipped safely. " +
2913
3714
  "The confirmed result reports applied/conflicted/failed counts and supports Undo. This tool does not omit duplicates, change amounts or dates, infer business context, or run broad Calendar matching. " +
2914
3715
  "For unsupported or more than 100-row cleanup, send the user to https://www.expensebot.ai/review-expenses?source=mcp.",
2915
- inputSchema: {
2916
- type: "object",
2917
- additionalProperties: false,
2918
- properties: {
2919
- change: {
2920
- type: "object",
2921
- additionalProperties: false,
2922
- description:
2923
- "Exactly one correction. The selected type determines which matching value field is required.",
2924
- properties: {
2925
- type: {
2926
- type: "string",
2927
- enum: ["category", "businessPurpose", "attendees"],
2928
- description: "The one correction kind to apply to every exact selected expense.",
2929
- },
2930
- category: {
2931
- type: "string",
2932
- description: "Configured expense category to apply when type is category.",
2933
- },
2934
- businessPurpose: {
2935
- type: "string",
2936
- description: "User-supplied business purpose to apply when type is businessPurpose.",
2937
- },
2938
- attendees: {
2939
- type: "array",
2940
- minItems: 1,
2941
- maxItems: 25,
2942
- items: { type: "string" },
2943
- description: "Attendee names explicitly supplied by the user when type is attendees; never infer names.",
2944
- },
2945
- attendeeMode: {
2946
- type: "string",
2947
- enum: ["add", "replace"],
2948
- description:
2949
- "Use add unless the user explicitly asks to replace existing attendees.",
2950
- },
2951
- },
2952
- required: ["type"],
2953
- },
2954
- selection: {
2955
- type: "object",
2956
- additionalProperties: false,
2957
- description: "Exact expenses returned by search_expenses and approved for this bounded correction.",
2958
- properties: {
2959
- items: {
2960
- type: "array",
2961
- minItems: 1,
2962
- maxItems: 100,
2963
- description: "One exact receipt identity per selected expense; never broaden this list after preview.",
2964
- items: {
2965
- type: "object",
2966
- additionalProperties: false,
2967
- properties: {
2968
- receiptId: {
2969
- type: "string",
2970
- description:
2971
- "Exact full expenseId/Column-Q receipt identity from search_expenses.",
2972
- },
2973
- expected: {
2974
- type: "object",
2975
- additionalProperties: false,
2976
- description:
2977
- "Optional optimistic-concurrency values copied from the search result.",
2978
- properties: {
2979
- category: {
2980
- type: "string",
2981
- description: "Current category observed before preview for conflict detection.",
2982
- },
2983
- notes: {
2984
- type: "string",
2985
- description: "Current structured Notes value observed before preview for conflict detection.",
2986
- },
2987
- },
2988
- },
2989
- },
2990
- required: ["receiptId"],
2991
- },
2992
- },
2993
- },
2994
- required: ["items"],
2995
- },
2996
- operationId: {
2997
- type: "string",
2998
- pattern: "^expense-bulk:[a-zA-Z0-9_-]{8,100}$",
2999
- description:
3000
- "Stable idempotency key generated once for preview and reused unchanged.",
3001
- },
3002
- confirm: {
3003
- type: "boolean",
3004
- description: "Omit/false for preview; true only after explicit approval.",
3005
- },
3006
- status: {
3007
- type: "boolean",
3008
- description: "Read operation status using operationId.",
3009
- },
3010
- undo: {
3011
- type: "boolean",
3012
- description: "Undo a completed correction within its Undo window.",
3013
- },
3014
- },
3015
- required: ["operationId"],
3016
- },
3716
+ inputSchema: REVIEWED_EXPENSE_CORRECTION_INPUT_SCHEMA,
3017
3717
  },
3018
3718
  ];
3019
3719
 
@@ -3118,7 +3818,16 @@ async function handleTool(name, args) {
3118
3818
  );
3119
3819
 
3120
3820
  case "fix_compliance":
3121
- return formatResultWithSchema(name, await client.execute("batch_fix", args));
3821
+ return formatResultWithSchema(name,
3822
+ await client.execute("correct_expenses", {
3823
+ change: args.change,
3824
+ selection: args.selection,
3825
+ operationId: args.operationId,
3826
+ confirm: args.confirm,
3827
+ status: args.status,
3828
+ undo: args.undo,
3829
+ })
3830
+ );
3122
3831
 
3123
3832
  case "check_tax_deductibility":
3124
3833
  return formatResultWithSchema(name,
@@ -3402,7 +4111,7 @@ async function handleTool(name, args) {
3402
4111
  url.searchParams.set("query", args?.feature || "");
3403
4112
  url.searchParams.set("utm_source", "mcp-onboarding");
3404
4113
  const res = await fetch(url.toString(), {
3405
- headers: { "User-Agent": "expensebot-mcp-auth/0.6.0" },
4114
+ headers: { "User-Agent": "expensebot-mcp-auth/0.6.26" },
3406
4115
  });
3407
4116
  const data = await res.json();
3408
4117
  return formatResultWithSchema(name, data);
@@ -3712,7 +4421,7 @@ function formatResultWithSchema(toolName, result) {
3712
4421
 
3713
4422
  async function main() {
3714
4423
  const server = new Server(
3715
- { name: "expensebot-auth", version: "0.6.24" },
4424
+ { name: "expensebot-auth", version: "0.6.26" },
3716
4425
  { capabilities: { tools: {} }, instructions: SERVER_INSTRUCTIONS }
3717
4426
  );
3718
4427