chia-explorer 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.
Files changed (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +81 -0
  3. package/dist/chia/amounts.d.ts +11 -0
  4. package/dist/chia/amounts.js +52 -0
  5. package/dist/chia/amounts.js.map +1 -0
  6. package/dist/chia/bech32.d.ts +8 -0
  7. package/dist/chia/bech32.js +31 -0
  8. package/dist/chia/bech32.js.map +1 -0
  9. package/dist/chia/coin-name.d.ts +15 -0
  10. package/dist/chia/coin-name.js +40 -0
  11. package/dist/chia/coin-name.js.map +1 -0
  12. package/dist/chia/hex.d.ts +4 -0
  13. package/dist/chia/hex.js +26 -0
  14. package/dist/chia/hex.js.map +1 -0
  15. package/dist/coinset/agent.d.ts +7 -0
  16. package/dist/coinset/agent.js +26 -0
  17. package/dist/coinset/agent.js.map +1 -0
  18. package/dist/coinset/pagination.d.ts +24 -0
  19. package/dist/coinset/pagination.js +42 -0
  20. package/dist/coinset/pagination.js.map +1 -0
  21. package/dist/index.d.ts +2 -0
  22. package/dist/index.js +12 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/network.d.ts +6 -0
  25. package/dist/network.js +18 -0
  26. package/dist/network.js.map +1 -0
  27. package/dist/prompts/address-summary.d.ts +2 -0
  28. package/dist/prompts/address-summary.js +34 -0
  29. package/dist/prompts/address-summary.js.map +1 -0
  30. package/dist/prompts/block-summary.d.ts +2 -0
  31. package/dist/prompts/block-summary.js +50 -0
  32. package/dist/prompts/block-summary.js.map +1 -0
  33. package/dist/prompts/network-status.d.ts +2 -0
  34. package/dist/prompts/network-status.js +29 -0
  35. package/dist/prompts/network-status.js.map +1 -0
  36. package/dist/schemas/common.d.ts +7 -0
  37. package/dist/schemas/common.js +24 -0
  38. package/dist/schemas/common.js.map +1 -0
  39. package/dist/server.d.ts +2 -0
  40. package/dist/server.js +42 -0
  41. package/dist/server.js.map +1 -0
  42. package/dist/tools/addresses/address-to-puzzle-hash.d.ts +2 -0
  43. package/dist/tools/addresses/address-to-puzzle-hash.js +21 -0
  44. package/dist/tools/addresses/address-to-puzzle-hash.js.map +1 -0
  45. package/dist/tools/addresses/puzzle-hash-to-address.d.ts +2 -0
  46. package/dist/tools/addresses/puzzle-hash-to-address.js +24 -0
  47. package/dist/tools/addresses/puzzle-hash-to-address.js.map +1 -0
  48. package/dist/tools/blockchain/count-block-transactions.d.ts +2 -0
  49. package/dist/tools/blockchain/count-block-transactions.js +52 -0
  50. package/dist/tools/blockchain/count-block-transactions.js.map +1 -0
  51. package/dist/tools/blockchain/get-block-by-hash.d.ts +2 -0
  52. package/dist/tools/blockchain/get-block-by-hash.js +27 -0
  53. package/dist/tools/blockchain/get-block-by-hash.js.map +1 -0
  54. package/dist/tools/blockchain/get-block-by-height.d.ts +2 -0
  55. package/dist/tools/blockchain/get-block-by-height.js +28 -0
  56. package/dist/tools/blockchain/get-block-by-height.js.map +1 -0
  57. package/dist/tools/blockchain/get-blockchain-state.d.ts +2 -0
  58. package/dist/tools/blockchain/get-blockchain-state.js +37 -0
  59. package/dist/tools/blockchain/get-blockchain-state.js.map +1 -0
  60. package/dist/tools/blockchain/get-netspace.d.ts +2 -0
  61. package/dist/tools/blockchain/get-netspace.js +26 -0
  62. package/dist/tools/blockchain/get-netspace.js.map +1 -0
  63. package/dist/tools/blockchain/get-peak-height.d.ts +2 -0
  64. package/dist/tools/blockchain/get-peak-height.js +23 -0
  65. package/dist/tools/blockchain/get-peak-height.js.map +1 -0
  66. package/dist/tools/coins/calculate-coin-name.d.ts +2 -0
  67. package/dist/tools/coins/calculate-coin-name.js +28 -0
  68. package/dist/tools/coins/calculate-coin-name.js.map +1 -0
  69. package/dist/tools/coins/get-balance.d.ts +2 -0
  70. package/dist/tools/coins/get-balance.js +35 -0
  71. package/dist/tools/coins/get-balance.js.map +1 -0
  72. package/dist/tools/coins/get-coin-by-name.d.ts +2 -0
  73. package/dist/tools/coins/get-coin-by-name.js +34 -0
  74. package/dist/tools/coins/get-coin-by-name.js.map +1 -0
  75. package/dist/tools/coins/get-coin-records-by-puzzle-hash.d.ts +2 -0
  76. package/dist/tools/coins/get-coin-records-by-puzzle-hash.js +36 -0
  77. package/dist/tools/coins/get-coin-records-by-puzzle-hash.js.map +1 -0
  78. package/dist/tools/shared/address-input.d.ts +12 -0
  79. package/dist/tools/shared/address-input.js +26 -0
  80. package/dist/tools/shared/address-input.js.map +1 -0
  81. package/dist/tools/shared/response.d.ts +3 -0
  82. package/dist/tools/shared/response.js +16 -0
  83. package/dist/tools/shared/response.js.map +1 -0
  84. package/dist/version.d.ts +1 -0
  85. package/dist/version.js +7 -0
  86. package/dist/version.js.map +1 -0
  87. package/package.json +75 -0
@@ -0,0 +1,26 @@
1
+ import { addressToPuzzleHash, looksLikeAddress, puzzleHashToAddress } from '../../chia/bech32.js';
2
+ import { isHex32, stripHexPrefix } from '../../chia/hex.js';
3
+ import { DEFAULT_NETWORK } from '../../network.js';
4
+ /**
5
+ * Resolve a user-supplied "address or puzzle hash" into a normalized form.
6
+ * If both an address and a network argument are provided and they disagree,
7
+ * throws — better to surface the mismatch than silently pick one.
8
+ */
9
+ export function resolveAddressOrPuzzleHash(input, requestedNetwork) {
10
+ const trimmed = input.trim();
11
+ if (looksLikeAddress(trimmed)) {
12
+ const { puzzleHash, network: detected } = addressToPuzzleHash(trimmed);
13
+ if (requestedNetwork && requestedNetwork !== detected) {
14
+ throw new Error(`network mismatch: address belongs to ${detected} but network argument was ${requestedNetwork}`);
15
+ }
16
+ return { puzzleHash, address: trimmed.toLowerCase(), network: detected };
17
+ }
18
+ if (isHex32(trimmed)) {
19
+ const network = requestedNetwork ?? DEFAULT_NETWORK;
20
+ const puzzleHash = stripHexPrefix(trimmed).toLowerCase();
21
+ const address = puzzleHashToAddress(puzzleHash, network);
22
+ return { puzzleHash, address, network };
23
+ }
24
+ throw new Error(`input is neither a valid xch/txch address nor a 32-byte hex puzzle hash: ${trimmed.slice(0, 40)}`);
25
+ }
26
+ //# sourceMappingURL=address-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address-input.js","sourceRoot":"","sources":["../../../src/tools/shared/address-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAClG,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAW,MAAM,kBAAkB,CAAC;AAQ5D;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CACxC,KAAa,EACb,gBAAqC;IAErC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,IAAI,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC;QAC9B,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;QACvE,IAAI,gBAAgB,IAAI,gBAAgB,KAAK,QAAQ,EAAE,CAAC;YACtD,MAAM,IAAI,KAAK,CACb,wCAAwC,QAAQ,6BAA6B,gBAAgB,EAAE,CAChG,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;IAC3E,CAAC;IACD,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACrB,MAAM,OAAO,GAAG,gBAAgB,IAAI,eAAe,CAAC;QACpD,MAAM,UAAU,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;QACzD,MAAM,OAAO,GAAG,mBAAmB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACzD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;IAC1C,CAAC;IACD,MAAM,IAAI,KAAK,CACb,4EAA4E,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CACnG,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
2
+ export declare function jsonText(data: unknown): CallToolResult;
3
+ export declare function errorText(err: unknown): CallToolResult;
@@ -0,0 +1,16 @@
1
+ function bigIntReplacer(_key, value) {
2
+ return typeof value === 'bigint' ? value.toString() : value;
3
+ }
4
+ export function jsonText(data) {
5
+ return {
6
+ content: [{ type: 'text', text: JSON.stringify(data, bigIntReplacer) }],
7
+ };
8
+ }
9
+ export function errorText(err) {
10
+ const message = err instanceof Error ? err.message : String(err);
11
+ return {
12
+ content: [{ type: 'text', text: JSON.stringify({ error: message }) }],
13
+ isError: true,
14
+ };
15
+ }
16
+ //# sourceMappingURL=response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.js","sourceRoot":"","sources":["../../../src/tools/shared/response.ts"],"names":[],"mappings":"AAEA,SAAS,cAAc,CAAC,IAAY,EAAE,KAAc;IAClD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAa;IACpC,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,cAAc,CAAC,EAAE,CAAC;KACxE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,GAAY;IACpC,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACjE,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;QACrE,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const VERSION: string;
@@ -0,0 +1,7 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { dirname, join } from 'node:path';
4
+ const pkgPath = join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json');
5
+ const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
6
+ export const VERSION = pkg.version;
7
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;AACpF,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAwB,CAAC;AAE7E,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC"}
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "chia-explorer",
3
+ "version": "0.1.0",
4
+ "description": "MCP server that answers questions about the Chia blockchain via the public coinset.org API",
5
+ "mcpName": "io.github.Spacetime-Technology/chia-explorer",
6
+ "type": "module",
7
+ "license": "MIT",
8
+ "author": "Spacetime Technology",
9
+ "keywords": [
10
+ "mcp",
11
+ "model-context-protocol",
12
+ "mcp-server",
13
+ "chia",
14
+ "blockchain",
15
+ "coinset",
16
+ "xch",
17
+ "claude",
18
+ "claude-desktop"
19
+ ],
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/Spacetime-Technology/chia-explorer.git"
23
+ },
24
+ "homepage": "https://github.com/Spacetime-Technology/chia-explorer#readme",
25
+ "bugs": {
26
+ "url": "https://github.com/Spacetime-Technology/chia-explorer/issues"
27
+ },
28
+ "bin": {
29
+ "chia-explorer": "./dist/index.js"
30
+ },
31
+ "files": [
32
+ "dist/**/*",
33
+ "README.md",
34
+ "LICENSE"
35
+ ],
36
+ "scripts": {
37
+ "prepare": "husky",
38
+ "preversion": "bash scripts/prerelease.sh",
39
+ "version": "node scripts/sync-server-json.js && git add server.json",
40
+ "postversion": "git push --follow-tags origin main",
41
+ "prepublishOnly": "npm run build",
42
+ "build": "tsc -p tsconfig.build.json && chmod +x dist/index.js",
43
+ "dev": "tsx src/index.ts",
44
+ "start": "node dist/index.js",
45
+ "test": "vitest run",
46
+ "test:watch": "vitest",
47
+ "typecheck": "tsc --noEmit",
48
+ "lint": "eslint src tests",
49
+ "format": "prettier --write src tests",
50
+ "format:check": "prettier --check src tests"
51
+ },
52
+ "dependencies": {
53
+ "@modelcontextprotocol/sdk": "^1.12.0",
54
+ "@scure/base": "^1.1.9",
55
+ "chia-agent": "^14.3.1",
56
+ "zod": "^3.24.0"
57
+ },
58
+ "devDependencies": {
59
+ "@eslint/js": "^10.0.1",
60
+ "@types/node": "^22.0.0",
61
+ "@typescript-eslint/eslint-plugin": "^8.59.3",
62
+ "@typescript-eslint/parser": "^8.59.3",
63
+ "eslint": "^10.4.0",
64
+ "eslint-config-prettier": "^10.1.8",
65
+ "husky": "^9.1.7",
66
+ "prettier": "^3.8.3",
67
+ "tsx": "^4.19.0",
68
+ "typescript": "^5.7.0",
69
+ "typescript-eslint": "^8.59.3",
70
+ "vitest": "^3.2.0"
71
+ },
72
+ "engines": {
73
+ "node": ">=20.0.0"
74
+ }
75
+ }