Search Memos
searchMemosSearch memos by keyword, date range, or category to locate specific entries.
Instructions
Search memos by keyword and date range
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "searchMemos"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| categoryId | No | ||
| end | No | End date for the search range use ISO 8601 format. ex: 2020-02-01T00:00:00+09:00 | |
| query | No | ||
| start | No | Start date for the search range use ISO 8601 format. ex: 2020-01-01T00:00:00+09:00 |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| memos | Yes |
Implementation Reference
- src/repository/memos.ts:64-87 (handler)The core handler logic. Filters memos by query string (title/content), categoryId, and date range (start/end).
export const searchMemos = async (params: SearchMemosParams) => { const { categoryId, end, query, start } = params await db.read() return db.data.memos.filter((memo) => { if (query && !memo.content.includes(query) && !memo.title.includes(query)) { return false } if (categoryId && memo.categoryId !== categoryId) { return false } const updatedAt = new Date(memo.updatedAt).getTime() if (start && updatedAt < start.getTime()) { return false } if (end && updatedAt > end.getTime()) { return false } return true }) } - src/schemas/memos.ts:42-69 (schema)Zod schema for searchMemos input: optional query (string), categoryId (string), start/end (ISO 8601 datetime strings transformed to Date).
export const SearchMemosSchema = z.object({ categoryId: z.string().optional(), end: z .string() .datetime({ message: "Invalid date format. Please use ISO 8601 format.", offset: true, }) .transform((date) => new Date(date)) .optional() .describe( "End date for the search range use ISO 8601 format. ex: 2020-02-01T00:00:00+09:00", ), query: z.string().optional(), start: z .string() .datetime({ message: "Invalid date format. Please use ISO 8601 format.", offset: true, }) .transform((date) => new Date(date)) .optional() .describe( "Start date for the search range use ISO 8601 format. ex: 2020-01-01T00:00:00+09:00", ), }) export type SearchMemosParams = z.infer<typeof SearchMemosSchema> - src/server/tools.ts:142-157 (registration)Registration of the 'searchMemos' tool on the MCP server via registerTool(), with schema references and handler.
server.registerTool( "searchMemos", { description: "Search memos by keyword and date range", inputSchema: SearchMemosSchema.shape, outputSchema: { memos: z.array(MemoSchema) }, title: "Search Memos", }, async (params) => { const memos = await searchMemos(params) return { content: [{ text: JSON.stringify(memos), type: "text" }], structuredContent: { memos }, } }, )