Create Memo
createMemoCreate a memo with a title and content, optionally specifying a category. Records the memo in a local database for later retrieval.
Instructions
Create a new memo
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| categoryId | No | ||
| content | Yes | ||
| title | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| memo | Yes |
Implementation Reference
- src/repository/memos.ts:5-18 (handler)The actual handler function that creates a memo. It takes a CreateMemo object, assigns it an ID via nanoid, sets createdAt/updatedAt timestamps, pushes it to the db, writes, and returns the new memo.
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)CreateMemoSchema defines the input validation schema for creating a memo (categoryId optional, content required, title required). CreateMemo is the inferred TypeScript type.
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:28-44 (registration)Registers the 'createMemo' tool on the MCP server with metadata (description, inputSchema, outputSchema, title) and the handler that calls createMemo and returns structured content.
export function registerTools(server: McpServer) { 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 }, } }, )