Loading...
Loading...
Search Zotero library using code execution for efficient multi-strategy searches without crash risks. Use this skill when the user needs comprehensive Zotero searches with automatic deduplication and ranking.
npx skill4agent add kerim/zotero-code-execution zotero-mcp-codeimport sys
sys.path.append('/Users/niyaro/Documents/Code/zotero-code-execution')
import setup_paths
from zotero_lib import SearchOrchestrator, format_results
# Single comprehensive search
orchestrator = SearchOrchestrator()
results = orchestrator.comprehensive_search(
"user's query here",
max_results=20 # Return top 20 most relevant
)
# Format and display
print(format_results(results, include_abstracts=True))import sys
sys.path.append('/Users/niyaro/Documents/Code/zotero-code-execution')
import setup_paths
from zotero_lib import SearchOrchestrator, format_results
orchestrator = SearchOrchestrator()
results = orchestrator.comprehensive_search("embodied cognition", max_results=20)
print(format_results(results))import sys
sys.path.append('/Users/niyaro/Documents/Code/zotero-code-execution')
import setup_paths
from zotero_lib import ZoteroLibrary, SearchOrchestrator, format_results
library = ZoteroLibrary()
orchestrator = SearchOrchestrator(library)
# Fetch broadly (safe - filtering happens in code)
items = library.search_items("machine learning", limit=100)
# Filter in code
filtered = orchestrator.filter_by_criteria(
items,
item_types=["journalArticle"],
date_range=(2020, 2025)
)
print(format_results(filtered[:15]))import sys
sys.path.append('/Users/niyaro/Documents/Code/zotero-code-execution')
import setup_paths
from zotero_lib import ZoteroLibrary, format_results
library = ZoteroLibrary()
results = library.search_items(
"Kahneman",
qmode="titleCreatorYear",
limit=50
)
# Sort by date
sorted_results = sorted(results, key=lambda x: x.date, reverse=True)
print(format_results(sorted_results))import sys
sys.path.append('/Users/niyaro/Documents/Code/zotero-code-execution')
import setup_paths
from zotero_lib import ZoteroLibrary, format_results
library = ZoteroLibrary()
results = library.search_by_tag(["learning", "cognition"], limit=50)
print(format_results(results[:20]))import sys
sys.path.append('/Users/niyaro/Documents/Code/zotero-code-execution')
import setup_paths
from zotero_lib import ZoteroLibrary, format_results
library = ZoteroLibrary()
results = library.get_recent(limit=20)
print(format_results(results))import sys
sys.path.append('/Users/niyaro/Documents/Code/zotero-code-execution')
import setup_paths
from zotero_lib import SearchOrchestrator, format_results
orchestrator = SearchOrchestrator()
# Search both topics
results1 = orchestrator.comprehensive_search("cognition", max_results=30)
results2 = orchestrator.comprehensive_search("learning", max_results=30)
# Find intersection
keys1 = {item.key for item in results1}
keys2 = {item.key for item in results2}
common_keys = keys1 & keys2
if common_keys:
common_items = [item for item in results1 if item.key in common_keys]
print("Papers about both topics:")
print(format_results(common_items))
else:
print("No papers found on both topics.")
print("\nCognition results:")
print(format_results(results1[:10]))
print("\nLearning results:")
print(format_results(results2[:10]))import sys
sys.path.append('/Users/niyaro/Documents/Code/zotero-code-execution')
import setup_paths
from zotero_lib import ZoteroLibrary, SearchOrchestrator, format_results
library = ZoteroLibrary()
orchestrator = SearchOrchestrator(library)
# Fetch large dataset
items = library.search_items("neural networks", limit=100)
# Custom filtering
recent_with_doi = [
item for item in items
if item.doi and item.date and int(item.date[:4]) >= 2020
]
print(format_results(recent_with_doi[:15]))import sys
sys.path.append('/Users/niyaro/Documents/Code/zotero-code-execution')
import setup_paths
from zotero_lib import ZoteroLibrary, SearchOrchestrator, format_results
library = ZoteroLibrary()
orchestrator = SearchOrchestrator(library)
all_results = set()
# Multiple search angles
queries = [
"skill transfer",
"transfer of learning",
"generalization of skills"
]
for query in queries:
results = library.search_items(query, limit=30)
all_results.update(results)
# Rank combined results
ranked = orchestrator._rank_items(list(all_results), "skill transfer")
print(format_results(ranked[:20]))import sys
sys.path.append('/Users/niyaro/Documents/Code/zotero-code-execution')
import setup_paths
from zotero_lib import ZoteroLibrary, SearchOrchestrator, format_results
library = ZoteroLibrary()
orchestrator = SearchOrchestrator(library)
# Initial search
initial = library.search_items("memory", limit=50)
# Analyze tags
tag_freq = {}
for item in initial:
for tag in item.tags:
tag_freq[tag] = tag_freq.get(tag, 0) + 1
# Find most common tag
if tag_freq:
most_common_tag = max(tag_freq, key=tag_freq.get)
# Refine search
refined = orchestrator.filter_by_criteria(
initial,
required_tags=[most_common_tag]
)
print(f"Papers with most common tag '{most_common_tag}':")
print(format_results(refined))SearchOrchestratorcomprehensive_search(query, max_results=20, use_semantic=True, use_keyword=True, use_tags=True, search_limit_per_strategy=50)querymax_resultsuse_semanticuse_keyworduse_tagssearch_limit_per_strategyfilter_by_criteria(items, item_types=None, date_range=None, required_tags=None, excluded_tags=None)itemsitem_typesdate_rangerequired_tagsexcluded_tagsZoteroLibrarysearch_items(query, qmode="titleCreatorYear", item_type="-attachment", limit=100, tag=None)semantic_search(query, limit=100, search_type="hybrid")search_by_tag(tags, item_type="-attachment", limit=100)get_recent(limit=50)get_tags()format_results(items, include_abstracts=True, max_abstract_length=300)orchestrator.comprehensive_search(
query,
max_results=20, # Top 20 results
search_limit_per_strategy=50 # Fetch 50 per strategy
)results = orchestrator.comprehensive_search(
query,
max_results=10,
search_limit_per_strategy=20
)results = orchestrator.comprehensive_search(
query,
max_results=30,
search_limit_per_strategy=100
)comprehensive_search("embodied cognition", max_results=20)# 5+ function calls, all results to context
results1 = zotero_semantic_search("query", limit=10) # Crash risk if > 15
results2 = zotero_search_items("query", limit=10)
# ... manual deduplication, no ranking
# All items (50+) load into context# 1 function call, only top results to context
results = orchestrator.comprehensive_search("query", max_results=20)
# Fetches 250+ items, processes in code, returns top 20import sys
sys.path.append('/Users/niyaro/Documents/Code/zotero-code-execution')
import setup_paths
from zotero_lib import SearchOrchestrator, format_results
orchestrator = SearchOrchestrator()
try:
results = orchestrator.comprehensive_search("query", max_results=20)
if results:
print(format_results(results))
else:
print("No results found. Try a broader search term.")
except Exception as e:
print(f"Search failed: {e}")
print("Please check your Zotero MCP configuration.")/Users/niyaro/Documents/Code/zotero-code-execution/examples.py| Task | Code |
|---|---|
| Basic search | |
| Filter by type | |
| Filter by date | |
| Search author | |
| Search by tag | |
| Recent items | |
| Format output | |
comprehensive_search()search_limit_per_strategy/Users/niyaro/Documents/Code/zotero-code-execution/QUICK_START.md/Users/niyaro/Documents/Code/zotero-code-execution/README.md/Users/niyaro/Documents/Code/zotero-code-execution/examples.py/Users/niyaro/Documents/Code/zotero-code-execution/HONEST_STATUS.md# Multiple manual MCP calls
results1 = zotero_semantic_search("query", limit=10)
results2 = zotero_search_items("query", limit=10)
# Manual deduplication...# One function call with code execution
import sys
sys.path.append('/Users/niyaro/Documents/Code/zotero-code-execution')
import setup_paths
from zotero_lib import SearchOrchestrator, format_results
orchestrator = SearchOrchestrator()
results = orchestrator.comprehensive_search("query", max_results=20)
print(format_results(results))/Users/niyaro/Documents/Code/zotero-code-execution/