search_memo
Search memo content using a keyword to retrieve relevant memos.
Instructions
Search for memos
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key_word | Yes | The key words to search for in the memo content. |
Implementation Reference
- src/mcp_server_memos/server.py:95-107 (handler)The async handler function `search_memo` in `MemoServiceToolAdapter`. It validates input using `SearchMemoRequest`, builds a `ListMemosRequest` with a filter for row_status 'NORMAL' and content_search matching the keyword, calls the gRPC `list_memos` API, and returns the concatenated memo contents as `TextContent`.
async def search_memo(self, args: dict) -> list[types.TextContent]: try: params = SearchMemoRequest.model_validate(args) except Exception as e: raise McpError(types.INVALID_PARAMS, str(e)) req = memos_api_v1.ListMemosRequest( filter=f"row_status == 'NORMAL' && content_search == ['{params.key_word}']" ) res = await self.memo_service.list_memos(list_memos_request=req) content = ", ".join([memo.content for memo in res.memos]) content = f"Search result:\n{content}" return [types.TextContent(type="text", text=content)] - src/mcp_server_memos/server.py:29-37 (schema)`SearchMemoRequest` Pydantic model defining the input schema. It has a single required field `key_word` (str) with a description.
class SearchMemoRequest(BaseModel): """Request to search memo""" key_word: Annotated[ str, Field( description="""The key words to search for in the memo content.""", ), ] - src/mcp_server_memos/server.py:13-18 (registration)`MemosTools` enum defining `SEARCH_MEMO = 'search_memo'` as the tool name constant.
class MemosTools(str, Enum): LIST_MEMO_TAGS = "list_memo_tags" SEARCH_MEMO = "search_memo" CREATE_MEMO = "create_memo" GET_MEMO = "get_memo" - src/mcp_server_memos/server.py:157-164 (registration)Tool registration in `list_tools()`: exposes the `search_memo` tool with its name, description, and input schema.
@server.list_tools() async def list_tools() -> list[types.Tool]: return [ types.Tool( name=MemosTools.SEARCH_MEMO, description="Search for memos", inputSchema=SearchMemoRequest.model_json_schema(), ), - src/mcp_server_memos/server.py:182-186 (registration)Tool dispatch in `call_tool()`: routes incoming tool calls with name `search_memo` to `tool_adapter.search_memo(args)`.
# search @server.call_tool() async def call_tool(name: str, args: dict) -> list[types.TextContent]: if name == MemosTools.SEARCH_MEMO: return await tool_adapter.search_memo(args)