Skip to main content
Glama

notes_search

Search Apple Notes for specific text within titles, bodies, or specified folders. Customize results by limiting output and including/excluding note bodies for precise retrieval.

Instructions

[Apple Notes operations] Search for notes containing specific text

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
folderNoOptional folder name to search in
includeBodyNoWhether to include note body in results (default: true)
limitNoMaximum number of results to return (default: 5)
queryYesText to search for in notes (title and body)

Implementation Reference

  • Handler function for the notes_search tool. This arrow function takes arguments (query, folder, limit, includeBody) and returns the AppleScript code that searches for matching notes in the Apple Notes application, constructs JSON output with note details.
    script: (args) => { const { query, folder = "", limit = 5, includeBody = true } = args; if (folder) { return ` tell application "Notes" set folderList to folders whose name is "${folder}" if length of folderList > 0 then set targetFolder to item 1 of folderList set matchingNotes to {} set allNotes to notes of targetFolder repeat with n in allNotes if name of n contains "${query}" or body of n contains "${query}" then set end of matchingNotes to n end if end repeat set resultCount to length of matchingNotes if resultCount > ${limit} then set resultCount to ${limit} set jsonResult to "[" repeat with i from 1 to resultCount set n to item i of matchingNotes set noteTitle to name of n set noteCreationDate to creation date of n set noteModDate to modification date of n ${includeBody ? 'set noteBody to body of n' : ''} set noteJson to "{\\"title\\": \\"" set noteJson to noteJson & noteTitle & "\\"" ${includeBody ? 'set noteJson to noteJson & ", \\"body\\": \\"" & noteBody & "\\""' : ''} set noteJson to noteJson & ", \\"creationDate\\": \\"" & noteCreationDate & "\\"" set noteJson to noteJson & ", \\"modificationDate\\": \\"" & noteModDate & "\\"}" set jsonResult to jsonResult & noteJson if i < resultCount then set jsonResult to jsonResult & ", " end repeat set jsonResult to jsonResult & "]" return jsonResult else return "Folder not found: ${folder}" end if end tell `; } else { return ` tell application "Notes" set matchingNotes to {} set allNotes to notes repeat with n in allNotes if name of n contains "${query}" or body of n contains "${query}" then set end of matchingNotes to n end if end repeat set resultCount to length of matchingNotes if resultCount > ${limit} then set resultCount to ${limit} set jsonResult to "[" repeat with i from 1 to resultCount set n to item i of matchingNotes set noteTitle to name of n set noteCreationDate to creation date of n set noteModDate to modification date of n ${includeBody ? 'set noteBody to body of n' : ''} set noteJson to "{\\"title\\": \\"" set noteJson to noteJson & noteTitle & "\\"" ${includeBody ? 'set noteJson to noteJson & ", \\"body\\": \\"" & noteBody & "\\""' : ''} set noteJson to noteJson & ", \\"creationDate\\": \\"" & noteCreationDate & "\\"" set noteJson to noteJson & ", \\"modificationDate\\": \\"" & noteModDate & "\\"}" set jsonResult to jsonResult & noteJson if i < resultCount then set jsonResult to jsonResult & ", " end repeat set jsonResult to jsonResult & "]" return jsonResult end tell `; }
  • Input schema for the notes_search tool, defining parameters: query (required string), folder (optional string), limit (optional number), includeBody (optional boolean).
    schema: { type: "object", properties: { query: { type: "string", description: "Text to search for in notes (title and body)" }, folder: { type: "string", description: "Optional folder name to search in" }, limit: { type: "number", description: "Maximum number of results to return (default: 5)" }, includeBody: { type: "boolean", description: "Whether to include note body in results (default: true)" } }, required: ["query"] }
  • src/index.ts:35-35 (registration)
    Registration of the notesCategory, which includes the 'search' script that becomes the notes_search tool, via server.addCategory.
    server.addCategory(notesCategory);
  • Dynamic tool registration in listTools handler: constructs tool name as category.name + '_' + script.name (e.g., 'notes_search'), includes description and schema.
    tools: this.categories.flatMap((category) => category.scripts.map((script) => ({ name: `${category.name}_${script.name}`, // Changed from dot to underscore description: `[${category.description}] ${script.description}`, inputSchema: script.schema || { type: "object", properties: {}, }, })), ),
  • Specific line constructing the 'notes_search' tool name from 'notes' category and 'search' script.
    name: `${category.name}_${script.name}`, // Changed from dot to underscore

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/joshrutkowski/applescript-mcp'

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