Zotero Project Collections Design
Goal
When Qiongli writes references to local Zotero through the companion, references should be grouped into project-specific Zotero collections instead of landing in one mixed library-level pool.
Current State
The MCPB already accepts collection_path and review_collection_path, and it passes collection_path to POST /qiongli/upsertItems. The companion exposes a /qiongli/collections endpoint, but the upsert path does not currently resolve, create, or attach items to collections.
Design
Collection selection uses this priority:
- Explicit
collection_path. - Explicit
review_collection_path. - Configured default review collection path.
- Configured default collection path.
- A derived project collection path from
project_title,research_title, ortopic. - No collection, preserving existing behavior.
Derived paths use the root Qiongli plus a slug from the supplied title, for example Qiongli/platform-governance. Slugs are lower-case ASCII, hyphen separated, capped to a small number of meaningful tokens, and never override an explicit collection path.
The MCPB owns conversation/project context. It resolves the final collection_path before posting to the companion. The companion owns Zotero library mutation: it resolves nested collection paths, creates missing collections, and adds both new and existing items to the resolved collection.
Companion Behavior
upsertItems should:
- Treat
dry_run: trueas non-mutating and report the intendedcollection_path. - Create nested collections when
dry_run: falseand the path is missing. - Add created items to the target collection.
- Add unchanged or updated duplicate items to the target collection if they are not already members.
- Include collection path/key details in each result where applicable.
MCPB Behavior
qiongli_zotero_upsert_references should:
- Expose
project_title,research_title, andtopicas optional schema fields. - Derive
Qiongli/<slug>only when no explicit or configured collection path is available. - Send the resolved
collection_pathto the companion.
Testing
Use TDD against the existing Node test suites:
- Companion unit tests for dry-run reporting, nested collection creation, and attaching duplicate items to collections.
- Bootstrap VM tests for Zotero runtime collection APIs.
- MCPB tests for schema exposure and derived
collection_pathpayloads.