@lerianstudio/matcher-mcp 1.0.0-beta.5
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/LICENSE +202 -0
- package/README.md +281 -0
- package/dist/auth/request-token.js +117 -0
- package/dist/auth/request-token.js.map +1 -0
- package/dist/config.js +95 -0
- package/dist/config.js.map +1 -0
- package/dist/matcher/client.js +168 -0
- package/dist/matcher/client.js.map +1 -0
- package/dist/observability/otel.js +223 -0
- package/dist/observability/otel.js.map +1 -0
- package/dist/server.js +245 -0
- package/dist/server.js.map +1 -0
- package/dist/spec/curated-operations.js +145 -0
- package/dist/spec/curated-operations.js.map +1 -0
- package/dist/spec/index.js +155 -0
- package/dist/spec/index.js.map +1 -0
- package/dist/spec/load.js +76 -0
- package/dist/spec/load.js.map +1 -0
- package/dist/spec/openapi.yaml +15217 -0
- package/dist/tools/context/create.js +100 -0
- package/dist/tools/context/create.js.map +1 -0
- package/dist/tools/context/get.js +31 -0
- package/dist/tools/context/get.js.map +1 -0
- package/dist/tools/context/index.js +21 -0
- package/dist/tools/context/index.js.map +1 -0
- package/dist/tools/context/list.js +78 -0
- package/dist/tools/context/list.js.map +1 -0
- package/dist/tools/context/shared.js +61 -0
- package/dist/tools/context/shared.js.map +1 -0
- package/dist/tools/context/update.js +105 -0
- package/dist/tools/context/update.js.map +1 -0
- package/dist/tools/dashboard/aggregates.js +34 -0
- package/dist/tools/dashboard/aggregates.js.map +1 -0
- package/dist/tools/dashboard/cash-impact.js +36 -0
- package/dist/tools/dashboard/cash-impact.js.map +1 -0
- package/dist/tools/dashboard/index.js +27 -0
- package/dist/tools/dashboard/index.js.map +1 -0
- package/dist/tools/dashboard/match-rate.js +35 -0
- package/dist/tools/dashboard/match-rate.js.map +1 -0
- package/dist/tools/dashboard/metrics.js +36 -0
- package/dist/tools/dashboard/metrics.js.map +1 -0
- package/dist/tools/dashboard/shared.js +122 -0
- package/dist/tools/dashboard/shared.js.map +1 -0
- package/dist/tools/dashboard/sla.js +33 -0
- package/dist/tools/dashboard/sla.js.map +1 -0
- package/dist/tools/dashboard/source-breakdown.js +36 -0
- package/dist/tools/dashboard/source-breakdown.js.map +1 -0
- package/dist/tools/dashboard/volume.js +35 -0
- package/dist/tools/dashboard/volume.js.map +1 -0
- package/dist/tools/dispute/close.js +49 -0
- package/dist/tools/dispute/close.js.map +1 -0
- package/dist/tools/dispute/get.js +27 -0
- package/dist/tools/dispute/get.js.map +1 -0
- package/dist/tools/dispute/index.js +17 -0
- package/dist/tools/dispute/index.js.map +1 -0
- package/dist/tools/dispute/list.js +137 -0
- package/dist/tools/dispute/list.js.map +1 -0
- package/dist/tools/dispute/shared.js +66 -0
- package/dist/tools/dispute/shared.js.map +1 -0
- package/dist/tools/dispute/submit-evidence.js +58 -0
- package/dist/tools/dispute/submit-evidence.js.map +1 -0
- package/dist/tools/exception/add-comment.js +50 -0
- package/dist/tools/exception/add-comment.js.map +1 -0
- package/dist/tools/exception/adjust-entry.js +71 -0
- package/dist/tools/exception/adjust-entry.js.map +1 -0
- package/dist/tools/exception/bulk-assign.js +47 -0
- package/dist/tools/exception/bulk-assign.js.map +1 -0
- package/dist/tools/exception/bulk-dispatch.js +69 -0
- package/dist/tools/exception/bulk-dispatch.js.map +1 -0
- package/dist/tools/exception/bulk-resolve.js +64 -0
- package/dist/tools/exception/bulk-resolve.js.map +1 -0
- package/dist/tools/exception/delete-comment.js +40 -0
- package/dist/tools/exception/delete-comment.js.map +1 -0
- package/dist/tools/exception/dispatch.js +64 -0
- package/dist/tools/exception/dispatch.js.map +1 -0
- package/dist/tools/exception/force-match.js +55 -0
- package/dist/tools/exception/force-match.js.map +1 -0
- package/dist/tools/exception/get.js +34 -0
- package/dist/tools/exception/get.js.map +1 -0
- package/dist/tools/exception/history.js +61 -0
- package/dist/tools/exception/history.js.map +1 -0
- package/dist/tools/exception/index.js +39 -0
- package/dist/tools/exception/index.js.map +1 -0
- package/dist/tools/exception/list-comments.js +35 -0
- package/dist/tools/exception/list-comments.js.map +1 -0
- package/dist/tools/exception/list.js +169 -0
- package/dist/tools/exception/list.js.map +1 -0
- package/dist/tools/exception/open-dispute.js +53 -0
- package/dist/tools/exception/open-dispute.js.map +1 -0
- package/dist/tools/exception/shared.js +98 -0
- package/dist/tools/exception/shared.js.map +1 -0
- package/dist/tools/fee-rule/create.js +106 -0
- package/dist/tools/fee-rule/create.js.map +1 -0
- package/dist/tools/fee-rule/delete.js +27 -0
- package/dist/tools/fee-rule/delete.js.map +1 -0
- package/dist/tools/fee-rule/get.js +27 -0
- package/dist/tools/fee-rule/get.js.map +1 -0
- package/dist/tools/fee-rule/index.js +21 -0
- package/dist/tools/fee-rule/index.js.map +1 -0
- package/dist/tools/fee-rule/list.js +64 -0
- package/dist/tools/fee-rule/list.js.map +1 -0
- package/dist/tools/fee-rule/shared.js +67 -0
- package/dist/tools/fee-rule/shared.js.map +1 -0
- package/dist/tools/fee-rule/update.js +70 -0
- package/dist/tools/fee-rule/update.js.map +1 -0
- package/dist/tools/fee-schedule/create.js +105 -0
- package/dist/tools/fee-schedule/create.js.map +1 -0
- package/dist/tools/fee-schedule/delete.js +32 -0
- package/dist/tools/fee-schedule/delete.js.map +1 -0
- package/dist/tools/fee-schedule/get.js +30 -0
- package/dist/tools/fee-schedule/get.js.map +1 -0
- package/dist/tools/fee-schedule/index.js +22 -0
- package/dist/tools/fee-schedule/index.js.map +1 -0
- package/dist/tools/fee-schedule/list.js +56 -0
- package/dist/tools/fee-schedule/list.js.map +1 -0
- package/dist/tools/fee-schedule/shared.js +58 -0
- package/dist/tools/fee-schedule/shared.js.map +1 -0
- package/dist/tools/fee-schedule/simulate.js +54 -0
- package/dist/tools/fee-schedule/simulate.js.map +1 -0
- package/dist/tools/fee-schedule/update.js +69 -0
- package/dist/tools/fee-schedule/update.js.map +1 -0
- package/dist/tools/generic/describe-operation.js +157 -0
- package/dist/tools/generic/describe-operation.js.map +1 -0
- package/dist/tools/generic/invoke.js +343 -0
- package/dist/tools/generic/invoke.js.map +1 -0
- package/dist/tools/generic/list-operations.js +73 -0
- package/dist/tools/generic/list-operations.js.map +1 -0
- package/dist/tools/ingestion/index.js +29 -0
- package/dist/tools/ingestion/index.js.map +1 -0
- package/dist/tools/ingestion/job-errors-list.js +45 -0
- package/dist/tools/ingestion/job-errors-list.js.map +1 -0
- package/dist/tools/ingestion/job-get.js +42 -0
- package/dist/tools/ingestion/job-get.js.map +1 -0
- package/dist/tools/ingestion/job-transactions-list.js +93 -0
- package/dist/tools/ingestion/job-transactions-list.js.map +1 -0
- package/dist/tools/ingestion/jobs-list.js +89 -0
- package/dist/tools/ingestion/jobs-list.js.map +1 -0
- package/dist/tools/ingestion/shared.js +84 -0
- package/dist/tools/ingestion/shared.js.map +1 -0
- package/dist/tools/ingestion/transaction-ignore.js +51 -0
- package/dist/tools/ingestion/transaction-ignore.js.map +1 -0
- package/dist/tools/ingestion/transactions-search.js +143 -0
- package/dist/tools/ingestion/transactions-search.js.map +1 -0
- package/dist/tools/match-rule/create.js +64 -0
- package/dist/tools/match-rule/create.js.map +1 -0
- package/dist/tools/match-rule/delete.js +35 -0
- package/dist/tools/match-rule/delete.js.map +1 -0
- package/dist/tools/match-rule/get.js +32 -0
- package/dist/tools/match-rule/get.js.map +1 -0
- package/dist/tools/match-rule/index.js +22 -0
- package/dist/tools/match-rule/index.js.map +1 -0
- package/dist/tools/match-rule/list.js +72 -0
- package/dist/tools/match-rule/list.js.map +1 -0
- package/dist/tools/match-rule/reorder.js +45 -0
- package/dist/tools/match-rule/reorder.js.map +1 -0
- package/dist/tools/match-rule/shared.js +71 -0
- package/dist/tools/match-rule/shared.js.map +1 -0
- package/dist/tools/match-rule/update.js +68 -0
- package/dist/tools/match-rule/update.js.map +1 -0
- package/dist/tools/matching/get.js +48 -0
- package/dist/tools/matching/get.js.map +1 -0
- package/dist/tools/matching/groups.js +98 -0
- package/dist/tools/matching/groups.js.map +1 -0
- package/dist/tools/matching/index.js +19 -0
- package/dist/tools/matching/index.js.map +1 -0
- package/dist/tools/matching/list.js +76 -0
- package/dist/tools/matching/list.js.map +1 -0
- package/dist/tools/matching/shared.js +77 -0
- package/dist/tools/matching/shared.js.map +1 -0
- package/dist/tools/matching/start.js +55 -0
- package/dist/tools/matching/start.js.map +1 -0
- package/dist/tools/report/count-exceptions.js +45 -0
- package/dist/tools/report/count-exceptions.js.map +1 -0
- package/dist/tools/report/count-matched.js +46 -0
- package/dist/tools/report/count-matched.js.map +1 -0
- package/dist/tools/report/count-transactions.js +44 -0
- package/dist/tools/report/count-transactions.js.map +1 -0
- package/dist/tools/report/count-unmatched.js +44 -0
- package/dist/tools/report/count-unmatched.js.map +1 -0
- package/dist/tools/report/export-exceptions.js +46 -0
- package/dist/tools/report/export-exceptions.js.map +1 -0
- package/dist/tools/report/export-matched.js +47 -0
- package/dist/tools/report/export-matched.js.map +1 -0
- package/dist/tools/report/export-summary.js +47 -0
- package/dist/tools/report/export-summary.js.map +1 -0
- package/dist/tools/report/export-unmatched.js +47 -0
- package/dist/tools/report/export-unmatched.js.map +1 -0
- package/dist/tools/report/export-variance.js +46 -0
- package/dist/tools/report/export-variance.js.map +1 -0
- package/dist/tools/report/index.js +40 -0
- package/dist/tools/report/index.js.map +1 -0
- package/dist/tools/report/matched.js +44 -0
- package/dist/tools/report/matched.js.map +1 -0
- package/dist/tools/report/shared.js +176 -0
- package/dist/tools/report/shared.js.map +1 -0
- package/dist/tools/report/summary.js +41 -0
- package/dist/tools/report/summary.js.map +1 -0
- package/dist/tools/report/unmatched.js +44 -0
- package/dist/tools/report/unmatched.js.map +1 -0
- package/dist/tools/report/variance.js +44 -0
- package/dist/tools/report/variance.js.map +1 -0
- package/dist/tools/source/create.js +84 -0
- package/dist/tools/source/create.js.map +1 -0
- package/dist/tools/source/get.js +41 -0
- package/dist/tools/source/get.js.map +1 -0
- package/dist/tools/source/index.js +22 -0
- package/dist/tools/source/index.js.map +1 -0
- package/dist/tools/source/list.js +72 -0
- package/dist/tools/source/list.js.map +1 -0
- package/dist/tools/source/shared.js +63 -0
- package/dist/tools/source/shared.js.map +1 -0
- package/dist/tools/source/update.js +73 -0
- package/dist/tools/source/update.js.map +1 -0
- package/dist/tools/tool-error.js +74 -0
- package/dist/tools/tool-error.js.map +1 -0
- package/dist/transport/body-limit.js +82 -0
- package/dist/transport/body-limit.js.map +1 -0
- package/dist/transport/http.js +154 -0
- package/dist/transport/http.js.map +1 -0
- package/package.json +68 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
# matcher-mcp
|
|
2
|
+
|
|
3
|
+
A [Model Context Protocol](https://modelcontextprotocol.io) server that lets an
|
|
4
|
+
operator drive the [Matcher](../) reconciliation engine through MCP tools.
|
|
5
|
+
|
|
6
|
+
## What this is
|
|
7
|
+
|
|
8
|
+
A **stateless credential relay**. On every inbound MCP connection it reads the
|
|
9
|
+
operator's `Authorization: Bearer <matcher-jwt>` header and forwards it verbatim
|
|
10
|
+
to the Matcher API, exposing the reconciliation surface as MCP tools. It holds
|
|
11
|
+
**no credentials** and performs **no token validation** — Matcher and plugin-auth
|
|
12
|
+
own that (Matcher itself does no local signature/`exp`/`nbf` checks either; it
|
|
13
|
+
delegates to plugin-auth). The server keeps no per-connection session state: a
|
|
14
|
+
fresh in-memory server is built per request, so it can be scaled or restarted
|
|
15
|
+
freely.
|
|
16
|
+
|
|
17
|
+
Tenant identity derives **entirely from the token**. The MCP server never
|
|
18
|
+
accepts, injects, or infers a `tenant_id` / `tenantId` / `tenant` parameter on
|
|
19
|
+
any tool, and Matcher resolves the tenant from the relayed JWT.
|
|
20
|
+
|
|
21
|
+
## Auth model
|
|
22
|
+
|
|
23
|
+
The operator's MCP client supplies the matcher bearer token as an
|
|
24
|
+
`Authorization: Bearer <matcher-jwt>` header on the connection. The server:
|
|
25
|
+
|
|
26
|
+
- forwards that header **verbatim** to the Matcher API on every tool call;
|
|
27
|
+
- **never logs, stores, or persists** the token;
|
|
28
|
+
- **never places it** in errors, tool output, spans, span attributes, span
|
|
29
|
+
events, or metrics.
|
|
30
|
+
|
|
31
|
+
The relay is **fail-closed**: a tool call with no relayed bearer credential is
|
|
32
|
+
rejected with operator-remediation text and makes **no** call to Matcher — it
|
|
33
|
+
never falls back to an unauthenticated or default-tenant request. Use the
|
|
34
|
+
`mcp_whoami` tool to confirm your client is sending the header; it reports
|
|
35
|
+
presence only and never echoes the token value.
|
|
36
|
+
|
|
37
|
+
## Deployment
|
|
38
|
+
|
|
39
|
+
The server ships as the segregated **`matcher-mcp`** Docker image — a distroless
|
|
40
|
+
Node service built by [`.github/workflows/build-mcp.yml`](../.github/workflows/build-mcp.yml)
|
|
41
|
+
and published to GHCR. The image rides the same `v<version>` semantic-release tag
|
|
42
|
+
as the matcher app, which also pins the embedded OpenAPI spec to the matched
|
|
43
|
+
matcher version. The bearer token the relay forwards is never baked into the
|
|
44
|
+
image.
|
|
45
|
+
|
|
46
|
+
It speaks **Streamable HTTP** and binds `MCP_PORT` (default `4019`), exposing two
|
|
47
|
+
endpoints:
|
|
48
|
+
|
|
49
|
+
| Method | Path | Purpose |
|
|
50
|
+
|--------|------------|--------------------------------------------------|
|
|
51
|
+
| `GET` | `/healthz` | Plain liveness probe. |
|
|
52
|
+
| `POST` | `/mcp` | The Streamable HTTP MCP endpoint clients connect to. |
|
|
53
|
+
|
|
54
|
+
Point any Streamable-HTTP MCP client at `POST /mcp` and send the matcher bearer
|
|
55
|
+
token as the `Authorization` header.
|
|
56
|
+
|
|
57
|
+
## Installing in an MCP client
|
|
58
|
+
|
|
59
|
+
The server speaks **Streamable HTTP**, so you connect a client to its `POST /mcp`
|
|
60
|
+
endpoint over the network and send your matcher JWT as
|
|
61
|
+
`Authorization: Bearer <token>`. There is **no stdio transport** — the usual
|
|
62
|
+
`command: npx …` MCP wiring does not apply here; every client below is configured
|
|
63
|
+
as a *remote / HTTP* server.
|
|
64
|
+
|
|
65
|
+
### 1. Get an endpoint
|
|
66
|
+
|
|
67
|
+
Two options for `<mcp-url>`:
|
|
68
|
+
|
|
69
|
+
- **Connect to a deployed server (recommended).** Point your client at a running
|
|
70
|
+
`matcher-mcp` (the GHCR image), e.g. `https://matcher-mcp.example.com/mcp`.
|
|
71
|
+
- **Run it locally with `npx`.** `@lerianstudio/matcher-mcp` is a **public**
|
|
72
|
+
package (Apache-2.0) — no registry auth needed. Start the relay (binds `:4019`)
|
|
73
|
+
pointed at your Matcher API:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
MATCHER_API_URL=https://your-matcher-api npx @lerianstudio/matcher-mcp
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
then use `http://localhost:4019/mcp` as `<mcp-url>`.
|
|
80
|
+
|
|
81
|
+
### 2. The token
|
|
82
|
+
|
|
83
|
+
Every client sends the **matcher JWT** as `Authorization: Bearer <matcher-jwt>`
|
|
84
|
+
on the MCP connection. The relay forwards it verbatim to the Matcher API; tenant
|
|
85
|
+
and identity derive entirely from it. Get it from your Access Manager /
|
|
86
|
+
plugin-auth — the same token you'd use against the Matcher API directly. The
|
|
87
|
+
relay holds no credentials of its own.
|
|
88
|
+
|
|
89
|
+
Replace `<matcher-jwt>` and `<mcp-url>` below accordingly.
|
|
90
|
+
|
|
91
|
+
### 3. Wire it into your client
|
|
92
|
+
|
|
93
|
+
**Claude Code** — CLI:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
claude mcp add --transport http matcher <mcp-url> \
|
|
97
|
+
--header "Authorization: Bearer <matcher-jwt>"
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
or `.mcp.json` (`${MATCHER_JWT}` is read from the environment at connect time):
|
|
101
|
+
|
|
102
|
+
```json
|
|
103
|
+
{
|
|
104
|
+
"mcpServers": {
|
|
105
|
+
"matcher": {
|
|
106
|
+
"type": "http",
|
|
107
|
+
"url": "<mcp-url>",
|
|
108
|
+
"headers": { "Authorization": "Bearer ${MATCHER_JWT}" }
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**opencode** — `opencode.json` (`{env:VAR}` reads from the environment):
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"$schema": "https://opencode.ai/config.json",
|
|
119
|
+
"mcp": {
|
|
120
|
+
"matcher": {
|
|
121
|
+
"type": "remote",
|
|
122
|
+
"url": "<mcp-url>",
|
|
123
|
+
"enabled": true,
|
|
124
|
+
"headers": { "Authorization": "Bearer {env:MATCHER_JWT}" }
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**droid (Factory)** — CLI:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
droid mcp add matcher <mcp-url> --type http \
|
|
134
|
+
--header "Authorization: Bearer <matcher-jwt>"
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
or `~/.factory/mcp.json` (user-level) / `.factory/mcp.json` (project-level):
|
|
138
|
+
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"mcpServers": {
|
|
142
|
+
"matcher": {
|
|
143
|
+
"type": "http",
|
|
144
|
+
"url": "<mcp-url>",
|
|
145
|
+
"headers": { "Authorization": "Bearer <matcher-jwt>" }
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
**pi (Pi coding agent)** — Streamable HTTP support comes from the
|
|
152
|
+
[`pi-mcp`](https://github.com/eliemessiecode/pi-mcp) extension. From inside pi:
|
|
153
|
+
|
|
154
|
+
```
|
|
155
|
+
/mcp add matcher <mcp-url> Authorization=Bearer <matcher-jwt>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Servers are stored in `~/.pi/agent/mcp/servers.json` (global) or
|
|
159
|
+
`.pi/mcp/servers.json` (project-level).
|
|
160
|
+
|
|
161
|
+
### 4. Verify the connection
|
|
162
|
+
|
|
163
|
+
Once connected, call the `mcp_whoami` tool. It reports **only** whether the
|
|
164
|
+
bearer header arrived (never echoing the token), so a `present: true` confirms
|
|
165
|
+
your client is sending `Authorization` correctly. A tool that returns "No matcher
|
|
166
|
+
credential" means the header is not reaching the server — re-check the `headers`
|
|
167
|
+
block above.
|
|
168
|
+
|
|
169
|
+
> Any Streamable-HTTP MCP client works the same way: point it at `<mcp-url>` and
|
|
170
|
+
> send `Authorization: Bearer <matcher-jwt>`. The four above are just the common
|
|
171
|
+
> ones; the pattern is identical everywhere.
|
|
172
|
+
|
|
173
|
+
## Configuration
|
|
174
|
+
|
|
175
|
+
All configuration is read once from the environment at boot and frozen. An
|
|
176
|
+
explicitly-set but invalid value fails loudly at boot rather than silently
|
|
177
|
+
degrading to a default. Env names mirror the matcher Go service.
|
|
178
|
+
|
|
179
|
+
| Variable | Default | Purpose |
|
|
180
|
+
|-------------------------------|-------------------------|---------|
|
|
181
|
+
| `MCP_PORT` | `4019` | Port the Streamable HTTP server binds (4018 is matcher, so this avoids a dev collision). |
|
|
182
|
+
| `MATCHER_API_URL` | `http://localhost:4018` | Base URL of the Matcher API the tools relay to (single source of truth for every tool). Trailing slashes are trimmed. |
|
|
183
|
+
| `MATCHER_TIMEOUT_MS` | `30000` | Per-request timeout the matcher HTTP client enforces via `AbortController`, matching matcher's 30s transaction timeout. |
|
|
184
|
+
| `MAX_BODY_BYTES` | `1048576` (1 MiB) | Maximum accepted inbound request body size; the transport rejects an over-limit body with `413` before parsing, so an unbounded read cannot exhaust memory. |
|
|
185
|
+
| `ENABLE_TELEMETRY` | `false` | Whether OpenTelemetry traces + metrics are exported. **Off** by default. |
|
|
186
|
+
| `OTEL_EXPORTER_OTLP_ENDPOINT` | _(SDK default)_ | OTLP HTTP endpoint traces + metrics export to when telemetry is enabled. When unset, the OTel SDK falls back to its own default (`localhost:4318`). |
|
|
187
|
+
| `OTEL_RESOURCE_SERVICE_NAME` | `matcher-mcp` | `service.name` stamped on exported telemetry, so the relay's signals are distinguishable from matcher's own in a shared collector. |
|
|
188
|
+
|
|
189
|
+
Telemetry is a **complete no-op** when `ENABLE_TELEMETRY` is false: no SDK is
|
|
190
|
+
initialized, no exporters are created, and no network calls are made, so dev,
|
|
191
|
+
test, and single-operator runs pay nothing. Whether telemetry is enabled or not,
|
|
192
|
+
spans and metrics record **only** the tool name and call outcome (plus the
|
|
193
|
+
matcher HTTP status on failure) — never tool arguments, headers, tenant
|
|
194
|
+
identifiers, or the token.
|
|
195
|
+
|
|
196
|
+
## Tool catalog
|
|
197
|
+
|
|
198
|
+
The server exposes a **curated** typed surface (one ergonomic tool per common
|
|
199
|
+
operation, with validated arguments) plus a **generic** escape hatch over the
|
|
200
|
+
full embedded OpenAPI spec.
|
|
201
|
+
|
|
202
|
+
### Curated families
|
|
203
|
+
|
|
204
|
+
| Family | Purpose |
|
|
205
|
+
|----------------|---------|
|
|
206
|
+
| `fee_schedule_*` | Manage fee schedules — create, list, get, update, delete, and simulate. |
|
|
207
|
+
| `fee_rule_*` | Manage fee rules attached to schedules — create, list, get, update, delete. |
|
|
208
|
+
| `match_rule_*` | Manage a context's match rules — create, list, get, update, delete, reorder. |
|
|
209
|
+
| `context_*` | Manage reconciliation contexts — create, list, get, update, delete. |
|
|
210
|
+
| `source_*` | Manage a context's data sources — create, list, get, update, delete. |
|
|
211
|
+
| `match_run_*` | Drive reconciliation runs — start a run, list runs, get a run, inspect match groups. |
|
|
212
|
+
| `exception_*` | Work reconciliation exceptions — list/get, history and comments (list/add/delete), per-exception action verbs (dispatch, open-dispute, force-match, adjust-entry), and cross-exception bulk actions (assign/resolve/dispatch). |
|
|
213
|
+
| `dispute_*` | Manage the dispute lifecycle — list, get, close, submit evidence. |
|
|
214
|
+
| `ingestion_*` | Inspect a context's import lifecycle — list jobs, get a job, list a job's per-row errors and transactions, search transactions, ignore a transaction. |
|
|
215
|
+
| `dashboard_*` | Read a context's reporting dashboard — combined aggregates plus focused slices (cash-impact, match-rate, metrics, SLA, source-breakdown, volume). |
|
|
216
|
+
| `report_*` | Pull a context's reports — paginated matched/unmatched/variance reads, the summary read, four counts (exceptions/matched/unmatched/transactions), and five base64 exports (exceptions/matched/summary/unmatched/variance). |
|
|
217
|
+
|
|
218
|
+
### Generic trio
|
|
219
|
+
|
|
220
|
+
| Tool | Purpose |
|
|
221
|
+
|------------------------------|---------|
|
|
222
|
+
| `matcher_list_operations` | List every operation in the embedded OpenAPI spec. |
|
|
223
|
+
| `matcher_describe_operation` | Describe one operation — its parameters, request body schema, and responses. |
|
|
224
|
+
| `matcher_invoke` | Assemble, validate, and dispatch any operation in the spec with the relayed token. |
|
|
225
|
+
|
|
226
|
+
The curated tools and `matcher_invoke` are two front doors onto a single matcher
|
|
227
|
+
HTTP client and a single token relay, so both surfaces map matcher errors
|
|
228
|
+
([RFC 9457](https://www.rfc-editor.org/rfc/rfc9457) problem+json) identically.
|
|
229
|
+
|
|
230
|
+
### Intentionally not curated
|
|
231
|
+
|
|
232
|
+
Multipart **file upload** (`uploadFile`) and **document extraction**
|
|
233
|
+
(`extractDocument`) carry a `multipart/form-data` binary body that a JSON tool
|
|
234
|
+
cannot express, and the inbound **webhook receiver** (`processCallback`) is an
|
|
235
|
+
inbound endpoint, not an operator action. These are deliberately left off the
|
|
236
|
+
curated surface and remain reachable only via `matcher_invoke`.
|
|
237
|
+
|
|
238
|
+
## Project layout
|
|
239
|
+
|
|
240
|
+
This is a **standalone pnpm project** with its own lockfile — not a workspace
|
|
241
|
+
member, mirroring the `ui/` precedent. It shares no dependency tree with the Go
|
|
242
|
+
module at the repo root.
|
|
243
|
+
|
|
244
|
+
```
|
|
245
|
+
mcp/
|
|
246
|
+
├── package.json # pnpm@11.5.2, Node >=22
|
|
247
|
+
├── tsconfig.json # strict, NodeNext (matches the MCP SDK's ESM packaging)
|
|
248
|
+
├── eslint.config.js # flat config, mirrors ui/
|
|
249
|
+
├── vitest.config.ts
|
|
250
|
+
└── src/
|
|
251
|
+
├── server.ts # entry point: builds the per-request server, wires tools + telemetry
|
|
252
|
+
├── config.ts # frozen, fail-loud bootstrap config
|
|
253
|
+
├── transport/ # Streamable HTTP transport (GET /healthz + POST /mcp)
|
|
254
|
+
├── auth/ # request-scoped fail-closed bearer-token relay
|
|
255
|
+
├── matcher/ # Matcher HTTP client
|
|
256
|
+
├── observability/ # OpenTelemetry init + token-free tool instrumentation
|
|
257
|
+
├── spec/ # embedded OpenAPI spec + operation index
|
|
258
|
+
└── tools/ # curated families + the generic trio
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## Development
|
|
262
|
+
|
|
263
|
+
Run all scripts from this directory (or with `pnpm -C mcp <script>`):
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
pnpm install # install deps (own lockfile)
|
|
267
|
+
pnpm typecheck # tsc --noEmit
|
|
268
|
+
pnpm lint # eslint
|
|
269
|
+
pnpm build # type-check + emit to dist/
|
|
270
|
+
pnpm test # run vitest
|
|
271
|
+
pnpm dev # run with --watch
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## Toolchain
|
|
275
|
+
|
|
276
|
+
Mirrors the `ui/` sub-project: **pnpm** (`pnpm@11.5.2`), Node `>=22`, ESLint flat
|
|
277
|
+
config (`@eslint/js` + `typescript-eslint`), and Vitest. There is no Prettier —
|
|
278
|
+
`ui/` does not use one, so neither does this project.
|
|
279
|
+
|
|
280
|
+
Build uses `tsc` (this is a Node service, not a browser bundle), which is the one
|
|
281
|
+
deliberate divergence from `ui/`'s Vite build.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// Request-scoped bearer-token relay — the security spine.
|
|
2
|
+
//
|
|
3
|
+
// Every tool that touches matcher data must use the *inbound caller's* bearer
|
|
4
|
+
// token, resolved per request, and fail closed when it is absent. This module
|
|
5
|
+
// owns that contract:
|
|
6
|
+
//
|
|
7
|
+
// - `runWithBearerToken(token, fn)` seeds an AsyncLocalStorage store at the
|
|
8
|
+
// HTTP boundary (transport/http.ts) so handlers can recover the token even
|
|
9
|
+
// when the SDK does not thread request headers through `extra`.
|
|
10
|
+
// - `getRequestBearerToken(extra?)` returns the current caller's token,
|
|
11
|
+
// preferring the SDK-native `extra.requestInfo.headers.authorization` when
|
|
12
|
+
// present and falling back to the ALS store seeded at the boundary.
|
|
13
|
+
// - `requireMatcherClient(extra?)` is the single chokepoint tools call: it
|
|
14
|
+
// reads the token, throws `UnauthenticatedError` when it is missing / empty
|
|
15
|
+
// / not a Bearer credential, and otherwise builds a per-request
|
|
16
|
+
// `MatcherClient` from it.
|
|
17
|
+
//
|
|
18
|
+
// Security invariants (asserted by tests):
|
|
19
|
+
// - The token is NEVER logged and NEVER placed in an error message.
|
|
20
|
+
// - No tenant identifier is read or injected anywhere — tenant identity
|
|
21
|
+
// derives solely from the relayed JWT (matcher + plugin-auth own it).
|
|
22
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
23
|
+
import { loadConfig } from '../config.js';
|
|
24
|
+
import { createMatcherClient } from '../matcher/client.js';
|
|
25
|
+
const authStorage = new AsyncLocalStorage();
|
|
26
|
+
/**
|
|
27
|
+
* Operator-facing remediation text shown when the caller did not relay a usable
|
|
28
|
+
* bearer token. It deliberately contains no token material and no internal
|
|
29
|
+
* detail — just what the operator must do to fix their connection.
|
|
30
|
+
*/
|
|
31
|
+
export const UNAUTHENTICATED_REMEDIATION = 'No matcher credential was provided. Configure your MCP client to send an ' +
|
|
32
|
+
'`Authorization: Bearer <your-matcher-jwt>` header on each request, then ' +
|
|
33
|
+
'retry. This server holds no credentials of its own and relays yours verbatim.';
|
|
34
|
+
/**
|
|
35
|
+
* Thrown when a tool requires the caller's matcher credential but none was
|
|
36
|
+
* relayed (missing, empty, or not a Bearer credential). Carries only the
|
|
37
|
+
* operator remediation text — never any token material.
|
|
38
|
+
*/
|
|
39
|
+
export class UnauthenticatedError extends Error {
|
|
40
|
+
constructor(message = UNAUTHENTICATED_REMEDIATION) {
|
|
41
|
+
super(message);
|
|
42
|
+
this.name = 'UnauthenticatedError';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/** Run `fn` with the given raw `Authorization` header bound to this async context. */
|
|
46
|
+
export function runWithBearerToken(authorization, fn) {
|
|
47
|
+
return authStorage.run({ authorization }, fn);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Pull the raw `Authorization` header value out of an SDK `extra`, if it carries
|
|
51
|
+
* request headers. Header names are case-insensitive; a multi-value header is
|
|
52
|
+
* not expected for `Authorization`, so we take the first element when an array.
|
|
53
|
+
*/
|
|
54
|
+
function authorizationFromExtra(extra) {
|
|
55
|
+
const headers = extra?.requestInfo?.headers;
|
|
56
|
+
if (!headers) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
60
|
+
if (name.toLowerCase() === 'authorization') {
|
|
61
|
+
return Array.isArray(value) ? value[0] : value;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Parse a Bearer token out of a raw `Authorization` header value.
|
|
68
|
+
* Returns the token when the header is the `Bearer <token>` scheme with a
|
|
69
|
+
* non-empty token; returns `undefined` for any other shape (missing, empty,
|
|
70
|
+
* wrong scheme). The scheme match is case-insensitive per RFC 7235.
|
|
71
|
+
*/
|
|
72
|
+
function parseBearer(authorization) {
|
|
73
|
+
if (!authorization) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
const match = /^Bearer[ \t]+(.+)$/i.exec(authorization.trim());
|
|
77
|
+
if (!match) {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
const token = match[1]?.trim();
|
|
81
|
+
return token && token.length > 0 ? token : undefined;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Resolve the current caller's bearer token, request-scoped.
|
|
85
|
+
*
|
|
86
|
+
* Resolution order:
|
|
87
|
+
* 1. SDK-native `extra.requestInfo.headers.authorization`, when the handler
|
|
88
|
+
* was given an `extra` carrying request headers.
|
|
89
|
+
* 2. The ALS store seeded by `runWithBearerToken` at the HTTP boundary.
|
|
90
|
+
*
|
|
91
|
+
* Returns `undefined` when no usable Bearer credential is present (missing,
|
|
92
|
+
* empty, or non-Bearer scheme) — callers fail closed on that.
|
|
93
|
+
*/
|
|
94
|
+
export function getRequestBearerToken(extra) {
|
|
95
|
+
const fromExtra = parseBearer(authorizationFromExtra(extra));
|
|
96
|
+
if (fromExtra) {
|
|
97
|
+
return fromExtra;
|
|
98
|
+
}
|
|
99
|
+
return parseBearer(authStorage.getStore()?.authorization);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The single chokepoint every matcher-touching tool calls. Reads the caller's
|
|
103
|
+
* request-scoped token and, when present, returns a `MatcherClient` bound to it.
|
|
104
|
+
* Fails closed with `UnauthenticatedError` when the token is absent / empty /
|
|
105
|
+
* not a Bearer credential.
|
|
106
|
+
*
|
|
107
|
+
* `config` is injectable for tests; production callers pass nothing and get the
|
|
108
|
+
* process config.
|
|
109
|
+
*/
|
|
110
|
+
export function requireMatcherClient(extra, config = loadConfig()) {
|
|
111
|
+
const token = getRequestBearerToken(extra);
|
|
112
|
+
if (!token) {
|
|
113
|
+
throw new UnauthenticatedError();
|
|
114
|
+
}
|
|
115
|
+
return createMatcherClient(config.matcherApiUrl, token);
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=request-token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-token.js","sourceRoot":"","sources":["../../src/auth/request-token.ts"],"names":[],"mappings":"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"}
|