Skip to content

Notes連携

Issue: #5 Notes連携

概要

macOS標準メモアプリを AppleScript で操作し、メモの作成・検索・閲覧を行う。

ツール定義

create_note

python
@mcp.tool()
def create_note(title: str, body: str, folder_name: str = "") -> str:
    """新しいメモを作成する"""
パラメータ必須説明
titlestrYesメモのタイトル
bodystrYes本文
folder_namestrNoフォルダ名

AppleScript:

applescript
tell application "Notes"
    tell folder "Notes"
        make new note with properties {name:"タイトル", body:"本文"}
    end tell
end tell

search_notes

python
@mcp.tool()
def search_notes(keyword: str) -> str:
    """キーワードでメモを検索する"""

read_note

python
@mcp.tool()
def read_note(title: str) -> str:
    """指定したタイトルのメモの内容を取得する"""

list_notes

python
@mcp.tool()
def list_notes(folder_name: str = "") -> str:
    """メモ一覧を取得する"""
パラメータ必須説明
folder_namestrNoフォルダ名(指定なしは全フォルダ)

append_to_note

python
@mcp.tool()
def append_to_note(title: str, text: str) -> str:
    """既存のメモに追記する"""

実装メモ

  • Notes の本文は HTML 形式で返る → プレーンテキストへの変換が必要
  • フォルダ名が日本語の場合もあるのでエンコーディングに注意