@nextnext/mcp-server 0.1.0 → 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.
Files changed (2) hide show
  1. package/dist/index.js +50 -38
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -51217,8 +51217,8 @@ function generateEncryptionKey() {
51217
51217
  var init_encryption = __esm(() => {
51218
51218
  if (import.meta.url === `file://${process.argv[1]}`) {
51219
51219
  if (process.argv.includes("--generate-key")) {
51220
- console.log("Generated SERVER_ENCRYPTION_KEY:");
51221
- console.log(generateEncryptionKey());
51220
+ console.error("Generated SERVER_ENCRYPTION_KEY:");
51221
+ console.error(generateEncryptionKey());
51222
51222
  }
51223
51223
  }
51224
51224
  });
@@ -54223,19 +54223,19 @@ function initRedis() {
54223
54223
  if (url3 && token) {
54224
54224
  redisClient = new Redis2({ url: url3, token });
54225
54225
  useRedis = true;
54226
- console.log("[Redis] Connected via Upstash REST API");
54226
+ console.error("[Redis] Connected via Upstash REST API");
54227
54227
  return true;
54228
54228
  } else if (url3) {
54229
54229
  try {
54230
54230
  redisClient = Redis2.fromEnv();
54231
54231
  useRedis = true;
54232
- console.log("[Redis] Connected via REDIS_URL");
54232
+ console.error("[Redis] Connected via REDIS_URL");
54233
54233
  return true;
54234
54234
  } catch (e7) {
54235
54235
  console.warn("[Redis] Failed to connect, falling back to in-memory storage");
54236
54236
  }
54237
54237
  }
54238
- console.log("[Redis] Not configured, using in-memory storage (data will not survive restarts)");
54238
+ console.error("[Redis] Not configured, using in-memory storage (data will not survive restarts)");
54239
54239
  return false;
54240
54240
  }
54241
54241
  async function getIdentity(pubkey) {
@@ -54313,7 +54313,7 @@ async function markSessionInitialized(sessionId) {
54313
54313
  if (useRedis && redisClient) {
54314
54314
  try {
54315
54315
  await redisClient.set(`${SESSION_PREFIX}${sessionId}`, state, { ex: SESSION_TTL });
54316
- console.log(`[Redis] Session ${sessionId.slice(0, 8)} marked as initialized`);
54316
+ console.error(`[Redis] Session ${sessionId.slice(0, 8)} marked as initialized`);
54317
54317
  } catch (error2) {
54318
54318
  console.error("[Redis] Error marking session initialized:", error2);
54319
54319
  }
@@ -54381,7 +54381,7 @@ __export(exports_context, {
54381
54381
  import { AsyncLocalStorage } from "async_hooks";
54382
54382
  function runWithSessionContext(sessionId, fn) {
54383
54383
  const cachedIdentity = sessionIdentityCache.get(sessionId);
54384
- console.log(`[runWithSessionContext] Session: ${sessionId.slice(0, 8)}, cached identity: ${cachedIdentity ? cachedIdentity.npub?.slice(0, 16) || "yes" : "none"}, cache size: ${sessionIdentityCache.size}`);
54384
+ console.error(`[runWithSessionContext] Session: ${sessionId.slice(0, 8)}, cached identity: ${cachedIdentity ? cachedIdentity.npub?.slice(0, 16) || "yes" : "none"}, cache size: ${sessionIdentityCache.size}`);
54385
54385
  return sessionStorage.run({ sessionId, identity: cachedIdentity }, fn);
54386
54386
  }
54387
54387
  function getCurrentSessionId() {
@@ -54401,7 +54401,7 @@ async function authenticateSession(encryptedKey) {
54401
54401
  let privateKeyHex;
54402
54402
  try {
54403
54403
  privateKeyHex = decryptNostrKey(encryptedKey);
54404
- console.log(`[Session] Decrypted key length: ${privateKeyHex.length}, first4: ${privateKeyHex.slice(0, 4)}`);
54404
+ console.error(`[Session] Decrypted key length: ${privateKeyHex.length}, first4: ${privateKeyHex.slice(0, 4)}`);
54405
54405
  } catch (error2) {
54406
54406
  console.error(`[Session] Decryption failed:`, error2);
54407
54407
  throw new Error(`Decryption failed: ${error2.message}. The key may have been created with a different server or is corrupted.`);
@@ -54413,10 +54413,10 @@ async function authenticateSession(encryptedKey) {
54413
54413
  let pubkey;
54414
54414
  let npub;
54415
54415
  try {
54416
- console.log(`[Session] Calling getPublicKey with hex (length=${privateKeyHex.length})`);
54416
+ console.error(`[Session] Calling getPublicKey with hex (length=${privateKeyHex.length})`);
54417
54417
  pubkey = getPublicKey2(privateKeyHex);
54418
54418
  npub = nip19_exports.npubEncode(pubkey);
54419
- console.log(`[Session] Derived pubkey: ${pubkey.slice(0, 8)}...`);
54419
+ console.error(`[Session] Derived pubkey: ${pubkey.slice(0, 8)}...`);
54420
54420
  } catch (error2) {
54421
54421
  console.error(`[Session] getPublicKey failed:`, error2);
54422
54422
  throw new Error(`Failed to derive public key: ${error2.message}`);
@@ -54427,14 +54427,14 @@ async function authenticateSession(encryptedKey) {
54427
54427
  npub
54428
54428
  };
54429
54429
  sessionIdentityCache.set(sessionId, identity);
54430
- console.log(`[authenticateSession] Cached identity for session ${sessionId.slice(0, 8)}, cache size now: ${sessionIdentityCache.size}`);
54430
+ console.error(`[authenticateSession] Cached identity for session ${sessionId.slice(0, 8)}, cache size now: ${sessionIdentityCache.size}`);
54431
54431
  const store = sessionStorage.getStore();
54432
54432
  if (store) {
54433
54433
  store.identity = identity;
54434
54434
  }
54435
54435
  const existingIdentity = await getIdentity(pubkey);
54436
54436
  if (existingIdentity) {
54437
- console.log(`[SessionContext] Returning user: ${npub.slice(0, 16)}... (sessions: ${existingIdentity.stats?.totalSessions || 0})`);
54437
+ console.error(`[SessionContext] Returning user: ${npub.slice(0, 16)}... (sessions: ${existingIdentity.stats?.totalSessions || 0})`);
54438
54438
  await recordNewSession(pubkey);
54439
54439
  } else {
54440
54440
  const newIdentity = {
@@ -54448,9 +54448,9 @@ async function authenticateSession(encryptedKey) {
54448
54448
  }
54449
54449
  };
54450
54450
  await saveIdentity(pubkey, newIdentity);
54451
- console.log(`[SessionContext] New user registered: ${npub.slice(0, 16)}...`);
54451
+ console.error(`[SessionContext] New user registered: ${npub.slice(0, 16)}...`);
54452
54452
  }
54453
- console.log(`[SessionContext] Session ${sessionId.slice(0, 8)}... authenticated as ${npub.slice(0, 16)}...`);
54453
+ console.error(`[SessionContext] Session ${sessionId.slice(0, 8)}... authenticated as ${npub.slice(0, 16)}...`);
54454
54454
  return identity;
54455
54455
  }
54456
54456
  function clearSessionIdentity() {
@@ -102131,7 +102131,7 @@ function getSupabaseClient() {
102131
102131
  supabase = createClient2(url3, key, {
102132
102132
  auth: { persistSession: false }
102133
102133
  });
102134
- console.log("[Supabase] Connected to:", url3);
102134
+ console.error("[Supabase] Connected to:", url3);
102135
102135
  return supabase;
102136
102136
  }
102137
102137
  function isSupabaseConfigured() {
@@ -102230,10 +102230,10 @@ async function createBurnerWallet(label, nostrPubkey) {
102230
102230
  label,
102231
102231
  nostrPubkey
102232
102232
  });
102233
- console.log(`[BurnerWallet] Created (Supabase): ${wallet.address} (${label || "unlabeled"}) ${nostrPubkey ? `linked to ${nostrPubkey.slice(0, 16)}...` : ""}`);
102233
+ console.error(`[BurnerWallet] Created (Supabase): ${wallet.address} (${label || "unlabeled"}) ${nostrPubkey ? `linked to ${nostrPubkey.slice(0, 16)}...` : ""}`);
102234
102234
  } else {
102235
102235
  memoryWallets.set(wallet.id, wallet);
102236
- console.log(`[BurnerWallet] Created (memory): ${wallet.address} (${label || "unlabeled"})`);
102236
+ console.error(`[BurnerWallet] Created (memory): ${wallet.address} (${label || "unlabeled"})`);
102237
102237
  }
102238
102238
  return wallet;
102239
102239
  }
@@ -102415,7 +102415,7 @@ async function createPaymentAuthorization(walletId, recipientAddress, amountUsdc
102415
102415
  r,
102416
102416
  s: s3
102417
102417
  };
102418
- console.log(`[x402Payer] Created authorization: ${amountUsdc} USDC from ${account.address} to ${recipientAddress}`);
102418
+ console.error(`[x402Payer] Created authorization: ${amountUsdc} USDC from ${account.address} to ${recipientAddress}`);
102419
102419
  return {
102420
102420
  success: true,
102421
102421
  authorization,
@@ -102442,13 +102442,13 @@ function deriveEvmAddress(nostrPrivateKeyHex) {
102442
102442
  }
102443
102443
  function getCurrentIdentity() {
102444
102444
  const sessionId = getCurrentSessionId();
102445
- console.log(`[getCurrentIdentity] Session: ${sessionId?.slice(0, 8) || "none"}`);
102445
+ console.error(`[getCurrentIdentity] Session: ${sessionId?.slice(0, 8) || "none"}`);
102446
102446
  const sessionIdentity = getSessionIdentity();
102447
102447
  if (sessionIdentity) {
102448
- console.log(`[getCurrentIdentity] Found identity: ${sessionIdentity.npub?.slice(0, 16) || sessionIdentity.pubkey.slice(0, 8)}`);
102448
+ console.error(`[getCurrentIdentity] Found identity: ${sessionIdentity.npub?.slice(0, 16) || sessionIdentity.pubkey.slice(0, 8)}`);
102449
102449
  return { pubkey: sessionIdentity.pubkey, privateKeyHex: sessionIdentity.privateKeyHex };
102450
102450
  }
102451
- console.log(`[getCurrentIdentity] No session identity found`);
102451
+ console.error(`[getCurrentIdentity] No session identity found`);
102452
102452
  const privateKeyHex = process.env.NOSTR_PRIVATE_KEY_HEX;
102453
102453
  if (privateKeyHex) {
102454
102454
  try {
@@ -102684,7 +102684,7 @@ var identityTools = [
102684
102684
 
102685
102685
  // src/tools/wallet-tools.ts
102686
102686
  function identityRequiredResponse(toolName) {
102687
- console.log(`[${toolName}] No identity found - session may have expired or instance restarted`);
102687
+ console.error(`[${toolName}] No identity found - session may have expired or instance restarted`);
102688
102688
  return {
102689
102689
  content: [{
102690
102690
  type: "text",
@@ -102947,7 +102947,7 @@ var nostrClient = null;
102947
102947
  function getNostrClient() {
102948
102948
  if (!nostrClient) {
102949
102949
  nostrClient = new NostrClient({ relayUrl: RELAY_URL });
102950
- console.log(`[NostrTools] Initialized with pubkey: ${nostrClient.getPublicKey()}`);
102950
+ console.error(`[NostrTools] Initialized with pubkey: ${nostrClient.getPublicKey()}`);
102951
102951
  }
102952
102952
  return nostrClient;
102953
102953
  }
@@ -102984,13 +102984,13 @@ var postIntentTool = {
102984
102984
  const { authenticateSession: authenticateSession2 } = await Promise.resolve().then(() => (init_context(), exports_context));
102985
102985
  await authenticateSession2(args.encryptedKey);
102986
102986
  identity = getCurrentIdentity();
102987
- console.log(`[post_intent] Auto-authenticated with provided key`);
102987
+ console.error(`[post_intent] Auto-authenticated with provided key`);
102988
102988
  } catch (error2) {
102989
102989
  console.error(`[post_intent] Auto-auth failed: ${error2.message}`);
102990
102990
  }
102991
102991
  }
102992
102992
  if (!identity) {
102993
- console.log(`[post_intent] No identity found - session may have expired or instance restarted`);
102993
+ console.error(`[post_intent] No identity found - session may have expired or instance restarted`);
102994
102994
  return {
102995
102995
  content: [{
102996
102996
  type: "text",
@@ -103049,7 +103049,7 @@ var postIntentTool = {
103049
103049
  };
103050
103050
  } catch (error2) {
103051
103051
  console.error("[postIntent] Error routing through Factory-API:", error2);
103052
- console.log("[postIntent] Falling back to direct relay post...");
103052
+ console.error("[postIntent] Falling back to direct relay post...");
103053
103053
  const client = getNostrClient();
103054
103054
  const result = await client.postIntent(intent);
103055
103055
  return {
@@ -107612,7 +107612,7 @@ class ConfigManager {
107612
107612
  }
107613
107613
  const enabledServers = config3.servers.filter((s3) => s3.enabled);
107614
107614
  if (enabledServers.length === 0) {
107615
- console.log("[ConfigManager] No external servers configured. Native tools will be available.");
107615
+ console.error("[ConfigManager] No external servers configured. Native tools will be available.");
107616
107616
  }
107617
107617
  }
107618
107618
  }
@@ -109081,7 +109081,8 @@ async function main() {
109081
109081
  }
109082
109082
  const port = portArg ? parseInt(portArg, 10) : 8000;
109083
109083
  const logLevel = process.env.MCP_LOG_LEVEL || "info";
109084
- const logger = createLogger(logLevel);
109084
+ const useStderrOnly = mode === "stdio";
109085
+ const logger = createLogger(logLevel, useStderrOnly);
109085
109086
  const redisEnabled = initRedis();
109086
109087
  if (redisEnabled) {
109087
109088
  logger.info("Redis session persistence enabled");
@@ -109126,7 +109127,7 @@ async function main() {
109126
109127
  logger.info("Loading configuration from environment variables");
109127
109128
  config3 = configManager.loadFromEnv();
109128
109129
  }
109129
- const configLogger = createLogger(config3.settings?.logLevel || "info");
109130
+ const configLogger = createLogger(config3.settings?.logLevel || "info", useStderrOnly);
109130
109131
  const gateway = new GatewayServer(config3, configLogger);
109131
109132
  await gateway.start();
109132
109133
  const transport = new StdioServerTransport;
@@ -109158,9 +109159,10 @@ async function main() {
109158
109159
  process.exit(1);
109159
109160
  }
109160
109161
  }
109161
- function createLogger(logLevel) {
109162
+ function createLogger(logLevel, useStderrOnly = false) {
109162
109163
  const levels = ["error", "warn", "info", "debug"];
109163
109164
  const levelIndex = levels.indexOf(logLevel.toLowerCase());
109165
+ const output4 = useStderrOnly ? (...args) => console.error(...args) : console.log.bind(console);
109164
109166
  return {
109165
109167
  error: (...args) => {
109166
109168
  if (levelIndex >= 0)
@@ -109168,23 +109170,33 @@ function createLogger(logLevel) {
109168
109170
  },
109169
109171
  warn: (...args) => {
109170
109172
  if (levelIndex >= 1)
109171
- console.warn("[WARN]", ...args);
109173
+ console.error("[WARN]", ...args);
109172
109174
  },
109173
109175
  info: (...args) => {
109174
- if (levelIndex >= 2)
109175
- console.info("[INFO]", ...args);
109176
+ if (levelIndex >= 2) {
109177
+ if (useStderrOnly) {
109178
+ console.error("[INFO]", ...args);
109179
+ } else {
109180
+ console.info("[INFO]", ...args);
109181
+ }
109182
+ }
109176
109183
  },
109177
109184
  log: (...args) => {
109178
- if (levelIndex >= 2)
109179
- console.log("[INFO]", ...args);
109185
+ if (levelIndex >= 2) {
109186
+ if (useStderrOnly) {
109187
+ console.error("[INFO]", ...args);
109188
+ } else {
109189
+ console.error("[INFO]", ...args);
109190
+ }
109191
+ }
109180
109192
  },
109181
109193
  debug: (...args) => {
109182
109194
  if (levelIndex >= 3)
109183
- console.debug("[DEBUG]", ...args);
109195
+ console.error("[DEBUG]", ...args);
109184
109196
  },
109185
109197
  trace: (...args) => {
109186
109198
  if (levelIndex >= 3)
109187
- console.trace("[TRACE]", ...args);
109199
+ console.error("[TRACE]", ...args);
109188
109200
  },
109189
109201
  assert: console.assert,
109190
109202
  clear: console.clear,
@@ -109205,7 +109217,7 @@ function createLogger(logLevel) {
109205
109217
  };
109206
109218
  }
109207
109219
  function showHelp() {
109208
- console.log(`
109220
+ console.error(`
109209
109221
  NextNext MCP Server - Sovereign Shopping Agent
109210
109222
 
109211
109223
  USAGE:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextnext/mcp-server",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "NextNext MCP Server - A sovereign shopping agent with crypto wallet integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",