Skip to main content
Glama

read_memory

Access and retrieve content from specific memory files on the Serena MCP server. Use this tool to extract relevant information based on the memory file name, ensuring efficient task completion without redundant reads.

Instructions

Read the content of a memory file. This tool should only be used if the information is relevant to the current task. You can infer whether the information is relevant from the memory file name. You should not read the same memory file multiple times in the same conversation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
max_answer_charsNo
memory_file_nameYes

Implementation Reference

  • The handler implementation for the 'read_memory' tool. The ReadMemoryTool.apply method loads and returns the content of the specified memory file from the project's memories_manager.
    class ReadMemoryTool(Tool): """ Reads the memory with the given name from Serena's project-specific memory store. """ def apply(self, memory_file_name: str, max_answer_chars: int = -1) -> str: """ Read the content of a memory file. This tool should only be used if the information is relevant to the current task. You can infer whether the information is relevant from the memory file name. You should not read the same memory file multiple times in the same conversation. """ return self.memories_manager.load_memory(memory_file_name)
  • ToolRegistry.__init__ automatically discovers all Tool subclasses in the serena.tools package (including ReadMemoryTool) and registers them by their derived name (e.g., 'read_memory' from 'ReadMemoryTool').
    def __init__(self) -> None: self._tool_dict: dict[str, RegisteredTool] = {} 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)
  • The get_name_from_cls method derives the tool name 'read_memory' from the class name 'ReadMemoryTool' during registration.
    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
  • SerenaAgent instantiates all registered tools, including ReadMemoryTool, using ToolRegistry.get_all_tool_classes().
    self._all_tools: dict[type[Tool], Tool] = {tool_class: tool_class(self) for tool_class in ToolRegistry().get_all_tool_classes()}

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