@ecadlabs/tezosx-mcp 1.0.5 → 1.0.7

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/dist/api.js CHANGED
@@ -67,17 +67,18 @@ export function createApiRouter(liveConfig) {
67
67
  const publicKey = await signer.publicKey();
68
68
  const address = await signer.publicKeyHash();
69
69
  log(`Returning existing pending keypair: ${address}`);
70
- res.json({ address, publicKey });
70
+ res.json({ address, publicKey, secretKey: existingPending });
71
71
  return;
72
72
  }
73
73
  const keypair = await generateKeypair();
74
74
  // Save to pending slot (active key stays untouched)
75
75
  savePendingKey(keypair.secretKey);
76
76
  log(`Generated and saved new pending keypair: ${keypair.address}`);
77
- // Return only public info — private key stays on server
77
+ // Return keypair info — private key is also persisted server-side
78
78
  res.json({
79
79
  address: keypair.address,
80
80
  publicKey: keypair.publicKey,
81
+ secretKey: keypair.secretKey,
81
82
  });
82
83
  }
83
84
  catch (error) {
package/dist/index.js CHANGED
@@ -31,27 +31,26 @@ function isValidPrivateKey(key) {
31
31
  const log = (msg) => console.error(`[tezosx-mcp] ${msg}`);
32
32
  const init = async () => {
33
33
  log('Starting server...');
34
- // Determine network
35
- const networkName = (process.env.TEZOS_NETWORK || 'mainnet');
34
+ // Try to load config: env vars first, then persistent store
35
+ const stored = loadConfig();
36
+ const privateKey = process.env.SPENDING_PRIVATE_KEY?.trim() || stored.spendingPrivateKey?.trim();
37
+ const spendingContract = process.env.SPENDING_CONTRACT?.trim() || stored.spendingContract?.trim();
38
+ const storedNetwork = stored.network && stored.network in NETWORKS ? stored.network : undefined;
39
+ // Determine network: env var > stored config > mainnet
40
+ const networkName = (process.env.TEZOS_NETWORK || storedNetwork || 'mainnet');
36
41
  if (!(networkName in NETWORKS)) {
37
42
  throw new ReferenceError(`Invalid network: ${networkName}. Valid options: ${Object.keys(NETWORKS).join(', ')}`);
38
43
  }
39
44
  log(`Network: ${networkName}`);
40
45
  // Create shared mutable config
41
46
  const liveConfig = createLiveConfig(networkName);
42
- // Try to load config: persistent store first, then env vars
43
- const stored = loadConfig();
44
- const privateKey = stored.spendingPrivateKey?.trim() || process.env.SPENDING_PRIVATE_KEY?.trim();
45
- const spendingContract = stored.spendingContract?.trim() || process.env.SPENDING_CONTRACT?.trim();
46
- const storedNetwork = stored.network && stored.network in NETWORKS ? stored.network : undefined;
47
- const configNetwork = storedNetwork || networkName;
48
47
  if (privateKey && spendingContract) {
49
48
  if (!isValidPrivateKey(privateKey)) {
50
49
  log('Warning: Invalid private key format. Must start with edsk, spsk, or p2sk. Wallet not configured.');
51
50
  }
52
51
  else {
53
52
  try {
54
- const spendingAddress = await configureLiveConfig(liveConfig, privateKey, spendingContract, configNetwork);
53
+ const spendingAddress = await configureLiveConfig(liveConfig, privateKey, spendingContract, networkName);
55
54
  log(`Wallet configured: ${spendingAddress}`);
56
55
  if (stored.spendingPrivateKey) {
57
56
  log('Config loaded from persistent store');