@cyanheads/libofcongress-mcp-server 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/AGENTS.md +388 -0
  2. package/CLAUDE.md +388 -0
  3. package/Dockerfile +83 -0
  4. package/LICENSE +201 -0
  5. package/README.md +316 -0
  6. package/changelog/0.1.x/0.1.0.md +22 -0
  7. package/changelog/0.1.x/0.1.1.md +29 -0
  8. package/changelog/0.2.x/0.2.0.md +13 -0
  9. package/changelog/0.2.x/0.2.1.md +14 -0
  10. package/changelog/template.md +119 -0
  11. package/dist/config/server-config.d.ts +13 -0
  12. package/dist/config/server-config.d.ts.map +1 -0
  13. package/dist/config/server-config.js +25 -0
  14. package/dist/config/server-config.js.map +1 -0
  15. package/dist/index.d.ts +7 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +35 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/mcp-server/resources/definitions/libofcongress-item.resource.d.ts +9 -0
  20. package/dist/mcp-server/resources/definitions/libofcongress-item.resource.d.ts.map +1 -0
  21. package/dist/mcp-server/resources/definitions/libofcongress-item.resource.js +24 -0
  22. package/dist/mcp-server/resources/definitions/libofcongress-item.resource.js.map +1 -0
  23. package/dist/mcp-server/tools/definitions/libofcongress-browse-collections.tool.d.ts +35 -0
  24. package/dist/mcp-server/tools/definitions/libofcongress-browse-collections.tool.d.ts.map +1 -0
  25. package/dist/mcp-server/tools/definitions/libofcongress-browse-collections.tool.js +119 -0
  26. package/dist/mcp-server/tools/definitions/libofcongress-browse-collections.tool.js.map +1 -0
  27. package/dist/mcp-server/tools/definitions/libofcongress-get-item.tool.d.ts +32 -0
  28. package/dist/mcp-server/tools/definitions/libofcongress-get-item.tool.d.ts.map +1 -0
  29. package/dist/mcp-server/tools/definitions/libofcongress-get-item.tool.js +97 -0
  30. package/dist/mcp-server/tools/definitions/libofcongress-get-item.tool.js.map +1 -0
  31. package/dist/mcp-server/tools/definitions/libofcongress-get-newspaper-page.tool.d.ts +29 -0
  32. package/dist/mcp-server/tools/definitions/libofcongress-get-newspaper-page.tool.d.ts.map +1 -0
  33. package/dist/mcp-server/tools/definitions/libofcongress-get-newspaper-page.tool.js +89 -0
  34. package/dist/mcp-server/tools/definitions/libofcongress-get-newspaper-page.tool.js.map +1 -0
  35. package/dist/mcp-server/tools/definitions/libofcongress-search-newspapers.tool.d.ts +40 -0
  36. package/dist/mcp-server/tools/definitions/libofcongress-search-newspapers.tool.d.ts.map +1 -0
  37. package/dist/mcp-server/tools/definitions/libofcongress-search-newspapers.tool.js +162 -0
  38. package/dist/mcp-server/tools/definitions/libofcongress-search-newspapers.tool.js.map +1 -0
  39. package/dist/mcp-server/tools/definitions/libofcongress-search-subjects.tool.d.ts +24 -0
  40. package/dist/mcp-server/tools/definitions/libofcongress-search-subjects.tool.d.ts.map +1 -0
  41. package/dist/mcp-server/tools/definitions/libofcongress-search-subjects.tool.js +86 -0
  42. package/dist/mcp-server/tools/definitions/libofcongress-search-subjects.tool.js.map +1 -0
  43. package/dist/mcp-server/tools/definitions/libofcongress-search.tool.d.ts +50 -0
  44. package/dist/mcp-server/tools/definitions/libofcongress-search.tool.d.ts.map +1 -0
  45. package/dist/mcp-server/tools/definitions/libofcongress-search.tool.js +171 -0
  46. package/dist/mcp-server/tools/definitions/libofcongress-search.tool.js.map +1 -0
  47. package/dist/services/lc-linked-data/lc-linked-data-service.d.ts +17 -0
  48. package/dist/services/lc-linked-data/lc-linked-data-service.d.ts.map +1 -0
  49. package/dist/services/lc-linked-data/lc-linked-data-service.js +71 -0
  50. package/dist/services/lc-linked-data/lc-linked-data-service.js.map +1 -0
  51. package/dist/services/lc-linked-data/types.d.ts +11 -0
  52. package/dist/services/lc-linked-data/types.d.ts.map +1 -0
  53. package/dist/services/lc-linked-data/types.js +6 -0
  54. package/dist/services/lc-linked-data/types.js.map +1 -0
  55. package/dist/services/loc-api/loc-api-service.d.ts +65 -0
  56. package/dist/services/loc-api/loc-api-service.d.ts.map +1 -0
  57. package/dist/services/loc-api/loc-api-service.js +418 -0
  58. package/dist/services/loc-api/loc-api-service.js.map +1 -0
  59. package/dist/services/loc-api/types.d.ts +156 -0
  60. package/dist/services/loc-api/types.d.ts.map +1 -0
  61. package/dist/services/loc-api/types.js +6 -0
  62. package/dist/services/loc-api/types.js.map +1 -0
  63. package/package.json +92 -0
  64. package/server.json +127 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 Casey Hand @cyanheads
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,316 @@
1
+ <div align="center">
2
+ <h1>@cyanheads/libofcongress-mcp-server</h1>
3
+ <p><b>Search LOC digital collections, browse Chronicling America newspapers with full OCR text, and look up LC Subject Headings via MCP. STDIO or Streamable HTTP.</b>
4
+ <div>6 Tools • 1 Resource</div>
5
+ </p>
6
+ </div>
7
+
8
+ <div align="center">
9
+
10
+ [![Version](https://img.shields.io/badge/Version-0.2.1-blue.svg?style=flat-square)](./CHANGELOG.md) [![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg?style=flat-square)](./LICENSE) [![Docker](https://img.shields.io/badge/Docker-ghcr.io-2496ED?style=flat-square&logo=docker&logoColor=white)](https://github.com/users/cyanheads/packages/container/package/libofcongress-mcp-server) [![MCP SDK](https://img.shields.io/badge/MCP%20SDK-^1.29.0-green.svg?style=flat-square)](https://modelcontextprotocol.io/) [![npm](https://img.shields.io/npm/v/%40cyanheads%2Flibofcongress-mcp-server?style=flat-square&logo=npm&logoColor=white)](https://www.npmjs.com/package/@cyanheads/libofcongress-mcp-server) [![TypeScript](https://img.shields.io/badge/TypeScript-^5.9.3-3178C6.svg?style=flat-square)](https://www.typescriptlang.org/) [![Bun](https://img.shields.io/badge/Bun-v1.3.11-blueviolet.svg?style=flat-square)](https://bun.sh/)
11
+
12
+ </div>
13
+
14
+ <div align="center">
15
+
16
+ [![Install in Claude Desktop](https://img.shields.io/badge/Install_in-Claude_Desktop-D97757?style=for-the-badge&logo=anthropic&logoColor=white)](https://github.com/cyanheads/libofcongress-mcp-server/releases/latest/download/libofcongress-mcp-server.mcpb) [![Install in Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en/install-mcp?name=libofcongress-mcp-server&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBjeWFuaGVhZHMvbGlib2Zjb25ncmVzcy1tY3Atc2VydmVyIl19) [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=for-the-badge&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode:mcp/install?%7B%22name%22%3A%22libofcongress-mcp-server%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40cyanheads%2Flibofcongress-mcp-server%22%5D%7D)
17
+
18
+ [![Framework](https://img.shields.io/badge/Built%20on-@cyanheads/mcp--ts--core-67E8F9?style=flat-square)](https://www.npmjs.com/package/@cyanheads/mcp-ts-core)
19
+
20
+ </div>
21
+
22
+ ---
23
+
24
+ ## Tools
25
+
26
+ 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:
27
+
28
+ | Tool | Description |
29
+ |:-----|:------------|
30
+ | `libofcongress_search` | Search LOC digital collections by keyword with optional format, date range, subject heading, and geographic location filters. Returns item summaries with IDs for follow-up retrieval. |
31
+ | `libofcongress_get_item` | Retrieve full metadata for a specific LOC item — contributors, subjects, rights, physical description, resource links (TIFF/JPEG/PDF), and related items. |
32
+ | `libofcongress_search_newspapers` | 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 `libofcongress_get_newspaper_page`. |
33
+ | `libofcongress_get_newspaper_page` | Retrieve the full OCR text of a specific newspaper page. Pass the `url` field from a `libofcongress_search_newspapers` result. Returns `ocr_available: false` when the page has no digitized text. |
34
+ | `libofcongress_search_subjects` | Search Library of Congress Subject Headings (LCSH) by keyword. Returns controlled-vocabulary labels and URIs — use the label as the `subject` filter in `libofcongress_search`. |
35
+ | `libofcongress_browse_collections` | List and browse LOC curated digital collections with descriptions, item counts, and slugs. Optionally filter by keyword. |
36
+
37
+ ### `libofcongress_search`
38
+
39
+ Search the LOC digital collections with full-text keyword matching and facet filters.
40
+
41
+ - Eight material formats: `photo`, `map`, `newspaper`, `manuscript`, `audio`, `film`, `book`, `notated-music`
42
+ - Date range filtering by year (inclusive start and end)
43
+ - Subject heading filter — use `libofcongress_search_subjects` first to get the exact LCSH spelling
44
+ - Geographic location filter (e.g., `"oklahoma"`, `"washington d.c."`)
45
+ - Pagination up to 100 results per page; contradictory pages (LOC API edge case) returned with a clear message
46
+ - Empty results include a `message` field with recovery hints — echoes the applied filters
47
+
48
+ ---
49
+
50
+ ### `libofcongress_get_item`
51
+
52
+ Retrieve the full metadata record for a specific LOC digital item.
53
+
54
+ - Returns contributors, LCSH subject headings, rights information, physical/technical description, and cataloger notes
55
+ - `resource_links` contains URLs to downloadable digital files (TIFF, JPEG, PDF) for items with digital surrogates
56
+ - `related_items` lists IDs of related LOC items for follow-up retrieval
57
+ - Deduplicates resource links from nested `files[]` arrays
58
+
59
+ ---
60
+
61
+ ### `libofcongress_search_newspapers`
62
+
63
+ Search historical newspaper pages in the Chronicling America corpus via the LOC `/newspapers/` endpoint.
64
+
65
+ - OCR text excerpts (~500 chars) returned inline for relevance assessment without a second hop
66
+ - Filters: keyword, date range, US state (full state name), newspaper publication title (partial match)
67
+ - Returns the `url` field needed by `libofcongress_get_newspaper_page` — do not construct these URLs manually
68
+ - OCR quality varies by digitization batch and era; 19th-century and degraded materials may contain garbled text
69
+ - Empty results include a `message` with recovery suggestions (broaden date, try different keywords, historical OCR caveat)
70
+
71
+ ---
72
+
73
+ ### `libofcongress_get_newspaper_page`
74
+
75
+ Retrieve the full OCR text and metadata for a specific newspaper page.
76
+
77
+ - Accepts the `url` field from a `libofcongress_search_newspapers` result — validates the URL prefix before any outbound request
78
+ - Fetches ALTO XML from the LOC text-services endpoint and extracts plain text from `CONTENT` attributes
79
+ - `ocr_available: false` when the page has no digitized text (image-only batch) — not an error, a data property
80
+ - Strips echoed `q=` params from fulltext URLs to avoid tile.loc.gov 404s (known LOC API quirk)
81
+
82
+ ---
83
+
84
+ ### `libofcongress_search_subjects`
85
+
86
+ Search Library of Congress Subject Headings (LCSH) via `id.loc.gov`.
87
+
88
+ - Returns standardized labels and stable LOC URIs for subjects matching the keyword
89
+ - `count` field indicates approximate number of LOC items carrying that heading (when available)
90
+ - Use the returned `label` exactly in the `libofcongress_search` `subject` filter — LCSH uses inverted forms ("Photography, Aerial", "World War, 1939-1945") that differ from natural language
91
+
92
+ ---
93
+
94
+ ### `libofcongress_browse_collections`
95
+
96
+ List and browse LOC curated digital collections.
97
+
98
+ - Returns collection `slug` — use as a `partof` facet value in `libofcongress_search` to scope searches to a single collection
99
+ - Optional keyword filter by collection name/description
100
+ - Item counts are approximate; omitted when the API doesn't provide them
101
+ - Pagination supported up to 100 collections per page
102
+
103
+ ## Resource
104
+
105
+ | Type | Name | Description |
106
+ |:-----|:-----|:------------|
107
+ | Resource | `libofcongress://item/{item_id}` | LOC digital item metadata by ID. Stable URI for injecting item context into agent conversations. Returns the same full record as `libofcongress_get_item`. |
108
+
109
+ All resource data is also reachable via `libofcongress_get_item`. Use `libofcongress_search` to discover item IDs first.
110
+
111
+ ## Features
112
+
113
+ Built on [`@cyanheads/mcp-ts-core`](https://www.npmjs.com/package/@cyanheads/mcp-ts-core):
114
+
115
+ - Declarative tool and resource definitions — single file per primitive, framework handles registration and validation
116
+ - Unified error handling — handlers throw, framework catches, classifies, and formats
117
+ - Pluggable auth: `none`, `jwt`, `oauth`
118
+ - Swappable storage backends: `in-memory`, `filesystem`, `Supabase`, `Cloudflare KV/R2/D1`
119
+ - Structured logging with optional OpenTelemetry tracing
120
+ - STDIO and Streamable HTTP transports
121
+
122
+ LOC-specific:
123
+
124
+ - Module-level rate-limit enforcement: 20 req/min limit; 429 responses trigger a 1-hour block with per-minute countdown in error messages
125
+ - Configurable pacing delay (default 3100ms, ~19 req/min) applied before every outbound LOC API request
126
+ - HTML-response detection guards against silent rate-limit proxy pages that return 200 with HTML
127
+ - Out-of-range page handling: LOC returns HTTP 400 or 520 for page numbers beyond the result set — treated as empty rather than errors
128
+ - ALTO XML parser for newspaper OCR text — extracts `CONTENT` attributes from LOC text-services responses
129
+ - Two-service architecture: `LocApiService` for `www.loc.gov` and `LcLinkedDataService` for `id.loc.gov`
130
+
131
+ Agent-friendly output:
132
+
133
+ - Empty results always include a `message` field with recovery hints — echoes the applied filters and suggests how to broaden
134
+ - Pagination status on every search response: `total`, `page`, `pages`, `has_next`
135
+ - `ocr_available` discriminator on newspaper page results so callers can branch on data availability without parsing text
136
+ - Recovery hints on all error contracts — actionable next steps for the agent on every failure mode
137
+
138
+ ## Getting started
139
+
140
+ Add the following to your MCP client configuration file.
141
+
142
+ ```json
143
+ {
144
+ "mcpServers": {
145
+ "libofcongress": {
146
+ "type": "stdio",
147
+ "command": "bunx",
148
+ "args": ["libofcongress-mcp-server@latest"],
149
+ "env": {
150
+ "MCP_TRANSPORT_TYPE": "stdio",
151
+ "MCP_LOG_LEVEL": "info"
152
+ }
153
+ }
154
+ }
155
+ }
156
+ ```
157
+
158
+ Or with npx (no Bun required):
159
+
160
+ ```json
161
+ {
162
+ "mcpServers": {
163
+ "libofcongress": {
164
+ "type": "stdio",
165
+ "command": "npx",
166
+ "args": ["-y", "libofcongress-mcp-server@latest"],
167
+ "env": {
168
+ "MCP_TRANSPORT_TYPE": "stdio",
169
+ "MCP_LOG_LEVEL": "info"
170
+ }
171
+ }
172
+ }
173
+ }
174
+ ```
175
+
176
+ Or with Docker:
177
+
178
+ ```json
179
+ {
180
+ "mcpServers": {
181
+ "libofcongress": {
182
+ "type": "stdio",
183
+ "command": "docker",
184
+ "args": [
185
+ "run", "-i", "--rm",
186
+ "-e", "MCP_TRANSPORT_TYPE=stdio",
187
+ "ghcr.io/cyanheads/libofcongress-mcp-server:latest"
188
+ ]
189
+ }
190
+ }
191
+ }
192
+ ```
193
+
194
+ For Streamable HTTP, set the transport and start the server:
195
+
196
+ ```sh
197
+ MCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3010 bun run start:http
198
+ # Server listens at http://localhost:3010/mcp
199
+ ```
200
+
201
+ ### Prerequisites
202
+
203
+ - [Bun v1.3.2](https://bun.sh/) or higher (or Node.js v24+).
204
+ - No API key required — the LOC JSON API and LC Linked Data endpoints are open. LOC recommends a descriptive `LOC_USER_AGENT` for polite access.
205
+
206
+ ### Installation
207
+
208
+ 1. **Clone the repository:**
209
+
210
+ ```sh
211
+ git clone https://github.com/cyanheads/libofcongress-mcp-server.git
212
+ ```
213
+
214
+ 2. **Navigate into the directory:**
215
+
216
+ ```sh
217
+ cd libofcongress-mcp-server
218
+ ```
219
+
220
+ 3. **Install dependencies:**
221
+
222
+ ```sh
223
+ bun install
224
+ ```
225
+
226
+ 4. **Configure environment:**
227
+
228
+ ```sh
229
+ cp .env.example .env
230
+ # edit .env if you want to set LOC_USER_AGENT or LOC_REQUEST_DELAY_MS
231
+ ```
232
+
233
+ ## Configuration
234
+
235
+ All configuration is validated at startup via Zod schemas in `src/config/server-config.ts`.
236
+
237
+ | Variable | Description | Default |
238
+ |:---------|:------------|:--------|
239
+ | `LOC_USER_AGENT` | User-Agent header sent with LOC API requests. LOC recommends a descriptive value for polite access. | `libofcongress-mcp-server/0.2.0` |
240
+ | `LOC_REQUEST_DELAY_MS` | Delay in milliseconds between LOC API requests to stay under the 20 req/min rate limit. | `3100` |
241
+ | `MCP_TRANSPORT_TYPE` | Transport: `stdio` or `http`. | `stdio` |
242
+ | `MCP_HTTP_PORT` | Port for HTTP server. | `3010` |
243
+ | `MCP_AUTH_MODE` | Auth mode: `none`, `jwt`, or `oauth`. | `none` |
244
+ | `MCP_LOG_LEVEL` | Log level (RFC 5424). | `info` |
245
+ | `LOGS_DIR` | Directory for log files (Node.js only). | `<project-root>/logs` |
246
+ | `STORAGE_PROVIDER_TYPE` | Storage backend. | `in-memory` |
247
+ | `OTEL_ENABLED` | Enable [OpenTelemetry instrumentation](https://github.com/cyanheads/mcp-ts-core/tree/main/docs/telemetry) (spans, metrics, completion logs). | `false` |
248
+
249
+ See [`.env.example`](./.env.example) for the full list of optional overrides.
250
+
251
+ ## Running the server
252
+
253
+ ### Local development
254
+
255
+ - **Build and run:**
256
+
257
+ ```sh
258
+ # One-time build
259
+ bun run rebuild
260
+
261
+ # Run the built server
262
+ bun run start:stdio
263
+ # or
264
+ bun run start:http
265
+ ```
266
+
267
+ - **Run checks and tests:**
268
+
269
+ ```sh
270
+ bun run devcheck # Lint, format, typecheck, security
271
+ bun run test # Vitest test suite
272
+ bun run lint:mcp # Validate MCP definitions against spec
273
+ ```
274
+
275
+ ### Docker
276
+
277
+ ```sh
278
+ docker build -t libofcongress-mcp-server .
279
+ docker run --rm -p 3010:3010 libofcongress-mcp-server
280
+ ```
281
+
282
+ The Dockerfile defaults to HTTP transport and logs to `/var/log/libofcongress-mcp-server`.
283
+
284
+ ## Project structure
285
+
286
+ | Directory | Purpose |
287
+ |:----------|:--------|
288
+ | `src/index.ts` | `createApp()` entry point — registers tools, resource, and initializes services. |
289
+ | `src/config` | Server-specific environment variable parsing (`LOC_USER_AGENT`, `LOC_REQUEST_DELAY_MS`). |
290
+ | `src/mcp-server/tools` | Tool definitions (`*.tool.ts`) — six LOC tools. |
291
+ | `src/mcp-server/resources` | Resource definitions — `libofcongress://item/{item_id}`. |
292
+ | `src/services/loc-api` | `LocApiService` wrapping `www.loc.gov` — search, item fetch, newspaper page, collection browser. |
293
+ | `src/services/lc-linked-data` | `LcLinkedDataService` wrapping `id.loc.gov` — LCSH subject heading suggest. |
294
+ | `tests/` | Unit and integration tests mirroring `src/`. |
295
+
296
+ ## Development guide
297
+
298
+ See [`CLAUDE.md`](./CLAUDE.md) for development guidelines and architectural rules. The short version:
299
+
300
+ - Handlers throw, framework catches — no `try/catch` in tool logic
301
+ - Use `ctx.log` for request-scoped logging, `ctx.state` for tenant-scoped storage
302
+ - Register new tools and resources via the arrays in `src/index.ts`
303
+ - Wrap external API calls: validate raw → normalize to domain type → return output schema; never fabricate missing fields
304
+
305
+ ## Contributing
306
+
307
+ Issues and pull requests are welcome. Run checks and tests before submitting:
308
+
309
+ ```sh
310
+ bun run devcheck
311
+ bun run test
312
+ ```
313
+
314
+ ## License
315
+
316
+ Apache-2.0 — see [LICENSE](LICENSE) for details.
@@ -0,0 +1,22 @@
1
+ ---
2
+ summary: "Initial release — LOC digital collections, Chronicling America newspaper search with full OCR, LCSH subject heading lookup, and collection browsing via MCP."
3
+ breaking: false
4
+ ---
5
+
6
+ # 0.1.0 — 2026-05-24
7
+
8
+ Initial release.
9
+
10
+ ## Added
11
+
12
+ - `loc_search` — full-text search across LOC digital collections with format, date range, subject heading, and geographic location filters
13
+ - `loc_get_item` — full metadata for a specific LOC item: contributors, subjects, rights, physical description, resource links, related items
14
+ - `loc_search_newspapers` — historical newspaper page search (Chronicling America corpus) with OCR excerpts, date range, state, and publication title filters
15
+ - `loc_get_newspaper_page` — full OCR text for a specific newspaper page; ALTO XML parsing with graceful `ocr_available: false` for image-only batches
16
+ - `loc_search_subjects` — Library of Congress Subject Headings (LCSH) search via `id.loc.gov` suggest endpoint; returns standardized labels and URIs for use as `loc_search` subject filters
17
+ - `loc_browse_collections` — lists and filters LOC curated digital collections; returns slugs usable as `partof` facet values in `loc_search`
18
+ - `loc://item/{item_id}` resource — stable URI for injecting item metadata into agent context
19
+ - `LocApiService` — LOC JSON API client with module-level rate-limit enforcement (20 req/min, 1-hour block on 429), configurable pacing delay, HTML-response detection, and out-of-range page handling (HTTP 400/520)
20
+ - `LcLinkedDataService` — `id.loc.gov` subject suggest client
21
+ - Server-level agent instructions: recommended tool-call order, two-hop newspaper workflow, rate-limit reminder
22
+ - 81 tests (7 test files) covering all tools and the item resource
@@ -0,0 +1,29 @@
1
+ ---
2
+ summary: "Initial npm publish — 6 tools, 1 resource, 81 tests, field-test fixes, and pre-launch polish"
3
+ breaking: false
4
+ ---
5
+
6
+ # 0.1.1 — 2026-05-24
7
+
8
+ First published release. Implements the full server surface, applies field-test fixes, and ships pre-launch polish over the initial scaffold tagged as 0.1.0.
9
+
10
+ ## Added
11
+
12
+ - `loc_search` — full-text search across LOC digital collections with format, date range, subject heading, and geographic location filters
13
+ - `loc_get_item` — full metadata for a specific LOC item: contributors, subjects, rights, physical description, resource links, related items
14
+ - `loc_search_newspapers` — historical newspaper page search (Chronicling America corpus) with OCR excerpts, date range, state, and publication title filters
15
+ - `loc_get_newspaper_page` — full OCR text for a specific newspaper page; ALTO XML parsing with graceful `ocr_available: false` for image-only batches
16
+ - `loc_search_subjects` — LCSH subject heading lookup via `id.loc.gov` suggest endpoint; returns standardized labels and URIs
17
+ - `loc_browse_collections` — curated LOC digital collections browser; returns slugs usable as `partof` facet values in `loc_search`
18
+ - `loc://item/{item_id}` resource — stable URI for injecting item metadata into agent context
19
+ - `LocApiService` — LOC JSON API client with module-level rate-limit enforcement (20 req/min, 1-hour block on 429), configurable pacing delay, HTML-response detection, and out-of-range page handling
20
+ - `LcLinkedDataService` — `id.loc.gov` subject suggest client
21
+ - Server-level agent instructions in `AGENTS.md`: recommended tool-call order, two-hop newspaper workflow, rate-limit reminder
22
+ - 81 tests across 7 files covering all tools and the item resource
23
+
24
+ ## Fixed
25
+
26
+ - `loc_search` and `loc_search_newspapers` — improved date range validation, field mapping corrections (`newspaper_title` from `partof_title` not `subject`), and sparse result handling
27
+ - `loc_get_newspaper_page` — hardened ALTO XML parsing; added rate-limit detection and configurable retry guidance
28
+ - `loc_get_item` — null-safety improvements for sparse upstream payloads
29
+ - `LocApiService` — corrected field extraction, added structured handling for HTTP 429/400/520 responses
@@ -0,0 +1,13 @@
1
+ ---
2
+ summary: "Tool prefix renamed loc_* → libofcongress_*; resource URI renamed loc:// → libofcongress://"
3
+ breaking: true
4
+ ---
5
+
6
+ # 0.2.0 — 2026-05-24
7
+
8
+ ## Changed
9
+
10
+ - All six tools renamed: `loc_search` → `libofcongress_search`, `loc_get_item` → `libofcongress_get_item`, `loc_search_newspapers` → `libofcongress_search_newspapers`, `loc_get_newspaper_page` → `libofcongress_get_newspaper_page`, `loc_search_subjects` → `libofcongress_search_subjects`, `loc_browse_collections` → `libofcongress_browse_collections` ([#12](https://github.com/cyanheads/libofcongress-mcp-server/issues/12))
11
+ - Resource URI renamed: `loc://item/{item_id}` → `libofcongress://item/{item_id}`
12
+ - Tool and resource definition files renamed to match: `loc-*.tool.ts` → `libofcongress-*.tool.ts`, `loc-item.resource.ts` → `libofcongress-item.resource.ts`
13
+ - Test files renamed to mirror the new filenames
@@ -0,0 +1,14 @@
1
+ ---
2
+ summary: "npm package scoped to @cyanheads/libofcongress-mcp-server"
3
+ breaking: false
4
+ ---
5
+
6
+ # 0.2.1 — 2026-05-24
7
+
8
+ ## Fixed
9
+
10
+ - **package name** corrected from bare `libofcongress-mcp-server` to `@cyanheads/libofcongress-mcp-server` — install via `npx -y @cyanheads/libofcongress-mcp-server`
11
+ - **`server.json` identifiers** updated to `@cyanheads/libofcongress-mcp-server` in both stdio and HTTP package entries
12
+ - **Cursor and VS Code install badges** recomputed with the scoped package name
13
+ - **`bundle` script** switched from `npm run build` to `bun run build` for consistency with the rest of the scripts
14
+ - **`author` field** aligned to the cyanheads convention (`cyanheads <casey@caseyjhand.com>`)