listNotes
Search and list all notes or filter them by specific tags to quickly find relevant information in your MCP Notes server.
Instructions
Lists all notes, or search notes with tags you seen in previous list operation.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tags | No | Optional tags to filter notes. do not specify this if you didn't certainly sure what tags you want. |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"tags": {
"description": "Optional tags to filter notes. do not specify this if you didn't certainly sure what tags you want.",
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
}
Implementation Reference
- src/notes-mcp-server/handlers.ts:11-53 (handler)The core handler function for the 'listNotes' tool. It performs a ScanCommand on the DynamoDB table, optionally filters by tags, simplifies the note data, updates the global ALL_RESOURCES list with note resources, and returns a formatted content response with note count and JSON list.export const handleListNotes = async ( docClient: DynamoDBDocumentClient, tableName: string, ALL_RESOURCES: Resource[], tags?: string[] ) => { const scanParams: any = { TableName: tableName }; if (tags && tags.length > 0) { scanParams.FilterExpression = "tags IN (:tags)"; scanParams.ExpressionAttributeValues = { ":tags": tags, }; } const command = new ScanCommand(scanParams); const response = await docClient.send(command); const notes = (response.Items as Note[]) || []; const simplifiedNotes = notes.map((note) => ({ id: note.id, title: note.title, summary: note.summary, tags: note.tags, })); ALL_RESOURCES.length = 0; notes.forEach((note) => { ALL_RESOURCES.push({ uri: `notes://notes/${note.id}`, name: note.title, mimeType: "application/json", text: JSON.stringify(note), }); }); return { content: [ { type: "text", text: `Found ${notes.length} notes.` }, { type: "text", text: JSON.stringify(simplifiedNotes) }, ], }; };
- Zod input schema for the listNotes tool, defining an optional array of tags for filtering notes.export const ListNotesInputSchema = z.object({ tags: z .array(z.string()) .optional() .describe("Optional tags to filter notes. do not specify this if you didn't certainly sure what tags you want."), });
- src/notes-mcp-server/tools.ts:11-17 (registration)Tool registration in getTools() function, which returns the list of available tools including 'listNotes' with its name, description, and converted JSON input schema. This is used by the listTools handler.export const getTools = (): Tool[] => [ { name: ToolName.LIST_NOTES, description: "Lists all notes, or search notes with tags you seen in previous list operation.", inputSchema: zodToJsonSchema(ListNotesInputSchema) as Tool["inputSchema"], },
- src/notes-mcp-server/server.ts:127-130 (registration)Tool dispatch/execution routing in the CallToolRequestSchema handler's switch statement. Parses input with schema and calls the handleListNotes function.case ToolName.LIST_NOTES: { const { tags } = ListNotesInputSchema.parse(args); return handleListNotes(docClient, tableName, ALL_RESOURCES, tags); }
- src/notes-mcp-server/types.ts:2-2 (helper)Enum definition for the tool name constant ToolName.LIST_NOTES = "listNotes".LIST_NOTES = "listNotes",