add-note
Create and save a new note with name and content on the MCP Notes Server, enabling efficient note management and persistence through CRUD operations.
Instructions
Create a new note
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | ||
| name | Yes |
Implementation Reference
- src/notes/tools/handle_tools.py:25-43 (handler)The primary handler function for executing the 'add-note' tool logic, including argument validation, storage interaction, and response formatting.async def _handle_add_note(self, arguments: Optional[Dict]) -> List[types.TextContent]: """Process note creation requests.""" if not arguments: raise ValueError("Missing arguments") note_name = arguments.get("name") content = arguments.get("content") if not note_name or not content: raise ValueError("Missing name or content") current_time, content = self.storage.add_note(note_name, content) return [ types.TextContent( type="text", text=f"Created note '{note_name}' with content: {content}\nCreated at: {current_time}", ) ]
- src/notes/tools/list_tools.py:11-22 (schema)The schema definition for the 'add-note' tool, specifying input parameters and requirements for validation.types.Tool( name="add-note", description="Create a new note", inputSchema={ "type": "object", "properties": { "name": {"type": "string"}, "content": {"type": "string"}, }, "required": ["name", "content"], }, ),
- src/notes/tools/list_tools.py:11-22 (registration)The tool registration entry in the list of available tools, including name, description, and schema.types.Tool( name="add-note", description="Create a new note", inputSchema={ "type": "object", "properties": { "name": {"type": "string"}, "content": {"type": "string"}, }, "required": ["name", "content"], }, ),
- src/notes/storage.py:31-43 (helper)Helper method in NoteStorage that performs the actual note addition to the in-memory dict and persists to JSON file.def add_note(self, name: str, content: str) -> tuple[str, str]: """Add a new note with content and timestamps.""" if name in self.notes: raise ValueError(f"Note '{name}' already exists") current_time = datetime.now().isoformat() self.notes[name] = { "content": content, "created_at": current_time, "modified_at": current_time } self.save_notes() return current_time, content