@scriptmasterlabs/mcp-x402 2.0.1 → 2.1.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/.well-known/agentcard.json +34 -34
- package/.well-known/ai.txt +32 -0
- package/CONTRIBUTING.md +76 -76
- package/LICENSE +21 -21
- package/README.md +304 -304
- package/agents.json +81 -67
- package/ai/faq.json +74 -0
- package/ai/summary.json +157 -0
- package/dist/lib/chains/base.d.ts.map +1 -1
- package/dist/lib/chains/base.js +2 -0
- package/dist/lib/chains/base.js.map +1 -1
- package/dist/lib/credit/bureau.d.ts +7 -1
- package/dist/lib/credit/bureau.d.ts.map +1 -1
- package/dist/lib/credit/bureau.js +40 -10
- package/dist/lib/credit/bureau.js.map +1 -1
- package/dist/server/index.js +128 -5
- package/dist/server/index.js.map +1 -1
- package/llms.txt +170 -70
- package/package.json +78 -78
- package/server.json +52 -48
- package/.env.example +0 -35
- package/.github/workflows/ci.yml +0 -59
- package/.github/workflows/keepalive.yml +0 -31
- package/Dockerfile +0 -19
- package/docker-compose.yml +0 -50
- package/mcp-publisher.exe +0 -0
- package/render.yaml +0 -39
- package/sdk/mcp-x402-sdk/package.json +0 -18
- package/sdk/mcp-x402-sdk/src/index.ts +0 -118
- package/sdk/mcp-x402-sdk/tsconfig.json +0 -14
- package/services/backtest_service.py +0 -176
- package/src/lib/chains/base.ts +0 -77
- package/src/lib/chains/solana.ts +0 -59
- package/src/lib/chains/xrpl.ts +0 -63
- package/src/lib/credit/bureau.ts +0 -65
- package/src/lib/sml-api/agentcard.ts +0 -40
- package/src/lib/sml-api/backtest.ts +0 -47
- package/src/lib/sml-api/brokers.ts +0 -160
- package/src/lib/sml-api/copytrader.ts +0 -33
- package/src/lib/sml-api/crawl.ts +0 -44
- package/src/lib/sml-api/echo.ts +0 -28
- package/src/lib/sml-api/forge.ts +0 -33
- package/src/lib/sml-api/ftd.ts +0 -53
- package/src/lib/sml-api/ghost.ts +0 -35
- package/src/lib/sml-api/launchpad.ts +0 -43
- package/src/lib/sml-api/leviathan.ts +0 -49
- package/src/lib/sml-api/nexus.ts +0 -50
- package/src/lib/sml-api/proof402.ts +0 -27
- package/src/lib/sml-api/rails.ts +0 -34
- package/src/lib/sml-api/shadow.ts +0 -35
- package/src/lib/sml-api/squeezeos.ts +0 -95
- package/src/lib/sml-api/xdeo.ts +0 -40
- package/src/lib/sml-api/xmit.ts +0 -40
- package/src/server/health.ts +0 -52
- package/src/server/index.ts +0 -213
- package/src/server/payments/ap2.ts +0 -101
- package/src/server/payments/receipt.ts +0 -85
- package/src/server/payments/router.ts +0 -110
- package/src/server/payments/wallet.ts +0 -123
- package/src/server/payments/x402.ts +0 -177
- package/src/server/registry/catalog.ts +0 -61
- package/src/server/registry/discovery.ts +0 -39
- package/src/server/registry/pricing.ts +0 -133
- package/src/server/security/acl.ts +0 -42
- package/src/server/security/audit.ts +0 -94
- package/src/server/security/rate-limit.ts +0 -84
- package/src/server/security/sandbox.ts +0 -40
- package/src/server/tools/agentcard.ts +0 -134
- package/src/server/tools/backtest.ts +0 -119
- package/src/server/tools/brokers.ts +0 -250
- package/src/server/tools/copytrader.ts +0 -104
- package/src/server/tools/crawl.ts +0 -70
- package/src/server/tools/discovery.ts +0 -202
- package/src/server/tools/echo.ts +0 -58
- package/src/server/tools/forge.ts +0 -87
- package/src/server/tools/ftd.ts +0 -88
- package/src/server/tools/ghost.ts +0 -93
- package/src/server/tools/index.ts +0 -42
- package/src/server/tools/launchpad.ts +0 -173
- package/src/server/tools/leviathan.ts +0 -81
- package/src/server/tools/nexus.ts +0 -76
- package/src/server/tools/proof402.ts +0 -87
- package/src/server/tools/rails.ts +0 -92
- package/src/server/tools/shadow.ts +0 -128
- package/src/server/tools/squeezeos.ts +0 -312
- package/src/server/tools/xdeo.ts +0 -67
- package/src/server/tools/xmit.ts +0 -68
- package/tests/integration/e2e.test.ts +0 -51
- package/tests/unit/payments.test.ts +0 -49
- package/tests/unit/security.test.ts +0 -92
- package/tests/unit/tools.test.ts +0 -42
- package/tsconfig.json +0 -21
- package/vitest.config.ts +0 -20
package/README.md
CHANGED
|
@@ -1,304 +1,304 @@
|
|
|
1
|
-
# mcp-x402 — The First MCP Server That Pays for Itself
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/@scriptmasterlabs/mcp-x402)
|
|
4
|
-
[](LICENSE)
|
|
5
|
-
[](https://github.com/timwal78/sml_portfolio/actions)
|
|
6
|
-
|
|
7
|
-
> **Demo video:** [30-second walkthrough](#) — coming within 48h of launch.
|
|
8
|
-
|
|
9
|
-
AI agents should pay for their own data — instantly, autonomously, compliantly. `mcp-x402` makes that real.
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npx @scriptmasterlabs/mcp-x402
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
## Why MCP Servers Are Broken (The Manifesto)
|
|
18
|
-
|
|
19
|
-
Every MCP server connecting to paid APIs today requires:
|
|
20
|
-
- A human to set up API keys
|
|
21
|
-
- A human to manage billing
|
|
22
|
-
- A human to top up credits when they run out
|
|
23
|
-
- A human to rotate keys when they expire
|
|
24
|
-
|
|
25
|
-
This defeats the entire point of autonomous agents. If your agent has to stop and ask a human for a credit card, it's not autonomous — it's a very expensive chatbot.
|
|
26
|
-
|
|
27
|
-
**We built the machine-native alternative.**
|
|
28
|
-
|
|
29
|
-
`mcp-x402` is the first MCP server where agents provision their own wallets, negotiate prices on-chain, pay autonomously, and receive cryptographic receipts — all without human intervention. The agent's credit score goes up every time it successfully transacts. It builds financial reputation the same way humans do.
|
|
30
|
-
|
|
31
|
-
This is the infrastructure layer that makes truly autonomous AI agents possible.
|
|
32
|
-
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
## One-Line Install
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
npm i -g @scriptmasterlabs/mcp-x402
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
Add to your Claude Code `~/.claude/config.json`:
|
|
42
|
-
|
|
43
|
-
```json
|
|
44
|
-
{
|
|
45
|
-
"mcpServers": {
|
|
46
|
-
"sml": {
|
|
47
|
-
"command": "npx",
|
|
48
|
-
"args": ["@scriptmasterlabs/mcp-x402"]
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
For Cursor (SSE mode), add to your MCP settings:
|
|
55
|
-
|
|
56
|
-
```json
|
|
57
|
-
{
|
|
58
|
-
"mcp-x402": {
|
|
59
|
-
"url": "http://localhost:3402/sse"
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
Then run: `MCP_TRANSPORT=sse npx @scriptmasterlabs/mcp-x402`
|
|
65
|
-
|
|
66
|
-
---
|
|
67
|
-
|
|
68
|
-
## Architecture
|
|
69
|
-
|
|
70
|
-
```
|
|
71
|
-
Claude / Cursor
|
|
72
|
-
│
|
|
73
|
-
▼ MCP Protocol (stdio / SSE)
|
|
74
|
-
mcp-x402 Server
|
|
75
|
-
├─ Input validation (Zod, 100% coverage)
|
|
76
|
-
├─ Rate limiter (100/min per tool)
|
|
77
|
-
├─ AP2 Mandate check (deny-by-default)
|
|
78
|
-
├─ Credit Bureau check (min score 300)
|
|
79
|
-
├─ Price registry (60s max cache)
|
|
80
|
-
├─ x402 payment engine
|
|
81
|
-
│ ├─ Base USDC (preferred, <3s)
|
|
82
|
-
│ ├─ XRPL RLUSD (500ms fallback)
|
|
83
|
-
│ └─ Solana USDC (last resort)
|
|
84
|
-
├─ 402Proof receipt generation
|
|
85
|
-
├─ SML API call (mTLS)
|
|
86
|
-
└─ Append-only SHA-256 audit log
|
|
87
|
-
│
|
|
88
|
-
▼ Result + receipt_id back to agent
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
---
|
|
92
|
-
|
|
93
|
-
## The 6 Tools
|
|
94
|
-
|
|
95
|
-
### `leviathan_signal` — $0.05 USDC | AP2 required
|
|
96
|
-
Institutional-grade squeeze signals. Multi-engine verdict (OracleEngine + RDT + SML Fractal Cascade).
|
|
97
|
-
|
|
98
|
-
```typescript
|
|
99
|
-
await use_mcp_tool('sml', 'leviathan_signal', {
|
|
100
|
-
ticker: 'MSTR',
|
|
101
|
-
signal_type: 'squeeze',
|
|
102
|
-
min_confidence: 75
|
|
103
|
-
});
|
|
104
|
-
// Returns: signal verdict + confidence + receipt_id
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### `xmit_edgar_decode` — $0.02 USDC | AP2 required
|
|
108
|
-
Parse SEC DEF 14A / 13F / 13D filings. Raw text never leaves SML servers.
|
|
109
|
-
|
|
110
|
-
```typescript
|
|
111
|
-
await use_mcp_tool('sml', 'xmit_edgar_decode', {
|
|
112
|
-
filing_url: 'https://www.sec.gov/Archives/edgar/data/...',
|
|
113
|
-
parse_target: 'executive_pay',
|
|
114
|
-
format: 'json'
|
|
115
|
-
});
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### `xdeo_earnings_estimate` — $0.02 USDC | AP2 required
|
|
119
|
-
Decentralized earnings oracle. Earns +2 Credit Bureau points per successful call.
|
|
120
|
-
|
|
121
|
-
```typescript
|
|
122
|
-
await use_mcp_tool('sml', 'xdeo_earnings_estimate', {
|
|
123
|
-
ticker: 'NVDA',
|
|
124
|
-
fiscal_quarter: 'Q12025',
|
|
125
|
-
estimate_type: 'all'
|
|
126
|
-
});
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### `ftd_threshold_scan` — Alerts FREE / Full $0.05 USDC
|
|
130
|
-
SEC Reg SHO FTD spike detection. 15-minute cache.
|
|
131
|
-
|
|
132
|
-
```typescript
|
|
133
|
-
// Free tier:
|
|
134
|
-
await use_mcp_tool('sml', 'ftd_threshold_scan', { scan_type: 'alerts' });
|
|
135
|
-
// Paid tier:
|
|
136
|
-
await use_mcp_tool('sml', 'ftd_threshold_scan', { scan_type: 'full', min_spike_multiplier: 3 });
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
### `nexus_agent_hire` — Query FREE / Hire 5% commission
|
|
140
|
-
Agent marketplace. Find and hire specialized AI agents.
|
|
141
|
-
|
|
142
|
-
```typescript
|
|
143
|
-
// Free query:
|
|
144
|
-
await use_mcp_tool('sml', 'nexus_agent_hire', { capability: 'options flow analysis', max_budget: '1.00', action: 'query' });
|
|
145
|
-
// Hire:
|
|
146
|
-
await use_mcp_tool('sml', 'nexus_agent_hire', { action: 'hire', agent_id: 'agent_abc', max_budget: '0.50' });
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
### `crawl_paid_fetch` — $0.005 USDC
|
|
150
|
-
Pay-per-fetch web scraping. Humans bypass automatically.
|
|
151
|
-
|
|
152
|
-
```typescript
|
|
153
|
-
await use_mcp_tool('sml', 'crawl_paid_fetch', {
|
|
154
|
-
url: 'https://example.com/data',
|
|
155
|
-
extract: 'tables'
|
|
156
|
-
});
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
---
|
|
160
|
-
|
|
161
|
-
## Payment Flow
|
|
162
|
-
|
|
163
|
-
1. **Discover** — Agent reads `agents.json` or `llms.txt`, sees tool prices
|
|
164
|
-
2. **Authorize** — AP2 mandate checked. Credit Bureau score ≥ 300 auto-approves
|
|
165
|
-
3. **Pay** — x402 stablecoin on cheapest/fastest chain (<3s on Base)
|
|
166
|
-
4. **Prove** — 402Proof receipt in every response
|
|
167
|
-
5. **Earn** — Credit Bureau score updates after success
|
|
168
|
-
|
|
169
|
-
Every successful tool call returns a `_meta` block:
|
|
170
|
-
```json
|
|
171
|
-
{
|
|
172
|
-
"_meta": {
|
|
173
|
-
"receipt_id": "uuid-here",
|
|
174
|
-
"tx_hash": "0xabc...",
|
|
175
|
-
"chain": "base",
|
|
176
|
-
"amount_paid": "0.05 USDC",
|
|
177
|
-
"timestamp": 1750000000000
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
---
|
|
183
|
-
|
|
184
|
-
## SDK — For MCP Server Authors
|
|
185
|
-
|
|
186
|
-
Install in one line:
|
|
187
|
-
```bash
|
|
188
|
-
npm i @scriptmasterlabs/mcp-x402-sdk
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
Drop into any MCP server in 5 lines:
|
|
192
|
-
```typescript
|
|
193
|
-
import { x402Payment } from '@scriptmasterlabs/mcp-x402-sdk';
|
|
194
|
-
|
|
195
|
-
server.tool(
|
|
196
|
-
'my_paid_tool',
|
|
197
|
-
myInputSchema,
|
|
198
|
-
x402Payment({
|
|
199
|
-
price: '0.01',
|
|
200
|
-
currency: 'USDC',
|
|
201
|
-
inputSchema: MyZodSchema,
|
|
202
|
-
handler: async (input, receipt) => ({
|
|
203
|
-
content: [{ type: 'text', text: JSON.stringify({ result: await myApi(input), receipt }) }],
|
|
204
|
-
}),
|
|
205
|
-
}),
|
|
206
|
-
);
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
That's it. The SDK handles wallet provisioning, AP2 mandate, chain routing, receipts, and audit logging.
|
|
210
|
-
|
|
211
|
-
---
|
|
212
|
-
|
|
213
|
-
## Security
|
|
214
|
-
|
|
215
|
-
| Requirement | Implementation |
|
|
216
|
-
|-------------|----------------|
|
|
217
|
-
| Keys in OS keychain only | `keytar` — macOS Keychain / Windows DPAPI / Linux Secret Service |
|
|
218
|
-
| mTLS on SML APIs | Pinned cert via `node-forge` |
|
|
219
|
-
| No PII in logs | Wallet addresses hashed (SHA-256 prefix), filing content redacted |
|
|
220
|
-
| Zod on all inputs | 100% coverage, validated before any execution |
|
|
221
|
-
| Append-only audit log | SHA-256 HMAC chained log, 7-day local + cloud backup |
|
|
222
|
-
| AP2 mandate required | Verified before every paid call, fail-closed |
|
|
223
|
-
| 402Proof receipt | Every transaction, registered with proof server |
|
|
224
|
-
| Credit Bureau check | min score 300 for auto-approve |
|
|
225
|
-
| $50 daily spend cap | Per wallet, enforced in-process |
|
|
226
|
-
| Testnet in CI | Base Sepolia only, max $0.10 test value |
|
|
227
|
-
| <3s end-to-end | Base mainnet target, 500ms multi-chain fallback |
|
|
228
|
-
|
|
229
|
-
---
|
|
230
|
-
|
|
231
|
-
## Environment Variables
|
|
232
|
-
|
|
233
|
-
See [`.env.example`](.env.example) for the full list. Key variables:
|
|
234
|
-
|
|
235
|
-
```bash
|
|
236
|
-
MCP_TRANSPORT=stdio # stdio (Claude Code) or sse (Cursor/remote)
|
|
237
|
-
SML_API_BASE=https://api.scriptmasterlabs.com
|
|
238
|
-
BASE_RPC_URL=https://mainnet.base.org
|
|
239
|
-
XRPL_RPC_URL=wss://xrplcluster.com
|
|
240
|
-
DAILY_SPEND_CAP_USD=50
|
|
241
|
-
AUTO_APPROVE_THRESHOLD_USD=1
|
|
242
|
-
TESTNET=false # Set true + CI_WALLET_SEED for CI
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
**Private keys**: Stored in your OS keychain automatically on first run. Never in env vars.
|
|
246
|
-
|
|
247
|
-
---
|
|
248
|
-
|
|
249
|
-
## Running Locally
|
|
250
|
-
|
|
251
|
-
```bash
|
|
252
|
-
git clone https://github.com/timwal78/sml_portfolio
|
|
253
|
-
cd mcp-x402
|
|
254
|
-
npm install
|
|
255
|
-
npm run build
|
|
256
|
-
npm start
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
With Docker:
|
|
260
|
-
```bash
|
|
261
|
-
docker build -t mcp-x402 .
|
|
262
|
-
docker run -p 3402:3402 -e MCP_TRANSPORT=sse mcp-x402
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
---
|
|
266
|
-
|
|
267
|
-
## Testing
|
|
268
|
-
|
|
269
|
-
```bash
|
|
270
|
-
npm test # All unit tests
|
|
271
|
-
npm run test:coverage # Coverage report (target: 90%)
|
|
272
|
-
TESTNET=true CI_WALLET_SEED="your mnemonic" npm run test:integration
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
---
|
|
276
|
-
|
|
277
|
-
## Ecosystem
|
|
278
|
-
|
|
279
|
-
| Service | URL | Role |
|
|
280
|
-
|---------|-----|------|
|
|
281
|
-
| SqueezeOS API | `squeezeos-api.onrender.com` | Market intelligence |
|
|
282
|
-
| 402Proof | `four02proof.onrender.com` | Payment receipts + Credit Bureau |
|
|
283
|
-
| Ghost Layer | `ghost-layer.onrender.com` | XRPL+Base toll gateway |
|
|
284
|
-
| ScriptMasterLabs | `scriptmasterlabs.com` | Operator homepage |
|
|
285
|
-
|
|
286
|
-
---
|
|
287
|
-
|
|
288
|
-
## MOAT
|
|
289
|
-
|
|
290
|
-
- Only MCP server with live x402 + AP2 + multi-chain production stack
|
|
291
|
-
- Only one with Agent Credit Bureau (300–850 scores)
|
|
292
|
-
- Only one backed by live financial intelligence marketplace
|
|
293
|
-
- Only one with SDVOSB federal credibility
|
|
294
|
-
- MIT licensed. No proprietary core.
|
|
295
|
-
|
|
296
|
-
---
|
|
297
|
-
|
|
298
|
-
## License
|
|
299
|
-
|
|
300
|
-
MIT — see [LICENSE](LICENSE)
|
|
301
|
-
|
|
302
|
-
Owner: [@TimmyCrypto78](https://github.com/timwal78) / ScriptMasterLabs
|
|
303
|
-
Launch Target: 2026-07-02
|
|
304
|
-
Target: 50K GitHub stars, 5K npm weekly downloads
|
|
1
|
+
# mcp-x402 — The First MCP Server That Pays for Itself
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@scriptmasterlabs/mcp-x402)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://github.com/timwal78/sml_portfolio/actions)
|
|
6
|
+
|
|
7
|
+
> **Demo video:** [30-second walkthrough](#) — coming within 48h of launch.
|
|
8
|
+
|
|
9
|
+
AI agents should pay for their own data — instantly, autonomously, compliantly. `mcp-x402` makes that real.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx @scriptmasterlabs/mcp-x402
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Why MCP Servers Are Broken (The Manifesto)
|
|
18
|
+
|
|
19
|
+
Every MCP server connecting to paid APIs today requires:
|
|
20
|
+
- A human to set up API keys
|
|
21
|
+
- A human to manage billing
|
|
22
|
+
- A human to top up credits when they run out
|
|
23
|
+
- A human to rotate keys when they expire
|
|
24
|
+
|
|
25
|
+
This defeats the entire point of autonomous agents. If your agent has to stop and ask a human for a credit card, it's not autonomous — it's a very expensive chatbot.
|
|
26
|
+
|
|
27
|
+
**We built the machine-native alternative.**
|
|
28
|
+
|
|
29
|
+
`mcp-x402` is the first MCP server where agents provision their own wallets, negotiate prices on-chain, pay autonomously, and receive cryptographic receipts — all without human intervention. The agent's credit score goes up every time it successfully transacts. It builds financial reputation the same way humans do.
|
|
30
|
+
|
|
31
|
+
This is the infrastructure layer that makes truly autonomous AI agents possible.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## One-Line Install
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm i -g @scriptmasterlabs/mcp-x402
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Add to your Claude Code `~/.claude/config.json`:
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"mcpServers": {
|
|
46
|
+
"sml": {
|
|
47
|
+
"command": "npx",
|
|
48
|
+
"args": ["@scriptmasterlabs/mcp-x402"]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
For Cursor (SSE mode), add to your MCP settings:
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"mcp-x402": {
|
|
59
|
+
"url": "http://localhost:3402/sse"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Then run: `MCP_TRANSPORT=sse npx @scriptmasterlabs/mcp-x402`
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Architecture
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
Claude / Cursor
|
|
72
|
+
│
|
|
73
|
+
▼ MCP Protocol (stdio / SSE)
|
|
74
|
+
mcp-x402 Server
|
|
75
|
+
├─ Input validation (Zod, 100% coverage)
|
|
76
|
+
├─ Rate limiter (100/min per tool)
|
|
77
|
+
├─ AP2 Mandate check (deny-by-default)
|
|
78
|
+
├─ Credit Bureau check (min score 300)
|
|
79
|
+
├─ Price registry (60s max cache)
|
|
80
|
+
├─ x402 payment engine
|
|
81
|
+
│ ├─ Base USDC (preferred, <3s)
|
|
82
|
+
│ ├─ XRPL RLUSD (500ms fallback)
|
|
83
|
+
│ └─ Solana USDC (last resort)
|
|
84
|
+
├─ 402Proof receipt generation
|
|
85
|
+
├─ SML API call (mTLS)
|
|
86
|
+
└─ Append-only SHA-256 audit log
|
|
87
|
+
│
|
|
88
|
+
▼ Result + receipt_id back to agent
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## The 6 Tools
|
|
94
|
+
|
|
95
|
+
### `leviathan_signal` — $0.05 USDC | AP2 required
|
|
96
|
+
Institutional-grade squeeze signals. Multi-engine verdict (OracleEngine + RDT + SML Fractal Cascade).
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
await use_mcp_tool('sml', 'leviathan_signal', {
|
|
100
|
+
ticker: 'MSTR',
|
|
101
|
+
signal_type: 'squeeze',
|
|
102
|
+
min_confidence: 75
|
|
103
|
+
});
|
|
104
|
+
// Returns: signal verdict + confidence + receipt_id
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### `xmit_edgar_decode` — $0.02 USDC | AP2 required
|
|
108
|
+
Parse SEC DEF 14A / 13F / 13D filings. Raw text never leaves SML servers.
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
await use_mcp_tool('sml', 'xmit_edgar_decode', {
|
|
112
|
+
filing_url: 'https://www.sec.gov/Archives/edgar/data/...',
|
|
113
|
+
parse_target: 'executive_pay',
|
|
114
|
+
format: 'json'
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### `xdeo_earnings_estimate` — $0.02 USDC | AP2 required
|
|
119
|
+
Decentralized earnings oracle. Earns +2 Credit Bureau points per successful call.
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
await use_mcp_tool('sml', 'xdeo_earnings_estimate', {
|
|
123
|
+
ticker: 'NVDA',
|
|
124
|
+
fiscal_quarter: 'Q12025',
|
|
125
|
+
estimate_type: 'all'
|
|
126
|
+
});
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### `ftd_threshold_scan` — Alerts FREE / Full $0.05 USDC
|
|
130
|
+
SEC Reg SHO FTD spike detection. 15-minute cache.
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
// Free tier:
|
|
134
|
+
await use_mcp_tool('sml', 'ftd_threshold_scan', { scan_type: 'alerts' });
|
|
135
|
+
// Paid tier:
|
|
136
|
+
await use_mcp_tool('sml', 'ftd_threshold_scan', { scan_type: 'full', min_spike_multiplier: 3 });
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### `nexus_agent_hire` — Query FREE / Hire 5% commission
|
|
140
|
+
Agent marketplace. Find and hire specialized AI agents.
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
// Free query:
|
|
144
|
+
await use_mcp_tool('sml', 'nexus_agent_hire', { capability: 'options flow analysis', max_budget: '1.00', action: 'query' });
|
|
145
|
+
// Hire:
|
|
146
|
+
await use_mcp_tool('sml', 'nexus_agent_hire', { action: 'hire', agent_id: 'agent_abc', max_budget: '0.50' });
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### `crawl_paid_fetch` — $0.005 USDC
|
|
150
|
+
Pay-per-fetch web scraping. Humans bypass automatically.
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
await use_mcp_tool('sml', 'crawl_paid_fetch', {
|
|
154
|
+
url: 'https://example.com/data',
|
|
155
|
+
extract: 'tables'
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Payment Flow
|
|
162
|
+
|
|
163
|
+
1. **Discover** — Agent reads `agents.json` or `llms.txt`, sees tool prices
|
|
164
|
+
2. **Authorize** — AP2 mandate checked. Credit Bureau score ≥ 300 auto-approves
|
|
165
|
+
3. **Pay** — x402 stablecoin on cheapest/fastest chain (<3s on Base)
|
|
166
|
+
4. **Prove** — 402Proof receipt in every response
|
|
167
|
+
5. **Earn** — Credit Bureau score updates after success
|
|
168
|
+
|
|
169
|
+
Every successful tool call returns a `_meta` block:
|
|
170
|
+
```json
|
|
171
|
+
{
|
|
172
|
+
"_meta": {
|
|
173
|
+
"receipt_id": "uuid-here",
|
|
174
|
+
"tx_hash": "0xabc...",
|
|
175
|
+
"chain": "base",
|
|
176
|
+
"amount_paid": "0.05 USDC",
|
|
177
|
+
"timestamp": 1750000000000
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## SDK — For MCP Server Authors
|
|
185
|
+
|
|
186
|
+
Install in one line:
|
|
187
|
+
```bash
|
|
188
|
+
npm i @scriptmasterlabs/mcp-x402-sdk
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Drop into any MCP server in 5 lines:
|
|
192
|
+
```typescript
|
|
193
|
+
import { x402Payment } from '@scriptmasterlabs/mcp-x402-sdk';
|
|
194
|
+
|
|
195
|
+
server.tool(
|
|
196
|
+
'my_paid_tool',
|
|
197
|
+
myInputSchema,
|
|
198
|
+
x402Payment({
|
|
199
|
+
price: '0.01',
|
|
200
|
+
currency: 'USDC',
|
|
201
|
+
inputSchema: MyZodSchema,
|
|
202
|
+
handler: async (input, receipt) => ({
|
|
203
|
+
content: [{ type: 'text', text: JSON.stringify({ result: await myApi(input), receipt }) }],
|
|
204
|
+
}),
|
|
205
|
+
}),
|
|
206
|
+
);
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
That's it. The SDK handles wallet provisioning, AP2 mandate, chain routing, receipts, and audit logging.
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Security
|
|
214
|
+
|
|
215
|
+
| Requirement | Implementation |
|
|
216
|
+
|-------------|----------------|
|
|
217
|
+
| Keys in OS keychain only | `keytar` — macOS Keychain / Windows DPAPI / Linux Secret Service |
|
|
218
|
+
| mTLS on SML APIs | Pinned cert via `node-forge` |
|
|
219
|
+
| No PII in logs | Wallet addresses hashed (SHA-256 prefix), filing content redacted |
|
|
220
|
+
| Zod on all inputs | 100% coverage, validated before any execution |
|
|
221
|
+
| Append-only audit log | SHA-256 HMAC chained log, 7-day local + cloud backup |
|
|
222
|
+
| AP2 mandate required | Verified before every paid call, fail-closed |
|
|
223
|
+
| 402Proof receipt | Every transaction, registered with proof server |
|
|
224
|
+
| Credit Bureau check | min score 300 for auto-approve |
|
|
225
|
+
| $50 daily spend cap | Per wallet, enforced in-process |
|
|
226
|
+
| Testnet in CI | Base Sepolia only, max $0.10 test value |
|
|
227
|
+
| <3s end-to-end | Base mainnet target, 500ms multi-chain fallback |
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Environment Variables
|
|
232
|
+
|
|
233
|
+
See [`.env.example`](.env.example) for the full list. Key variables:
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
MCP_TRANSPORT=stdio # stdio (Claude Code) or sse (Cursor/remote)
|
|
237
|
+
SML_API_BASE=https://api.scriptmasterlabs.com
|
|
238
|
+
BASE_RPC_URL=https://mainnet.base.org
|
|
239
|
+
XRPL_RPC_URL=wss://xrplcluster.com
|
|
240
|
+
DAILY_SPEND_CAP_USD=50
|
|
241
|
+
AUTO_APPROVE_THRESHOLD_USD=1
|
|
242
|
+
TESTNET=false # Set true + CI_WALLET_SEED for CI
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**Private keys**: Stored in your OS keychain automatically on first run. Never in env vars.
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## Running Locally
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
git clone https://github.com/timwal78/sml_portfolio
|
|
253
|
+
cd mcp-x402
|
|
254
|
+
npm install
|
|
255
|
+
npm run build
|
|
256
|
+
npm start
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
With Docker:
|
|
260
|
+
```bash
|
|
261
|
+
docker build -t mcp-x402 .
|
|
262
|
+
docker run -p 3402:3402 -e MCP_TRANSPORT=sse mcp-x402
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## Testing
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
npm test # All unit tests
|
|
271
|
+
npm run test:coverage # Coverage report (target: 90%)
|
|
272
|
+
TESTNET=true CI_WALLET_SEED="your mnemonic" npm run test:integration
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## Ecosystem
|
|
278
|
+
|
|
279
|
+
| Service | URL | Role |
|
|
280
|
+
|---------|-----|------|
|
|
281
|
+
| SqueezeOS API | `squeezeos-api.onrender.com` | Market intelligence |
|
|
282
|
+
| 402Proof | `four02proof.onrender.com` | Payment receipts + Credit Bureau |
|
|
283
|
+
| Ghost Layer | `ghost-layer.onrender.com` | XRPL+Base toll gateway |
|
|
284
|
+
| ScriptMasterLabs | `scriptmasterlabs.com` | Operator homepage |
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## MOAT
|
|
289
|
+
|
|
290
|
+
- Only MCP server with live x402 + AP2 + multi-chain production stack
|
|
291
|
+
- Only one with Agent Credit Bureau (300–850 scores)
|
|
292
|
+
- Only one backed by live financial intelligence marketplace
|
|
293
|
+
- Only one with SDVOSB federal credibility
|
|
294
|
+
- MIT licensed. No proprietary core.
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## License
|
|
299
|
+
|
|
300
|
+
MIT — see [LICENSE](LICENSE)
|
|
301
|
+
|
|
302
|
+
Owner: [@TimmyCrypto78](https://github.com/timwal78) / ScriptMasterLabs
|
|
303
|
+
Launch Target: 2026-07-02
|
|
304
|
+
Target: 50K GitHub stars, 5K npm weekly downloads
|