permamind
Version:
An MCP server that provides an immortal memory layer for AI agents and clients
43 lines (42 loc) • 1.42 kB
JavaScript
import { z } from "zod";
import { getCurrentUserState } from "../../../server.js";
import { ToolCommand } from "../../core/index.js";
export class GetUserPublicKeyCommand extends ToolCommand {
context;
metadata = {
description: "Get the current user's public key (wallet address)",
name: "getUserPublicKey",
openWorldHint: false,
readOnlyHint: true,
title: "Get User Public Key",
};
parametersSchema = z.object({});
constructor(context) {
super();
this.context = context;
}
async execute() {
try {
const { initializationComplete, publicKey } = getCurrentUserState();
// Check if initialization is still in progress
if (!initializationComplete ||
!publicKey ||
publicKey === "initializing") {
return JSON.stringify({
error: "Wallet is still initializing. Please wait a moment and try again.",
success: false,
});
}
return JSON.stringify({
publicKey,
success: true,
});
}
catch (error) {
return JSON.stringify({
error: `Failed to get user public key: ${error instanceof Error ? error.message : "Unknown error"}`,
success: false,
});
}
}
}