Skip to main content
Glama
evernote_client.py3.52 kB
""" Evernote API クライアント Evernote APIへのアクセスを抽象化し、必要な操作を提供します。 """ import asyncio from typing import Any from evernote.api.client import EvernoteClient as EvernoteSDK from evernote.edam.error.ttypes import ( EDAMNotFoundException, EDAMSystemException, EDAMUserException, ) class EvernoteClient: """Evernote API client wrapper.""" def __init__(self, token: str, sandbox: bool = False): """ Initialize the Evernote client. Args: token: Evernote API token sandbox: Whether to use sandbox environment """ self.token = token self.sandbox = sandbox # Initialize Evernote SDK client self._sdk_client = EvernoteSDK(token=token, sandbox=sandbox) # Get NoteStore - this is used for most operations self._note_store = self._sdk_client.get_note_store() async def list_notebooks(self) -> list[dict[str, Any]]: """ Get list of notebooks. Returns: List of notebook objects """ try: # Evernote SDKは同期APIなので、asyncio.to_thread()で非同期化 notebooks = await asyncio.to_thread(self._note_store.listNotebooks) # レスポンスを辞書形式に変換 return [ { "guid": notebook.guid, "name": notebook.name, "stack": notebook.stack if hasattr(notebook, "stack") else None, "default_notebook": ( notebook.defaultNotebook if hasattr(notebook, "defaultNotebook") else False ), } for notebook in notebooks ] except EDAMUserException as e: raise ValueError(f"User error: {e.parameter} - {e.errorCode}") except EDAMSystemException as e: raise RuntimeError(f"System error: {e.errorCode} - {e.message}") except Exception as e: raise RuntimeError(f"Unexpected error listing notebooks: {str(e)}") async def search_notes(self, query: str, max_results: int = 50) -> list[dict[str, Any]]: """ Search for notes. Args: query: Search query (Evernote search syntax) max_results: Maximum number of results Returns: List of note objects """ # TODO: Evernote SDK を使用してノートを検索 raise NotImplementedError("Not implemented") async def get_note(self, guid: str) -> dict[str, Any]: """ Get note by GUID. Args: guid: Note GUID Returns: Note object """ # TODO: Evernote SDK を使用してノートを取得 raise NotImplementedError("Not implemented") async def create_note( self, title: str, content: str, notebook_guid: str | None = None, tags: list[str] | None = None, ) -> dict[str, Any]: """ Create a new note. Args: title: Note title content: Note content (ENML format) notebook_guid: Notebook GUID (optional) tags: List of tags (optional) Returns: Created note object """ # TODO: Evernote SDK を使用してノートを作成 raise NotImplementedError("Not implemented")

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/AnotherStream/mcp-notes-connector'

If you have feedback or need assistance with the MCP directory API, please join our Discord server