getNote
Retrieve specific notes by their ID using a TypeScript-based MCP server designed for note-taking CRUD operations with JSON responses.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| noteId | Yes | The 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
- src/server.ts:18-62 (handler)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) } ] }; } }, );
- src/server.ts:15-17 (schema)Input schema for getNote tool using Zod: noteId as string.{ noteId: z.string().describe("The ID of the note to retrieve") },
- src/notes-store.ts:30-32 (helper)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]; }
- src/notes-store.ts:2-7 (schema)Type definition for the Note object returned by getNote.export interface Note { id: string; title: string; content: string; createdAt: string; }