Skip to main content
Glama

note_save

Capture decisions, context, meeting notes, or blockers by creating or updating notes with markdown content and optional tags. Links notes to projects, epics, or tasks for structured tracking.

Instructions

Create or update a note. Notes capture decisions, context, progress, meeting notes, blockers, technical details, or release info. If "id" is provided, updates the existing note; otherwise creates a new one.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idNoNote ID (omit to create new)
titleYesNote title
contentYesFull note content (markdown supported)
note_typeNogeneral
related_entity_typeNoLink note to an entity
related_entity_idNoID of the related entity
tagsNo

Implementation Reference

  • The main handler function for the note_save tool. It accepts args (id, title, content, note_type, related_entity_type, related_entity_id, tags). If id is provided, it updates the existing note via UPDATE...RETURNING; otherwise it creates a new note via INSERT...RETURNING. It also logs the activity via logActivity.
    function handleNoteSave(args: Record<string, unknown>) {
      const db = getDb();
      const id = args.id as number | undefined;
      const title = args.title as string;
      const content = args.content as string;
      const noteType = (args.note_type as string) ?? 'general';
      const relatedEntityType = (args.related_entity_type as string) ?? null;
      const relatedEntityId = (args.related_entity_id as number) ?? null;
      const tags = JSON.stringify((args.tags as string[]) ?? []);
    
      if (id !== undefined) {
        // Update existing note
        const existing = db.prepare('SELECT * FROM notes WHERE id = ?').get(id);
        if (!existing) throw new Error(`Note ${id} not found`);
    
        const note = db
          .prepare(
            `UPDATE notes SET title = ?, content = ?, note_type = ?, related_entity_type = ?,
             related_entity_id = ?, tags = ?, updated_at = datetime('now')
             WHERE id = ? RETURNING *`
          )
          .get(title, content, noteType, relatedEntityType, relatedEntityId, tags, id);
    
        logActivity(db, 'note', id, 'updated', null, null, null, `Note '${title}' updated`);
        return note;
      } else {
        // Create new note
        const note = db
          .prepare(
            `INSERT INTO notes (title, content, note_type, related_entity_type, related_entity_id, tags)
             VALUES (?, ?, ?, ?, ?, ?) RETURNING *`
          )
          .get(title, content, noteType, relatedEntityType, relatedEntityId, tags);
    
        const row = note as Record<string, unknown>;
        logActivity(db, 'note', row.id as number, 'created', null, null, null, `Note '${title}' created`);
        return note;
      }
    }
  • Input schema for note_save. Defines the JSON input schema with properties: id (optional integer), title (required string), content (required string), note_type (enum with default 'general'), related_entity_type (enum), related_entity_id (integer), and tags (array of strings).
    inputSchema: {
      type: 'object',
      properties: {
        id: { type: 'integer', description: 'Note ID (omit to create new)' },
        title: { type: 'string', description: 'Note title' },
        content: { type: 'string', description: 'Full note content (markdown supported)' },
        note_type: {
          type: 'string',
          enum: ['general', 'decision', 'context', 'meeting', 'technical', 'blocker', 'progress', 'release'],
          default: 'general',
        },
        related_entity_type: {
          type: 'string',
          enum: ['project', 'epic', 'task'],
          description: 'Link note to an entity',
        },
        related_entity_id: { type: 'integer', description: 'ID of the related entity' },
        tags: { type: 'array', items: { type: 'string' } },
      },
      required: ['title', 'content'],
    },
  • The tool definition (name: 'note_save') is exported in the definitions array and the handler mapping is exported in the handlers record (line 194). These are imported into src/index.ts (line 14) and spread into ALL_TOOLS (line 28) and ALL_HANDLERS (line 42). The server dispatches to ALL_HANDLERS[name] in the CallToolRequestSchema handler (line 78-103).
    export const definitions: Tool[] = [
      {
        name: 'note_save',
        description:
          'Create or update a note. Notes capture decisions, context, progress, meeting notes, blockers, technical details, or release info. If "id" is provided, updates the existing note; otherwise creates a new one.',
        annotations: { title: 'Save Note', readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
        inputSchema: {
          type: 'object',
          properties: {
            id: { type: 'integer', description: 'Note ID (omit to create new)' },
            title: { type: 'string', description: 'Note title' },
            content: { type: 'string', description: 'Full note content (markdown supported)' },
            note_type: {
              type: 'string',
              enum: ['general', 'decision', 'context', 'meeting', 'technical', 'blocker', 'progress', 'release'],
              default: 'general',
            },
            related_entity_type: {
              type: 'string',
              enum: ['project', 'epic', 'task'],
              description: 'Link note to an entity',
            },
            related_entity_id: { type: 'integer', description: 'ID of the related entity' },
            tags: { type: 'array', items: { type: 'string' } },
          },
          required: ['title', 'content'],
        },
      },
      {
        name: 'note_list',
        description: 'List notes with optional filters. Returns notes sorted by most recent first.',
        annotations: { title: 'List Notes', readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
        inputSchema: {
          type: 'object',
          properties: {
            note_type: {
              type: 'string',
              enum: ['general', 'decision', 'context', 'meeting', 'technical', 'blocker', 'progress', 'release'],
            },
            related_entity_type: { type: 'string', enum: ['project', 'epic', 'task'] },
            related_entity_id: { type: 'integer' },
            tag: { type: 'string', description: 'Filter by a single tag' },
            limit: { type: 'integer', default: 30 },
          },
        },
      },
      {
        name: 'note_search',
        description: 'Search across note titles and content by keyword.',
        annotations: { title: 'Search Notes', readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
        inputSchema: {
          type: 'object',
          properties: {
            query: { type: 'string', description: 'Search keywords' },
            note_type: {
              type: 'string',
              enum: ['general', 'decision', 'context', 'meeting', 'technical', 'blocker', 'progress', 'release'],
            },
            limit: { type: 'integer', default: 20 },
          },
          required: ['query'],
        },
      },
      {
        name: 'note_delete',
        description: 'Delete a note by ID.',
        annotations: { title: 'Delete Note', readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
        inputSchema: {
          type: 'object',
          properties: {
            id: { type: 'integer', description: 'Note ID' },
          },
          required: ['id'],
        },
      },
    ];
    
    function handleNoteSave(args: Record<string, unknown>) {
      const db = getDb();
      const id = args.id as number | undefined;
      const title = args.title as string;
      const content = args.content as string;
      const noteType = (args.note_type as string) ?? 'general';
      const relatedEntityType = (args.related_entity_type as string) ?? null;
      const relatedEntityId = (args.related_entity_id as number) ?? null;
      const tags = JSON.stringify((args.tags as string[]) ?? []);
    
      if (id !== undefined) {
        // Update existing note
        const existing = db.prepare('SELECT * FROM notes WHERE id = ?').get(id);
        if (!existing) throw new Error(`Note ${id} not found`);
    
        const note = db
          .prepare(
            `UPDATE notes SET title = ?, content = ?, note_type = ?, related_entity_type = ?,
             related_entity_id = ?, tags = ?, updated_at = datetime('now')
             WHERE id = ? RETURNING *`
          )
          .get(title, content, noteType, relatedEntityType, relatedEntityId, tags, id);
    
        logActivity(db, 'note', id, 'updated', null, null, null, `Note '${title}' updated`);
        return note;
      } else {
        // Create new note
        const note = db
          .prepare(
            `INSERT INTO notes (title, content, note_type, related_entity_type, related_entity_id, tags)
             VALUES (?, ?, ?, ?, ?, ?) RETURNING *`
          )
          .get(title, content, noteType, relatedEntityType, relatedEntityId, tags);
    
        const row = note as Record<string, unknown>;
        logActivity(db, 'note', row.id as number, 'created', null, null, null, `Note '${title}' created`);
        return note;
      }
    }
    
    function handleNoteList(args: Record<string, unknown>) {
      const db = getDb();
      const noteType = args.note_type as string | undefined;
      const relatedEntityType = args.related_entity_type as string | undefined;
      const relatedEntityId = args.related_entity_id as number | undefined;
      const tag = args.tag as string | undefined;
      const limit = (args.limit as number) ?? 30;
    
      const whereClauses: string[] = [];
      const params: unknown[] = [];
    
      if (noteType) {
        whereClauses.push('note_type = ?');
        params.push(noteType);
      }
      if (relatedEntityType) {
        whereClauses.push('related_entity_type = ?');
        params.push(relatedEntityType);
      }
      if (relatedEntityId !== undefined) {
        whereClauses.push('related_entity_id = ?');
        params.push(relatedEntityId);
      }
      if (tag) {
        addTagFilter(whereClauses, params, tag, 'notes');
      }
    
      const whereStr = whereClauses.length > 0 ? `WHERE ${whereClauses.join(' AND ')}` : '';
    
      const sql = `SELECT * FROM notes ${whereStr} ORDER BY created_at DESC LIMIT ?`;
      params.push(limit);
    
      return db.prepare(sql).all(...params);
    }
    
    function handleNoteSearch(args: Record<string, unknown>) {
      const db = getDb();
      const query = args.query as string;
      const noteType = args.note_type as string | undefined;
      const limit = (args.limit as number) ?? 20;
    
      const whereClauses = ['(title LIKE ? OR content LIKE ?)'];
      const pattern = `%${query}%`;
      const params: unknown[] = [pattern, pattern];
    
      if (noteType) {
        whereClauses.push('note_type = ?');
        params.push(noteType);
      }
    
      const sql = `SELECT * FROM notes WHERE ${whereClauses.join(' AND ')} ORDER BY created_at DESC LIMIT ?`;
      params.push(limit);
    
      return db.prepare(sql).all(...params);
    }
    
    function handleNoteDelete(args: Record<string, unknown>) {
      const db = getDb();
      const id = args.id as number;
    
      const note = db.prepare('SELECT * FROM notes WHERE id = ?').get(id) as Record<string, unknown> | undefined;
      if (!note) throw new Error(`Note ${id} not found`);
    
      db.prepare('DELETE FROM notes WHERE id = ?').run(id);
      logActivity(db, 'note', id, 'deleted', null, null, null, `Note '${note.title}' deleted`);
    
      return { id, title: note.title, deleted: true };
    }
    
    export const handlers: Record<string, ToolHandler> = {
      note_save: handleNoteSave,
      note_list: handleNoteList,
      note_search: handleNoteSearch,
      note_delete: handleNoteDelete,
    };
  • The logActivity helper used by handleNoteSave to log note creation/update events to the activity_log table.
    export function logActivity(
      db: Database.Database,
      entityType: string,
      entityId: number,
      action: string,
      fieldName: string | null,
      oldValue: string | null,
      newValue: string | null,
      summary: string
    ): void {
      db.prepare(
        `INSERT INTO activity_log (entity_type, entity_id, action, field_name, old_value, new_value, summary)
         VALUES (?, ?, ?, ?, ?, ?, ?)`
      ).run(entityType, entityId, action, fieldName, oldValue, newValue, summary);
    }
  • The SQL schema for the notes table, defining the database structure that note_save operates on.
    CREATE TABLE IF NOT EXISTS notes (
      id                  INTEGER PRIMARY KEY AUTOINCREMENT,
      title               TEXT NOT NULL,
      content             TEXT NOT NULL,
      note_type           TEXT NOT NULL DEFAULT 'general'
                            CHECK (note_type IN (
                              'general', 'decision', 'context', 'meeting',
                              'technical', 'blocker', 'progress', 'release'
                            )),
      related_entity_type TEXT CHECK (related_entity_type IN ('project', 'epic', 'task') OR related_entity_type IS NULL),
      related_entity_id   INTEGER,
      tags                TEXT NOT NULL DEFAULT '[]',
      metadata            TEXT NOT NULL DEFAULT '{}',
      created_at          TEXT NOT NULL DEFAULT (datetime('now')),
      updated_at          TEXT NOT NULL DEFAULT (datetime('now'))
    );
Behavior4/5

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

Annotations already indicate the tool is not read-only (readOnlyHint=false), so mutation is expected. The description adds value by specifying the create/update behavior based on 'id' presence and listing supported note categories. No contradictions with annotations.

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?

Two sentences that are concise and front-loaded: the first sentence states the core action, the second adds the critical create/update distinction. No unnecessary information.

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

Completeness3/5

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

The description covers the essentials (purpose and id behavior) but lacks mention of return values or error scenarios. Without an output schema, more context about success response or failure handling would improve completeness.

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 description coverage is 71%, so baseline is 3. The description reinforces the id-based update logic (already in the schema) and lists note types, but does not add new parameter semantics beyond what the enums and descriptions provide.

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 'Create or update a note' with specific verb and resource. It distinguishes from sibling tools like note_list, note_search, and note_delete by implying creation/modification operations. Also lists note categories, reinforcing what the tool handles.

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

Usage Guidelines3/5

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

The description explains the condition for update vs create ('If id is provided...'), providing clear usage context. However, it does not explicitly state when to use this tool over alternatives (e.g., note_delete, task_update) or provide exclusion criteria.

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/spranab/saga-mcp'

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