Skip to main content
Glama

search_memos

Search for memos using text queries and filters for creator, tags, and visibility to find specific notes in your knowledge base.

Instructions

Search for memos with optional filters.

Args: query: Text to search for in memo content creator_id: Filter by creator user ID tag: Filter by tag name visibility: Filter by visibility (PUBLIC, PROTECTED, PRIVATE) limit: Maximum number of results to return (default: 10) offset: Number of results to skip (default: 0)

Returns: JSON string containing the list of matching memos

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryNo
creator_idNo
tagNo
visibilityNo
limitNo
offsetNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'search_memos' tool. It constructs filters from input parameters, makes an HTTP GET request to the Memos API, processes the response, and returns a formatted JSON string of matching memos. Includes error handling.
    @mcp.tool()
    async def search_memos(
        query: Optional[str] = None,
        creator_id: Optional[int] = None,
        tag: Optional[str] = None,
        visibility: Optional[str] = None,
        limit: int = 10,
        offset: int = 0
    ) -> str:
        """
        Search for memos with optional filters.
        
        Args:
            query: Text to search for in memo content
            creator_id: Filter by creator user ID
            tag: Filter by tag name
            visibility: Filter by visibility (PUBLIC, PROTECTED, PRIVATE)
            limit: Maximum number of results to return (default: 10)
            offset: Number of results to skip (default: 0)
        
        Returns:
            JSON string containing the list of matching memos
        """
        # Build filter expression
        filters = []
        
        if creator_id is not None:
            filters.append(f"creator_id == {creator_id}")
        
        if query:
            # Escape quotes in query
            escaped_query = query.replace('"', '\\"')
            filters.append(f'content.contains("{escaped_query}")')
        
        if tag:
            escaped_tag = tag.replace('"', '\\"')
            filters.append(f'tag in ["{escaped_tag}"]')
        
        if visibility:
            filters.append(f'visibility == "{visibility.upper()}"')
        
        # Combine filters with AND operator
        filter_str = " && ".join(filters) if filters else ""
        
        # Build request parameters
        params = {
            "pageSize": limit,
        }
        
        if filter_str:
            params["filter"] = filter_str
        
        # Calculate page token for pagination
        if offset > 0:
            # For simplicity, we'll use offset/limit approach
            # In production, you'd want to use proper page tokens
            page = offset // limit
            if page > 0:
                params["pageToken"] = f"offset={offset}"
        
        try:
            async with httpx.AsyncClient() as client:
                response = await client.get(
                    f"{MEMOS_BASE_URL}/api/v1/memos",
                    params=params,
                    headers=get_headers(),
                    timeout=30.0
                )
                response.raise_for_status()
                data = response.json()
                
                # Format the response nicely
                memos = data.get("memos", [])
                result = {
                    "count": len(memos),
                    "memos": [
                        {
                            "name": memo.get("name"),
                            "uid": memo.get("uid"),
                            "creator": memo.get("creator"),
                            "content": memo.get("content"),
                            "visibility": memo.get("visibility"),
                            "pinned": memo.get("pinned", False),
                            "createTime": memo.get("createTime"),
                            "updateTime": memo.get("updateTime"),
                            "displayTime": memo.get("displayTime"),
                        }
                        for memo in memos
                    ],
                    "nextPageToken": data.get("nextPageToken", "")
                }
                
                return str(result)
                
        except httpx.HTTPError as e:
            return f"Error searching memos: {str(e)}"
        except Exception as e:
            return f"Unexpected error: {str(e)}"
  • Helper utility function used by search_memos (and other tools) to generate HTTP headers for authenticated API requests to the Memos server.
    def get_headers() -> dict:
        """Get headers for API requests including authentication"""
        headers = {
            "Content-Type": "application/json",
        }
        if MEMOS_API_TOKEN:
            headers["Authorization"] = f"Bearer {MEMOS_API_TOKEN}"
        return headers
  • server.py:31-31 (registration)
    The @mcp.tool() decorator registers the search_memos function as an MCP tool.
    @mcp.tool()
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the tool 'Returns: JSON string containing the list of matching memos,' which adds some context about the output format. However, it doesn't describe critical behaviors like whether this is a read-only operation (implied but not stated), pagination details beyond limit/offset, error handling, or any rate limits. For a search tool with zero annotation coverage, this leaves significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and well-structured. It starts with a clear purpose statement, followed by a bulleted 'Args' section that efficiently documents each parameter, and ends with a 'Returns' statement. Every sentence earns its place by providing essential information without redundancy or fluff, making it easy to scan and understand.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (a search tool with 6 parameters), no annotations, and an output schema (implied by 'Has output schema: true'), the description is mostly complete. It thoroughly documents parameters and mentions the return format. However, it lacks behavioral details like read-only confirmation, error cases, or pagination context, which would be helpful despite the output schema. For a tool with no annotations, it does well but has minor gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, so the description must fully compensate. It provides detailed semantics for all 6 parameters in the 'Args' section, explaining what each filter does (e.g., 'query: Text to search for in memo content,' 'visibility: Filter by visibility (PUBLIC, PROTECTED, PRIVATE)'), including default values. This adds substantial meaning beyond the bare schema, fully documenting parameter purposes and usage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as 'Search for memos with optional filters,' which is a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'get_memo' (which likely retrieves a single memo by ID) or 'create_memo'/'update_memo' (which are write operations). The purpose is clear but lacks sibling differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to prefer 'search_memos' over 'get_memo' (e.g., for filtering vs. direct ID lookup) or any prerequisites like authentication needs. There's only implied usage based on the tool name and parameters, with no explicit context or exclusions provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/Red5d/memos_mcp'

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