@cyanheads/libofcongress-mcp-server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@@cyanheads/libofcongress-mcp-serverSearch Chronicling America for newspapers about the 1918 flu"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Public Hosted Server: https://libofcongress.caseyjhand.com/mcp
Overview
Library of Congress digital collections, Chronicling America newspaper archives, and LC Subject Headings (LCSH) authority data. Search items and newspaper pages, retrieve full item metadata and OCR text, resolve LCSH subject terms, and browse curated collections from any MCP client. Runs as a stdio process, a local Streamable HTTP server, or the public hosted endpoint above.
Tools
Tool | Description |
| Search LOC digital collections by keyword with format, date range, subject, location, and collection filters. |
| Retrieve full metadata for a specific LOC digital item — contributors, subjects, rights, formats, and resource links. |
| Search historical newspaper pages in the Chronicling America corpus with OCR excerpts. |
| Retrieve the full OCR text and metadata for a specific newspaper page. |
| Search Library of Congress Subject Headings (LCSH) by keyword. |
| List and browse LOC curated digital collections, optionally filtered by keyword. |
Resources
Resource | Description |
| LOC digital item metadata by ID — stable URI for injecting item context into agent conversations. |
All resource data is also reachable via libofcongress_get_item. Use libofcongress_search to discover item IDs first.
Related MCP server: historical-investigator-mcp
Capability reference
libofcongress_search tool
Filters: eight material formats (
photo,map,newspaper,manuscript,audio,film,book,notated-music), inclusive year range (date_start/date_end), LCSH subject (exact spelling fromlibofcongress_search_subjects), location, andcollection_slug(fromlibofcongress_browse_collections, mutually exclusive withformat); up to 100 results per pageEach result carries
is_item—truefor catalog items whoseidresolves vialibofcongress_get_item,falsefor collections, exhibit/guide pages, and newspaper pages, whoseurlshould be opened instead
libofcongress_get_item tool
Takes a search result's
idverbatim, simple or multi-segment (newspaper pages:sn95047246/1935-09-05/ed-1); returns contributors with their roles, LCSH subject headings, notes, summary, languages, locations, rights, physical description, call number, former IDs, formats, andaccess_restrictedresource_linkscarries downloadable file URLs (TIFF/JPEG/PDF) andrelated_itemsrelated record IDs or URLs, both in full; fields absent upstream are omitted rather than filled
libofcongress_search_newspapers tool
Filters: keyword, inclusive date range, US state (full name), and newspaper title (partial match); up to 100 results per page
Each result carries a ~500-character OCR excerpt for relevance assessment,
states(every state LOC indexes the title under), and theurlthatlibofcongress_get_newspaper_pagetakes verbatim
libofcongress_get_newspaper_page tool
Takes the
urlfrom alibofcongress_search_newspapersresult; anything outsidehttps://www.loc.gov/resource/is rejected asinvalid_page_urlbefore any requestReturns
ocr_textwith the issue'snewspaper_title,date,place_of_publication,states,edition, the page'ssequence, and the issue'ssegment_count;ocr_available: falsemarks an image-only page, and anoticeflags a page whose OCR exists but did not come back
libofcongress_search_subjects tool
Keyword query, up to 50 results per call (default 10); returns LCSH
labeland stable LOCuri— pass the label verbatim aslibofcongress_search'ssubjectfilter, since LCSH uses inverted forms ("Photography, Aerial", "World War, 1939-1945")When id.loc.gov's ranked suggest pool, rather than a lack of coverage, yields an empty or short result, the response says so with a recovery hint
libofcongress_browse_collections tool
Optional keyword filter on collection name and description; up to 100 collections per page
Each collection carries a
slugforlibofcongress_search'scollection_slug(taken from the loc.gov route, not derivable from the title);item_countis approximate and omitted when LOC doesn't provide it
libofcongress://item/{+item_id} resource
Returns the same full record as
libofcongress_get_item, asapplication/jsonitem_idcomes from alibofcongress_searchresult'sidfield, or fromlibofcongress_get_itemMulti-segment newspaper IDs keep their slashes intact (e.g.
libofcongress://item/sn95047246/1935-09-05/ed-1); percent-encoded slashes (%2F) also resolve
Features
Built on @cyanheads/mcp-ts-core: stdio and Streamable HTTP transports, pluggable auth (none / jwt / oauth), swappable storage (in-memory, filesystem, Supabase, Cloudflare KV/R2/D1), structured logging with optional OpenTelemetry tracing.
Library of Congress-specific:
Module-level rate-limit enforcement: 20 req/min limit; 429 responses trigger a 1-hour block, and the error's recovery hint counts down the minutes left and names the time it lifts
Configurable pacing delay (default 3100ms, ~19 req/min) applied before every outbound LOC API request
HTML-response detection guards against silent rate-limit proxy pages that return 200 with HTML
Out-of-range page handling: a page past the end of the results (HTTP 404 on any page after the first) or past the retrieval ceiling (HTTP 400) returns an empty result with a notice, not an error — both point back to page 1 for the real page count, and the ceiling notice also explains how to partition a search that matches more than LOC will page through
Transient-fault resilience: network drops and timeouts retry with backoff behind a 30s per-request timeout ceiling; the 429 rate-limit path is never retried, since a retry would deepen LOC's 1-hour block
Newspaper OCR is surfaced as-is: quality varies by digitization batch and era, and 19th-century or degraded pages may contain garbled text
Agent-friendly output:
Empty results always include a
noticefield with recovery hints — echoes the applied filters and suggests how to broadenPagination status on every search response (
total,page,pages,has_next), capped at LOC's ~100,000-item retrieval ceiling, with a notice disclosing how to page past itocr_availableandis_itemdiscriminator fields let callers branch on data availability without parsing textRecovery hints on every typed error contract — actionable next steps for the agent on every failure mode
Getting started
Public Hosted Instance
A public instance is available at https://libofcongress.caseyjhand.com/mcp — no installation required. Point any MCP client at it via Streamable HTTP:
{
"mcpServers": {
"libofcongress-mcp-server": {
"type": "streamable-http",
"url": "https://libofcongress.caseyjhand.com/mcp"
}
}
}Self-Hosted / Local
Add the following to your MCP client configuration file.
{
"mcpServers": {
"libofcongress-mcp-server": {
"type": "stdio",
"command": "bunx",
"args": ["@cyanheads/libofcongress-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio",
"MCP_SESSION_MODE": "stateless",
"MCP_LOG_LEVEL": "info"
}
}
}
}Or with npx (no Bun required):
{
"mcpServers": {
"libofcongress-mcp-server": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@cyanheads/libofcongress-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio",
"MCP_SESSION_MODE": "stateless",
"MCP_LOG_LEVEL": "info"
}
}
}
}Or with Docker:
{
"mcpServers": {
"libofcongress-mcp-server": {
"type": "stdio",
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "MCP_TRANSPORT_TYPE=stdio",
"-e", "MCP_SESSION_MODE=stateless",
"ghcr.io/cyanheads/libofcongress-mcp-server:latest"
]
}
}
}For Streamable HTTP, set the transport and start the server:
MCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3010 bun run start:http
# Server listens at http://localhost:3010/mcpPrerequisites
Bun v1.4.0 or higher (or Node.js v24+).
No API key required — the LOC JSON API and LC Linked Data endpoints are open. LOC recommends a descriptive
LOC_USER_AGENTfor polite access.
Installation
Clone the repository:
git clone https://github.com/cyanheads/libofcongress-mcp-server.gitNavigate into the directory:
cd libofcongress-mcp-serverInstall dependencies:
bun installConfigure environment:
cp .env.example .env
# edit .env if you want to set LOC_USER_AGENT or LOC_REQUEST_DELAY_MSConfiguration
All configuration is validated at startup via Zod schemas in src/config/server-config.ts.
Variable | Description | Default |
| User-Agent header sent with LOC API requests. LOC recommends a descriptive value for polite access. |
|
| Delay in milliseconds between LOC API requests to stay under the 20 req/min rate limit. |
|
| Transport: |
|
| Port for HTTP server. |
|
| Auth mode: |
|
| HTTP session mode. This server is explicitly stateless. |
|
| Log level (RFC 5424). |
|
| Directory for log files (Node.js only). |
|
| Log each failed tool call's arguments and result, redacted by key name and capped at |
|
| Storage backend. |
|
| Enable OpenTelemetry instrumentation (spans, metrics, completion logs). |
|
See .env.example for the full list of optional overrides.
Running the server
Local development
Build and run:
# One-time build bun run rebuild # Run the built server bun run start:stdio # or bun run start:httpRun checks and tests:
bun run devcheck # Lint, format, typecheck, security bun run test # Vitest test suite bun run lint:mcp # Validate MCP definitions against spec
Docker
docker build -t libofcongress-mcp-server .
docker run --rm -p 3010:3010 libofcongress-mcp-serverThe Dockerfile defaults to HTTP transport, stateless session mode, and logs to /var/log/libofcongress-mcp-server. OpenTelemetry peer dependencies are installed by default — build with --build-arg OTEL_ENABLED=false to omit them.
Project structure
Directory | Purpose |
|
|
| Server-specific environment variable parsing ( |
| Tool definitions ( |
| Resource definitions — |
|
|
|
|
| Unit and integration tests mirroring |
Development guide
See CLAUDE.md for development guidelines and architectural rules. The short version:
Handlers throw, framework catches — no
try/catchin tool logicUse
ctx.logfor request-scoped logging,ctx.statefor tenant-scoped storageRegister new tools and resources via the arrays in
src/index.tsWrap external API calls: validate raw → normalize to domain type → return output schema; never fabricate missing fields
Contributing
Issues are welcome. Run checks and tests before submitting:
bun run devcheck
bun run testLicense
Apache-2.0 — see LICENSE for details.
This server cannot be deployed
Maintenance
Related MCP Connectors
Chronicling America MCP — full-text search of ~150 years of digitized U.S.
Library of Congress (loc.gov) MCP — the world's largest library.
Internet Archive (archive.org) item search & metadata MCP.
Search 14.5M Smithsonian Open Access objects, get CC0 images, find cross-collection connections.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceProvides access to the Library of Congress (loc.gov) data, enabling AI agents to search and retrieve information from the world's largest library.7 npmMIT
- FlicenseAqualityDmaintenanceEnables searching and retrieving historical records from the Library of Congress, including newspapers, photos, maps, manuscripts, audio, and film, via the Model Context Protocol.101-
- AlicenseAqualityBmaintenanceMCP server for searching and retrieving full-text pages from the Library of Congress, including newspapers, books, and manuscripts, via the loc.gov API.3Apache 2.0
- AlicenseNot gradedqualityAmaintenanceSearch and trace US federal rules across the Federal Register (proposed/final rules and notices), the eCFR (codified, point-in-time CFR full text, locally mirrored), and Regulations.gov (rulemaking dockets and public comments) via MCP.708 npm1Apache 2.0