Skip to main content
Glama
9Ninety
by 9Ninety

writeNote

Create or update notes with a unique ID, title, summary, tags, and content on the MCP Notes server for organized and structured documentation.

Instructions

Creates or updates a note with a unique ID suffixed by a random number.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesContent of the note
idYesUnique identifier of the note, should be unique enough like "a-note-about-python-file-server-design-109".
summaryYesShort summary of the note
tagsYesTags of the note
titleYesTitle of the note, describe what was inside the content.

Implementation Reference

  • The handler function that executes the writeNote tool: puts the note into DynamoDB using PutCommand, updates the ALL_RESOURCES list, and returns a success message.
    export const handleWriteNote = async (
      docClient: DynamoDBDocumentClient,
      tableName: string,
      note: Note,
      ALL_RESOURCES: Resource[]
    ) => {
      const command = new PutCommand({ TableName: tableName, Item: note });
      await docClient.send(command);
    
      const resourceIndex = ALL_RESOURCES.findIndex(
        (res) => res.uri === `notes://notes/${note.id}`
      );
      const newResource = {
        uri: `notes://notes/${note.id}`,
        name: note.title,
        mimeType: "application/json",
        text: JSON.stringify(note),
      };
    
      if (resourceIndex !== -1) {
        ALL_RESOURCES[resourceIndex] = newResource;
      } else {
        ALL_RESOURCES.push(newResource);
      }
    
      return {
        content: [
          {
            type: "text",
            text: `Note with ID '${note.id}' has been written/updated.`,
          },
        ],
      };
    };
  • Zod schema definition for Note (used directly as WriteNoteInputSchema), including id, title, summary, tags, content with descriptions.
    export const NoteSchema = z.object({
      id: z
        .string()
        .describe(
          'Unique identifier of the note, should be unique enough like "a-note-about-python-file-server-design-109".'
        ),
      title: z
        .string()
        .describe("Title of the note, describe what was inside the content."),
      summary: z.string().describe("Short summary of the note"),
      tags: z.array(z.string()).describe("Tags of the note"),
      content: z.string().describe("Content of the note"),
    });
    
    export type Note = z.infer<typeof NoteSchema>;
    
    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."),
    });
    
    export const GetNoteInputSchema = z.object({
      id: z.string().describe("ID of the note to retrieve"),
    });
    
    export const WriteNoteInputSchema = NoteSchema;
  • Registers the listTools handler which returns the list of tools including writeNote via getTools().
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      const tools: Tool[] = getTools();
      return { tools };
    });
  • Defines the MCP Tool object for writeNote with name, description, and JSON schema converted from Zod.
    {
      name: ToolName.WRITE_NOTE,
      description:
        "Creates or updates a note with a unique ID suffixed by a random number.",
      inputSchema: zodToJsonSchema(WriteNoteInputSchema) as Tool["inputSchema"],
    },
  • Dispatcher in callTool handler that validates input with WriteNoteInputSchema and invokes the handleWriteNote function.
    case ToolName.WRITE_NOTE: {
      const note = WriteNoteInputSchema.parse(args);
      return handleWriteNote(docClient, tableName, note, ALL_RESOURCES);
    }
  • Type definition enum ToolName including WRITE_NOTE = "writeNote" used throughout for tool identification.
    export enum ToolName {
      LIST_NOTES = "listNotes",
      GET_NOTE = "getNote",
      WRITE_NOTE = "writeNote",
      DELETE_NOTE = "deleteNote",
    }
Install Server

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/9Ninety/MCPNotes'

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