@aibtc/mcp-server 1.49.0 → 1.50.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aibtc/mcp-server",
3
- "version": "1.49.0",
3
+ "version": "1.50.0",
4
4
  "description": "Bitcoin-native MCP server for AI agents: BTC/STX wallets, DeFi yield, sBTC peg, NFTs, and x402 payments.",
5
5
  "mcpName": "io.github.aibtcdev/mcp-server",
6
6
  "type": "module",
@@ -65,6 +65,7 @@
65
65
  "light-bolt11-decoder": "^3.2.0",
66
66
  "micro-ordinals": "^0.3.0",
67
67
  "nostr-tools": "^2.23.3",
68
+ "path-to-regexp": "^8.4.0",
68
69
  "sbtc": "^0.3.2",
69
70
  "tslib": "^2.8.1",
70
71
  "ws": "^8.19.0",
@@ -76,5 +77,8 @@
76
77
  "tsx": "^4.21.0",
77
78
  "typescript": "^5.9.3",
78
79
  "vitest": "^4.0.18"
80
+ },
81
+ "overrides": {
82
+ "lodash": "^4.18.0"
79
83
  }
80
84
  }
package/skill/SKILL.md CHANGED
@@ -4,7 +4,7 @@ description: Bitcoin L1 wallet for agents - check balances, send BTC, manage UTX
4
4
  license: MIT
5
5
  metadata:
6
6
  author: aibtcdev
7
- version: 1.49.0 # x-release-please-version
7
+ version: 1.50.0 # x-release-please-version
8
8
  npm: "@aibtc/mcp-server"
9
9
  github: https://github.com/aibtcdev/aibtc-mcp-server
10
10
  ---
