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