Skip to content

feat: inject live notebook names into tool descriptions and add graceful fallback#45

Open
autojack-bot[bot] wants to merge 4 commits into
mainfrom
feat/notebook-aware-descriptions
Open

feat: inject live notebook names into tool descriptions and add graceful fallback#45
autojack-bot[bot] wants to merge 4 commits into
mainfrom
feat/notebook-aware-descriptions

Conversation

@autojack-bot
Copy link
Copy Markdown

@autojack-bot autojack-bot Bot commented Jun 1, 2026

Closes #44

Summary

  • Notebook-aware tool descriptions: On API init and on first ListTools call, the server fetches the notebook list and injects available notebook names directly into the notebookName field descriptions of evernote_create_note and evernote_update_note. Agents see e.g. Available notebooks: "Personal", "Work", "Inbox". Default: "Personal". before they write anything.

  • Graceful fallback for unknown notebooks: When a notebookName is passed that doesn't match any existing notebook:

    1. The server tries to auto-create the notebook and proceeds normally, with a ⚠️ note in the response that it was created.
    2. If creation fails (permissions, quota, etc.), it falls back to the default notebook and includes a clear warning in the response explaining what happened.
  • notebookName added to evernote_update_note: Allows moving a note to a different notebook via the update tool. Same fallback logic applies.

Implementation

  • src/index.ts: Added notebookCache, refreshNotebookCache(), background seeding in ensureAPI(), dynamic ListToolsRequestSchema handler, and updated create_note/update_note handlers.
  • src/tool-schemas.ts: Added notebookName: z.string().optional() to UpdateNoteSchema.

Test plan

  • TypeScript build passes (npm run build)
  • All 124 existing tests pass (npm test)
  • Manually verify: after auth, calling list_tools returns notebookName descriptions with actual notebook names
  • Manually verify: passing a non-existent notebook to create_note auto-creates it or falls back gracefully

autojack-bot Bot and others added 3 commits June 1, 2026 14:32
…ful fallback

On connect/init, fetch the notebook list and cache it. The ListTools
handler injects the available notebook names into the notebookName
field descriptions of evernote_create_note and evernote_update_note,
so agents know exactly what notebooks are valid before writing.

When a notebookName is passed that doesn't exist:
- First tries to auto-create the notebook
- Falls back to the default notebook if creation fails
- Includes a clear warning in the response either way

Also adds notebookName support to evernote_update_note so notes can
be moved between notebooks with the same graceful fallback behavior.

Closes #44
Apply config({ quiet: true }) consistently to install-to-claude.js and
auth-standalone.ts, matching the pattern already in index.ts. Add a unit
test that enforces the quiet flag is present in all runtime entrypoints.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the Evernote MCP server’s notebook UX by (1) surfacing live notebook names directly in tool argument descriptions during tool discovery, and (2) making notebookName handling in note create/update resilient by auto-creating missing notebooks and falling back to the default notebook when creation fails.

Changes:

  • Added notebook caching + list_tools enrichment to inject live notebook names (and default) into evernote_create_note / evernote_update_note argument descriptions.
  • Implemented “missing notebook” behavior: auto-create on demand; if creation fails, fall back to default notebook and warn in tool output.
  • Extended Zod schemas to reject empty/whitespace-only notebookName, and added notebookName support to UpdateNoteSchema plus unit tests.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/tool-schemas.ts Tightens validation for notebookName (trim + non-empty) and adds notebookName to update schema.
src/notebook-tool-descriptions.ts New helper to resolve notebook cache for discovery and inject notebook names into tool schemas.
src/index.ts Implements notebook cache, discovery-time enrichment, and notebook fallback logic for create/update note.
src/auth-standalone.ts Loads dotenv with quiet: true.
scripts/install-to-claude.js Loads dotenv with quiet: true.
tests/unit/tool-schemas.test.ts Adds unit coverage for UpdateNoteSchema rejecting empty notebookName.
tests/unit/notebook-tool-descriptions.test.ts Adds unit coverage for discovery-time notebook resolution + schema enrichment.
tests/unit/dotenv-quiet.test.ts Ensures runtime entrypoints use quiet dotenv loading.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/notebook-tool-descriptions.ts Outdated
Comment thread src/index.ts
Comment thread src/index.ts Outdated
Comment thread src/index.ts Outdated
Comment thread src/index.ts Outdated
Comment thread src/index.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Surface notebook list on connect + graceful fallback for missing notebooks

2 participants