scholar-paper-cli
spm — CLI for Semantic Scholar. 15 commands, persistent SQLite cache, offline fallback, multilingual semantic search.
Pairs with the writing-for-agents skill for hackathon, proposal, thesis, and article workflows.
Features
- 15 commands: paper/author search, details, citations, references, recommendations, related, session tracking, BibTeX export
- Persistent SQLite cache with 30-day TTL. Repeat queries cost zero.
- Offline fallback: when Semantic Scholar is unreachable, return cached data with offline flag.
- Multilingual semantic search via
intfloat/multilingual-e5-small(100+ languages including Indonesian). - Portable CLI: JSON on stdout, pipeable, scriptable, works in any agent that can run bash and in a plain terminal.
Install
Requires Python 3.13 and uv.
git clone https://github.com/TudeOrangBiasa/scholar-paper-cli
cd scholar-paper-cli
uv sync
# Download embedding model (~118MB, one time)
# See models/README.md for details
Run
spm --help
spm search "quantum entanglement" --limit 2
Every command prints a JSON {"data": ..., "meta": ...} envelope on stdout. Errors print {"error": {"type", "message"}} with a non-zero exit code.
Skill
Teach your agent the CLI by installing the skill:
mkdir -p ~/.config/opencode/skills/spm
cp skills/spm/SKILL.md ~/.config/opencode/skills/spm/
The skill documents every command, the output contract, caching semantics, embeddings, and workflow recipes.
Commands (15)
| Command | Flags (defaults) | Description |
|---|---|---|
spm search <query> |
--limit (10), --offset (0) |
Search papers by query |
spm paper <id> |
--embed |
Get paper by ID, persists + embeds |
spm citations <id> |
--limit (100), --offset (0) |
Papers that cite this paper |
spm references <id> |
--limit (100), --offset (0) |
Papers referenced by this paper |
spm author-search <query> |
--limit (10), --offset (0) |
Search authors by name |
spm author <id> |
— | Get author by ID, persists |
spm author-top <id> |
--limit (10) |
Top papers by citation count |
spm author-duplicates <query> |
--limit (50), --threshold (0.8) |
Group authors by name similarity |
spm consolidate <canonical> <dup>... |
— | Merge duplicate authors in storage |
spm recommend <id> |
--limit (100) |
SS API recommendations |
spm related <id> |
--k (10) |
Local KNN via semantic embeddings |
spm session add <session> <id> |
— | Track paper in working session |
spm session list <session> |
— | List papers in session |
spm session remove <session> <id> |
— | Remove paper from session |
spm bibtex <session> |
— | Export session as BibTeX |
Every command returns a ToolResponse with data and meta (cache metadata: source, cached, offline, fetched_at, ttl_until).
Configuration
See docs/CONFIGURATION.md for all SPM_* environment variables.
Command call flow
A command follows this sequence:
- Shell/agent runs
spm <command>. - cli.py parses args and assembles state (cache dir, SQLite, API client, optional embedder).
- Tool function composes
CachedSemanticScholarClient+ storage CRUD + (optionally) embedder. - Cache check: fresh hit returns cached data. Stale or miss triggers step 5.
- API call (if online): SS API via rate-limited, circuit-broken, offline-aware client.
- Persist: paper, author, citation, session rows written to SQLite. Embedding stored in
embeddings_vec. - Wrap: response enveloped as
ToolResponse[data, meta], printed as JSON on stdout.
See docs/PLAN.md for the full design rationale.
Development
uv run pytest # all tests
uv run ruff check # lint
uv run ty check # type check
uv run ruff format # auto-format
See docs/PLAN.md for the full plan, docs/WORKFLOW.md for document-writing integration, docs/CONFIGURATION.md for env vars.
Status
v0.1.0 feature-complete. 14 of 14 planned issues done. Security review applied: 0 CRITICAL, 0 HIGH, 0 MEDIUM.
Future work is open-ended. See docs/PLAN.md for the original plan and the one deferred item: cross-encoder rerank (v3 in the plan, blocked by bundle size and missing Indonesian benchmark for any small multilingual cross-encoder).
Acknowledgments
- Semantic Scholar (Allen AI) for the Graph API and the public dataset of ~200M academic papers.
- akapet00/semantic-scholar-mcp for the upstream reference. The 15 command set mirrors the original 15 tools.
- argparse (stdlib) for the CLI interface.
- Open source libraries: Pydantic, httpx, sqlite-vec, ONNX Runtime, tokenizers, pytest, ruff, ty.
- Embedding model: intfloat/multilingual-e5-small (MIT license).
How to contribute
- Check docs/PLAN.md for the project plan and any open work.
- Read AGENTS.md for conventions (TDD, ponytail, anti-AI-slop rules).
- Open an issue describing the change.
- Write tests first, then minimum code, then verify all checks pass:
uv run pytest uv run ruff check src tests uv run ty check src tests uv run ruff format --check src tests
- Open a PR. Title format:
type(scope): short description(e.g.feat(api): add batch search endpoint).
License
MIT. See LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scholar_paper_cli-0.1.0.tar.gz.
File metadata
- Download URL: scholar_paper_cli-0.1.0.tar.gz
- Upload date:
- Size: 87.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.2","id":"zara","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5644cf2d5c932364f72db13b93f37bc6d7223b67776ebfad19dc64f64780548d
|
|
| MD5 |
52ca926468ba6339a9b7771cbd1689ce
|
|
| BLAKE2b-256 |
6d3692c12f94463d3bb3ca67a2a8ebb4cd1f606484f67b99ab2f38fe522cb17c
|
File details
Details for the file scholar_paper_cli-0.1.0-py3-none-any.whl.
File metadata
- Download URL: scholar_paper_cli-0.1.0-py3-none-any.whl
- Upload date:
- Size: 34.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.2","id":"zara","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4fc5c013debab3ccffce84cc01ef0a05ec9e01b7472b74fac270b40c4a41cbed
|
|
| MD5 |
59a30129dadea66345a58cb2b3ec5259
|
|
| BLAKE2b-256 |
13f32152f8fff7bac80166ed3eb05df34dd4d0284707a5383d0e22a5c00c0ffa
|