search_memo
Search for specific memos in the MCP Server Memos database using keywords to locate relevant content efficiently.
Instructions
Search for memos
Input Schema
TableJSON 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-108 (handler)The core handler function for the 'search_memo' tool. It validates the input arguments using SearchMemoRequest, constructs a ListMemosRequest to query the memo service with the keyword filter, joins the memo contents, formats the result, and returns it 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-39 (schema)Pydantic BaseModel defining the input schema for the search_memo tool, specifying the required 'key_word' parameter.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:160-164 (registration)Registration of the 'search_memo' tool in the list_tools() function, providing name, description, and input schema.types.Tool( name=MemosTools.SEARCH_MEMO, description="Search for memos", inputSchema=SearchMemoRequest.model_json_schema(), ),
- src/mcp_server_memos/server.py:185-186 (registration)Dispatch logic in the call_tool() handler that routes calls to 'search_memo' to the tool adapter's search_memo method.if name == MemosTools.SEARCH_MEMO: return await tool_adapter.search_memo(args)
- src/mcp_server_memos/server.py:13-18 (helper)Enum defining the tool names, including SEARCH_MEMO = 'search_memo', used for registration and dispatching.class MemosTools(str, Enum): LIST_MEMO_TAGS = "list_memo_tags" SEARCH_MEMO = "search_memo" CREATE_MEMO = "create_memo" GET_MEMO = "get_memo"