create_note
Create a new Markdown note with a title, content, and optional tags to organize information in the Notes MCP Server.
Instructions
Create a new Markdown note
Args: title: Note title content: Note content tags: Optional comma-separated list of tags
Returns: Confirmation message of note creation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | ||
| content | Yes | ||
| tags | No |
Implementation Reference
- notes_server.py:22-49 (handler)The handler function for the 'create_note' tool. Decorated with @mcp.tool(), it creates a new Markdown note file with timestamped filename, adds metadata like creation date and tags, writes the content, and returns a confirmation.def create_note(title: str, content: str, tags: str = "") -> str: """ Create a new Markdown note Args: title: Note title content: Note content tags: Optional comma-separated list of tags Returns: Confirmation message of note creation """ ensure_notes_dir() timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") filename = f"{timestamp}_{sanitize_filename(title)}.md" filepath = os.path.join(NOTES_DIR, filename) note_content = f"# {title}\n\n" note_content += f"**Created:** {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n" if tags: note_content += f"**Tags:** {tags}\n" note_content += f"\n---\n\n{content}\n" with open(filepath, "w", encoding="utf-8") as f: f.write(note_content) return f"Note '{title}' created: {filename}"
- notes_server.py:15-19 (helper)Helper function to sanitize note titles for safe filenames, used in create_note.def sanitize_filename(title: str) -> str: """Converts a note title into a safe filename""" safe_title = re.sub(r'[^\w\s-]', '', title) safe_title = re.sub(r'\s+', '_', safe_title) return safe_title.lower()[:100]
- notes_server.py:11-13 (helper)Helper function to ensure the notes directory exists, called by create_note.def ensure_notes_dir(): """Creates the notes directory if it does not exist""" Path(NOTES_DIR).mkdir(exist_ok=True)