Skip to main content
Glama

Scan Notes

scan_notes
Read-onlyIdempotent

Retrieve metadata and text previews from multiple Apple Notes in bulk. Filter by folder or control pagination for efficient access.

Instructions

Bulk scan notes returning metadata and a text preview for each.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
folderNoFilter by folder name. Omit to scan all notes.
limitNoMax number of notes to return (default: 100)
offsetNoNumber of notes to skip for pagination (default: 0)
previewLengthNoPreview text length in characters (default: 300)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
totalYes
offsetYes
returnedYes
notesYes

Implementation Reference

  • Registration of the scan_notes tool on the MCP server with input/output schemas, description, and handler.
    server.registerTool(
      "scan_notes",
      {
        title: "Scan Notes",
        description:
          "Bulk scan notes returning metadata and a text preview for each. Supports pagination via offset. Optionally filter by folder. Use this to get an overview before organizing.",
        inputSchema: {
          folder: z.string().max(500).optional().describe("Filter by folder name. Omit to scan all notes."),
          limit: z
            .number()
            .int()
            .min(1)
            .max(LIMITS.NOTES_BULK_SCAN)
            .optional()
            .default(100)
            .describe("Max number of notes to return (default: 100)"),
          offset: z
            .number()
            .int()
            .min(0)
            .optional()
            .default(0)
            .describe("Number of notes to skip for pagination (default: 0)"),
          previewLength: z
            .number()
            .int()
            .min(1)
            .max(5000)
            .optional()
            .default(300)
            .describe("Preview text length in characters (default: 300)"),
        },
        outputSchema: {
          total: z.number(),
          offset: z.number(),
          returned: z.number(),
          notes: z.array(
            z.object({
              id: z.string(),
              name: z.string(),
              folder: z.string(),
              creationDate: z.string(),
              modificationDate: z.string(),
              preview: z.string(),
              charCount: z.number(),
              shared: z.boolean(),
            }),
          ),
        },
        annotations: {
          readOnlyHint: true,
          destructiveHint: false,
          idempotentHint: true,
          openWorldHint: false,
        },
      },
      async ({ folder, limit, offset, previewLength }) => {
        try {
          const result = await runJxa<ScanResult>(scanNotesScript(limit, previewLength, offset, folder));
          result.notes = filterSharedAccess(result.notes, config, "notes");
          result.returned = result.notes.length;
          return okUntrustedLinkedStructured("scan_notes", result);
        } catch (e) {
          return errJxaFor("scan notes", e);
        }
      },
    );
  • The async handler function for scan_notes. It calls scanNotesScript via JXA to bulk scan notes, filters shared access, and returns structured results.
      async ({ folder, limit, offset, previewLength }) => {
        try {
          const result = await runJxa<ScanResult>(scanNotesScript(limit, previewLength, offset, folder));
          result.notes = filterSharedAccess(result.notes, config, "notes");
          result.returned = result.notes.length;
          return okUntrustedLinkedStructured("scan_notes", result);
        } catch (e) {
          return errJxaFor("scan notes", e);
        }
      },
    );
  • The scanNotesScript function generates a JXA (JavaScript for Automation) script string that scans Apple Notes with pagination (limit/offset), optional folder filtering, and preview text extraction with character count.
    export function scanNotesScript(limit: number, previewLength: number, offset: number, folder?: string): string {
      if (folder) {
        return `
          const Notes = Application('Notes');
          const folders = Notes.folders.whose({name: '${esc(folder)}'})();
          if (folders.length === 0) throw new Error('Folder not found: ${esc(folder)}');
          const f = folders[0];
          const names = f.notes.name();
          const ids = f.notes.id();
          const creationDates = f.notes.creationDate();
          const modificationDates = f.notes.modificationDate();
          const shareds = f.notes.shared();
          const start = Math.min(${offset}, names.length);
          const end = Math.min(start + ${limit}, names.length);
          const result = [];
          for (let i = start; i < end; i++) {
            const pt = f.notes[i].plaintext();
            result.push({
              id: ids[i],
              name: names[i],
              folder: '${esc(folder)}',
              creationDate: creationDates[i].toISOString(),
              modificationDate: modificationDates[i].toISOString(),
              preview: pt.substring(0, ${previewLength}),
              charCount: pt.length,
              shared: shareds[i]
            });
          }
          JSON.stringify({total: names.length, offset: start, returned: result.length, notes: result});
        `;
      }
      return `
        const Notes = Application('Notes');
        const names = Notes.notes.name();
        const ids = Notes.notes.id();
        const creationDates = Notes.notes.creationDate();
        const modificationDates = Notes.notes.modificationDate();
        const containers = Notes.notes.container();
        const shareds = Notes.notes.shared();
        const start = Math.min(${offset}, names.length);
        const end = Math.min(start + ${limit}, names.length);
        const result = [];
        for (let i = start; i < end; i++) {
          const pt = Notes.notes[i].plaintext();
          result.push({
            id: ids[i],
            name: names[i],
            folder: containers[i].name(),
            creationDate: creationDates[i].toISOString(),
            modificationDate: modificationDates[i].toISOString(),
            preview: pt.substring(0, ${previewLength}),
            charCount: pt.length,
            shared: shareds[i]
          });
        }
        JSON.stringify({total: names.length, offset: start, returned: result.length, notes: result});
      `;
    }
  • Input and output schemas for the scan_notes tool, defining parameters (folder, limit, offset, previewLength) and return shape (total, offset, returned, notes array with metadata + preview + charCount).
    inputSchema: {
      folder: z.string().max(500).optional().describe("Filter by folder name. Omit to scan all notes."),
      limit: z
        .number()
        .int()
        .min(1)
        .max(LIMITS.NOTES_BULK_SCAN)
        .optional()
        .default(100)
        .describe("Max number of notes to return (default: 100)"),
      offset: z
        .number()
        .int()
        .min(0)
        .optional()
        .default(0)
        .describe("Number of notes to skip for pagination (default: 0)"),
      previewLength: z
        .number()
        .int()
        .min(1)
        .max(5000)
        .optional()
        .default(300)
        .describe("Preview text length in characters (default: 300)"),
    },
    outputSchema: {
      total: z.number(),
      offset: z.number(),
      returned: z.number(),
      notes: z.array(
        z.object({
          id: z.string(),
          name: z.string(),
          folder: z.string(),
          creationDate: z.string(),
          modificationDate: z.string(),
          preview: z.string(),
          charCount: z.number(),
          shared: z.boolean(),
        }),
      ),
  • Constant LIMITS.NOTES_BULK_SCAN = 500, which is the max limit enforced in the scan_notes input schema.
    /** Max notes for scan_notes bulk operation */
    NOTES_BULK_SCAN: 500,
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint, destructiveHint, and idempotentHint. The description adds that it returns metadata and text preview, which is consistent, but no additional behavioral traits (e.g., rate limits, auth) are disclosed beyond what annotations imply.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence that front-loads the action and output, with no redundant information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the presence of an output schema and comprehensive annotations, the description is sufficient for a simple scanning tool. It could mention read-only nature, but annotations cover that. Good completeness for the complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. The description adds no parameter-specific meaning; it only restates the output. The schema already documents all parameters clearly.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it scans notes in bulk and returns metadata with a text preview, effectively distinguishing it from siblings like search_notes or read_note.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool compared to alternatives (e.g., search_notes, list_notes). The description only states what it does without context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/heznpc/AirMCP'

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