loc-mcp

loc-mcp

MCP server for searching and retrieving full-text pages from the Library of Congress, including newspapers, books, and manuscripts, via the loc.gov API.

Category
访问服务器

README

loc-mcp

A CLI and MCP server for the Library of Congress JSON API: newspapers, books and manuscripts, all full-text indexed and all resolvable to the individual page.

Keyless, no registration, no affiliation required.

Scope

Searches cover the whole of loc.gov by default. --collection <slug> narrows to one collection — chronicling-america for the historic newspapers, which is where the bulk of the transcribed text lives.

There is nothing special-cased about the newspapers. The dedicated chroniclingamerica.loc.gov API has been retired and that collection is now reachable only as one collection of loc.gov, so it is simply one value of --collection like any other.

Install

uv tool install .

Commands

locgov search "<query>" [--pages N|N-M|all] [filters] [--json]
locgov snippets <reference> "<query>"   # the query in context on that page
locgov get <reference>                  # OCR text, prints path to the cached file

A reference is the loc.gov URL printed for each search result. It is both the citation link and the argument the other two commands take.

$ locgov search '"Brooklyn Bridge"' --collection chronicling-america \
    --from-year 1883 --to-year 1883 --per-page 2
# "Brooklyn Bridge" — 2363 results in chronicling-america, page 1 of 1182
[1] 1883-06-16  Image 2 of The Lincoln County leader (White Oaks, Lincoln County, N.M.), June 16, 1883
    the lincoln county leader (white oaks, lincoln county, n.m.) 1882-189? · p. 2 · english · new mexico
    https://www.loc.gov/resource/sn87090072/1883-06-16/ed-1/?sp=2

Note the nested quotes. '"Brooklyn Bridge"' is a phrase search; "Brooklyn Bridge" lets the shell strip the quotes and becomes an AND search, which on this same 1883 range reports 11,098 hits instead of 2,363.

Filters for search: --from-year, --to-year, --language, --state, --title, --collection, --level, --per-page, --sort.

--sort takes relevance (default), date_asc or date_desc.

Query syntax

Bare words are ANDed, and "quoted phrases" match exactly.

There is no boolean OR and no NOT. The words OR and NOT, a leading -, parentheses and | are all silently stripped from the query rather than rejected:

Query Hits
telegraph 3,212,711
telegraph cable 594,470
telegraph -cable 594,470
telegraph NOT cable 594,470

The last three are the same AND query. Each variant of a term therefore needs its own search, and a query written as (a OR b) quietly returns only pages holding both. This is the single most important thing to know before planning a sweep against this source.

Result totals are true counts

Unlike a relevance-ranked archive, loc.gov filters: the reported total is a real count of matching pages, so it can be quoted as one and --sort date_asc is safe on any query. The decade facet counts sum exactly to the reported total.

Pages, not documents

--level page is the default and resolves a hit to the individual page it sits on, for a book or a manuscript exactly as for a newspaper. That is what makes snippets and per-page text available. --level item returns whole documents instead; those have no snippet service, and get on one downloads the entire transcription in a single file.

Readability

By default search returns only material whose text can actually be retrieved (online-format:online text). A hit that cannot be read is of no use, so this is on unless you pass --include-unreadable, and anything unreadable that does slip through is flagged in the output.

Cost

Requests are paced at one every four seconds, shared across processes, so parallel callers share one budget. The Library publishes a limit of 20 requests per minute and blocks an offending IP for a full hour, which is what the conservative default is for. Override with LOC_MIN_REQUEST_INTERVAL only with reason.

Budget in requests: search is one request per result page (up to 150 results each), snippets and get are one request each after a one-off lookup per page that is then memoised on disk — and search seeds that memo for every result it returns. OCR downloads are cached under $XDG_CACHE_HOME/loc-mcp.

MCP server

uv run loc-mcp-install

Installs to Claude Code, Codex CLI and Gemini CLI. The CLI is the primary interface; the server exposes the same client.

License

Apache 2.0

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选