list_memories
Retrieve and manage available memories in the Serena MCP server. Use this tool to list stored memories, enabling efficient access and integration with the read_memory function for detailed analysis or processing.
Instructions
List available memories. Any memory can be read using the read_memory tool.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/serena/tools/memory_tools.py:43-52 (handler)The handler function for the "list_memories" MCP tool. It serializes the list of memory names from the project's memories_manager into JSON.class ListMemoriesTool(Tool): """ Lists memories in Serena's project-specific memory store. """ def apply(self) -> str: """ List available memories. Any memory can be read using the `read_memory` tool. """ return self._to_json(self.memories_manager.list_memories())
- src/serena/project.py:48-49 (helper)The core helper method in MemoriesManager that lists all memory file names (stripping .md extension) in the project's memories directory.def list_memories(self) -> list[str]: return [f.name.replace(".md", "") for f in self._memory_dir.iterdir() if f.is_file()]
- src/serena/agent.py:214-244 (registration)Instantiates all discovered Tool subclasses (including ListMemoriesTool) as instances in the agent's _all_tools dict during SerenaAgent initialization.self._all_tools: dict[type[Tool], Tool] = {tool_class: tool_class(self) for tool_class in ToolRegistry().get_all_tool_classes()} tool_names = [tool.get_name_from_cls() for tool in self._all_tools.values()] # If GUI log window is enabled, set the tool names for highlighting if self._gui_log_viewer is not None: self._gui_log_viewer.set_tool_names(tool_names) token_count_estimator = RegisteredTokenCountEstimator[self.serena_config.token_count_estimator] log.info(f"Will record tool usage statistics with token count estimator: {token_count_estimator.name}.") self._tool_usage_stats = ToolUsageStats(token_count_estimator) # log fundamental information log.info(f"Starting Serena server (version={serena_version()}, process id={os.getpid()}, parent process id={os.getppid()})") log.info("Configuration file: %s", self.serena_config.config_file_path) log.info("Available projects: {}".format(", ".join(self.serena_config.project_names))) log.info(f"Loaded tools ({len(self._all_tools)}): {', '.join([tool.get_name_from_cls() for tool in self._all_tools.values()])}") self._check_shell_settings() # determine the base toolset defining the set of exposed tools (which e.g. the MCP shall see), # limited by the Serena config, the context (which is fixed for the session) and JetBrains mode tool_inclusion_definitions: list[ToolInclusionDefinition] = [self.serena_config, self._context] if self._context.single_project: tool_inclusion_definitions.extend(self._single_project_context_tool_inclusion_definitions(project)) if self.serena_config.jetbrains: tool_inclusion_definitions.append(SerenaAgentMode.from_name_internal("jetbrains")) self._base_tool_set = ToolSet.default().apply(*tool_inclusion_definitions) self._exposed_tools = AvailableTools([t for t in self._all_tools.values() if self._base_tool_set.includes_name(t.get_name())]) log.info(f"Number of exposed tools: {len(self._exposed_tools)}")
- src/serena/tools/tools_base.py:362-369 (registration)ToolRegistry discovers and registers all Tool subclasses from serena.tools modules, mapping 'ListMemoriesTool' to 'list_memories'.for cls in iter_subclasses(Tool): if not cls.__module__.startswith("serena.tools"): continue is_optional = issubclass(cls, ToolMarkerOptional) name = cls.get_name_from_cls() if name in self._tool_dict: raise ValueError(f"Duplicate tool name found: {name}. Tool classes must have unique names.") self._tool_dict[name] = RegisteredTool(tool_class=cls, is_optional=is_optional, tool_name=name)