createMemo
Create and store memos with titles and content using a local database for agents to record and manage information.
Instructions
Create a new memo
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| categoryId | No | ||
| content | Yes | ||
| title | Yes |
Implementation Reference
- src/repository/memos.ts:5-18 (handler)Core handler function that creates a new memo: generates ID with nanoid, adds timestamps, appends to in-memory DB, and persists it.export const createMemo = async (memo: CreateMemo) => { const now = new Date().toISOString() const newMemo = { ...memo, createdAt: now, id: nanoid(), updatedAt: now, } db.data.memos.push(newMemo) await db.write() return newMemo }
- src/schemas/memos.ts:26-32 (schema)Zod schema defining the input structure for createMemo: title (string), content (string), optional categoryId (string).export const CreateMemoSchema = z.object({ categoryId: z.string().optional(), content: z.string(), title: z.string(), }) export type CreateMemo = z.infer<typeof CreateMemoSchema>
- src/server/tools.ts:29-44 (registration)Registers the createMemo tool with the MCP server, providing schema, description, and a thin handler that delegates to the core createMemo function and formats the MCP response.server.registerTool( "createMemo", { description: "Create a new memo", inputSchema: CreateMemoSchema.shape, outputSchema: { memo: MemoSchema }, title: "Create Memo", }, async (memo) => { const newMemo = await createMemo(memo) return { content: [{ text: JSON.stringify(newMemo), type: "text" }], structuredContent: { memo: newMemo }, } }, )