Skip to content

## Add MCP tool for biblio graph expansion

The core graph expansion logic alrea

Goal

(promoted from note)

Context

(see source note)

Prompt

Fix the issue described in /storage2/arash/projects/projio/docs/log/issue/issue-arash-20260328-174906-119594.md. Read it first, then implement the proposed fix.

Acceptance Criteria

  • [ ]

Result

Completed in 174.3s (1 steps, model: opus)

Session: 4cb2c2fb-6809-4442-a655-4072de191bfb Result note: /storage2/arash/worklog/workflow/captures/20260328-180454-594e4e/note.md

Output

All four files have been created/updated:

1. **`packages/biblio/src/biblio/mcp.py`** — Added `graph_expand()` function after `library_set_bulk` that loads config, reads seed records from `resolved.jsonl`, returns error if none found, otherwise calls `expand_openalex_reference_graph` and returns a summary dict.

2. **`src/projio/mcp/biblio.py`** — Added `biblio_graph_expand()` wrapper before `biblio_rag_sync` following the same pattern (check `_biblio_available()`, get root, import from biblio.mcp, call, wrap in `json_dict()`).

3. **`src/projio/mcp/server.py`** — Registered `@server.tool("biblio_graph_expand")` after `biblio_rag_sync` and before `# --- Notio tools ---`, with parameters `citekeys: list[str] = []`, `direction: str = "references"`, `merge: bool = True`, `force: bool = False`.

4. **`packages/biblio/tests/test_biblio_graph_mcp.py`** — Two smoke tests:
   - `test_graph_expand_error_when_no_resolved_jsonl` — verifies error dict when no seed records exist
   - `test_graph_expand_calls_expand_correctly` — uses monkeypatch to verify correct arg forwarding

Please run the verification commands to confirm:
```bash
python3 -c "from biblio.mcp import graph_expand; print('OK')"
cd packages/biblio && python3 -m pytest tests/test_biblio_graph_mcp.py -v

Next Steps

  1. Run python3 -m pytest packages/biblio/tests/test_biblio_graph_mcp.py -v to verify the smoke tests pass.
  2. Update the MCP tool instructions in the three places (worklog MCP server, worklog CLAUDE.md, projio codegen) to include biblio_graph_expand.
  3. Save and push changes with datalad_save and datalad_push. ```