Skip to main content
Glama

Simple TypeScript MCP Server

by jasonkneen

getNote

Retrieve specific notes by their ID using a TypeScript-based MCP server designed for note-taking CRUD operations with JSON responses.

Input Schema

NameRequiredDescriptionDefault
noteIdYesThe ID of the note to retrieve

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "noteId": { "description": "The ID of the note to retrieve", "type": "string" } }, "required": [ "noteId" ], "type": "object" }

Implementation Reference

  • The async handler function registered for the 'getNote' MCP tool. It retrieves the note using notesStore.getNote, handles not found and errors, and returns structured JSON content.
    async ({ noteId }) => { try { const note = notesStore.getNote(noteId); if (!note) { 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 }, null, 2) } ] }; } catch (err) { return { content: [ { type: "text", text: JSON.stringify({ success: false, error: "Failed to retrieve note", noteId }, null, 2) } ] }; } },
  • src/server.ts:13-63 (registration)
    Registration of the 'getNote' tool with MCP server using server.tool(), including input schema and handler function.
    server.tool( "getNote", { noteId: z.string().describe("The ID of the note to retrieve") }, async ({ noteId }) => { try { const note = notesStore.getNote(noteId); if (!note) { 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 }, null, 2) } ] }; } catch (err) { return { content: [ { type: "text", text: JSON.stringify({ success: false, error: "Failed to retrieve note", noteId }, null, 2) } ] }; } }, );
  • Input schema for getNote tool using Zod: noteId as string.
    { noteId: z.string().describe("The ID of the note to retrieve") },
  • Helper method in NotesStore class that implements the core logic to retrieve a note by ID from the in-memory store.
    getNote(id: string): Note | undefined { return this.notes[id]; }
  • Type definition for the Note object returned by getNote.
    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