create_collection
Organize your Zotero library by creating new collections to categorize and manage research materials.
Instructions
Create a new Zotero collection
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| parent_key | No |
Implementation Reference
- src/zotero_mcp/server.py:162-166 (handler)The handler function in the server that exposes the 'create_collection' tool via FastMCP.
@mcp.tool(description="Create a new Zotero collection") def create_collection(name: str, parent_key: str = "") -> str: """Create a collection, optionally under a parent collection.""" key = _get_client().create_collection(name, parent_key) return json.dumps({"key": key}, ensure_ascii=False) - src/zotero_mcp/client.py:279-289 (handler)The actual implementation logic that interacts with the pyzotero client to create a collection.
def create_collection(self, name: str, parent_key: str = "") -> str: """Create a collection. Returns collection key.""" payload = {"name": name} if parent_key: payload["parentCollection"] = parent_key resp = self.zot.create_collections([payload]) created = resp.get("successful", resp.get("success", {})) if created: val = list(created.values())[0] if isinstance(created, dict) else created[0] return val.get("key", val.get("data", {}).get("key", "")) if isinstance(val, dict) else str(val) raise RuntimeError(f"Failed to create collection: {resp.get('failed', resp)}")