server
zocrates.mcp.server ¶
Zocrates FastMCP Server definition.
Exposes 4 core academic retrieval tools, resources for reading OKF bundles and knowledge catalogs, and prompt templates for structured literature review.
STRICT INVARIANT: Stdout is reserved strictly for JSON-RPC 2.0 protocol frames. All logging, diagnostic messages, and tracebacks MUST route exclusively to sys.stderr.
BackendClient ¶
HTTP client for communicating with the local Zocrates FastAPI backend.
Initialize the MCP backend client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str | None
|
Optional backend base URL (defaults to ZOCRATES_BACKEND_URL or http://127.0.0.1:8765). |
None
|
client
|
Client | None
|
Optional preconfigured httpx.Client instance. |
None
|
auth_token
|
str | None
|
Optional authentication token (auto-resolved if omitted). |
None
|
Source code in zocrates/mcp/backend_client.py
close ¶
get_catalog ¶
get_relations ¶
Retrieve verified related papers from the literature knowledge graph.
Source code in zocrates/mcp/backend_client.py
get_toc ¶
Retrieve Table of Contents and outline metadata for a document.
read_document ¶
Read full document Markdown or targeted assets (sections, figures, tables).
Source code in zocrates/mcp/backend_client.py
search ¶
Perform hybrid semantic + BM25 keyword search over library chunks.
Source code in zocrates/mcp/backend_client.py
get_document_markdown ¶
Return the complete OKF document Markdown for a given item key.
Source code in zocrates/mcp/server.py
get_document_relations ¶
Return literature neighborhood relations for a given item key as a Markdown table.
Source code in zocrates/mcp/server.py
get_document_toc ¶
Retrieve the human- and agent-readable Table of Contents, Title, Abstract/Summary, Sections outline with word counts, and Figures/Tables catalog from toc.md.
Automatically resolves parent item keys to converted child attachments (PDF-first priority) and materializes notes on demand.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item_key
|
str
|
Unique Zotero item key (e.g., 'ABCD1234'). |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing table of contents content, title, authors, year, and sections. |
Source code in zocrates/mcp/server.py
get_library_index ¶
Return the root-level knowledge base catalog index.md listing all converted documents.
Source code in zocrates/mcp/server.py
get_related_items ¶
Discover verified related papers and literature connections from the Zocrates knowledge graph for a given item.
Returns target item keys, titles, relation types (human_curated, hybrid_search, shared_tags), and similarity scores.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item_key
|
str
|
Unique Zotero item key (e.g., 'ABCD1234'). |
required |
ceiling
|
int
|
Maximum number of related papers to return (clamped between 1 and 50). |
25
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing verified relations and total count. |
literature_review ¶
Guides an AI agent through a systematic 4-step literature review workflow over the local Zotero library.
Source code in zocrates/mcp/server.py
read_document ¶
Read full document Markdown or targeted sections, figures, or tables from the OKF bundle.
Accepts exact asset IDs from toc.md ('s0', 's1', 'f1', 't1'), a list of IDs, or fuzzy heading names. When asset_id is omitted, returns the document in ~3000-word pages. Tables return raw CSV structured content when available; figures return synthetic captions and asset file paths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item_key
|
str
|
Unique Zotero item key (e.g., 'ABCD1234'). |
required |
asset_id
|
str | list[str] | None
|
Optional asset ID (e.g., 's1', 't1'), list of IDs, or fuzzy heading name. |
None
|
page
|
int | None
|
Optional 1-indexed page number if reading the full document paginated. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing document assets with content, headings, word counts, and intersecting chunk IDs. |
Source code in zocrates/mcp/server.py
search_corpus ¶
Hybrid (dense vector + FTS5 BM25) search over the indexed Zotero library with compound pre-filtering.
Supports filtering by item_key(s) and chunk_type ('frontmatter', 'figure', 'table', 'equation', 'code', 'text'). Searching chunk_type='frontmatter' discovers paper metadata, abstracts, and bibliographic details. Results include cosine_similarity and rrf_score.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Natural language research query or keyword query. |
required |
item_key
|
str | list[str] | None
|
Optional item key or list of keys to restrict search scope. |
None
|
chunk_type
|
str | list[str] | None
|
Optional chunk type or list of chunk types to filter by. |
None
|
limit
|
int
|
Number of results to return (clamped between 1 and 20 by backend). |
10
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing search status and list of matching chunk results with metadata. |