Skip to main content
Glama
jasonkneen

Simple TypeScript MCP Server

by jasonkneen

updateNote

Modify note details in the MCP server by providing the note ID along with updated title and content. Ideal for maintaining accurate and current note-taking records.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentNoThe updated content of the note
noteIdYesThe ID of the note to update
titleNoThe updated title of the note

Implementation Reference

  • MCP tool handler for 'updateNote': validates input, calls notesStore.updateNote, handles errors, and returns JSON response.
    async ({ noteId, title, content }) => { try { const updatedNote = notesStore.updateNote(noteId, { title, content }); if (!updatedNote) { return { content: [ { type: "text", text: JSON.stringify({ success: false, error: "Note not found", noteId }, null, 2) } ] }; } return { content: [ { type: "text", text: JSON.stringify({ success: true, note: updatedNote }, null, 2) } ] }; } catch (err) { return { content: [ { type: "text", text: JSON.stringify({ success: false, error: "Failed to update note", noteId }, null, 2) } ] }; } },
  • Zod input schema for the updateNote tool defining parameters: noteId (required), title and content (optional).
    { noteId: z.string().describe("The ID of the note to update"), title: z.string().optional().describe("The updated title of the note"), content: z.string().optional().describe("The updated content of the note") },
  • src/server.ts:139-191 (registration)
    Registration of the 'updateNote' tool with the MCP server using server.tool().
    server.tool( "updateNote", { noteId: z.string().describe("The ID of the note to update"), title: z.string().optional().describe("The updated title of the note"), content: z.string().optional().describe("The updated content of the note") }, async ({ noteId, title, content }) => { try { const updatedNote = notesStore.updateNote(noteId, { title, content }); if (!updatedNote) { return { content: [ { type: "text", text: JSON.stringify({ success: false, error: "Note not found", noteId }, null, 2) } ] }; } return { content: [ { type: "text", text: JSON.stringify({ success: true, note: updatedNote }, null, 2) } ] }; } catch (err) { return { content: [ { type: "text", text: JSON.stringify({ success: false, error: "Failed to update note", noteId }, null, 2) } ] }; } }, );
  • Core helper method in NotesStore class that performs the actual note update logic in memory.
    updateNote(id: string, updates: { title?: string; content?: string }): Note | undefined { const note = this.notes[id]; if (!note) { return undefined; } if (updates.title !== undefined) { note.title = updates.title; } if (updates.content !== undefined) { note.content = updates.content; } return note; }
  • TypeScript interface defining the Note data structure used by the updateNote functionality.
    export interface Note { id: string; title: string; content: string; createdAt: string; }

Other Tools

Related 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/jasonkneen/mcp-server-ts'

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