Skip to main content
Glama
108yen
by 108yen

searchMemos

Search memos by keyword and date range to quickly find specific notes stored in the memo-mcp server database.

Instructions

Search memos by keyword and date range

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryIdNo
endNoEnd date for the search range use ISO 8601 format. ex: 2020-02-01T00:00:00+09:00
queryNo
startNoStart date for the search range use ISO 8601 format. ex: 2020-01-01T00:00:00+09:00

Implementation Reference

  • Core handler function that performs the memo search by filtering based on query, categoryId, and date range (start/end). Reads from DB and returns matching memos.
    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
      })
    }
  • Zod schema defining input parameters for searchMemos: optional categoryId, query, start/end dates with datetime parsing.
    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>
  • Registers the searchMemos tool with the MCP server, specifying input/output schemas, description, and a thin handler that delegates to the repository function and formats the response.
    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 },
        }
      },
    )

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/108yen/memo-mcp'

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