Skip to main content
Glama

list_memories

Retrieve available memory entries from the Serena MCP server to access stored information for coding tasks.

Instructions

List available memories. Any memory can be read using the read_memory tool.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Implementation of the MCP tool handler for "list_memories". The apply method retrieves the list of memories from the project's memories_manager and serializes it to 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())
  • Core utility method in MemoriesManager that lists the names of memory files (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()]
  • Class method that derives the MCP tool name 'list_memories' from the class name 'ListMemoriesTool'.
    @classmethod
    def get_name_from_cls(cls) -> str:
        name = cls.__name__
        if name.endswith("Tool"):
            name = name[:-4]
        # convert to snake_case
        name = "".join(["_" + c.lower() if c.isupper() else c for c in name]).lstrip("_")
        return name
  • ToolRegistry discovers all Tool subclasses (including ListMemoriesTool) via iter_subclasses and registers them by name.
    for cls in iter_subclasses(Tool):
        if not any(cls.__module__.startswith(pkg) for pkg in tool_packages):
            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)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/oraios/serena'

If you have feedback or need assistance with the MCP directory API, please join our Discord server