@mcpaid/sdk 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +176 -0
- package/NPM_RESTRUCTURE.md +86 -0
- package/OPERATOR-LICENSE.md +18 -0
- package/README.md +380 -0
- package/SELF-HOSTING.md +108 -0
- package/dist/circuit-breaker/circuit-breaker.d.ts +26 -0
- package/dist/circuit-breaker/circuit-breaker.d.ts.map +1 -0
- package/dist/circuit-breaker/circuit-breaker.js +128 -0
- package/dist/circuit-breaker/circuit-breaker.js.map +1 -0
- package/dist/cli.d.ts +21 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +1560 -0
- package/dist/cli.js.map +1 -0
- package/dist/contracts/ToolPayRouter.d.ts +288 -0
- package/dist/contracts/ToolPayRouter.d.ts.map +1 -0
- package/dist/contracts/ToolPayRouter.js +370 -0
- package/dist/contracts/ToolPayRouter.js.map +1 -0
- package/dist/contracts/router-registry.d.ts +19 -0
- package/dist/contracts/router-registry.d.ts.map +1 -0
- package/dist/contracts/router-registry.js +28 -0
- package/dist/contracts/router-registry.js.map +1 -0
- package/dist/fee/fee-calculator.d.ts +35 -0
- package/dist/fee/fee-calculator.d.ts.map +1 -0
- package/dist/fee/fee-calculator.js +57 -0
- package/dist/fee/fee-calculator.js.map +1 -0
- package/dist/fee/fee-ledger.d.ts +66 -0
- package/dist/fee/fee-ledger.d.ts.map +1 -0
- package/dist/fee/fee-ledger.js +181 -0
- package/dist/fee/fee-ledger.js.map +1 -0
- package/dist/gateway/config-loader.d.ts +38 -0
- package/dist/gateway/config-loader.d.ts.map +1 -0
- package/dist/gateway/config-loader.js +125 -0
- package/dist/gateway/config-loader.js.map +1 -0
- package/dist/gateway/server-registry.d.ts +25 -0
- package/dist/gateway/server-registry.d.ts.map +1 -0
- package/dist/gateway/server-registry.js +59 -0
- package/dist/gateway/server-registry.js.map +1 -0
- package/dist/gateway/toolpay-gateway.d.ts +57 -0
- package/dist/gateway/toolpay-gateway.d.ts.map +1 -0
- package/dist/gateway/toolpay-gateway.js +320 -0
- package/dist/gateway/toolpay-gateway.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/sdk/client-agent.d.ts +47 -0
- package/dist/sdk/client-agent.d.ts.map +1 -0
- package/dist/sdk/client-agent.js +158 -0
- package/dist/sdk/client-agent.js.map +1 -0
- package/dist/sdk/server-sdk.d.ts +51 -0
- package/dist/sdk/server-sdk.d.ts.map +1 -0
- package/dist/sdk/server-sdk.js +170 -0
- package/dist/sdk/server-sdk.js.map +1 -0
- package/dist/settlement/base-contract-client.d.ts +156 -0
- package/dist/settlement/base-contract-client.d.ts.map +1 -0
- package/dist/settlement/base-contract-client.js +156 -0
- package/dist/settlement/base-contract-client.js.map +1 -0
- package/dist/settlement/nonce-store.d.ts +54 -0
- package/dist/settlement/nonce-store.d.ts.map +1 -0
- package/dist/settlement/nonce-store.js +125 -0
- package/dist/settlement/nonce-store.js.map +1 -0
- package/dist/settlement/onchain-verifier.d.ts +41 -0
- package/dist/settlement/onchain-verifier.d.ts.map +1 -0
- package/dist/settlement/onchain-verifier.js +114 -0
- package/dist/settlement/onchain-verifier.js.map +1 -0
- package/dist/settlement/payment-orchestrator.d.ts +59 -0
- package/dist/settlement/payment-orchestrator.d.ts.map +1 -0
- package/dist/settlement/payment-orchestrator.js +282 -0
- package/dist/settlement/payment-orchestrator.js.map +1 -0
- package/dist/settlement/permit-verifier.d.ts +60 -0
- package/dist/settlement/permit-verifier.d.ts.map +1 -0
- package/dist/settlement/permit-verifier.js +80 -0
- package/dist/settlement/permit-verifier.js.map +1 -0
- package/dist/settlement/session-wallet.d.ts +60 -0
- package/dist/settlement/session-wallet.d.ts.map +1 -0
- package/dist/settlement/session-wallet.js +105 -0
- package/dist/settlement/session-wallet.js.map +1 -0
- package/dist/transports/sse-transport.d.ts +27 -0
- package/dist/transports/sse-transport.d.ts.map +1 -0
- package/dist/transports/sse-transport.js +65 -0
- package/dist/transports/sse-transport.js.map +1 -0
- package/dist/transports/stdio-bridge.d.ts +29 -0
- package/dist/transports/stdio-bridge.d.ts.map +1 -0
- package/dist/transports/stdio-bridge.js +133 -0
- package/dist/transports/stdio-bridge.js.map +1 -0
- package/dist/types/circuit-breaker.d.ts +22 -0
- package/dist/types/circuit-breaker.d.ts.map +1 -0
- package/dist/types/circuit-breaker.js +5 -0
- package/dist/types/circuit-breaker.js.map +1 -0
- package/dist/types/ledger.d.ts +57 -0
- package/dist/types/ledger.d.ts.map +1 -0
- package/dist/types/ledger.js +5 -0
- package/dist/types/ledger.js.map +1 -0
- package/dist/types/mcp.d.ts +67 -0
- package/dist/types/mcp.d.ts.map +1 -0
- package/dist/types/mcp.js +5 -0
- package/dist/types/mcp.js.map +1 -0
- package/dist/types/pricing.d.ts +68 -0
- package/dist/types/pricing.d.ts.map +1 -0
- package/dist/types/pricing.js +5 -0
- package/dist/types/pricing.js.map +1 -0
- package/dist/types/x402.d.ts +76 -0
- package/dist/types/x402.d.ts.map +1 -0
- package/dist/types/x402.js +5 -0
- package/dist/types/x402.js.map +1 -0
- package/dist/utils/units.d.ts +45 -0
- package/dist/utils/units.d.ts.map +1 -0
- package/dist/utils/units.js +141 -0
- package/dist/utils/units.js.map +1 -0
- package/package.json +72 -0
- package/src/contracts/ToolPayRouter.json +371 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# NPM Restructure Plan โ v2.0.0 (client-only public package)
|
|
2
|
+
|
|
3
|
+
> Status (implemented, unreleased): index exports trimmed to public-only;
|
|
4
|
+
> `files` excludes worker/d1-store/page renderers/relayer/services/oracle;
|
|
5
|
+
> `exports` map added; `relayer --run` gated behind `MCPAID_OPERATOR=1`.
|
|
6
|
+
> Verified: `tsc` clean, 150/150 tests pass, `npm pack --dry-run` = 111 files /
|
|
7
|
+
> 102kB package / 462kB unpacked (was 146 / 209kB / 1.0MB), zero operator
|
|
8
|
+
> matches in tarball. Remaining: version bump + publish (see ยง6).
|
|
9
|
+
|
|
10
|
+
## Goal
|
|
11
|
+
`@mcpaid/sdk` 2.0.0 must contain everything needed to **USE** MCPaid (as an MCP developer or agent/user) and nothing needed to **OPERATE** a full MCPaid instance (own Cloudflare edge + ledger + relayer + contract deployment). Today's 1.5.x tarball ships the operator half (`dist/worker.js` 70kB, `d1-store`, dashboard/landing/docs HTML, `withdrawal-relayer`, `settle-withdrawals`, migrations) โ 146 files / ~1MB unpacked. 2.0.0 removes it.
|
|
12
|
+
|
|
13
|
+
Enforcement note: this is hygiene + license clarity, not a technical lock. The x402/402 flow is reimplementable; fee enforcement on production self-hosts stays via `OPERATOR-LICENSE.md` + official-router listing (see prior discussion).
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 1. Current tarball inventory (`npm pack --dry-run` @1.5.3)
|
|
18
|
+
|
|
19
|
+
**REMOVE from public package (operate-an-instance):**
|
|
20
|
+
- `dist/worker.js` (+ map/d.ts) โ the entire Cloudflare edge app
|
|
21
|
+
- `dist/gateway/d1-store.js` โ D1 ledger/auth/sessions/withdrawals persistence
|
|
22
|
+
- `dist/gateway/dashboard-html.js`, `landing-html.js`, `docs-html.js`, `docs-markdown.js` โ worker-served site (keep sources in repo, just don't ship)
|
|
23
|
+
- `dist/settlement/withdrawal-relayer.js` โ cron settlement operator
|
|
24
|
+
- `dist/settlement/base-contract-client.js` (operator half โ receipt verification for settlement; client only needs permit verification)
|
|
25
|
+
- `dist/services/email-service.js` โ OTP mail sender (edge-only)
|
|
26
|
+
- `dist/oracle/challenge-signer.js` โ check usage; if edge-only, remove
|
|
27
|
+
- `src/contracts/ToolPayRouter.json` (keep ABI? see ยง2) + `scripts/` (deploy/settle/bridge-to-base) + `migrations/` + `wrangler.jsonc` (already unshipped โ confirm stays unshipped)
|
|
28
|
+
|
|
29
|
+
**KEEP in public package (use MCPaid):**
|
|
30
|
+
- `dist/sdk/client-agent.js` โ agent 402 flow (core)
|
|
31
|
+
- `dist/sdk/server-sdk.js` โ embedded dev gateway (keep: this is "use", not "operate edge")
|
|
32
|
+
- `dist/transports/stdio-bridge.js` (+ `sse-transport`) โ Claude/Cursor wiring
|
|
33
|
+
- `dist/cli.js` โ **trimmed** command surface (see ยง3)
|
|
34
|
+
- `dist/fee/fee-calculator.js`, `dist/utils/units.js` โ pricing math clients need
|
|
35
|
+
- `dist/settlement/permit-verifier.js`, `nonce-store.js`, `onchain-verifier.js` (verify-only), `session-wallet.js` (client session proofs)
|
|
36
|
+
- `dist/circuit-breaker/` โ agent safety
|
|
37
|
+
- `dist/contracts/router-registry.js` (official router/treasury constants โ trust signal) + `ToolPayRouter.json` ABI (read-only, for verification) + `ToolPayRouter.sol` reference via repo link, not shipped bytecode pipeline
|
|
38
|
+
- `dist/types/*`, `dist/gateway/config-loader.js`, `server-registry.js`, `toolpay-gateway.js` (embedded path only โ no D1/KV imports)
|
|
39
|
+
- Docs: `README.md`, `SELF-HOSTING.md` (pointer only), `OPERATOR-LICENSE.md`, `LICENSE`
|
|
40
|
+
|
|
41
|
+
## 2. Proposed split
|
|
42
|
+
|
|
43
|
+
- **Public: `@mcpaid/sdk@2.0.0`** (this repo, restructured `src/`):
|
|
44
|
+
- `src/public/` (or keep paths, gate via build): `sdk/`, `transports/`, `cli/` (trimmed), `fee/fee-calculator`, `utils/units`, `settlement/{permit-verifier,nonce-store,onchain-verifier,session-wallet}`, `circuit-breaker/`, `contracts/{router-registry,ToolPayRouter.json}`, `types/`, `gateway/{config-loader,server-registry,toolpay-gateway}` (embedded only).
|
|
45
|
+
- `package.json`: `files` allowlist (not blocklist) โ exactly the kept `dist/` subtrees + 4 md files. `exports`: `./*` limited to public entry points (`./dist/index.js`, `./dist/cli.js`); no `./dist/worker.js` export.
|
|
46
|
+
- **Private: `@mcpaid/edge` (new private repo or `edge/` + `.npmrc` restricted, never published publicly):**
|
|
47
|
+
- `src/worker.ts`, `gateway/d1-store`, `gateway/{dashboard,landing,docs}-html`, `settlement/{withdrawal-relayer,base-contract-client}`, `services/email-service`, `oracle/challenge-signer` (if edge-only), `scripts/{deploy-contract,settle-withdrawals}`, `migrations/`, `wrangler.jsonc`, `.dev.vars` handling.
|
|
48
|
+
- Consumes `@mcpaid/sdk` as a dependency for shared types/fee math;its own CI runs `wrangler deploy`.
|
|
49
|
+
- **Contracts:** keep `ToolPayRouter.sol` source public in repo for auditability (trust win), but the *deployment pipeline* (`scripts/deploy-contract.ts`, `deployments/`, treasury keys) lives private. Public package ships ABI JSON only.
|
|
50
|
+
|
|
51
|
+
## 3. CLI surface trim (2.0.0 breaking)
|
|
52
|
+
|
|
53
|
+
Keep (use hosted): `init`, `validate`, `dev`, `tunnel`, `bridge` (+ `agent-proxy` alias), `publish`, `server list|remove`, `login|logout|whoami`, `withdraw|withdrawals` (request + view), `wallet new|status`.
|
|
54
|
+
Remove or gate: `relayer --run` (operator settlement โ move to private `@mcpaid/edge` CLI or require explicit `MCPAID_OPERATOR=1` + big warning), `start` (decide: keep as local-dev convenience OR remove to push all traffic to hosted; recommendation: **keep** โ removing it hurts legit local dev more than it hurts forkers, and forkers don't need it).
|
|
55
|
+
|
|
56
|
+
## 4. Versioning & breaking changes (2.0.0)
|
|
57
|
+
|
|
58
|
+
- Major bump: removed exports (`worker`, `d1-store`, page renderers, relayer, email-service), removed CLI `relayer --run`, tightened `files`/`exports`.
|
|
59
|
+
- `TOOLPAY_PERMIT_DOMAIN.verifyingContract` already moved `0x0` โ official router in 1.5.x โ keep in 2.0.0; document as breaking for anyone self-signing against old domain.
|
|
60
|
+
- Migration guide (one page in README): "If you imported `dist/worker.js` / `d1-store` / page HTML from the SDK, vendor 1.5.x or contact `business@mcpaid.dev` for an operator agreement."
|
|
61
|
+
|
|
62
|
+
## 5. Implementation steps
|
|
63
|
+
|
|
64
|
+
1. Create `edge/` (or new repo) + move operator sources; update imports to `@mcpaid/sdk`.
|
|
65
|
+
2. Rewrite `src/index.ts` exports to public-only; add `exports` map in `package.json`; rewrite `files` as allowlist.
|
|
66
|
+
3. Trim `cli.ts` (`relayer` path) + help text; update README CLI table.
|
|
67
|
+
4. Move `migrations/`, `wrangler.jsonc`, deploy scripts out of the public publish path (keep in repo root but excluded via `files` + docs note, or move into `edge/`).
|
|
68
|
+
5. Update `SELF-HOSTING.md` โ "production edge = private/licensed; public SDK cannot stand one up."
|
|
69
|
+
6. `npm pack --dry-run` audit: assert no `worker`, `d1-store`, `dashboard-html`, `withdrawal-relayer`, `email-service`, `migrations`, `wrangler` in tarball; assert tarball < ~400kB unpacked.
|
|
70
|
+
7. Full `npm run build` + `npm test` (update/remove tests importing private modules; keep e2e via public embedded gateway).
|
|
71
|
+
8. Publish `2.0.0` fresh (post-unpublish +24h window if going the delete route).
|
|
72
|
+
|
|
73
|
+
## 6. Publish checklist (delete + fresh)
|
|
74
|
+
|
|
75
|
+
- [ ] `npm pack` backup of 1.5.x; confirm `@mcpaid` scope ownership
|
|
76
|
+
- [ ] `npm unpublish @mcpaid/sdk -f` (or Support ticket); start 24h clock
|
|
77
|
+
- [ ] Land ยงยง1โ5 on main; `npm version 2.0.0`
|
|
78
|
+
- [ ] `npm pack --dry-run` assert list (ยง5.6)
|
|
79
|
+
- [ ] `npm publish --access public` + verify npm page (README, files, no `wrangler deploy` section)
|
|
80
|
+
- [ ] Tag `v2.0.0`; note old versions unrecoverable (burned version numbers)
|
|
81
|
+
|
|
82
|
+
## 7. Open decisions (need your call)
|
|
83
|
+
|
|
84
|
+
1. `start` (local embedded gateway): keep or cut in 2.0.0?
|
|
85
|
+
2. `ToolPayRouter.sol` source: keep public in repo (audit trust) โ agreed? (Deployment stays private.)
|
|
86
|
+
3. Private edge: same repo `edge/` folder vs separate private repo?
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# MCPaid Operator License (Edge Gateway + Router)
|
|
2
|
+
|
|
3
|
+
Client SDK (`src/sdk/`, `src/transports/`, `bridge`, agent) remains **Apache-2.0** (see `LICENSE`).
|
|
4
|
+
|
|
5
|
+
## Operating your own gateway
|
|
6
|
+
|
|
7
|
+
Running `src/worker.ts`, `wrangler.jsonc`, `migrations/`, `contracts/ToolPayRouter.sol`, or `scripts/deploy-contract.ts` in **production** (real users, real USDC, public network) requires either:
|
|
8
|
+
|
|
9
|
+
1. **Use of the official hosted routers** โ settle through the official `ToolPayRouter` contracts (`src/contracts/router-registry.ts`: Base mainnet `0x406240a9af02596a20ef9779aa214143c794ecee`), which atomically route the protocol fee to the official treasury; or
|
|
10
|
+
2. **A commercial operator agreement** with MCPaid (contact `business@mcpaid.dev`) permitting an alternate treasury/fee.
|
|
11
|
+
|
|
12
|
+
Non-production use (local dev, testnet `base-sepolia`, CI, evaluation) is permitted without an agreement.
|
|
13
|
+
|
|
14
|
+
## Why
|
|
15
|
+
|
|
16
|
+
The hosted `mcpaid.dev` network (discovery, dashboard auth, D1 ledger, 60-second relayer, support) is funded by the 3% protocol cut enforced on-chain by the official router. Changing `ROUTER_CONTRACT_ADDRESS`, `PLATFORM_TREASURY_WALLET`, or `PLATFORM_FEE_BPS` to divert that cut on a production self-host is a breach of this license and grounds for delisting from hosted discovery/clients.
|
|
17
|
+
|
|
18
|
+
Technical measures (`verifyingContract` binding, `isOfficialRouter()` warnings in the agent client) are signals only โ they can be removed in a fork. Enforcement is via this license.
|
package/README.md
ADDED
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
# MCPaid: Zero-Friction MCP Monetization & Micropayment Infrastructure
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@mcpaid/sdk)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://basescan.org)
|
|
6
|
+
[](https://basescan.org/token/0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913)
|
|
7
|
+
[](test)
|
|
8
|
+
|
|
9
|
+
**MCPaid** enables developers of [Model Context Protocol (MCP)](https://modelcontextprotocol.io) servers to seamlessly monetize tools with pay-per-use micropayments (e.g. $0.005 / call), gasless AI agent authorizations via **HTTP 402 + EIP-712**, and **automated 60-second on-chain USDC payouts on Base L2**.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## โก Key Capabilities
|
|
14
|
+
|
|
15
|
+
1. **Sub-5ms Global Edge Gateway (Cloudflare Workers + V8 Isolates)**:
|
|
16
|
+
- High-throughput reverse proxy deployed across 310+ cities worldwide.
|
|
17
|
+
- Decorates MCP tool catalogs with pricing schemas and challenges unauthorized calls with RFC-compliant HTTP 402.
|
|
18
|
+
- Serverless SQLite persistence via Cloudflare D1 with global read replication and KV challenge nonces with 120s anti-replay TTL.
|
|
19
|
+
|
|
20
|
+
2. **Gasless Micropayment Vouchers (EIP-712 on Base L2)**:
|
|
21
|
+
- Autonomous AI agents sign typed micro-vouchers off-chain without spending ETH on gas or waiting for block confirmations.
|
|
22
|
+
- Native support for Circle USDC on **Base Mainnet** (`0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913`) and **Base Sepolia** (`0x036CbD53842c5426634e7929541eC2318f3dCF7e`).
|
|
23
|
+
|
|
24
|
+
3. **Automated 1-Minute Base L2 Payout Relayer (`* * * * *`)**:
|
|
25
|
+
- Developers receive **97.00% net revenue** on every tool call (3.00% protocol fee).
|
|
26
|
+
- Earnings accumulate in real-time in the D1 edge financial ledger.
|
|
27
|
+
- When a developer requests a withdrawal, Cloudflare Workers' isolated cron relayer automatically executes the on-chain ERC-20 transfer on Base L2 every **60 seconds**, stamping confirmed BaseScan receipts directly into the dashboard.
|
|
28
|
+
- **Zero HTTP Attack Surface**: All payout execution paths run strictly via internal edge cron triggers or authenticated local operator scripts (`mcpaid relayer --run`).
|
|
29
|
+
|
|
30
|
+
4. **Zero-Config Live Development Tunnel (`mcpaid dev`)**:
|
|
31
|
+
- Monetize MCP servers running locally on hardware (`http://127.0.0.1:3000/mcp`) without buying domains or renting cloud VPS servers.
|
|
32
|
+
- Launches an encrypted TLS 1.3 tunnel with an integrated **Security Shield** that drops direct bypass traffic with `403 Forbidden`.
|
|
33
|
+
|
|
34
|
+
5. **Server Management & Anti-Hijacking Security**:
|
|
35
|
+
- Clean-slate server de-registration via Web Dashboard or CLI (`mcpaid server remove <id>`).
|
|
36
|
+
- Ownership verification ensures server IDs cannot be overwritten by unauthorized third parties.
|
|
37
|
+
- Passwordless 2FA email authentication with 30-day sliding-window sessions.
|
|
38
|
+
|
|
39
|
+
6. **Agent Safety Circuit Breakers**:
|
|
40
|
+
- Built-in velocity limiters (sliding 1-minute window).
|
|
41
|
+
- Spend ceiling hard caps (`maxPricePerCallUsd`, `maxTotalBudgetUsd`).
|
|
42
|
+
- Infinite duplicate parameter loop detection.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## ๐ Installation
|
|
47
|
+
|
|
48
|
+
### Global CLI
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm install -g @mcpaid/sdk
|
|
52
|
+
# or run directly with npx:
|
|
53
|
+
npx @mcpaid/sdk --help
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### TypeScript / Node.js SDK
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npm install @mcpaid/sdk
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## ๐ Developer Quickstarts
|
|
65
|
+
|
|
66
|
+
### Option A: The 3-Minute Local Developer Quickstart (`mcpaid dev`)
|
|
67
|
+
|
|
68
|
+
Monetize an MCP server running on your laptop or workstation without cloud hosting:
|
|
69
|
+
|
|
70
|
+
1. **Ensure your local MCP server is running** (e.g. on port 3000 at `http://127.0.0.1:3000/mcp`).
|
|
71
|
+
2. **Generate your configuration & authenticate**:
|
|
72
|
+
```bash
|
|
73
|
+
npx @mcpaid/sdk init
|
|
74
|
+
npx @mcpaid/sdk login
|
|
75
|
+
```
|
|
76
|
+
3. **Launch the Live Dev Tunnel & Security Shield**:
|
|
77
|
+
```bash
|
|
78
|
+
npx @mcpaid/sdk dev
|
|
79
|
+
```
|
|
80
|
+
*The CLI creates an encrypted tunnel, registers your server at `https://mcpaid.dev/mcp/:serverId`, activates the security shield, and streams live tool executions and earnings to your terminal.*
|
|
81
|
+
4. **Give your public URL to agents or users**:
|
|
82
|
+
```bash
|
|
83
|
+
npx @mcpaid/sdk bridge --gateway https://mcpaid.dev/mcp/:serverId
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
### Option B: Cloud-Deployed Production Server (`mcpaid publish`)
|
|
89
|
+
|
|
90
|
+
For MCP servers hosted on public cloud providers (Render, Fly.io, Railway, AWS, Cloudflare Workers):
|
|
91
|
+
|
|
92
|
+
1. **Configure `mcpaid.config.json`**:
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"serverId": "stock-oracle",
|
|
96
|
+
"name": "Market Intelligence MCP",
|
|
97
|
+
"upstreamUrl": "https://mcp.yourcompany.com/sse",
|
|
98
|
+
"payoutWallet": "0xYourBaseL2PayoutAddress",
|
|
99
|
+
"network": "base",
|
|
100
|
+
"currency": "USDC",
|
|
101
|
+
"tools": [
|
|
102
|
+
{ "toolName": "health_ping", "type": "free" },
|
|
103
|
+
{ "toolName": "get_stock_quote", "type": "paid", "priceUsd": "0.01" }
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
2. **Validate and Publish to the Global Edge**:
|
|
108
|
+
```bash
|
|
109
|
+
npx @mcpaid/sdk validate
|
|
110
|
+
npx @mcpaid/sdk publish mcpaid.config.json
|
|
111
|
+
```
|
|
112
|
+
3. **Manage & List Live Servers**:
|
|
113
|
+
```bash
|
|
114
|
+
npx @mcpaid/sdk server list
|
|
115
|
+
```
|
|
116
|
+
4. **Decommission & Remove Servers Anytime**:
|
|
117
|
+
```bash
|
|
118
|
+
npx @mcpaid/sdk server remove stock-oracle
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
### Option C: Browser Web Dashboard ([mcpaid.dev/dashboard](https://mcpaid.dev/dashboard))
|
|
124
|
+
|
|
125
|
+
Prefer a graphical interface? Manage everything from your browser:
|
|
126
|
+
|
|
127
|
+
1. **Passwordless 2FA Login**: Enter your developer email and submit the 6-digit verification code. Check *"Remember this terminal"* for a persistent 30-day session.
|
|
128
|
+
2. **Configure Payout Wallet**: Click **[ EDIT ]** in the dashboard header and set your Base EVM wallet address (`0x...`).
|
|
129
|
+
3. **Publish Servers**: Click **>_ Publish MCP Server** to open the visual tool pricing builder.
|
|
130
|
+
4. **Disconnect Servers**: Click **>_ Disconnect Server** on any server card to remove it from the network.
|
|
131
|
+
5. **Withdraw Earnings**: Click **>_ Withdraw to Base L2** to cash out accrued USDC. Within 60 seconds, the automated relayer confirms the transfer on Base Mainnet and stamps the BaseScan transaction link.
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## ๐ค For AI Agents & Users: Calling Monetized Tools
|
|
136
|
+
|
|
137
|
+
Autonomous agents (Claude Desktop, Cursor, OpenCode, AutoGPT, LangChain, CrewAI) invoke monetized tools using off-chain EIP-712 micro-permits.
|
|
138
|
+
|
|
139
|
+
### 1. Generate an Agent Wallet
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
npx @mcpaid/sdk wallet new --agent
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Save the generated private key in your agent's environment:
|
|
146
|
+
```env
|
|
147
|
+
AGENT_PRIVATE_KEY=0xYourAgentPrivateKey...
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### 2. Fund with Base USDC
|
|
151
|
+
|
|
152
|
+
* **Base Mainnet (Production - 8453)**:
|
|
153
|
+
- Token Contract: `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913`
|
|
154
|
+
- Withdraw USDC directly from **Coinbase** selecting the **Base** network (near-zero fees, instant), or bridge from Ethereum at [bridge.base.org](https://bridge.base.org).
|
|
155
|
+
- *Note: Agents only need USDC! Because micro-permits are signed off-chain, agents do not need ETH for gas.*
|
|
156
|
+
* **Base Sepolia (Testnet - 84532)**:
|
|
157
|
+
- Token Contract: `0x036CbD53842c5426634e7929541eC2318f3dCF7e`
|
|
158
|
+
- Claim free testnet USDC at [faucet.circle.com](https://faucet.circle.com) (select Base Sepolia).
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
### 3. Connect Claude Desktop
|
|
163
|
+
|
|
164
|
+
Edit your `claude_desktop_config.json` (Mac: `~/Library/Application Support/Claude/claude_desktop_config.json`):
|
|
165
|
+
|
|
166
|
+
```json
|
|
167
|
+
{
|
|
168
|
+
"mcpServers": {
|
|
169
|
+
"market-oracle": {
|
|
170
|
+
"command": "npx",
|
|
171
|
+
"args": [
|
|
172
|
+
"-y",
|
|
173
|
+
"@mcpaid/sdk",
|
|
174
|
+
"bridge",
|
|
175
|
+
"--gateway",
|
|
176
|
+
"https://mcpaid.dev/mcp/stock-oracle"
|
|
177
|
+
],
|
|
178
|
+
"env": {
|
|
179
|
+
"AGENT_PRIVATE_KEY": "0xYourAgentPrivateKey..."
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### 4. Connect Cursor / Antigravity
|
|
187
|
+
|
|
188
|
+
In your project root, create `.cursor/mcp.json`:
|
|
189
|
+
|
|
190
|
+
```json
|
|
191
|
+
{
|
|
192
|
+
"mcpServers": {
|
|
193
|
+
"market-oracle": {
|
|
194
|
+
"command": "npx -y @mcpaid/sdk bridge --gateway https://mcpaid.dev/mcp/stock-oracle",
|
|
195
|
+
"env": {
|
|
196
|
+
"AGENT_PRIVATE_KEY": "0xYourAgentPrivateKey..."
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
### 5. Programmatic Integration (TypeScript & Python)
|
|
206
|
+
|
|
207
|
+
#### TypeScript Agent SDK
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
import { ToolPayClientAgent } from '@mcpaid/sdk';
|
|
211
|
+
|
|
212
|
+
const agent = new ToolPayClientAgent({
|
|
213
|
+
privateKey: process.env.AGENT_PRIVATE_KEY as `0x${string}`,
|
|
214
|
+
spendPolicy: {
|
|
215
|
+
autoApprove: true,
|
|
216
|
+
maxPricePerCallUsd: '0.05', // Maximum $0.05 per tool call
|
|
217
|
+
maxTotalBudgetUsd: '5.00', // Maximum cumulative spend ceiling
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
// Automatically intercepts HTTP 402, signs EIP-712 voucher, and replays tool execution
|
|
222
|
+
const result = await agent.executeToolCall(
|
|
223
|
+
{
|
|
224
|
+
jsonrpc: '2.0',
|
|
225
|
+
id: 1,
|
|
226
|
+
method: 'tools/call',
|
|
227
|
+
params: { name: 'get_stock_quote', arguments: { symbol: 'AAPL' } },
|
|
228
|
+
},
|
|
229
|
+
async (req, proof) => {
|
|
230
|
+
return fetch('https://mcpaid.dev/mcp/stock-oracle', {
|
|
231
|
+
method: 'POST',
|
|
232
|
+
headers: {
|
|
233
|
+
'Content-Type': 'application/json',
|
|
234
|
+
Authorization: `Bearer ${JSON.stringify(proof)}`,
|
|
235
|
+
},
|
|
236
|
+
body: JSON.stringify(req),
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
);
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
#### Python Autonomous Agent
|
|
243
|
+
|
|
244
|
+
```python
|
|
245
|
+
import json, os, requests
|
|
246
|
+
from eth_account import Account
|
|
247
|
+
from eth_account.messages import encode_typed_data
|
|
248
|
+
|
|
249
|
+
GATEWAY_URL = "https://mcpaid.dev/mcp/stock-oracle"
|
|
250
|
+
agent = Account.from_key(os.getenv("AGENT_PRIVATE_KEY"))
|
|
251
|
+
|
|
252
|
+
req = {
|
|
253
|
+
"jsonrpc": "2.0",
|
|
254
|
+
"id": 1,
|
|
255
|
+
"method": "tools/call",
|
|
256
|
+
"params": {"name": "get_stock_quote", "arguments": {"symbol": "AAPL"}}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
# 1. Initial invocation (returns 402 Challenge)
|
|
260
|
+
resp = requests.post(GATEWAY_URL, json=req)
|
|
261
|
+
|
|
262
|
+
if resp.status_code == 402:
|
|
263
|
+
challenge = resp.json()["error"]["data"]
|
|
264
|
+
|
|
265
|
+
# 2. Sign EIP-712 Typed Data off-chain (zero gas)
|
|
266
|
+
typed_data = {
|
|
267
|
+
"types": {
|
|
268
|
+
"EIP712Domain": [
|
|
269
|
+
{"name": "name", "type": "string"},
|
|
270
|
+
{"name": "version", "type": "string"},
|
|
271
|
+
{"name": "chainId", "type": "uint256"},
|
|
272
|
+
{"name": "verifyingContract", "type": "address"}
|
|
273
|
+
],
|
|
274
|
+
"ToolPayment": [
|
|
275
|
+
{"name": "serverId", "type": "string"},
|
|
276
|
+
{"name": "toolName", "type": "string"},
|
|
277
|
+
{"name": "challengeNonce", "type": "string"},
|
|
278
|
+
{"name": "amountMicro", "type": "uint256"},
|
|
279
|
+
{"name": "recipient", "type": "address"},
|
|
280
|
+
{"name": "deadline", "type": "uint256"}
|
|
281
|
+
]
|
|
282
|
+
},
|
|
283
|
+
"primaryType": "ToolPayment",
|
|
284
|
+
"domain": {
|
|
285
|
+
"name": "ToolPay MicroPermit",
|
|
286
|
+
"version": "1",
|
|
287
|
+
"chainId": challenge["chainId"],
|
|
288
|
+
"verifyingContract": challenge.get("verifyingContract", "0x406240a9af02596a20ef9779aa214143c794ecee")
|
|
289
|
+
},
|
|
290
|
+
"message": {
|
|
291
|
+
"serverId": challenge["serverId"],
|
|
292
|
+
"toolName": challenge["toolName"],
|
|
293
|
+
"challengeNonce": challenge["challengeNonce"],
|
|
294
|
+
"amountMicro": int(challenge["amountMicro"]),
|
|
295
|
+
"recipient": challenge["recipientWallet"],
|
|
296
|
+
"deadline": int(challenge["expiresAt"])
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
signed = agent.sign_message(encode_typed_data(full_message=typed_data))
|
|
301
|
+
|
|
302
|
+
voucher = {
|
|
303
|
+
"scheme": "eip712-permit",
|
|
304
|
+
"challengeNonce": challenge["challengeNonce"],
|
|
305
|
+
"signerWallet": agent.address,
|
|
306
|
+
"signature": signed.signature.hex(),
|
|
307
|
+
"deadline": challenge["expiresAt"]
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
# 3. Replay with voucher in Authorization header
|
|
311
|
+
headers = {"Authorization": f"Bearer {json.dumps(voucher)}"}
|
|
312
|
+
resp = requests.post(GATEWAY_URL, json=req, headers=headers)
|
|
313
|
+
|
|
314
|
+
print("Tool Result:", resp.json()["result"])
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
## ๐ ๏ธ CLI Command Reference
|
|
320
|
+
|
|
321
|
+
| Command | Arguments / Flags | Description |
|
|
322
|
+
| :--- | :--- | :--- |
|
|
323
|
+
| `mcpaid init` | `โ` | Scaffold sample `mcpaid.config.json` in current directory. |
|
|
324
|
+
| `mcpaid validate` | `[config-path]` | Validate JSON syntax, pricing rules, and upstream targets. |
|
|
325
|
+
| `mcpaid dev` | `[config-path] [--gateway <url>]` | Launch zero-config encrypted dev tunnel with local Security Shield. |
|
|
326
|
+
| `mcpaid tunnel` | `[port]` | Launch standalone Cloudflare tunnel for local port (default: 3000). |
|
|
327
|
+
| `mcpaid publish` | `[config-path] [--gateway <url>]` | Publish and monetize an MCP server on MCPaid Edge Gateway. |
|
|
328
|
+
| `mcpaid server list` | `โ` | List all MCP servers and pricing rules registered under your account. |
|
|
329
|
+
| `mcpaid server remove` | `<server-id>` | Disconnect and permanently remove an MCP server (clean slate). |
|
|
330
|
+
| `mcpaid login` | `[--email <addr>]` | Sign in with passwordless 2FA email confirmation code. |
|
|
331
|
+
| `mcpaid whoami` | `โ` | Display authenticated developer profile and payout wallet. |
|
|
332
|
+
| `mcpaid logout` | `โ` | Revoke active session token and wipe local credentials. |
|
|
333
|
+
| `mcpaid withdraw` | `[amount]` | Withdraw accrued USDC earnings to your verified Base L2 wallet. |
|
|
334
|
+
| `mcpaid withdrawals` | `โ` | View payout history, live batch states, and confirmed BaseScan receipts. |
|
|
335
|
+
| `mcpaid relayer` | `[--run]` | Inspect 1-minute automated relayer status or run a local operator batch. |
|
|
336
|
+
| `mcpaid wallet new` | `--developer \| --agent` | Generate dedicated EVM keypairs for developer payouts or agent spending. |
|
|
337
|
+
| `mcpaid wallet status` | `โ` | Inspect configured environment wallet addresses and network settings. |
|
|
338
|
+
| `mcpaid bridge` | `--gateway <url> [--key <k>]` | Pipe local stdio from Claude Desktop or Cursor to remote gateway. |
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
## ๐ Smart Contracts & Base Mainnet Deployment
|
|
343
|
+
|
|
344
|
+
* **Contract**: [`ToolPayRouter.sol`](contracts/ToolPayRouter.sol)
|
|
345
|
+
* **Network**: Base Mainnet (Chain ID `8453`)
|
|
346
|
+
* **Contract Address**: [`0x406240a9af02596a20ef9779aa214143c794ecee`](https://basescan.org/address/0x406240a9af02596a20ef9779aa214143c794ecee)
|
|
347
|
+
* **Deployment Tx**: [`0xdcd1d86775cba316b9d26a5878e3fab4b7bd1f0ebedf382d5bd1d4cef0dce7f7`](https://basescan.org/tx/0xdcd1d86775cba316b9d26a5878e3fab4b7bd1f0ebedf382d5bd1d4cef0dce7f7)
|
|
348
|
+
* **Platform Treasury**: `0x49E9fEc4e08310Fb106de24711aBCe51028ECbad`
|
|
349
|
+
* **Default Take Rate**: 3.00% (300 bps)
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
## ๐งช Comprehensive Test Suite
|
|
354
|
+
|
|
355
|
+
MCPaid includes **150 automated unit and integration tests** across 23 suites covering edge handlers, cryptographic verifiers, smart contract splits, financial ledgers, and the automated relayer:
|
|
356
|
+
|
|
357
|
+
```bash
|
|
358
|
+
npm test
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
```
|
|
362
|
+
# tests 150
|
|
363
|
+
# suites 23
|
|
364
|
+
# pass 150
|
|
365
|
+
# fail 0
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
---
|
|
369
|
+
|
|
370
|
+
## ๐ ๏ธ Self-Hosting Your Own Gateway?
|
|
371
|
+
|
|
372
|
+
Using `mcpaid publish`, `mcpaid dev`, and `mcpaid.dev/dashboard` above means you are on the **hosted MCPaid network** (global edge, discovery at `mcpaid.dev/mcp/:id`, managed 60-second relayer, 3.00% protocol fee).
|
|
373
|
+
|
|
374
|
+
If instead you want to operate your own isolated gateway (your own Cloudflare Worker + D1 + KV + `ToolPayRouter` contract + treasury), see [SELF-HOSTING.md](SELF-HOSTING.md). Note: a self-hosted gateway is a separate network โ you lose hosted discovery, dashboard logins, and the managed relayer, and you take on all ops/settlement custody yourself.
|
|
375
|
+
|
|
376
|
+
---
|
|
377
|
+
|
|
378
|
+
## ๐ License
|
|
379
|
+
|
|
380
|
+
Apache-2.0 ยฉ MCPaid Network. See [LICENSE](LICENSE) for details.
|