@@ -1,128 +0,0 @@
1
- /**
2
- * Ordinal Indexer Service
3
- *
4
- * Combines Hiro Ordinals API with mempool.space to classify UTXOs:
5
- * - Cardinal: Safe to spend (no inscriptions)
6
- * - Ordinal: Contains inscriptions (must not spend accidentally)
7
- *
8
- * Uses free APIs:
9
- * - Hiro Ordinals API: https://api.hiro.so/ordinals/v1/inscriptions?address={address}
10
- * - mempool.space API: via MempoolApi service
11
- */
12
- import type { Network } from "../config/networks.js";
13
- import type { UTXO } from "./mempool-api.js";
14
- /**
15
- * Inscription data from Hiro Ordinals API
16
- */
17
- export interface Inscription {
18
- /**
19
- * Inscription ID (txid + inscription number)
20
- */
21
- id: string;
22
- /**
23
- * Inscription number (global ordinal)
24
- */
25
- number: number;
26
- /**
27
- * Content type (e.g., "text/plain", "image/png")
28
- */
29
- content_type: string;
30
- /**
31
- * Content length in bytes
32
- */
33
- content_length: number;
34
- /**
35
- * Genesis transaction ID
36
- */
37
- genesis_tx_id: string;
38
- /**
39
- * Genesis block height
40
- */
41
- genesis_block_height: number;
42
- /**
43
- * Genesis block hash
44
- */
45
- genesis_block_hash: string;
46
- /**
47
- * Genesis timestamp
48
- */
49
- genesis_timestamp: number;
50
- /**
51
- * Location of the inscription (txid:vout:offset)
52
- */
53
- location: string;
54
- /**
55
- * Output reference (txid:vout) - this is what we use to match UTXOs
56
- */
57
- output: string;
58
- /**
59
- * Current owner address
60
- */
61
- address: string;
62
- /**
63
- * Offset within the output
64
- */
65
- offset: string;
66
- }
67
- /**
68
- * Classified UTXOs
69
- */
70
- export interface ClassifiedUtxos {
71
- /**
72
- * Cardinal UTXOs - safe to spend (no inscriptions)
73
- */
74
- cardinal: UTXO[];
75
- /**
76
- * Ordinal UTXOs - contain inscriptions (do not spend)
77
- */
78
- ordinal: UTXO[];
79
- }
80
- /**
81
- * Ordinal Indexer Service
82
- *
83
- * Note: Hiro Ordinals API only supports mainnet. On testnet, all UTXOs are
84
- * treated as cardinal (safe to spend) since we cannot index inscriptions.
85
- */
86
- export declare class OrdinalIndexer {
87
- private readonly network;
88
- private readonly mempoolApi;
89
- private readonly isMainnet;
90
- constructor(network: Network);
91
- /**
92
- * Get all inscriptions for a Bitcoin address
93
- *
94
- * @param address - Bitcoin address (bc1... for mainnet)
95
- * @returns Array of inscriptions with their output references (empty on testnet)
96
- * @throws Error if API request fails
97
- */
98
- getInscriptionsForAddress(address: string): Promise<Inscription[]>;
99
- /**
100
- * Classify UTXOs into cardinal (safe to spend) and ordinal (contains inscriptions)
101
- *
102
- * @param address - Bitcoin address
103
- * @returns Classified UTXOs
104
- * @throws Error if API requests fail
105
- */
106
- classifyUtxos(address: string): Promise<ClassifiedUtxos>;
107
- /**
108
- * Get cardinal UTXOs (safe to spend - no inscriptions)
109
- *
110
- * @param address - Bitcoin address
111
- * @returns Cardinal UTXOs only
112
- * @throws Error if API requests fail
113
- */
114
- getCardinalUtxos(address: string): Promise<UTXO[]>;
115
- /**
116
- * Get ordinal UTXOs (contain inscriptions - do not spend)
117
- *
118
- * @param address - Bitcoin address
119
- * @returns Ordinal UTXOs only
120
- * @throws Error if API requests fail
121
- */
122
- getOrdinalUtxos(address: string): Promise<UTXO[]>;
123
- }
124
- /**
125
- * Create an ordinal indexer for the given network
126
- */
127
- export declare function createOrdinalIndexer(network: Network): OrdinalIndexer;
128
- //# sourceMappingURL=ordinal-indexer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ordinal-indexer.d.ts","sourceRoot":"","sources":["../../src/services/ordinal-indexer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAI7C;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAYD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjB;;OAEG;IACH,OAAO,EAAE,IAAI,EAAE,CAAC;CACjB;AAID;;;;;GAKG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAU;gBAExB,OAAO,EAAE,OAAO;IAM5B;;;;;;OAMG;IACG,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IA8CxE;;;;;;OAMG;IACG,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IA6B9D;;;;;;OAMG;IACG,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAKxD;;;;;;OAMG;IACG,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;CAKxD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,cAAc,CAErE"}
@@ -1,126 +0,0 @@
1
- /**
2
- * Ordinal Indexer Service
3
- *
4
- * Combines Hiro Ordinals API with mempool.space to classify UTXOs:
5
- * - Cardinal: Safe to spend (no inscriptions)
6
- * - Ordinal: Contains inscriptions (must not spend accidentally)
7
- *
8
- * Uses free APIs:
9
- * - Hiro Ordinals API: https://api.hiro.so/ordinals/v1/inscriptions?address={address}
10
- * - mempool.space API: via MempoolApi service
11
- */
12
- import { MempoolApi } from "./mempool-api.js";
13
- import { HiroApiRateLimitError } from "./hiro-api.js";
14
- const HIRO_ORDINALS_API_URL = "https://api.hiro.so/ordinals/v1";
15
- /**
16
- * Ordinal Indexer Service
17
- *
18
- * Note: Hiro Ordinals API only supports mainnet. On testnet, all UTXOs are
19
- * treated as cardinal (safe to spend) since we cannot index inscriptions.
20
- */
21
- export class OrdinalIndexer {
22
- network;
23
- mempoolApi;
24
- isMainnet;
25
- constructor(network) {
26
- this.network = network;
27
- this.mempoolApi = new MempoolApi(network);
28
- this.isMainnet = network === "mainnet";
29
- }
30
- /**
31
- * Get all inscriptions for a Bitcoin address
32
- *
33
- * @param address - Bitcoin address (bc1... for mainnet)
34
- * @returns Array of inscriptions with their output references (empty on testnet)
35
- * @throws Error if API request fails
36
- */
37
- async getInscriptionsForAddress(address) {
38
- // Testnet: return empty (Hiro API doesn't index testnet inscriptions)
39
- if (!this.isMainnet) {
40
- return [];
41
- }
42
- const allInscriptions = [];
43
- let offset = 0;
44
- const limit = 60; // Hiro API default/max per page
45
- // Fetch all pages
46
- while (true) {
47
- const url = `${HIRO_ORDINALS_API_URL}/inscriptions?address=${address}&limit=${limit}&offset=${offset}`;
48
- const response = await fetch(url);
49
- if (!response.ok) {
50
- if (response.status === 429) {
51
- const retryAfter = response.headers.get("Retry-After");
52
- const retryAfterSeconds = retryAfter && !isNaN(parseInt(retryAfter, 10)) ? parseInt(retryAfter, 10) : 60;
53
- throw new HiroApiRateLimitError(`Hiro Ordinals API rate limit exceeded. Retry after ${retryAfterSeconds}s`, retryAfterSeconds);
54
- }
55
- const errorText = await response.text().catch(() => "Unknown error");
56
- throw new Error(`Failed to fetch inscriptions from Hiro API: ${response.status} ${response.statusText} - ${errorText}`);
57
- }
58
- const data = (await response.json());
59
- allInscriptions.push(...data.results);
60
- // Check if we've fetched all inscriptions
61
- if (offset + data.results.length >= data.total) {
62
- break;
63
- }
64
- offset += limit;
65
- }
66
- return allInscriptions;
67
- }
68
- /**
69
- * Classify UTXOs into cardinal (safe to spend) and ordinal (contains inscriptions)
70
- *
71
- * @param address - Bitcoin address
72
- * @returns Classified UTXOs
73
- * @throws Error if API requests fail
74
- */
75
- async classifyUtxos(address) {
76
- // Fetch UTXOs from mempool.space
77
- const utxos = await this.mempoolApi.getUtxos(address);
78
- // Fetch inscriptions from Hiro Ordinals API
79
- const inscriptions = await this.getInscriptionsForAddress(address);
80
- // Build set of outputs that contain inscriptions
81
- // Hiro API returns "output" field as "txid:vout"
82
- const ordinalOutputs = new Set(inscriptions.map((inscription) => inscription.output));
83
- // Classify UTXOs
84
- const cardinal = [];
85
- const ordinal = [];
86
- for (const utxo of utxos) {
87
- const outputRef = `${utxo.txid}:${utxo.vout}`;
88
- if (ordinalOutputs.has(outputRef)) {
89
- ordinal.push(utxo);
90
- }
91
- else {
92
- cardinal.push(utxo);
93
- }
94
- }
95
- return { cardinal, ordinal };
96
- }
97
- /**
98
- * Get cardinal UTXOs (safe to spend - no inscriptions)
99
- *
100
- * @param address - Bitcoin address
101
- * @returns Cardinal UTXOs only
102
- * @throws Error if API requests fail
103
- */
104
- async getCardinalUtxos(address) {
105
- const classified = await this.classifyUtxos(address);
106
- return classified.cardinal;
107
- }
108
- /**
109
- * Get ordinal UTXOs (contain inscriptions - do not spend)
110
- *
111
- * @param address - Bitcoin address
112
- * @returns Ordinal UTXOs only
113
- * @throws Error if API requests fail
114
- */
115
- async getOrdinalUtxos(address) {
116
- const classified = await this.classifyUtxos(address);
117
- return classified.ordinal;
118
- }
119
- }
120
- /**
121
- * Create an ordinal indexer for the given network
122
- */
123
- export function createOrdinalIndexer(network) {
124
- return new OrdinalIndexer(network);
125
- }
126
- //# sourceMappingURL=ordinal-indexer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ordinal-indexer.js","sourceRoot":"","sources":["../../src/services/ordinal-indexer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAgFtD,MAAM,qBA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