Skip to main content
Glama
litMcp

litMcp

by L1nze

Library Query

library_query

Run read-only SQL against the local literature library to filter, rank, and screen collected papers, extract evidence, and explore the schema.

Instructions

Query the local literature library with read-only SQL.

TRIGGER after any search to screen, filter, or rank the collected papers (从已检索文献库中筛选/排序, e.g. top-N by citations, year/journal/author filters, substr(fulltext,1,N) evidence extraction).

This is the universal query tool — freely explore schema and run ad-hoc queries:

  • Explore schema: SELECT name FROM sqlite_master WHERE type='table'; PRAGMA table_info(<table>)

  • Count / filter: SELECT count(*) FROM works WHERE ...

  • Plain queries: read-only SQLite SELECT / WITH / EXPLAIN queries — joins, aggregations, window functions, etc.

  • Keyword relevance: FTS5 bm25() ranking over title, abstract, and full text (see below).

Schema: works — id, doi, title, publication_year, publication_date, type, cited_by_count, is_oa, oa_status, has_content, abstract, language, source_id, source_name, authors_json, concepts_json, keywords_json, referenced_works, related_works, raw_json. sources — id, display_name, host_organization, issn_l, issn, type, alternate_titles, abbreviated_title, homepage, works_count, cited_by_count, is_oa, is_in_doaj, topic.

Work ids are OpenAlex ids (W...) or, for hits that OpenAlex does not index, source-prefixed ids from search_multi (arxiv:..., pmid:..., doi:...).

Full-text search: the works_fts FTS5 index covers title, abstract, and fulltext. Use MATCH with bm25() ranking (lower is better): SELECT w.id, w.title, bm25(works_fts) AS rank FROM works_fts JOIN works w ON w.rowid = works_fts.rowid WHERE works_fts MATCH 'sensor AND fusion' ORDER BY rank LIMIT 20

Chinese full-text search: CJK text is indexed as character bigrams, so wrap Chinese keywords with cjk_fts instead of quoting them (中文关键词必须用 cjk_fts 包裹): ... WHERE works_fts MATCH cjk_fts('锂电池 极耳') ORDER BY rank

WAL mode allows concurrent reads + writes — library_query does not block search_keyword / search_ids and vice versa. Database-level read-only enforcement rejects mutations even when they are hidden inside a CTE. WITH RECURSIVE is rejected (an unterminated recursion would starve the shared read connection), and any single statement is interrupted after 30 seconds. Use LIMIT and bounded substr() expressions when selecting large columns such as fulltext or raw_json.

Output is capped: BLOB columns render as <BLOB N bytes>, very long text values are cut with an in-band <truncated: ...> marker, and results over 200 rows or 200,000 chars are trimmed. A trimmed result is returned as an object with rows, truncated, and notes instead of a bare array. Project only the columns you need.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "sql": "<sql>"
    },
    "name": "library_query"
  }
}

Input Schema

NameRequiredDescriptionDefault
sqlYesSQLite SQL (read-only).

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.9/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations supplied, the description carries the full burden and does so: read-only enforcement at the database level (including inside CTEs), WITH RECURSIVE rejection, a 30-second per-statement timeout, WAL concurrency behavior, and output caps (200 rows / 200,000 chars, BLOB rendering, <truncated> markers). These are exactly the constraints an agent needs to avoid failed or truncated calls.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Trigger, examples, schema, and constraints are front-loaded and each section is skimmable. Some bulk comes from listing full column sets for works and sources, which partly duplicates what the advertised PRAGMA table_info exploration would reveal.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex SQL-execution tool, nothing material is missing: dialect, schema, id formats, ranking, safety limits, and truncation behavior are all covered, and return-shape behavior is described even though an output schema exists.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Only one parameter (sql) at 100% schema coverage, yet the description adds substantial meaning: available tables and columns, OpenAlex vs source-prefixed id formats, FTS5 bm25() ranking semantics with a worked example, the cjk_fts() wrapper requirement for Chinese keywords, and LIMIT/substr guidance for large columns.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource — 'Query the local literature library with read-only SQL' — and explicitly labels itself the 'universal query tool', which separates it from the retrieval siblings (search_keyword, search_ids, search_multi) that only fetch papers.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives an explicit trigger ('TRIGGER after any search to screen, filter, or rank the collected papers') plus concrete use cases (top-N by citations, year/journal/author filters, substr evidence extraction). It also names the sibling tools it runs concurrently with, so an agent knows this is post-retrieval screening, not discovery.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.