@ldgr/mcp 0.1.1 → 0.1.2

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/README.md CHANGED
@@ -13,7 +13,7 @@ A remote MCP connection cannot install software, access local files, unlock a wa
13
13
  Node.js 20.19 or newer is required. Install the package, then create or import a wallet in your own terminal:
14
14
 
15
15
  ```sh
16
- npm install --global @ldgr/mcp@0.1.1
16
+ npm install --global @ldgr/mcp@0.1.2
17
17
  ldgr-mcp wallet create --testnet
18
18
  # Or: ldgr-mcp wallet import --testnet
19
19
  ldgr-mcp wallet list
@@ -73,6 +73,10 @@ Restart the MCP process after upgrading; a running process keeps its loaded SDK.
73
73
 
74
74
  All monetary values are decimal strings in display units. Tool schemas reject unknown fields and credentials. Reads use fixed official network endpoints, verify ledger identity, reject redirects, time out after 15 seconds per fetch and bound responses to 1 MiB. Metadata from the ledger remains untrusted text. A `NOT_FOUND` response does not establish that an earlier transaction submission failed.
75
75
 
76
+ Version 0.1.2 preserves HTTP 404 as `NOT_FOUND` for escrow reads as well as the
77
+ other contract templates. Other HTTP failures and malformed successful responses
78
+ remain `OPERATION_FAILED`; upstream response bodies are never exposed in errors.
79
+
76
80
  ## Prepare, review and approve
77
81
 
78
82
  `claim_faucet_drop` takes an explicit `network` and public `address`. With local
package/dist/cli.js CHANGED
@@ -42,7 +42,7 @@ import { getMcpWalletInfo, saveMcpRequest, validateMcpRequest } from "@ldgr/cli/
42
42
 
43
43
  // src/index.ts
44
44
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
45
- import { LdgrClientError } from "@ldgr/client";
45
+ import { LdgrClientError as LdgrClientError2 } from "@ldgr/client";
46
46
  import { assertAssetDecimals, assertAssetDisplayName, normalizeAssetTicker, parseDecimalAmount as parseDecimalAmount2 } from "@ldgr/protocol";
47
47
  import { z as z2 } from "zod";
48
48
 
@@ -90,7 +90,7 @@ function assertFaucetUrl(value) {
90
90
  }
91
91
 
92
92
  // src/transport.ts
93
- import { createLdgrClient } from "@ldgr/client";
93
+ import { createLdgrClient, LdgrClientError } from "@ldgr/client";
94
94
  var MAX_RESPONSE_BYTES = 1048576;
95
95
  function readTransport(request = globalThis.fetch.bind(globalThis)) {
96
96
  return async (input) => {
@@ -147,7 +147,7 @@ async function checkedClient(network, request) {
147
147
  async function readPublicPath(network, path, request) {
148
148
  const response = await request(`${network === "mainnet" ? "https://ldgr.ltd" : "https://tst.ldgr.ltd"}${path}`);
149
149
  if (!response.ok)
150
- throw new Error("LDGR read failed");
150
+ throw new LdgrClientError(response.status, "LDGR read failed", undefined);
151
151
  const data = await response.json();
152
152
  if (!data || typeof data !== "object" || Array.isArray(data))
153
153
  throw new Error("Invalid response");
@@ -163,7 +163,7 @@ class AssetMismatchError extends Error {
163
163
  class WalletNetworkMismatchError extends Error {
164
164
  }
165
165
  function createLdgrMcpServer(options = {}) {
166
- const server = new McpServer({ name: "ldgr", version: "0.1.1" }, { instructions: INSTRUCTIONS });
166
+ const server = new McpServer({ name: "ldgr", version: "0.1.2" }, { instructions: INSTRUCTIONS });
167
167
  const request = readTransport(options.fetch);
168
168
  const now = options.now ?? Date.now;
169
169
  const envelope = (network, source, data) => ({ network, source, data });
@@ -174,7 +174,7 @@ function createLdgrMcpServer(options = {}) {
174
174
  const data = await run(args);
175
175
  return { content: [{ type: "text", text: JSON.stringify(data) }] };
176
176
  } catch (error) {
177
- const code = error instanceof WalletNetworkMismatchError ? "WALLET_NETWORK_MISMATCH" : error instanceof AssetMismatchError ? "ASSET_MISMATCH" : error instanceof LdgrClientError && error.status === 404 ? "NOT_FOUND" : "OPERATION_FAILED";
177
+ const code = error instanceof WalletNetworkMismatchError ? "WALLET_NETWORK_MISMATCH" : error instanceof AssetMismatchError ? "ASSET_MISMATCH" : error instanceof LdgrClientError2 && error.status === 404 ? "NOT_FOUND" : "OPERATION_FAILED";
178
178
  const message = code === "NOT_FOUND" ? "The requested record was not found on the explicit network. This is not proof that a previous submission failed; reconcile an uncertain submission before retrying." : code === "ASSET_MISMATCH" ? "The record does not match the requested exact asset code." : code === "WALLET_NETWORK_MISMATCH" ? "The selected CLI wallet uses a different network. The network argument checks the selected wallet; it does not switch wallets or networks. Request the selected network, or run wallet list and wallet select in your own terminal to choose a wallet on the intended network. Keep any custom --wallet path consistent. No wallet settings were changed." : "LDGR operation could not complete. Check the explicit network, address, asset, values and service availability. No transaction was signed or submitted.";
179
179
  return { isError: true, content: [{ type: "text", text: JSON.stringify({ error: { code, message } }) }] };
180
180
  }
@@ -312,7 +312,7 @@ function createLdgrMcpServer(options = {}) {
312
312
  }, false);
313
313
  tool("wallet_setup_instructions", "Explain user-run CLI wallet installation, creation/import and MCP connection. This tool cannot install software or access local files.", { network: networkSchema }, async (args) => ({
314
314
  network: args.network,
315
- install: "npm install --global @ldgr/mcp@0.1.1",
315
+ install: "npm install --global @ldgr/mcp@0.1.2",
316
316
  node: ">=20.19.0",
317
317
  create: `ldgr-mcp wallet create${args.network === "testnet" ? " --testnet" : ""}`,
318
318
  import: `ldgr-mcp wallet import${args.network === "testnet" ? " --testnet" : ""}`,
@@ -390,7 +390,7 @@ async function startLdgrMcpStdio(options = {}) {
390
390
  }
391
391
 
392
392
  // src/cli.ts
393
- var HELP = `LDGR MCP 0.1.1
393
+ var HELP = `LDGR MCP 0.1.2
394
394
 
395
395
  ldgr-mcp Start local MCP over stdio
396
396
  ldgr-mcp --wallet <path> Start MCP with a selected wallet store
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/index.ts
2
2
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
- import { LdgrClientError } from "@ldgr/client";
3
+ import { LdgrClientError as LdgrClientError2 } from "@ldgr/client";
4
4
  import { assertAssetDecimals, assertAssetDisplayName, normalizeAssetTicker, parseDecimalAmount as parseDecimalAmount2 } from "@ldgr/protocol";
5
5
  import { z as z2 } from "zod";
6
6
 
@@ -48,7 +48,7 @@ function assertFaucetUrl(value) {
48
48
  }
49
49
 
50
50
  // src/transport.ts
51
- import { createLdgrClient } from "@ldgr/client";
51
+ import { createLdgrClient, LdgrClientError } from "@ldgr/client";
52
52
  var MAX_RESPONSE_BYTES = 1048576;
53
53
  function readTransport(request = globalThis.fetch.bind(globalThis)) {
54
54
  return async (input) => {
@@ -105,7 +105,7 @@ async function checkedClient(network, request) {
105
105
  async function readPublicPath(network, path, request) {
106
106
  const response = await request(`${network === "mainnet" ? "https://ldgr.ltd" : "https://tst.ldgr.ltd"}${path}`);
107
107
  if (!response.ok)
108
- throw new Error("LDGR read failed");
108
+ throw new LdgrClientError(response.status, "LDGR read failed", undefined);
109
109
  const data = await response.json();
110
110
  if (!data || typeof data !== "object" || Array.isArray(data))
111
111
  throw new Error("Invalid response");
@@ -121,7 +121,7 @@ class AssetMismatchError extends Error {
121
121
  class WalletNetworkMismatchError extends Error {
122
122
  }
123
123
  function createLdgrMcpServer(options = {}) {
124
- const server = new McpServer({ name: "ldgr", version: "0.1.1" }, { instructions: INSTRUCTIONS });
124
+ const server = new McpServer({ name: "ldgr", version: "0.1.2" }, { instructions: INSTRUCTIONS });
125
125
  const request = readTransport(options.fetch);
126
126
  const now = options.now ?? Date.now;
127
127
  const envelope = (network, source, data) => ({ network, source, data });
@@ -132,7 +132,7 @@ function createLdgrMcpServer(options = {}) {
132
132
  const data = await run(args);
133
133
  return { content: [{ type: "text", text: JSON.stringify(data) }] };
134
134
  } catch (error) {
135
- const code = error instanceof WalletNetworkMismatchError ? "WALLET_NETWORK_MISMATCH" : error instanceof AssetMismatchError ? "ASSET_MISMATCH" : error instanceof LdgrClientError && error.status === 404 ? "NOT_FOUND" : "OPERATION_FAILED";
135
+ const code = error instanceof WalletNetworkMismatchError ? "WALLET_NETWORK_MISMATCH" : error instanceof AssetMismatchError ? "ASSET_MISMATCH" : error instanceof LdgrClientError2 && error.status === 404 ? "NOT_FOUND" : "OPERATION_FAILED";
136
136
  const message = code === "NOT_FOUND" ? "The requested record was not found on the explicit network. This is not proof that a previous submission failed; reconcile an uncertain submission before retrying." : code === "ASSET_MISMATCH" ? "The record does not match the requested exact asset code." : code === "WALLET_NETWORK_MISMATCH" ? "The selected CLI wallet uses a different network. The network argument checks the selected wallet; it does not switch wallets or networks. Request the selected network, or run wallet list and wallet select in your own terminal to choose a wallet on the intended network. Keep any custom --wallet path consistent. No wallet settings were changed." : "LDGR operation could not complete. Check the explicit network, address, asset, values and service availability. No transaction was signed or submitted.";
137
137
  return { isError: true, content: [{ type: "text", text: JSON.stringify({ error: { code, message } }) }] };
138
138
  }
@@ -270,7 +270,7 @@ function createLdgrMcpServer(options = {}) {
270
270
  }, false);
271
271
  tool("wallet_setup_instructions", "Explain user-run CLI wallet installation, creation/import and MCP connection. This tool cannot install software or access local files.", { network: networkSchema }, async (args) => ({
272
272
  network: args.network,
273
- install: "npm install --global @ldgr/mcp@0.1.1",
273
+ install: "npm install --global @ldgr/mcp@0.1.2",
274
274
  node: ">=20.19.0",
275
275
  create: `ldgr-mcp wallet create${args.network === "testnet" ? " --testnet" : ""}`,
276
276
  import: `ldgr-mcp wallet import${args.network === "testnet" ? " --testnet" : ""}`,
package/dist/stdio.js CHANGED
@@ -4,7 +4,7 @@ import { getMcpWalletInfo, saveMcpRequest, validateMcpRequest } from "@ldgr/cli/
4
4
 
5
5
  // src/index.ts
6
6
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
7
- import { LdgrClientError } from "@ldgr/client";
7
+ import { LdgrClientError as LdgrClientError2 } from "@ldgr/client";
8
8
  import { assertAssetDecimals, assertAssetDisplayName, normalizeAssetTicker, parseDecimalAmount as parseDecimalAmount2 } from "@ldgr/protocol";
9
9
  import { z as z2 } from "zod";
10
10
 
@@ -52,7 +52,7 @@ function assertFaucetUrl(value) {
52
52
  }
53
53
 
54
54
  // src/transport.ts
55
- import { createLdgrClient } from "@ldgr/client";
55
+ import { createLdgrClient, LdgrClientError } from "@ldgr/client";
56
56
  var MAX_RESPONSE_BYTES = 1048576;
57
57
  function readTransport(request = globalThis.fetch.bind(globalThis)) {
58
58
  return async (input) => {
@@ -109,7 +109,7 @@ async function checkedClient(network, request) {
109
109
  async function readPublicPath(network, path, request) {
110
110
  const response = await request(`${network === "mainnet" ? "https://ldgr.ltd" : "https://tst.ldgr.ltd"}${path}`);
111
111
  if (!response.ok)
112
- throw new Error("LDGR read failed");
112
+ throw new LdgrClientError(response.status, "LDGR read failed", undefined);
113
113
  const data = await response.json();
114
114
  if (!data || typeof data !== "object" || Array.isArray(data))
115
115
  throw new Error("Invalid response");
@@ -125,7 +125,7 @@ class AssetMismatchError extends Error {
125
125
  class WalletNetworkMismatchError extends Error {
126
126
  }
127
127
  function createLdgrMcpServer(options = {}) {
128
- const server = new McpServer({ name: "ldgr", version: "0.1.1" }, { instructions: INSTRUCTIONS });
128
+ const server = new McpServer({ name: "ldgr", version: "0.1.2" }, { instructions: INSTRUCTIONS });
129
129
  const request = readTransport(options.fetch);
130
130
  const now = options.now ?? Date.now;
131
131
  const envelope = (network, source, data) => ({ network, source, data });
@@ -136,7 +136,7 @@ function createLdgrMcpServer(options = {}) {
136
136
  const data = await run(args);
137
137
  return { content: [{ type: "text", text: JSON.stringify(data) }] };
138
138
  } catch (error) {
139
- const code = error instanceof WalletNetworkMismatchError ? "WALLET_NETWORK_MISMATCH" : error instanceof AssetMismatchError ? "ASSET_MISMATCH" : error instanceof LdgrClientError && error.status === 404 ? "NOT_FOUND" : "OPERATION_FAILED";
139
+ const code = error instanceof WalletNetworkMismatchError ? "WALLET_NETWORK_MISMATCH" : error instanceof AssetMismatchError ? "ASSET_MISMATCH" : error instanceof LdgrClientError2 && error.status === 404 ? "NOT_FOUND" : "OPERATION_FAILED";
140
140
  const message = code === "NOT_FOUND" ? "The requested record was not found on the explicit network. This is not proof that a previous submission failed; reconcile an uncertain submission before retrying." : code === "ASSET_MISMATCH" ? "The record does not match the requested exact asset code." : code === "WALLET_NETWORK_MISMATCH" ? "The selected CLI wallet uses a different network. The network argument checks the selected wallet; it does not switch wallets or networks. Request the selected network, or run wallet list and wallet select in your own terminal to choose a wallet on the intended network. Keep any custom --wallet path consistent. No wallet settings were changed." : "LDGR operation could not complete. Check the explicit network, address, asset, values and service availability. No transaction was signed or submitted.";
141
141
  return { isError: true, content: [{ type: "text", text: JSON.stringify({ error: { code, message } }) }] };
142
142
  }
@@ -274,7 +274,7 @@ function createLdgrMcpServer(options = {}) {
274
274
  }, false);
275
275
  tool("wallet_setup_instructions", "Explain user-run CLI wallet installation, creation/import and MCP connection. This tool cannot install software or access local files.", { network: networkSchema }, async (args) => ({
276
276
  network: args.network,
277
- install: "npm install --global @ldgr/mcp@0.1.1",
277
+ install: "npm install --global @ldgr/mcp@0.1.2",
278
278
  node: ">=20.19.0",
279
279
  create: `ldgr-mcp wallet create${args.network === "testnet" ? " --testnet" : ""}`,
280
280
  import: `ldgr-mcp wallet import${args.network === "testnet" ? " --testnet" : ""}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ldgr/mcp",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {