@cyanheads/libofcongress-mcp-server
Click on "Install 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
Tools
Six tools covering the Library of Congress digital holdings — general search with format/date/subject/location filters, full item retrieval, Chronicling America newspaper search with OCR, single-page full-text fetch, LCSH subject heading lookup, and curated collection browsing:
Tool | Description |
| Search LOC digital collections by keyword with optional format, date range, subject heading, geographic location, and collection filters. Returns item summaries with IDs for follow-up retrieval. |
| Retrieve full metadata for a specific LOC item — contributors, subjects, summary, languages, locations, rights, physical description, call number, formats, access restrictions, resource links (TIFF/JPEG/PDF), and related items. |
| Search historical newspaper pages in the Chronicling America corpus. Returns pages with OCR text excerpts (~500 chars), publication title, date, state, and the URL needed for |
| Retrieve the full OCR text of a specific newspaper page. Pass the |
| Search Library of Congress Subject Headings (LCSH) by keyword. Returns controlled-vocabulary labels and URIs — use the label as the |
| List and browse LOC curated digital collections with descriptions, item counts, and slugs. Optionally filter by keyword. |
libofcongress_search
Search the LOC digital collections with full-text keyword matching and facet filters.
Eight material formats:
photo,map,newspaper,manuscript,audio,film,book,notated-musicDate range filtering by year (inclusive start and end)
Subject heading filter — use
libofcongress_search_subjectsfirst to get the exact LCSH spellingGeographic location filter (e.g.,
"oklahoma","washington d.c.")collection_slugscopes the search to one curated collection — pass a slug fromlibofcongress_browse_collections. Mutually exclusive withformat(each selects a different LOC endpoint); an unknown slug returnscollection_not_foundPagination up to 100 results per page —
pages/has_nextrespect LOC's ~100,000-item retrieval ceiling (a notice discloses how to reach the rest: partition by date, subject, or location); real results on a page beyond the reported total are always returned, never discardedEmpty results include a
noticefield with recovery hints — echoes the applied filtersEach result carries
is_item—truefor catalog items whoseidresolves vialibofcongress_get_item,falsefor non-item results (collections, exhibit/guide pages, newspaper pages); open theirurlinstead
libofcongress_get_item
Retrieve the full metadata record for a specific LOC digital item.
Returns contributors, LCSH subject headings, rights information, physical/technical description, and cataloger notes
Also returns
summary,languages,locations,call_number(shelf location for requesting the physical original),former_ids,original_formats,online_formats, andaccess_restricted— all sourced from the same upstream response, no extra requestresource_linkscontains URLs to downloadable digital files (TIFF, JPEG, PDF) for items with digital surrogatesrelated_itemslists IDs of related LOC items for follow-up retrievalresource_linksandrelated_itemsrender in full in bothstructuredContentandcontent[]— no truncation, socontent[]-only clients see every valueDeduplicates resource links from nested
files[]arraysAccepts multi-segment item IDs verbatim (e.g. newspaper pages
sn95047246/1935-09-05/ed-1); returnedurlis always an absolutehttps://URLFields absent upstream are omitted rather than filled — a sparse record stays sparse
libofcongress_search_newspapers
Search historical newspaper pages in the Chronicling America corpus via the LOC /newspapers/ endpoint.
OCR text excerpts (~500 chars) returned inline for relevance assessment without a second hop
Filters: keyword, date range, US state (full state name), newspaper publication title (partial match)
Returns the
urlfield needed bylibofcongress_get_newspaper_page— do not construct these URLs manuallyOCR quality varies by digitization batch and era; 19th-century and degraded materials may contain garbled text
Empty results include a
noticewith recovery suggestions (broaden date, try different keywords, historical OCR caveat)
libofcongress_get_newspaper_page
Retrieve the full OCR text and metadata for a specific newspaper page.
Accepts the
urlfield from alibofcongress_search_newspapersresult — validates the URL prefix before any outbound requestFetches JSON from the LOC text-services endpoint (
tile.loc.gov) and reads plain text from thefull_textfieldocr_available: falsewhen the page has no digitized text (image-only batch) — not an error, a data propertyWhen
ocr_availableistruebut the text service returns nothing, a notice discloses the retrieval miss on both response surfaces — distinct from a genuinely image-only pageStrips echoed
q=params from fulltext URLs to avoid tile.loc.gov 404s (known LOC API quirk)
libofcongress_search_subjects
Search Library of Congress Subject Headings (LCSH) via id.loc.gov.
Returns standardized labels and stable LOC URIs for subjects matching the keyword
countfield indicates approximate number of LOC items carrying that heading (when available)Use the returned
labelexactly in thelibofcongress_searchsubjectfilter — LCSH uses inverted forms ("Photography, Aerial", "World War, 1939-1945") that differ from natural languageDraws from the id.loc.gov suggest endpoint's full 50-candidate pool (not scaled to
limit) and filters to true LCSH headings, so a heading ranked below name-authority records isn't reported as a false empty; when that ranked pool — rather than a lack of coverage — yields an empty or short result, the response discloses it with a recovery hint
libofcongress_browse_collections
List and browse LOC curated digital collections.
Returns collection
slug— pass it tolibofcongress_searchascollection_slugto search inside that collectionSlugs come from the collection's loc.gov route, not its title —
"Aaron Copland Collection"lives ataaron-copland, so they aren't guessableOptional keyword filter by collection name/description
Item counts are approximate; omitted when the API doesn't provide them
Pagination supported up to 100 collections per page
Related MCP server: mcp-europeana
Resource
Type | Name | Description |
Resource |
| LOC digital item metadata by ID. Stable URI for injecting item context into agent conversations. Returns the same full record as |
All resource data is also reachable via libofcongress_get_item. Use libofcongress_search to discover item IDs first.
Write the item ID with its slashes intact — libofcongress://item/sn95047246/1935-09-05/ed-1 is the canonical form for a multi-segment newspaper ID. Percent-encoded slashes (%2F) also resolve.
Features
Built on @cyanheads/mcp-ts-core:
Declarative tool and resource definitions — single file per primitive, framework handles registration and validation
Unified error handling — handlers throw, framework catches, classifies, and formats
Pluggable auth:
none,jwt,oauthSwappable storage backends:
in-memory,filesystem,Supabase,Cloudflare KV/R2/D1Structured logging with optional OpenTelemetry tracing
STDIO and Streamable HTTP transports
LOC-specific:
Module-level rate-limit enforcement: 20 req/min limit; 429 responses trigger a 1-hour block with per-minute countdown in error messages
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: LOC returns HTTP 400 or 520 for page numbers beyond the result set — treated as empty rather than errors
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
JSON OCR extraction for newspaper text — reads the
full_textfield from LOC text-services responsesTwo-service architecture:
LocApiServiceforwww.loc.govandLcLinkedDataServiceforid.loc.gov
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_availablediscriminator on newspaper page results so callers can branch on data availability without parsing textRecovery hints on all error contracts — actionable next steps for the agent on every failure mode
Getting started
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_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_LOG_LEVEL": "info"
}
}
}
}Or with Docker:
{
"mcpServers": {
"libofcongress-mcp-server": {
"type": "stdio",
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "MCP_TRANSPORT_TYPE=stdio",
"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.3.2 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: |
|
| Log level (RFC 5424). |
|
| Directory for log files (Node.js only). |
|
| 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 and logs to /var/log/libofcongress-mcp-server.
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 and pull requests 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 installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityBmaintenanceEnables searching and accessing OCR text from millions of digitized documents in Gallica, the digital library of the Bibliothèque nationale de France, through MCP tools for text search, snippet retrieval, and full-text download.Last updated31Apache 2.0
- Alicense-qualityCmaintenanceEnables searching and retrieving records from the Europeana digital collection, including metadata such as titles, creators, dates, and images, via two MCP tools: search and record.Last updated28MIT
- Alicense-qualityCmaintenanceProvides access to the Library of Congress (loc.gov) data, enabling AI agents to search and retrieve information from the world's largest library.Last updated8MIT
- FlicenseAqualityCmaintenanceEnables searching and retrieving historical records from the Library of Congress, including newspapers, photos, maps, manuscripts, audio, and film, via the Model Context Protocol.Last updated10
Related MCP Connectors
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.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/cyanheads/libofcongress-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server