permamind
Version:
An MCP server that provides an immortal memory layer for AI agents and clients
33 lines (32 loc) • 1.1 kB
JavaScript
import { z } from "zod";
import { hubService } from "../../../services/HubService.js";
import { ToolCommand } from "../../core/index.js";
import { MEMORY_KIND } from "../constants.js";
const searchMemoriesSchema = z
.object({
search: z.string().describe("keyword or content"),
})
.strict();
export class SearchMemoriesCommand extends ToolCommand {
metadata = {
description: "Search stored memories by keywords or content",
name: "searchMemory",
openWorldHint: false,
readOnlyHint: true,
title: "Search Memory",
};
parametersSchema = searchMemoriesSchema;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
constructor(_context) {
super();
}
async execute(args, context) {
try {
const memories = await hubService.search(context.hubId, args.search, MEMORY_KIND);
return JSON.stringify(memories);
}
catch (error) {
throw new Error(`Failed to search memories: ${error instanceof Error ? error.message : "Unknown error"}`);
}
}
}