kaleido-mcp 0.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/LICENSE +17 -0
- package/README.md +55 -0
- package/dist/clients/market-client.d.ts +33 -0
- package/dist/clients/market-client.js +72 -0
- package/dist/clients/market-client.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +80 -0
- package/dist/index.js.map +1 -0
- package/dist/mpp-client.d.ts +80 -0
- package/dist/mpp-client.js +186 -0
- package/dist/mpp-client.js.map +1 -0
- package/dist/server.d.ts +58 -0
- package/dist/server.js +106 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/kaleidoswap-tools.d.ts +3 -0
- package/dist/tools/kaleidoswap-tools.js +263 -0
- package/dist/tools/kaleidoswap-tools.js.map +1 -0
- package/dist/tools/market-tools.d.ts +2 -0
- package/dist/tools/market-tools.js +49 -0
- package/dist/tools/market-tools.js.map +1 -0
- package/dist/tools/mpp-tools.d.ts +2 -0
- package/dist/tools/mpp-tools.js +133 -0
- package/dist/tools/mpp-tools.js.map +1 -0
- package/dist/tools/rln-tools.d.ts +3 -0
- package/dist/tools/rln-tools.js +245 -0
- package/dist/tools/rln-tools.js.map +1 -0
- package/dist/tools/spark-tools.d.ts +2 -0
- package/dist/tools/spark-tools.js +218 -0
- package/dist/tools/spark-tools.js.map +1 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
Copyright 2026 KaleidoSwap
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# kaleido-mcp
|
|
2
|
+
|
|
3
|
+
Unified MCP server for the Kaleidoswap stack.
|
|
4
|
+
|
|
5
|
+
This repo is the **composition layer** that exposes the focused MCP domains through one connection:
|
|
6
|
+
|
|
7
|
+
- Spark wallet tools
|
|
8
|
+
- RLN wallet tools
|
|
9
|
+
- KaleidoSwap DEX tools
|
|
10
|
+
- MPP / L402 payment-gated API tools
|
|
11
|
+
- market data tools
|
|
12
|
+
|
|
13
|
+
The canonical tool contracts mirror the focused servers:
|
|
14
|
+
|
|
15
|
+
- `kaleidoswap_*`
|
|
16
|
+
- `wdk_*`
|
|
17
|
+
- `spark_*`
|
|
18
|
+
- `mpp_*`
|
|
19
|
+
- `l402_*`
|
|
20
|
+
|
|
21
|
+
Legacy `rln_*` and generic `get_*` market aliases are still present for compatibility during migration.
|
|
22
|
+
|
|
23
|
+
## Required Environment
|
|
24
|
+
|
|
25
|
+
| Env var | Required | Description |
|
|
26
|
+
| --- | --- | --- |
|
|
27
|
+
| `WDK_SEED` | yes | BIP-39 mnemonic for the Spark wallet |
|
|
28
|
+
| `SPARK_NETWORK` | no | `MAINNET` or `REGTEST` |
|
|
29
|
+
| `SPARK_SCAN_API_KEY` | no | SparkScan API key |
|
|
30
|
+
| `SPARK_USDT_TOKEN` | no | Default Spark token identifier |
|
|
31
|
+
| `RLN_NODE_URL` | no | RLN daemon URL, default `http://localhost:3001` |
|
|
32
|
+
| `KALEIDOSWAP_API_URL` | no | KaleidoSwap API URL, default `https://api.kaleidoswap.com` |
|
|
33
|
+
| `PORT` | no | Enable Streamable HTTP transport |
|
|
34
|
+
| `MCP_AUTH_TOKEN` | no | Bearer token for HTTP mode |
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm install
|
|
40
|
+
npm run build
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# stdio
|
|
47
|
+
WDK_SEED="word1 word2 ..." node dist/index.js
|
|
48
|
+
|
|
49
|
+
# HTTP
|
|
50
|
+
PORT=3010 WDK_SEED="word1 word2 ..." node dist/index.js
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Repo Role
|
|
54
|
+
|
|
55
|
+
`kaleido-mcp` is intended to stay thin. Domain logic should live in the focused MCP packages or shared libraries, not be reimplemented here.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Market data client — CoinGecko free tier + alternative.me Fear&Greed.
|
|
3
|
+
* Ported from mpp-gateway-mcp/src/market-client.ts.
|
|
4
|
+
*/
|
|
5
|
+
export interface PriceResult {
|
|
6
|
+
asset: string;
|
|
7
|
+
vs_currency: string;
|
|
8
|
+
price: number;
|
|
9
|
+
change_24h_pct: number | null;
|
|
10
|
+
market_cap_usd: number | null;
|
|
11
|
+
volume_24h_usd: number | null;
|
|
12
|
+
last_updated: string;
|
|
13
|
+
}
|
|
14
|
+
export interface OhlcvCandle {
|
|
15
|
+
timestamp: number;
|
|
16
|
+
open: number;
|
|
17
|
+
high: number;
|
|
18
|
+
low: number;
|
|
19
|
+
close: number;
|
|
20
|
+
}
|
|
21
|
+
export interface SentimentResult {
|
|
22
|
+
index_value: number;
|
|
23
|
+
classification: string;
|
|
24
|
+
timestamp: string;
|
|
25
|
+
}
|
|
26
|
+
export declare class MarketClient {
|
|
27
|
+
getPrice(asset: string, vsCurrency?: string): Promise<PriceResult>;
|
|
28
|
+
getMarketData(assets: string[]): Promise<PriceResult[]>;
|
|
29
|
+
getOhlcv(asset: string, days: number): Promise<OhlcvCandle[]>;
|
|
30
|
+
getFearGreedIndex(): Promise<SentimentResult>;
|
|
31
|
+
private coinId;
|
|
32
|
+
private fetch;
|
|
33
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Market data client — CoinGecko free tier + alternative.me Fear&Greed.
|
|
3
|
+
* Ported from mpp-gateway-mcp/src/market-client.ts.
|
|
4
|
+
*/
|
|
5
|
+
const COINGECKO = 'https://api.coingecko.com/api/v3';
|
|
6
|
+
const COIN_IDS = {
|
|
7
|
+
BTC: 'bitcoin', USDT: 'tether', XAUT: 'tether-gold', ETH: 'ethereum',
|
|
8
|
+
};
|
|
9
|
+
export class MarketClient {
|
|
10
|
+
async getPrice(asset, vsCurrency = 'usd') {
|
|
11
|
+
const id = this.coinId(asset);
|
|
12
|
+
const data = await this.fetch(`${COINGECKO}/simple/price?ids=${id}&vs_currencies=${vsCurrency}&include_market_cap=true&include_24hr_vol=true&include_24hr_change=true&include_last_updated_at=true`);
|
|
13
|
+
const e = data[id];
|
|
14
|
+
if (!e)
|
|
15
|
+
throw new Error(`No price data for ${asset}`);
|
|
16
|
+
return {
|
|
17
|
+
asset: asset.toUpperCase(), vs_currency: vsCurrency.toUpperCase(),
|
|
18
|
+
price: e[vsCurrency] ?? 0,
|
|
19
|
+
change_24h_pct: e[`${vsCurrency}_24h_change`] ?? null,
|
|
20
|
+
market_cap_usd: e[`${vsCurrency}_market_cap`] ?? null,
|
|
21
|
+
volume_24h_usd: e[`${vsCurrency}_24h_vol`] ?? null,
|
|
22
|
+
last_updated: new Date((e['last_updated_at'] ?? 0) * 1000).toISOString(),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
async getMarketData(assets) {
|
|
26
|
+
const ids = assets.map(a => this.coinId(a)).join(',');
|
|
27
|
+
const data = await this.fetch(`${COINGECKO}/simple/price?ids=${ids}&vs_currencies=usd&include_market_cap=true&include_24hr_vol=true&include_24hr_change=true&include_last_updated_at=true`);
|
|
28
|
+
return assets.map(asset => {
|
|
29
|
+
const e = data[this.coinId(asset)] ?? {};
|
|
30
|
+
return {
|
|
31
|
+
asset: asset.toUpperCase(), vs_currency: 'USD',
|
|
32
|
+
price: e['usd'] ?? 0,
|
|
33
|
+
change_24h_pct: e['usd_24h_change'] ?? null,
|
|
34
|
+
market_cap_usd: e['usd_market_cap'] ?? null,
|
|
35
|
+
volume_24h_usd: e['usd_24h_vol'] ?? null,
|
|
36
|
+
last_updated: new Date((e['last_updated_at'] ?? 0) * 1000).toISOString(),
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
async getOhlcv(asset, days) {
|
|
41
|
+
const id = this.coinId(asset);
|
|
42
|
+
const raw = await this.fetch(`${COINGECKO}/coins/${id}/ohlc?vs_currency=usd&days=${days}`);
|
|
43
|
+
return raw.map(([ts, o, h, l, c]) => ({ timestamp: ts, open: o, high: h, low: l, close: c }));
|
|
44
|
+
}
|
|
45
|
+
async getFearGreedIndex() {
|
|
46
|
+
const data = await this.fetch('https://api.alternative.me/fng/?limit=1');
|
|
47
|
+
const e = data.data?.[0];
|
|
48
|
+
if (!e)
|
|
49
|
+
throw new Error('No fear/greed data');
|
|
50
|
+
return {
|
|
51
|
+
index_value: parseInt(e.value, 10),
|
|
52
|
+
classification: e.value_classification,
|
|
53
|
+
timestamp: new Date(parseInt(e.timestamp, 10) * 1000).toISOString(),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
coinId(asset) {
|
|
57
|
+
const id = COIN_IDS[asset.toUpperCase()];
|
|
58
|
+
if (!id)
|
|
59
|
+
throw new Error(`Unknown asset: ${asset}. Supported: ${Object.keys(COIN_IDS).join(', ')}`);
|
|
60
|
+
return id;
|
|
61
|
+
}
|
|
62
|
+
async fetch(url) {
|
|
63
|
+
const res = await fetch(url, { headers: { Accept: 'application/json' } });
|
|
64
|
+
if (!res.ok) {
|
|
65
|
+
if (res.status === 429)
|
|
66
|
+
throw new Error('Market data rate limit (HTTP 429). Wait 30s.');
|
|
67
|
+
throw new Error(`Market data failed: HTTP ${res.status}`);
|
|
68
|
+
}
|
|
69
|
+
return res.json();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=market-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"market-client.js","sourceRoot":"","sources":["../../src/clients/market-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,SAAS,GAAG,kCAAkC,CAAA;AACpD,MAAM,QAAQ,GAA2B;IACvC,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,EAAE,UAAU;CACrE,CAAA;AAWD,MAAM,OAAO,YAAY;IACvB,KAAK,CAAC,QAAQ,CAAC,KAAa,EAAE,UAAU,GAAG,KAAK;QAC9C,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAC7B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAC3B,GAAG,SAAS,qBAAqB,EAAE,kBAAkB,UAAU,sGAAsG,CACtK,CAAA;QACD,MAAM,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAA;QAClB,IAAI,CAAC,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,KAAK,EAAE,CAAC,CAAA;QACrD,OAAO;YACL,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,EAAE,WAAW,EAAE,UAAU,CAAC,WAAW,EAAE;YACjE,KAAK,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC;YACzB,cAAc,EAAE,CAAC,CAAC,GAAG,UAAU,aAAa,CAAC,IAAI,IAAI;YACrD,cAAc,EAAE,CAAC,CAAC,GAAG,UAAU,aAAa,CAAC,IAAI,IAAI;YACrD,cAAc,EAAE,CAAC,CAAC,GAAG,UAAU,UAAU,CAAC,IAAI,IAAI;YAClD,YAAY,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,iBAAiB,CA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AE,CAAC,CAAA;QACzE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG;gBAAE,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAA;YACvF,MAAM,IAAI,KAAK,CAAC,4BAA4B,GAAG,CAAC,MAAM,EAAE,CAAC,CAAA;QAC3D,CAAC;QACD,OAAO,GAAG,CAAC,IAAI,EAAgB,CAAA;IACjC,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* kaleido-mcp — Unified KaleidoSwap + WDK MCP Server
|
|
4
|
+
*
|
|
5
|
+
* Single MCP server for all KaleidoSwap agent operations:
|
|
6
|
+
* • WDK Spark L2 wallet (fee-free transfers, Lightning pay/receive, BTC bridge)
|
|
7
|
+
* • RLN node (RGB assets, Lightning channels, atomic HTLC swaps)
|
|
8
|
+
* • KaleidoSwap DEX (quotes, REST orders, atomic swaps, LSPS1 channels)
|
|
9
|
+
* • MPP / L402 (payment-gated API access, challenge/credential flow)
|
|
10
|
+
* • 402index.io (discover paid APIs by protocol/category)
|
|
11
|
+
* • Market data (prices, OHLCV, Fear & Greed sentiment)
|
|
12
|
+
*
|
|
13
|
+
* ~60 tools, one process, one connection.
|
|
14
|
+
*
|
|
15
|
+
* Required env vars:
|
|
16
|
+
* WDK_SEED — BIP-39 mnemonic for Spark wallet
|
|
17
|
+
*
|
|
18
|
+
* Optional env vars:
|
|
19
|
+
* SPARK_NETWORK — MAINNET | REGTEST (default: MAINNET)
|
|
20
|
+
* SPARK_SCAN_API_KEY — SparkScan API key
|
|
21
|
+
* SPARK_USDT_TOKEN — Spark USDT token identifier (btkn1...)
|
|
22
|
+
* RLN_NODE_URL — RLN daemon URL (default: http://localhost:3001)
|
|
23
|
+
* KALEIDOSWAP_API_URL — KaleidoSwap API (default: https://api.kaleidoswap.com)
|
|
24
|
+
* PORT — Enable StreamableHTTP on this port (default: stdio)
|
|
25
|
+
* MCP_AUTH_TOKEN — Bearer token for HTTP mode
|
|
26
|
+
*
|
|
27
|
+
* Usage:
|
|
28
|
+
* WDK_SEED="word1 ... word12" node dist/index.js
|
|
29
|
+
* PORT=3010 WDK_SEED="..." node dist/index.js
|
|
30
|
+
*/
|
|
31
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* kaleido-mcp — Unified KaleidoSwap + WDK MCP Server
|
|
4
|
+
*
|
|
5
|
+
* Single MCP server for all KaleidoSwap agent operations:
|
|
6
|
+
* • WDK Spark L2 wallet (fee-free transfers, Lightning pay/receive, BTC bridge)
|
|
7
|
+
* • RLN node (RGB assets, Lightning channels, atomic HTLC swaps)
|
|
8
|
+
* • KaleidoSwap DEX (quotes, REST orders, atomic swaps, LSPS1 channels)
|
|
9
|
+
* • MPP / L402 (payment-gated API access, challenge/credential flow)
|
|
10
|
+
* • 402index.io (discover paid APIs by protocol/category)
|
|
11
|
+
* • Market data (prices, OHLCV, Fear & Greed sentiment)
|
|
12
|
+
*
|
|
13
|
+
* ~60 tools, one process, one connection.
|
|
14
|
+
*
|
|
15
|
+
* Required env vars:
|
|
16
|
+
* WDK_SEED — BIP-39 mnemonic for Spark wallet
|
|
17
|
+
*
|
|
18
|
+
* Optional env vars:
|
|
19
|
+
* SPARK_NETWORK — MAINNET | REGTEST (default: MAINNET)
|
|
20
|
+
* SPARK_SCAN_API_KEY — SparkScan API key
|
|
21
|
+
* SPARK_USDT_TOKEN — Spark USDT token identifier (btkn1...)
|
|
22
|
+
* RLN_NODE_URL — RLN daemon URL (default: http://localhost:3001)
|
|
23
|
+
* KALEIDOSWAP_API_URL — KaleidoSwap API (default: https://api.kaleidoswap.com)
|
|
24
|
+
* PORT — Enable StreamableHTTP on this port (default: stdio)
|
|
25
|
+
* MCP_AUTH_TOKEN — Bearer token for HTTP mode
|
|
26
|
+
*
|
|
27
|
+
* Usage:
|
|
28
|
+
* WDK_SEED="word1 ... word12" node dist/index.js
|
|
29
|
+
* PORT=3010 WDK_SEED="..." node dist/index.js
|
|
30
|
+
*/
|
|
31
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
32
|
+
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
33
|
+
import { createServer } from './server.js';
|
|
34
|
+
import { createServer as createHttpServer } from 'node:http';
|
|
35
|
+
const WDK_SEED = process.env.WDK_SEED ?? '';
|
|
36
|
+
const SPARK_NET = (process.env.SPARK_NETWORK ?? 'MAINNET');
|
|
37
|
+
const RLN_URL = process.env.RLN_NODE_URL ?? 'http://localhost:3001';
|
|
38
|
+
const KALEIDO_URL = process.env.KALEIDOSWAP_API_URL ?? 'https://api.kaleidoswap.com';
|
|
39
|
+
const PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : null;
|
|
40
|
+
if (!WDK_SEED) {
|
|
41
|
+
process.stderr.write('[kaleido-mcp] WARNING: WDK_SEED not set — Spark wallet tools will be disabled\n');
|
|
42
|
+
process.stderr.write('[kaleido-mcp] Set WDK_SEED="word1 word2 ... word12" to enable Spark features\n');
|
|
43
|
+
// Continue without Spark — RLN, KaleidoSwap, MPP, and market tools still available
|
|
44
|
+
}
|
|
45
|
+
async function main() {
|
|
46
|
+
const server = createServer({
|
|
47
|
+
wdkSeed: WDK_SEED,
|
|
48
|
+
sparkNetwork: SPARK_NET,
|
|
49
|
+
sparkScanApiKey: process.env.SPARK_SCAN_API_KEY,
|
|
50
|
+
sparkUsdtToken: process.env.SPARK_USDT_TOKEN,
|
|
51
|
+
rlnNodeUrl: RLN_URL,
|
|
52
|
+
kaleidoswapApiUrl: KALEIDO_URL,
|
|
53
|
+
});
|
|
54
|
+
const label = `Spark(${SPARK_NET}) + RLN(${RLN_URL}) + KaleidoSwap(${KALEIDO_URL})`;
|
|
55
|
+
if (PORT) {
|
|
56
|
+
const AUTH_TOKEN = process.env.MCP_AUTH_TOKEN ?? null;
|
|
57
|
+
const httpServer = createHttpServer(async (req, res) => {
|
|
58
|
+
if (AUTH_TOKEN && req.headers['authorization'] !== `Bearer ${AUTH_TOKEN}`) {
|
|
59
|
+
res.writeHead(401, { 'Content-Type': 'application/json' });
|
|
60
|
+
res.end(JSON.stringify({ error: 'Unauthorized' }));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: undefined });
|
|
64
|
+
res.on('close', () => transport.close().catch(() => { }));
|
|
65
|
+
await server.connect(transport);
|
|
66
|
+
await transport.handleRequest(req, res);
|
|
67
|
+
});
|
|
68
|
+
httpServer.listen(PORT, '0.0.0.0', () => process.stderr.write(`[kaleido-mcp] HTTP on port ${PORT} — ${label}\n`));
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
const transport = new StdioServerTransport();
|
|
72
|
+
await server.connect(transport);
|
|
73
|
+
process.stderr.write(`[kaleido-mcp] stdio connected — ${label}\n`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
main().catch(err => {
|
|
77
|
+
process.stderr.write(`[kaleido-mcp] Fatal: ${err}\n`);
|
|
78
|
+
process.exit(1);
|
|
79
|
+
});
|
|
80
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAA;AAClG,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAA6C,MAAM,WAAW,CAAA;AAEvG,MAAM,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AC,CAAA"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MPP (Machine Payments Protocol) client.
|
|
3
|
+
* Implements the Challenge -> Credential -> Receipt flow over HTTP.
|
|
4
|
+
*/
|
|
5
|
+
export type MppMethod = 'lightning' | 'tempo' | 'stripe' | 'card' | (string & {});
|
|
6
|
+
export type MppIntent = 'charge' | 'session' | (string & {});
|
|
7
|
+
/**
|
|
8
|
+
* Parsed MPP challenge from an HTTP 402 `WWW-Authenticate` header.
|
|
9
|
+
*/
|
|
10
|
+
export interface MppChallenge {
|
|
11
|
+
id: string;
|
|
12
|
+
/** @deprecated alias for `id` kept for backwards compatibility */
|
|
13
|
+
challenge_id: string;
|
|
14
|
+
url: string;
|
|
15
|
+
method: MppMethod;
|
|
16
|
+
intent: MppIntent;
|
|
17
|
+
amount?: string;
|
|
18
|
+
currency?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
request?: string;
|
|
21
|
+
digest?: string;
|
|
22
|
+
invoice?: string;
|
|
23
|
+
macaroon?: string;
|
|
24
|
+
amount_msat?: number;
|
|
25
|
+
amount_sats?: number;
|
|
26
|
+
expires_at?: number;
|
|
27
|
+
raw_header?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface MppCredential {
|
|
30
|
+
id: string;
|
|
31
|
+
/** @deprecated alias for `id` */
|
|
32
|
+
challenge_id?: string;
|
|
33
|
+
method: MppMethod;
|
|
34
|
+
intent?: MppIntent;
|
|
35
|
+
preimage?: string;
|
|
36
|
+
macaroon?: string;
|
|
37
|
+
session_id?: string;
|
|
38
|
+
session_voucher?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface MppReceipt {
|
|
41
|
+
receipt_id?: string;
|
|
42
|
+
paid_at?: string;
|
|
43
|
+
method?: string;
|
|
44
|
+
amount?: string;
|
|
45
|
+
currency?: string;
|
|
46
|
+
amount_msat?: number;
|
|
47
|
+
}
|
|
48
|
+
export interface MppResourceResponse {
|
|
49
|
+
ok: boolean;
|
|
50
|
+
status: number;
|
|
51
|
+
data: unknown;
|
|
52
|
+
receipt?: MppReceipt;
|
|
53
|
+
raw_receipt_header?: string;
|
|
54
|
+
}
|
|
55
|
+
export interface MppProblemDetail {
|
|
56
|
+
type: string;
|
|
57
|
+
title: string;
|
|
58
|
+
status: number;
|
|
59
|
+
detail?: string;
|
|
60
|
+
}
|
|
61
|
+
export declare const MppErrorCode: {
|
|
62
|
+
readonly PaymentRequired: "payment-required";
|
|
63
|
+
readonly PaymentInsufficient: "payment-insufficient";
|
|
64
|
+
readonly PaymentExpired: "payment-expired";
|
|
65
|
+
readonly VerificationFailed: "verification-failed";
|
|
66
|
+
readonly MalformedCredential: "malformed-credential";
|
|
67
|
+
readonly InvalidChallenge: "invalid-challenge";
|
|
68
|
+
};
|
|
69
|
+
export declare class MppClient {
|
|
70
|
+
requestChallenge(url: string): Promise<MppChallenge>;
|
|
71
|
+
submitCredential(url: string, credential: MppCredential): Promise<MppResourceResponse>;
|
|
72
|
+
buildLightningCredential(challenge: MppChallenge, preimage: string): MppCredential;
|
|
73
|
+
serializeCredential(credential: MppCredential): string;
|
|
74
|
+
deserializeCredential(raw: string): MppCredential;
|
|
75
|
+
parseChallenge(url: string, header: string): MppChallenge;
|
|
76
|
+
private buildPaymentAuthHeader;
|
|
77
|
+
private parseReceipt;
|
|
78
|
+
private base64urlDecode;
|
|
79
|
+
private randomId;
|
|
80
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MPP (Machine Payments Protocol) client.
|
|
3
|
+
* Implements the Challenge -> Credential -> Receipt flow over HTTP.
|
|
4
|
+
*/
|
|
5
|
+
export const MppErrorCode = {
|
|
6
|
+
PaymentRequired: 'payment-required',
|
|
7
|
+
PaymentInsufficient: 'payment-insufficient',
|
|
8
|
+
PaymentExpired: 'payment-expired',
|
|
9
|
+
VerificationFailed: 'verification-failed',
|
|
10
|
+
MalformedCredential: 'malformed-credential',
|
|
11
|
+
InvalidChallenge: 'invalid-challenge',
|
|
12
|
+
};
|
|
13
|
+
export class MppClient {
|
|
14
|
+
async requestChallenge(url) {
|
|
15
|
+
let res;
|
|
16
|
+
try {
|
|
17
|
+
res = await fetch(url, {
|
|
18
|
+
method: 'GET',
|
|
19
|
+
headers: { Accept: 'application/json' },
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
throw new Error(`Cannot reach ${url}: ${err instanceof Error ? err.message : String(err)}`);
|
|
24
|
+
}
|
|
25
|
+
if (res.status !== 402) {
|
|
26
|
+
throw new Error(`Expected HTTP 402 from ${url}, got ${res.status}. This resource may not be MPP-protected.`);
|
|
27
|
+
}
|
|
28
|
+
const authHeader = res.headers.get('WWW-Authenticate');
|
|
29
|
+
if (!authHeader) {
|
|
30
|
+
throw new Error(`HTTP 402 received but no WWW-Authenticate header at ${url}`);
|
|
31
|
+
}
|
|
32
|
+
return this.parseChallenge(url, authHeader);
|
|
33
|
+
}
|
|
34
|
+
async submitCredential(url, credential) {
|
|
35
|
+
const headers = {
|
|
36
|
+
Accept: 'application/json',
|
|
37
|
+
'Payment-Authorization': this.buildPaymentAuthHeader(credential),
|
|
38
|
+
};
|
|
39
|
+
if (credential.macaroon && credential.preimage) {
|
|
40
|
+
headers.Authorization = `L402 ${credential.macaroon}:${credential.preimage}`;
|
|
41
|
+
}
|
|
42
|
+
const res = await fetch(url, { method: 'GET', headers });
|
|
43
|
+
let data;
|
|
44
|
+
try {
|
|
45
|
+
const body = await res.text();
|
|
46
|
+
data = body ? JSON.parse(body) : {};
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
data = null;
|
|
50
|
+
}
|
|
51
|
+
const receiptHeader = res.headers.get('Payment-Receipt');
|
|
52
|
+
const receipt = receiptHeader ? this.parseReceipt(receiptHeader) : undefined;
|
|
53
|
+
return {
|
|
54
|
+
ok: res.ok,
|
|
55
|
+
status: res.status,
|
|
56
|
+
data,
|
|
57
|
+
receipt,
|
|
58
|
+
raw_receipt_header: receiptHeader ?? undefined,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
buildLightningCredential(challenge, preimage) {
|
|
62
|
+
return {
|
|
63
|
+
id: challenge.id,
|
|
64
|
+
challenge_id: challenge.id,
|
|
65
|
+
method: 'lightning',
|
|
66
|
+
intent: challenge.intent,
|
|
67
|
+
preimage,
|
|
68
|
+
macaroon: challenge.macaroon,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
serializeCredential(credential) {
|
|
72
|
+
return JSON.stringify(credential);
|
|
73
|
+
}
|
|
74
|
+
deserializeCredential(raw) {
|
|
75
|
+
try {
|
|
76
|
+
return JSON.parse(raw);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
throw new Error('Invalid credential format. Expected JSON string from wdk_mpp_pay.');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
parseChallenge(url, header) {
|
|
83
|
+
const stripped = header.replace(/^Payment\s+/i, '').replace(/^L402\s+/i, '');
|
|
84
|
+
const params = {};
|
|
85
|
+
for (const match of stripped.matchAll(/(\w+)=(?:"([^"]*)"|([^\s,]+))/g)) {
|
|
86
|
+
params[match[1]] = match[2] ?? match[3];
|
|
87
|
+
}
|
|
88
|
+
const method = (params.method ?? 'lightning');
|
|
89
|
+
const intent = (params.intent ?? 'charge');
|
|
90
|
+
const id = params.id ?? params.challenge_id ?? params.nonce ?? this.randomId();
|
|
91
|
+
let invoice;
|
|
92
|
+
let macaroon;
|
|
93
|
+
let amountMsat;
|
|
94
|
+
if (params.request) {
|
|
95
|
+
try {
|
|
96
|
+
const decoded = JSON.parse(this.base64urlDecode(params.request));
|
|
97
|
+
invoice = (decoded.invoice ?? decoded.bolt11);
|
|
98
|
+
macaroon = (decoded.macaroon ?? decoded.token);
|
|
99
|
+
if (decoded.amount_msat)
|
|
100
|
+
amountMsat = Number(decoded.amount_msat);
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
// Some servers use a non-JSON request payload.
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
invoice ??= params.invoice;
|
|
107
|
+
macaroon ??= params.macaroon ?? params.token;
|
|
108
|
+
if (!amountMsat && params.amount) {
|
|
109
|
+
const amount = parseFloat(params.amount);
|
|
110
|
+
const currency = (params.currency ?? 'sat').toLowerCase();
|
|
111
|
+
if (currency === 'sat' || currency === 'sats')
|
|
112
|
+
amountMsat = amount * 1_000;
|
|
113
|
+
else if (currency === 'msat' || currency === 'msats')
|
|
114
|
+
amountMsat = amount;
|
|
115
|
+
else if (currency === 'btc')
|
|
116
|
+
amountMsat = Math.round(amount * 1e11);
|
|
117
|
+
}
|
|
118
|
+
const amountSats = amountMsat ? Math.ceil(amountMsat / 1000) : undefined;
|
|
119
|
+
return {
|
|
120
|
+
id,
|
|
121
|
+
challenge_id: id,
|
|
122
|
+
url,
|
|
123
|
+
method,
|
|
124
|
+
intent,
|
|
125
|
+
amount: params.amount,
|
|
126
|
+
currency: params.currency,
|
|
127
|
+
description: params.description,
|
|
128
|
+
request: params.request,
|
|
129
|
+
digest: params.digest,
|
|
130
|
+
invoice,
|
|
131
|
+
macaroon,
|
|
132
|
+
amount_msat: amountMsat,
|
|
133
|
+
amount_sats: amountSats,
|
|
134
|
+
expires_at: params.expires_at ? parseInt(params.expires_at, 10) : undefined,
|
|
135
|
+
raw_header: header,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
buildPaymentAuthHeader(credential) {
|
|
139
|
+
const id = credential.id ?? credential.challenge_id ?? '';
|
|
140
|
+
const parts = [
|
|
141
|
+
`Payment id="${id}"`,
|
|
142
|
+
`method="${credential.method}"`,
|
|
143
|
+
];
|
|
144
|
+
if (credential.intent)
|
|
145
|
+
parts.push(`intent="${credential.intent}"`);
|
|
146
|
+
if (credential.preimage)
|
|
147
|
+
parts.push(`preimage="${credential.preimage}"`);
|
|
148
|
+
if (credential.macaroon)
|
|
149
|
+
parts.push(`macaroon="${credential.macaroon}"`);
|
|
150
|
+
if (credential.session_id)
|
|
151
|
+
parts.push(`session_id="${credential.session_id}"`);
|
|
152
|
+
if (credential.session_voucher)
|
|
153
|
+
parts.push(`voucher="${credential.session_voucher}"`);
|
|
154
|
+
return parts.join(', ');
|
|
155
|
+
}
|
|
156
|
+
parseReceipt(header) {
|
|
157
|
+
try {
|
|
158
|
+
if (header.trim().startsWith('{')) {
|
|
159
|
+
return JSON.parse(header);
|
|
160
|
+
}
|
|
161
|
+
const params = {};
|
|
162
|
+
for (const match of header.matchAll(/(\w+)=(?:"([^"]*)"|([^\s,]+))/g)) {
|
|
163
|
+
params[match[1]] = match[2] ?? match[3];
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
receipt_id: params.receipt_id,
|
|
167
|
+
paid_at: params.paid_at,
|
|
168
|
+
method: params.method,
|
|
169
|
+
amount: params.amount,
|
|
170
|
+
currency: params.currency,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
return {};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
base64urlDecode(input) {
|
|
178
|
+
const base64 = input.replace(/-/g, '+').replace(/_/g, '/');
|
|
179
|
+
const padded = base64.padEnd(base64.length + (4 - (base64.length % 4)) % 4, '=');
|
|
180
|
+
return Buffer.from(padded, 'base64').toString('utf8');
|
|
181
|
+
}
|
|
182
|
+
randomId() {
|
|
183
|
+
return Math.random().toString(36).substring(2, 12);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=mpp-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mpp-client.js","sourceRoot":"","sources":["../src/mpp-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgEH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,eAAe,EAAE,kBAAkB;IACnC,mBAAmB,EAAE,sBAAsB;IAC3C,cAAc,EAAE,iBAAiB;IACjC,kBAAkB,EAAE,qBAAqB;IACzC,mBAAmB,EAA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*
|
|
6
|
+
* LAYER 1 — WDK built-in tools (via registerTools):
|
|
7
|
+
* • WALLET_TOOLS — getAddress, getBalance, sendTransaction, transfer,
|
|
8
|
+
* getTokenBalance, quoteSendTransaction, quoteTransfer,
|
|
9
|
+
* getFeeRates, sign, verify (all scoped to 'spark' chain)
|
|
10
|
+
* • PRICING_TOOLS — getCurrentPrice, getHistoricalPrice (Bitfinex)
|
|
11
|
+
*
|
|
12
|
+
* LAYER 2 — Custom Spark tools (Lightning invoices, BTC bridge, fee-free transfers):
|
|
13
|
+
* spark_get_balance, spark_get_address, spark_create_lightning_invoice, spark_pay_lightning_invoice,
|
|
14
|
+
* spark_quote_lightning_payment, spark_get_deposit_address,
|
|
15
|
+
* spark_quote_withdraw, spark_withdraw, spark_get_transfers,
|
|
16
|
+
* spark_send_sats, spark_transfer_token, spark_mpp_pay, spark_get_token_balance
|
|
17
|
+
*
|
|
18
|
+
* LAYER 3 — RLN (RGB Lightning Node) tools:
|
|
19
|
+
* wdk_get_node_info, wdk_get_balances, wdk_list_assets, wdk_get_asset_balance,
|
|
20
|
+
* wdk_get_address, wdk_create_rgb_invoice, wdk_create_ln_invoice,
|
|
21
|
+
* wdk_pay_invoice, wdk_send_btc, wdk_send_asset, wdk_list_channels,
|
|
22
|
+
* wdk_connect_peer, wdk_open_channel, wdk_list_payments,
|
|
23
|
+
* wdk_refresh_transfers, wdk_atomic_taker, wdk_list_swaps,
|
|
24
|
+
* wdk_get_swap, wdk_mpp_pay
|
|
25
|
+
*
|
|
26
|
+
* LAYER 4 — KaleidoSwap DEX tools:
|
|
27
|
+
* kaleidoswap_get_assets, kaleidoswap_get_pairs, kaleidoswap_get_quote,
|
|
28
|
+
* kaleidoswap_get_spreads, kaleidoswap_place_order, kaleidoswap_get_order_status,
|
|
29
|
+
* kaleidoswap_get_open_orders, kaleidoswap_cancel_order, kaleidoswap_get_position,
|
|
30
|
+
* kaleidoswap_atomic_init, kaleidoswap_atomic_execute, kaleidoswap_atomic_status,
|
|
31
|
+
* kaleidoswap_lsp_get_info, kaleidoswap_lsp_estimate_fees,
|
|
32
|
+
* kaleidoswap_lsp_create_order, kaleidoswap_lsp_get_order
|
|
33
|
+
*
|
|
34
|
+
* LAYER 5 — MPP / L402 / 402index.io:
|
|
35
|
+
* mpp_request_challenge, mpp_submit_credential, mpp_parse_challenge_header,
|
|
36
|
+
* l402_request_challenge, l402_fetch_resource, search_paid_apis
|
|
37
|
+
*
|
|
38
|
+
* LAYER 6 — Market data (CoinGecko / alternative.me):
|
|
39
|
+
* l402_get_price, l402_get_market_data, l402_get_ohlcv, l402_get_sentiment
|
|
40
|
+
*
|
|
41
|
+
* Legacy aliases are retained temporarily for older `rln_*` and generic `get_*` callers.
|
|
42
|
+
*/
|
|
43
|
+
import { WdkMcpServer } from '@tetherto/wdk-mcp-toolkit';
|
|
44
|
+
export interface KaleidoMcpConfig {
|
|
45
|
+
/** BIP-39 seed phrase for WDK Spark wallet */
|
|
46
|
+
wdkSeed: string;
|
|
47
|
+
/** Spark network (default: MAINNET) */
|
|
48
|
+
sparkNetwork: 'MAINNET' | 'REGTEST';
|
|
49
|
+
/** SparkScan API key (optional, for enhanced queries) */
|
|
50
|
+
sparkScanApiKey?: string;
|
|
51
|
+
/** Spark USDT token identifier (btkn1...) */
|
|
52
|
+
sparkUsdtToken?: string;
|
|
53
|
+
/** RLN node HTTP URL (e.g. http://localhost:3001) */
|
|
54
|
+
rlnNodeUrl: string;
|
|
55
|
+
/** KaleidoSwap API base URL */
|
|
56
|
+
kaleidoswapApiUrl: string;
|
|
57
|
+
}
|
|
58
|
+
export declare function createServer(config: KaleidoMcpConfig): WdkMcpServer;
|