get_note
Retrieve the full content of a specific note from your knowledge base by providing its category path and title.
Instructions
Retrieve the full content of a specific note
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category_path | Yes | Category path (e.g., 'work/clients/acme') | |
| title | Yes | Note title (can use full filename or friendly title) |
Implementation Reference
- src/knowledge_base_mcp/server.py:466-496 (handler)The handler function that executes the 'get_note' tool. It extracts arguments, calls storage.get_note, formats the note with metadata, and returns formatted TextContent.async def handle_get_note(arguments: dict) -> list[TextContent]: """Handle get_note tool call.""" try: category_path = arguments["category_path"] title = arguments["title"] # Get note note = storage.get_note(category_path, title) # Format output with frontmatter output = f"# {note.title}\n\n" output += f"**Category:** {note.category or 'root'}\n" output += f"**Tags:** {', '.join(note.frontmatter.tags) if note.frontmatter.tags else 'none'}\n" output += f"**Date:** {note.frontmatter.date}\n" if note.frontmatter.updated: output += f"**Updated:** {note.frontmatter.updated}\n" # Add metadata if any if note.frontmatter.metadata: output += "\n**Additional Info:**\n" for key, value in note.frontmatter.metadata.items(): output += f"- {key}: {value}\n" output += f"\n---\n\n{note.content}" return [TextContent(type="text", text=output)] except (NoteNotFoundError, StorageError) as e: return [TextContent(type="text", text=str(e))] except Exception as e: return [TextContent(type="text", text=f"β Error: {str(e)}")]
- Input schema definition for the 'get_note' tool, specifying required category_path and title parameters.Tool( name="get_note", description="Retrieve the full content of a specific note", inputSchema={ "type": "object", "properties": { "category_path": { "type": "string", "description": "Category path (e.g., 'work/clients/acme')", }, "title": { "type": "string", "description": "Note title (can use full filename or friendly title)", }, }, "required": ["category_path", "title"], }, ),
- src/knowledge_base_mcp/server.py:304-305 (registration)Dispatch logic in the main call_tool function that routes 'get_note' calls to the handle_get_note handler.elif name == "get_note": return await handle_get_note(arguments)
- Core storage method that retrieves a note by computing the file path and parsing the markdown file into a Note object. Called by the handler.def get_note(self, category_path: str, title: str) -> Note: """ Retrieve a note by category path and title. Args: category_path: Category path (e.g., "work/clients/acme") title: Note title (can be friendly name or filename) Returns: Note object Raises: NoteNotFoundError: If note doesn't exist """ normalized = normalize_path(category_path) file_path = self._get_note_path(normalized, title) if not file_path.exists(): raise NoteNotFoundError( f"β Error: Note '{title}' not found in {normalized or 'root'}/\n" f"π‘ Tip: Use search_notes to find existing notes" ) return self._parse_note_file(file_path)