@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.
- package/AGENTS.md +388 -0
- package/CLAUDE.md +388 -0
- package/Dockerfile +83 -0
- package/LICENSE +201 -0
- package/README.md +316 -0
- package/changelog/0.1.x/0.1.0.md +22 -0
- package/changelog/0.1.x/0.1.1.md +29 -0
- package/changelog/0.2.x/0.2.0.md +13 -0
- package/changelog/0.2.x/0.2.1.md +14 -0
- package/changelog/template.md +119 -0
- package/dist/config/server-config.d.ts +13 -0
- package/dist/config/server-config.d.ts.map +1 -0
- package/dist/config/server-config.js +25 -0
- package/dist/config/server-config.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server/resources/definitions/libofcongress-item.resource.d.ts +9 -0
- package/dist/mcp-server/resources/definitions/libofcongress-item.resource.d.ts.map +1 -0
- package/dist/mcp-server/resources/definitions/libofcongress-item.resource.js +24 -0
- package/dist/mcp-server/resources/definitions/libofcongress-item.resource.js.map +1 -0
- package/dist/mcp-server/tools/definitions/libofcongress-browse-collections.tool.d.ts +35 -0
- package/dist/mcp-server/tools/definitions/libofcongress-browse-collections.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/libofcongress-browse-collections.tool.js +119 -0
- package/dist/mcp-server/tools/definitions/libofcongress-browse-collections.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/libofcongress-get-item.tool.d.ts +32 -0
- package/dist/mcp-server/tools/definitions/libofcongress-get-item.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/libofcongress-get-item.tool.js +97 -0
- package/dist/mcp-server/tools/definitions/libofcongress-get-item.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/libofcongress-get-newspaper-page.tool.d.ts +29 -0
- package/dist/mcp-server/tools/definitions/libofcongress-get-newspaper-page.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/libofcongress-get-newspaper-page.tool.js +89 -0
- package/dist/mcp-server/tools/definitions/libofcongress-get-newspaper-page.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/libofcongress-search-newspapers.tool.d.ts +40 -0
- package/dist/mcp-server/tools/definitions/libofcongress-search-newspapers.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/libofcongress-search-newspapers.tool.js +162 -0
- package/dist/mcp-server/tools/definitions/libofcongress-search-newspapers.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/libofcongress-search-subjects.tool.d.ts +24 -0
- package/dist/mcp-server/tools/definitions/libofcongress-search-subjects.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/libofcongress-search-subjects.tool.js +86 -0
- package/dist/mcp-server/tools/definitions/libofcongress-search-subjects.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/libofcongress-search.tool.d.ts +50 -0
- package/dist/mcp-server/tools/definitions/libofcongress-search.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/libofcongress-search.tool.js +171 -0
- package/dist/mcp-server/tools/definitions/libofcongress-search.tool.js.map +1 -0
- package/dist/services/lc-linked-data/lc-linked-data-service.d.ts +17 -0
- package/dist/services/lc-linked-data/lc-linked-data-service.d.ts.map +1 -0
- package/dist/services/lc-linked-data/lc-linked-data-service.js +71 -0
- package/dist/services/lc-linked-data/lc-linked-data-service.js.map +1 -0
- package/dist/services/lc-linked-data/types.d.ts +11 -0
- package/dist/services/lc-linked-data/types.d.ts.map +1 -0
- package/dist/services/lc-linked-data/types.js +6 -0
- package/dist/services/lc-linked-data/types.js.map +1 -0
- package/dist/services/loc-api/loc-api-service.d.ts +65 -0
- package/dist/services/loc-api/loc-api-service.d.ts.map +1 -0
- package/dist/services/loc-api/loc-api-service.js +418 -0
- package/dist/services/loc-api/loc-api-service.js.map +1 -0
- package/dist/services/loc-api/types.d.ts +156 -0
- package/dist/services/loc-api/types.d.ts.map +1 -0
- package/dist/services/loc-api/types.js +6 -0
- package/dist/services/loc-api/types.js.map +1 -0
- package/package.json +92 -0
- package/server.json +127 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
---
|
|
2
|
+
# FORMAT REFERENCE — do not edit. Copy this file to
|
|
3
|
+
# `changelog/<major.minor>.x/<version>.md` (e.g. `changelog/0.8.x/0.8.6.md`)
|
|
4
|
+
# to author a new release. Set that file's H1 to `# <version> — YYYY-MM-DD`
|
|
5
|
+
# with a concrete date.
|
|
6
|
+
|
|
7
|
+
# Required. One-line GitHub Release-style headline. 350 character cap.
|
|
8
|
+
# Default short and scannable. Don't pad, don't stitch unrelated changes with
|
|
9
|
+
# semicolons — pick the headline. Quotes required: unquoted YAML treats `: `
|
|
10
|
+
# inside the value as a key separator and fails GitHub's strict parser.
|
|
11
|
+
summary: ""
|
|
12
|
+
|
|
13
|
+
# Set `true` when consumers must change code to upgrade: API removals,
|
|
14
|
+
# signature changes, config renames, behavior changes that break existing
|
|
15
|
+
# usage. Flagged as `Breaking` in the rollup.
|
|
16
|
+
breaking: false
|
|
17
|
+
|
|
18
|
+
# Set `true` if this release contains any security fix. Pairs with the
|
|
19
|
+
# `## Security` section below. Flagged as `Security` in the rollup so
|
|
20
|
+
# users can triage upgrade urgency at a glance.
|
|
21
|
+
security: false
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
# <version> — YYYY-MM-DD
|
|
25
|
+
|
|
26
|
+
<!--
|
|
27
|
+
AUTHORING GUIDE — applies to the new per-version file you create from this
|
|
28
|
+
template.
|
|
29
|
+
|
|
30
|
+
Audience: someone scanning release notes to decide what affects them. Lead
|
|
31
|
+
each bullet with the symbol or concept name in **bold** so they can skip
|
|
32
|
+
what's irrelevant and zoom in on what's not.
|
|
33
|
+
|
|
34
|
+
Tone: terse, fact-dense, not verbose. Default to one sentence per bullet —
|
|
35
|
+
name the symbol, state what changed, stop. Use a second sentence only when
|
|
36
|
+
it carries weight. If a bullet feels long, it is.
|
|
37
|
+
|
|
38
|
+
Cut: mechanism walkthroughs (those belong in JSDoc, AGENTS.md, or the
|
|
39
|
+
relevant skill), ceremonial framings ("This release introduces…",
|
|
40
|
+
backwards-compat paragraphs), file-by-file test enumerations, internal
|
|
41
|
+
implementation notes. Prefer code/symbol names over English re-explanations.
|
|
42
|
+
|
|
43
|
+
Narrative intro: skip by default. Add one short sentence only when the
|
|
44
|
+
release theme genuinely needs framing the bullets can't carry.
|
|
45
|
+
|
|
46
|
+
Sections: Keep a Changelog order — Added, Changed, Deprecated, Removed,
|
|
47
|
+
Fixed, Security. Include only sections with entries; delete the rest
|
|
48
|
+
(including the commented-out scaffolding below). Don't ship empty headers.
|
|
49
|
+
|
|
50
|
+
Include: every distinct fact a reader needs to adopt or audit the release —
|
|
51
|
+
new exports, signatures, lint rule IDs, env vars, breaking changes, version
|
|
52
|
+
bumps on shipped skills. Nothing more.
|
|
53
|
+
|
|
54
|
+
Links: link issues, PRs, docs, or skills where they help a reader jump to
|
|
55
|
+
context. Once per item per entry — don't re-link the same issue in summary,
|
|
56
|
+
narrative, and bullet. Skip links for inline symbol names; code spans speak
|
|
57
|
+
for themselves.
|
|
58
|
+
|
|
59
|
+
Issue/PR URLs: use full URLs. GitHub's bare `#NN` auto-link only resolves
|
|
60
|
+
inside its own UI, not in npm reads or local editors.
|
|
61
|
+
|
|
62
|
+
[#38](https://github.com/cyanheads/mcp-ts-core/issues/38) ← issue
|
|
63
|
+
[#42](https://github.com/cyanheads/mcp-ts-core/pull/42) ← PR
|
|
64
|
+
|
|
65
|
+
Verify numbers exist before linking (`gh issue view NN`, `gh pr view NN`).
|
|
66
|
+
Never speculate on a future number — `#42` for an upcoming PR silently
|
|
67
|
+
resolves to whatever real item already owns 42, and timeline previews pull
|
|
68
|
+
in that unrelated item's metadata.
|
|
69
|
+
|
|
70
|
+
TAG ANNOTATIONS — the annotated tag body renders as the GitHub Release body
|
|
71
|
+
via `gh release create --notes-from-tag`. The tag is a derivative of this
|
|
72
|
+
changelog entry — a condensed, scannable version, not a copy. Format:
|
|
73
|
+
|
|
74
|
+
<theme — omit version number, GitHub prepends it>
|
|
75
|
+
← blank line
|
|
76
|
+
<1-2 sentence context: what this release does>
|
|
77
|
+
← blank line
|
|
78
|
+
Dependency bumps: ← section header
|
|
79
|
+
← blank line
|
|
80
|
+
- `@cyanheads/mcp-ts-core` ^0.9.1 → ^0.9.6 ← bullet
|
|
81
|
+
← blank line
|
|
82
|
+
Changed: ← only sections with entries
|
|
83
|
+
← blank line
|
|
84
|
+
- `format()` output includes `query` in text mode
|
|
85
|
+
← blank line
|
|
86
|
+
Added:
|
|
87
|
+
← blank line
|
|
88
|
+
- `manifest.json` scaffolded for MCPB bundle support
|
|
89
|
+
- Install badges (Claude Desktop, Cursor, VS Code)
|
|
90
|
+
← blank line
|
|
91
|
+
<N> tests pass; `bun run devcheck` clean. ← footer
|
|
92
|
+
|
|
93
|
+
Never a flat comma-separated string. Always structured markdown with
|
|
94
|
+
sections. The tag must scan well as a rendered GitHub Release page.
|
|
95
|
+
-->
|
|
96
|
+
|
|
97
|
+
## Added
|
|
98
|
+
|
|
99
|
+
-
|
|
100
|
+
|
|
101
|
+
## Changed
|
|
102
|
+
|
|
103
|
+
-
|
|
104
|
+
|
|
105
|
+
<!-- ## Deprecated
|
|
106
|
+
|
|
107
|
+
- -->
|
|
108
|
+
|
|
109
|
+
<!-- ## Removed
|
|
110
|
+
|
|
111
|
+
- -->
|
|
112
|
+
|
|
113
|
+
## Fixed
|
|
114
|
+
|
|
115
|
+
-
|
|
116
|
+
|
|
117
|
+
<!-- ## Security
|
|
118
|
+
|
|
119
|
+
- -->
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Server-specific configuration for libofcongress-mcp-server.
|
|
3
|
+
* @module config/server-config
|
|
4
|
+
*/
|
|
5
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
declare const ServerConfigSchema: z.ZodObject<{
|
|
7
|
+
userAgent: z.ZodDefault<z.ZodString>;
|
|
8
|
+
requestDelayMs: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
export type ServerConfig = z.infer<typeof ServerConfigSchema>;
|
|
11
|
+
export declare function getServerConfig(): ServerConfig;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=server-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-config.d.ts","sourceRoot":"","sources":["../../src/config/server-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAG3C,QAAA,MAAM,kBAAkB;;;iBAatB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAI9D,wBAAgB,eAAe,IAAI,YAAY,CAM9C"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Server-specific configuration for libofcongress-mcp-server.
|
|
3
|
+
* @module config/server-config
|
|
4
|
+
*/
|
|
5
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { parseEnvConfig } from '@cyanheads/mcp-ts-core/config';
|
|
7
|
+
const ServerConfigSchema = z.object({
|
|
8
|
+
userAgent: z
|
|
9
|
+
.string()
|
|
10
|
+
.default('libofcongress-mcp-server/0.2.1')
|
|
11
|
+
.describe('User-Agent header sent with LOC API requests. LOC recommends a descriptive value for polite access.'),
|
|
12
|
+
requestDelayMs: z.coerce
|
|
13
|
+
.number()
|
|
14
|
+
.default(3100)
|
|
15
|
+
.describe('Delay in milliseconds between LOC API requests to stay under the 20 req/min rate limit (~19/min at default).'),
|
|
16
|
+
});
|
|
17
|
+
let _config;
|
|
18
|
+
export function getServerConfig() {
|
|
19
|
+
_config ??= parseEnvConfig(ServerConfigSchema, {
|
|
20
|
+
userAgent: 'LOC_USER_AGENT',
|
|
21
|
+
requestDelayMs: 'LOC_REQUEST_DELAY_MS',
|
|
22
|
+
});
|
|
23
|
+
return _config;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=server-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-config.js","sourceRoot":"","sources":["../../src/config/server-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,OAAO,CAAC,gCAAgC,CAAC;SACzC,QAAQ,CACP,qGAAqG,CACtG;IACH,cAAc,EAAE,CAAC,CAAC,MAAM;SACrB,MAAM,EAAE;SACR,OAAO,CAAC,IAAI,CAAC;SACb,QAAQ,CACP,8GAA8G,CAC/G;CACJ,CAAC,CAAC;AAIH,IAAI,OAAiC,CAAC;AAEtC,MAAM,UAAU,eAAe;IAC7B,OAAO,KAAK,cAAc,CAAC,kBAAkB,EAAE;QAC7C,SAAS,EAAE,gBAAgB;QAC3B,cAAc,EAAE,sBAAsB;KACvC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;GAGG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview libofcongress-mcp-server MCP server entry point.
|
|
4
|
+
* @module index
|
|
5
|
+
*/
|
|
6
|
+
import { createApp } from '@cyanheads/mcp-ts-core';
|
|
7
|
+
import { locItemResource } from './mcp-server/resources/definitions/libofcongress-item.resource.js';
|
|
8
|
+
import { locBrowseCollections } from './mcp-server/tools/definitions/libofcongress-browse-collections.tool.js';
|
|
9
|
+
import { locGetItem } from './mcp-server/tools/definitions/libofcongress-get-item.tool.js';
|
|
10
|
+
import { locGetNewspaperPage } from './mcp-server/tools/definitions/libofcongress-get-newspaper-page.tool.js';
|
|
11
|
+
import { locSearch } from './mcp-server/tools/definitions/libofcongress-search.tool.js';
|
|
12
|
+
import { locSearchNewspapers } from './mcp-server/tools/definitions/libofcongress-search-newspapers.tool.js';
|
|
13
|
+
import { locSearchSubjects } from './mcp-server/tools/definitions/libofcongress-search-subjects.tool.js';
|
|
14
|
+
import { initLcLinkedDataService } from './services/lc-linked-data/lc-linked-data-service.js';
|
|
15
|
+
import { initLocApiService } from './services/loc-api/loc-api-service.js';
|
|
16
|
+
await createApp({
|
|
17
|
+
tools: [
|
|
18
|
+
locSearch,
|
|
19
|
+
locGetItem,
|
|
20
|
+
locSearchNewspapers,
|
|
21
|
+
locGetNewspaperPage,
|
|
22
|
+
locSearchSubjects,
|
|
23
|
+
locBrowseCollections,
|
|
24
|
+
],
|
|
25
|
+
resources: [locItemResource],
|
|
26
|
+
prompts: [],
|
|
27
|
+
instructions: 'Library of Congress digital collections server. Use libofcongress_search_subjects to find exact LCSH terms before subject-filtering libofcongress_search. ' +
|
|
28
|
+
'Newspaper research: libofcongress_search_newspapers → libofcongress_get_newspaper_page (two hops). ' +
|
|
29
|
+
'Rate limit: 20 req/min; violations block for 1 hour.',
|
|
30
|
+
setup(core) {
|
|
31
|
+
initLocApiService(core.config, core.storage);
|
|
32
|
+
initLcLinkedDataService(core.config, core.storage);
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,mEAAmE,CAAC;AACpG,OAAO,EAAE,oBAAoB,EAAE,MAAM,yEAAyE,CAAC;AAC/G,OAAO,EAAE,UAAU,EAAE,MAAM,+DAA+D,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAAE,MAAM,yEAAyE,CAAC;AAC9G,OAAO,EAAE,SAAS,EAAE,MAAM,6DAA6D,CAAC;AACxF,OAAO,EAAE,mBAAmB,EAAE,MAAM,wEAAwE,CAAC;AAC7G,OAAO,EAAE,iBAAiB,EAAE,MAAM,sEAAsE,CAAC;AACzG,OAAO,EAAE,uBAAuB,EAAE,MAAM,qDAAqD,CAAC;AAC9F,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAE1E,MAAM,SAAS,CAAC;IACd,KAAK,EAAE;QACL,SAAS;QACT,UAAU;QACV,mBAAmB;QACnB,mBAAmB;QACnB,iBAAiB;QACjB,oBAAoB;KACrB;IACD,SAAS,EAAE,CAAC,eAAe,CAAC;IAC5B,OAAO,EAAE,EAAE;IACX,YAAY,EACV,4JAA4J;QAC5J,qGAAqG;QACrG,sDAAsD;IACxD,KAAK,CAAC,IAAI;QACR,iBAAiB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7C,uBAAuB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview libofcongress://item/{item_id} resource — stable LOC item metadata URI for agent context injection.
|
|
3
|
+
* @module mcp-server/resources/definitions/libofcongress-item.resource
|
|
4
|
+
*/
|
|
5
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
export declare const locItemResource: import("@cyanheads/mcp-ts-core").ResourceDefinition<z.ZodObject<{
|
|
7
|
+
item_id: z.ZodString;
|
|
8
|
+
}, z.core.$strip>, undefined, undefined>;
|
|
9
|
+
//# sourceMappingURL=libofcongress-item.resource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"libofcongress-item.resource.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/resources/definitions/libofcongress-item.resource.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAY,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAGrD,eAAO,MAAM,eAAe;;wCAoB1B,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview libofcongress://item/{item_id} resource — stable LOC item metadata URI for agent context injection.
|
|
3
|
+
* @module mcp-server/resources/definitions/libofcongress-item.resource
|
|
4
|
+
*/
|
|
5
|
+
import { resource, z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { getLocApiService } from '../../../services/loc-api/loc-api-service.js';
|
|
7
|
+
export const locItemResource = resource('libofcongress://item/{item_id}', {
|
|
8
|
+
name: 'loc-item',
|
|
9
|
+
title: 'LOC Item',
|
|
10
|
+
description: 'LOC digital item metadata by ID. Stable URI for injecting item context into agent conversations. Returns the same full record as libofcongress_get_item. Use libofcongress_search to discover item IDs first.',
|
|
11
|
+
mimeType: 'application/json',
|
|
12
|
+
params: z.object({
|
|
13
|
+
item_id: z
|
|
14
|
+
.string()
|
|
15
|
+
.describe('LOC item ID (e.g., "loc.pnp.ppmsc.02404" or "2009632251"). Same ID as in libofcongress_search result "id" field.'),
|
|
16
|
+
}),
|
|
17
|
+
handler(params, ctx) {
|
|
18
|
+
ctx.log.debug('libofcongress://item resource', { item_id: params.item_id });
|
|
19
|
+
const svc = getLocApiService();
|
|
20
|
+
// Service throws notFound when the item doesn't exist — let it bubble.
|
|
21
|
+
return svc.getItem(params.item_id, ctx);
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=libofcongress-item.resource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"libofcongress-item.resource.js","sourceRoot":"","sources":["../../../../src/mcp-server/resources/definitions/libofcongress-item.resource.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAEzE,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAC,gCAAgC,EAAE;IACxE,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,UAAU;IACjB,WAAW,EACT,+MAA+M;IACjN,QAAQ,EAAE,kBAAkB;IAC5B,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,OAAO,EAAE,CAAC;aACP,MAAM,EAAE;aACR,QAAQ,CACP,kHAAkH,CACnH;KACJ,CAAC;IAEF,OAAO,CAAC,MAAM,EAAE,GAAG;QACjB,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,+BAA+B,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5E,MAAM,GAAG,GAAG,gBAAgB,EAAE,CAAC;QAC/B,uEAAuE;QACvE,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC1C,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview libofcongress_browse_collections tool — list and browse LOC curated digital collections.
|
|
3
|
+
* @module mcp-server/tools/definitions/libofcongress-browse-collections.tool
|
|
4
|
+
*/
|
|
5
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
export declare const locBrowseCollections: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
|
|
8
|
+
query: z.ZodOptional<z.ZodString>;
|
|
9
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
10
|
+
page: z.ZodDefault<z.ZodNumber>;
|
|
11
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
12
|
+
collections: z.ZodArray<z.ZodObject<{
|
|
13
|
+
slug: z.ZodString;
|
|
14
|
+
title: z.ZodString;
|
|
15
|
+
description: z.ZodOptional<z.ZodString>;
|
|
16
|
+
item_count: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
url: z.ZodString;
|
|
18
|
+
}, z.core.$strip>>;
|
|
19
|
+
total: z.ZodNumber;
|
|
20
|
+
page: z.ZodNumber;
|
|
21
|
+
pages: z.ZodNumber;
|
|
22
|
+
has_next: z.ZodBoolean;
|
|
23
|
+
message: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, z.core.$strip>, readonly [{
|
|
25
|
+
readonly reason: "empty_results";
|
|
26
|
+
readonly code: JsonRpcErrorCode.NotFound;
|
|
27
|
+
readonly when: "No collections matched the keyword filter.";
|
|
28
|
+
readonly recovery: "Broaden the keyword or call without a query to list all LOC digital collections.";
|
|
29
|
+
}, {
|
|
30
|
+
readonly reason: "rate_limit_exceeded";
|
|
31
|
+
readonly code: JsonRpcErrorCode.ServiceUnavailable;
|
|
32
|
+
readonly when: "LOC API rate limit exceeded; requests are blocked for approximately 1 hour.";
|
|
33
|
+
readonly recovery: "Wait approximately 1 hour before retrying. Reduce request frequency to stay under 20 req/min.";
|
|
34
|
+
}]>;
|
|
35
|
+
//# sourceMappingURL=libofcongress-browse-collections.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"libofcongress-browse-collections.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/libofcongress-browse-collections.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmI/B,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview libofcongress_browse_collections tool — list and browse LOC curated digital collections.
|
|
3
|
+
* @module mcp-server/tools/definitions/libofcongress-browse-collections.tool
|
|
4
|
+
*/
|
|
5
|
+
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
import { getLocApiService } from '../../../services/loc-api/loc-api-service.js';
|
|
8
|
+
export const locBrowseCollections = tool('libofcongress_browse_collections', {
|
|
9
|
+
title: 'Browse LOC Collections',
|
|
10
|
+
description: 'List and browse Library of Congress curated digital collections. Returns collection names, descriptions, item counts, slugs, and URLs. Optionally filter by keyword. Collections are curated subsets of the digital holdings with specific focuses (e.g., "Civil War Glass Negatives", "Baseball Cards", "WPA Posters"). Use the slug value with libofcongress_search to scope searches to a single collection by passing it as a partof facet filter.',
|
|
11
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
12
|
+
input: z.object({
|
|
13
|
+
query: z
|
|
14
|
+
.string()
|
|
15
|
+
.optional()
|
|
16
|
+
.describe('Optional keyword to filter collections by name or description. Omit to list all collections.'),
|
|
17
|
+
limit: z
|
|
18
|
+
.number()
|
|
19
|
+
.int()
|
|
20
|
+
.min(1)
|
|
21
|
+
.max(100)
|
|
22
|
+
.default(25)
|
|
23
|
+
.describe('Maximum number of collections to return. Default 25, max 100.'),
|
|
24
|
+
page: z
|
|
25
|
+
.number()
|
|
26
|
+
.int()
|
|
27
|
+
.min(1)
|
|
28
|
+
.default(1)
|
|
29
|
+
.describe('1-indexed page number for paginating results.'),
|
|
30
|
+
}),
|
|
31
|
+
output: z.object({
|
|
32
|
+
collections: z
|
|
33
|
+
.array(z
|
|
34
|
+
.object({
|
|
35
|
+
slug: z
|
|
36
|
+
.string()
|
|
37
|
+
.describe('Collection URL slug — use as a partof facet value in libofcongress_search to scope searches to this collection.'),
|
|
38
|
+
title: z.string().describe('Collection name.'),
|
|
39
|
+
description: z
|
|
40
|
+
.string()
|
|
41
|
+
.optional()
|
|
42
|
+
.describe("Description of the collection's scope and contents."),
|
|
43
|
+
item_count: z
|
|
44
|
+
.number()
|
|
45
|
+
.optional()
|
|
46
|
+
.describe('Approximate number of items in this collection. Omitted when unavailable.'),
|
|
47
|
+
url: z.string().describe('Collection URL on loc.gov.'),
|
|
48
|
+
})
|
|
49
|
+
.describe('A single LOC curated digital collection.'))
|
|
50
|
+
.describe('LOC curated collections matching the keyword filter, or all collections when no keyword is specified.'),
|
|
51
|
+
total: z.number().describe('Total number of matching collections across all pages.'),
|
|
52
|
+
page: z.number().describe('Current 1-indexed page number.'),
|
|
53
|
+
pages: z.number().describe('Total number of pages available.'),
|
|
54
|
+
has_next: z.boolean().describe('True when more pages are available after this one.'),
|
|
55
|
+
message: z
|
|
56
|
+
.string()
|
|
57
|
+
.optional()
|
|
58
|
+
.describe('Recovery hint when results are empty — suggests broadening the keyword. Absent on non-empty result pages.'),
|
|
59
|
+
}),
|
|
60
|
+
errors: [
|
|
61
|
+
{
|
|
62
|
+
reason: 'empty_results',
|
|
63
|
+
code: JsonRpcErrorCode.NotFound,
|
|
64
|
+
when: 'No collections matched the keyword filter.',
|
|
65
|
+
recovery: 'Broaden the keyword or call without a query to list all LOC digital collections.',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
reason: 'rate_limit_exceeded',
|
|
69
|
+
code: JsonRpcErrorCode.ServiceUnavailable,
|
|
70
|
+
when: 'LOC API rate limit exceeded; requests are blocked for approximately 1 hour.',
|
|
71
|
+
recovery: 'Wait approximately 1 hour before retrying. Reduce request frequency to stay under 20 req/min.',
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
async handler(input, ctx) {
|
|
75
|
+
ctx.log.info('libofcongress_browse_collections', { query: input.query, page: input.page });
|
|
76
|
+
const svc = getLocApiService();
|
|
77
|
+
const result = await svc.browseCollections({
|
|
78
|
+
...(input.query?.trim() && { query: input.query.trim() }),
|
|
79
|
+
limit: input.limit,
|
|
80
|
+
page: input.page,
|
|
81
|
+
}, ctx);
|
|
82
|
+
if (result.items.length === 0) {
|
|
83
|
+
return {
|
|
84
|
+
collections: [],
|
|
85
|
+
total: 0,
|
|
86
|
+
page: input.page,
|
|
87
|
+
pages: 0,
|
|
88
|
+
has_next: false,
|
|
89
|
+
message: input.query
|
|
90
|
+
? `No collections matched "${input.query}". Try a broader keyword or call without a query to list all LOC digital collections.`
|
|
91
|
+
: 'No collections found. The LOC collections endpoint may be temporarily unavailable.',
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
collections: result.items,
|
|
96
|
+
total: result.pagination.total,
|
|
97
|
+
page: result.pagination.page,
|
|
98
|
+
pages: result.pagination.pages,
|
|
99
|
+
has_next: result.pagination.hasNext,
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
format: (result) => {
|
|
103
|
+
const lines = [];
|
|
104
|
+
lines.push(`**Total:** ${result.total} | **Page:** ${result.page} of ${result.pages} | **has_next:** ${result.has_next}`);
|
|
105
|
+
if (result.message)
|
|
106
|
+
lines.push(`\n> ${result.message}`);
|
|
107
|
+
for (const col of result.collections) {
|
|
108
|
+
lines.push(`\n## ${col.title}`);
|
|
109
|
+
lines.push(`**Slug:** ${col.slug}`);
|
|
110
|
+
if (col.item_count !== undefined)
|
|
111
|
+
lines.push(`**Items:** ${col.item_count}`);
|
|
112
|
+
if (col.description)
|
|
113
|
+
lines.push(col.description);
|
|
114
|
+
lines.push(`**URL:** ${col.url}`);
|
|
115
|
+
}
|
|
116
|
+
return [{ type: 'text', text: lines.join('\n') }];
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
//# sourceMappingURL=libofcongress-browse-collections.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"libofcongress-browse-collections.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/libofcongress-browse-collections.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAEzE,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC,kCAAkC,EAAE;IAC3E,KAAK,EAAE,wBAAwB;IAC/B,WAAW,EACT,wbAAwb;IAC1b,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE;IACxD,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,KAAK,EAAE,CAAC;aACL,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CACP,8FAA8F,CAC/F;QACH,KAAK,EAAE,CAAC;aACL,MAAM,EAAE;aACR,GAAG,EAAE;aACL,GAAG,CAAC,CAAC,CAAC;aACN,GAAG,CAAC,GAAG,CAAC;aACR,OAAO,CAAC,EAAE,CAAC;aACX,QAAQ,CAAC,+DAA+D,CAAC;QAC5E,IAAI,EAAE,CAAC;aACJ,MAAM,EAAE;aACR,GAAG,EAAE;aACL,GAAG,CAAC,CAAC,CAAC;aACN,OAAO,CAAC,CAAC,CAAC;aACV,QAAQ,CAAC,+CAA+C,CAAC;KAC7D,CAAC;IACF,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,WAAW,EAAE,CAAC;aACX,KAAK,CACJ,CAAC;aACE,MAAM,CAAC;YACN,IAAI,EAAE,CAAC;iBACJ,MAAM,EAAE;iBACR,QAAQ,CACP,iHAAiH,CAClH;YACH,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;YAC9C,WAAW,EAAE,CAAC;iBACX,MAAM,EAAE;iBACR,QAA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;QACxD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;YACrC,KAAK,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC;YAChC,KAAK,CAAC,IAAI,CAAC,aAAa,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;YACpC,IAAI,GAAG,CAAC,UAAU,KAAK,SAAS;gBAAE,KAAK,CAAC,IAAI,CAAC,cAAc,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;YAC7E,IAAI,GAAG,CAAC,WAAW;gBAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;YACjD,KAAK,CAAC,IAAI,CAAC,YAAY,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview libofcongress_get_item tool — retrieve full metadata for a LOC digital item.
|
|
3
|
+
* @module mcp-server/tools/definitions/libofcongress-get-item.tool
|
|
4
|
+
*/
|
|
5
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
export declare const locGetItem: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
|
|
8
|
+
item_id: z.ZodString;
|
|
9
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
10
|
+
item_id: z.ZodString;
|
|
11
|
+
title: z.ZodString;
|
|
12
|
+
date: z.ZodOptional<z.ZodString>;
|
|
13
|
+
contributors: z.ZodArray<z.ZodString>;
|
|
14
|
+
subject_headings: z.ZodArray<z.ZodString>;
|
|
15
|
+
notes: z.ZodArray<z.ZodString>;
|
|
16
|
+
rights_information: z.ZodOptional<z.ZodString>;
|
|
17
|
+
physical_description: z.ZodOptional<z.ZodString>;
|
|
18
|
+
resource_links: z.ZodArray<z.ZodString>;
|
|
19
|
+
related_items: z.ZodArray<z.ZodString>;
|
|
20
|
+
url: z.ZodString;
|
|
21
|
+
}, z.core.$strip>, readonly [{
|
|
22
|
+
readonly reason: "item_not_found";
|
|
23
|
+
readonly code: JsonRpcErrorCode.NotFound;
|
|
24
|
+
readonly when: "No item exists for the given ID.";
|
|
25
|
+
readonly recovery: "Verify the ID from libofcongress_search results. IDs are not guessable — use libofcongress_search to find a valid ID.";
|
|
26
|
+
}, {
|
|
27
|
+
readonly reason: "rate_limit_exceeded";
|
|
28
|
+
readonly code: JsonRpcErrorCode.ServiceUnavailable;
|
|
29
|
+
readonly when: "LOC API rate limit exceeded; requests are blocked for approximately 1 hour.";
|
|
30
|
+
readonly recovery: "Wait approximately 1 hour before retrying. Reduce request frequency to stay under 20 req/min.";
|
|
31
|
+
}]>;
|
|
32
|
+
//# sourceMappingURL=libofcongress-get-item.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"libofcongress-get-item.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/libofcongress-get-item.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;GA8FrB,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview libofcongress_get_item tool — retrieve full metadata for a LOC digital item.
|
|
3
|
+
* @module mcp-server/tools/definitions/libofcongress-get-item.tool
|
|
4
|
+
*/
|
|
5
|
+
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
import { getLocApiService } from '../../../services/loc-api/loc-api-service.js';
|
|
8
|
+
export const locGetItem = tool('libofcongress_get_item', {
|
|
9
|
+
title: 'Get LOC Item',
|
|
10
|
+
description: 'Retrieve the full metadata record for a specific LOC digital item. Returns contributors, subjects, rights information, physical description, notes, related items, and links to digital resources (TIFF, JPEG, PDF) for items with digital surrogates. Use after libofcongress_search to get complete details on a result. Pass the bare item ID from the search result — do not include URL path segments.',
|
|
11
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
12
|
+
input: z.object({
|
|
13
|
+
item_id: z
|
|
14
|
+
.string()
|
|
15
|
+
.min(1)
|
|
16
|
+
.describe('LOC item ID from a libofcongress_search result\'s "id" field (e.g., "loc.pnp.ppmsc.02404" or "2009632251"). Pass the bare ID only — no URL path segments.'),
|
|
17
|
+
}),
|
|
18
|
+
output: z.object({
|
|
19
|
+
item_id: z.string().describe('The LOC item ID.'),
|
|
20
|
+
title: z.string().describe('Item title.'),
|
|
21
|
+
date: z.string().optional().describe('Publication or creation date.'),
|
|
22
|
+
contributors: z
|
|
23
|
+
.array(z.string())
|
|
24
|
+
.describe('Names of contributors, creators, or photographers.'),
|
|
25
|
+
subject_headings: z.array(z.string()).describe('LCSH subject headings assigned to this item.'),
|
|
26
|
+
notes: z.array(z.string()).describe('Descriptive notes and annotations from catalogers.'),
|
|
27
|
+
rights_information: z
|
|
28
|
+
.string()
|
|
29
|
+
.optional()
|
|
30
|
+
.describe('Rights and reproduction statement for this item.'),
|
|
31
|
+
physical_description: z
|
|
32
|
+
.string()
|
|
33
|
+
.optional()
|
|
34
|
+
.describe('Physical or technical description of the original item.'),
|
|
35
|
+
resource_links: z
|
|
36
|
+
.array(z.string())
|
|
37
|
+
.describe('URLs to downloadable digital files (TIFF, JPEG, PDF). Empty when no digital surrogate exists.'),
|
|
38
|
+
related_items: z
|
|
39
|
+
.array(z.string())
|
|
40
|
+
.describe('IDs or URLs of related LOC items for follow-up retrieval.'),
|
|
41
|
+
url: z.string().describe('Canonical LOC item URL.'),
|
|
42
|
+
}),
|
|
43
|
+
errors: [
|
|
44
|
+
{
|
|
45
|
+
reason: 'item_not_found',
|
|
46
|
+
code: JsonRpcErrorCode.NotFound,
|
|
47
|
+
when: 'No item exists for the given ID.',
|
|
48
|
+
recovery: 'Verify the ID from libofcongress_search results. IDs are not guessable — use libofcongress_search to find a valid ID.',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
reason: 'rate_limit_exceeded',
|
|
52
|
+
code: JsonRpcErrorCode.ServiceUnavailable,
|
|
53
|
+
when: 'LOC API rate limit exceeded; requests are blocked for approximately 1 hour.',
|
|
54
|
+
recovery: 'Wait approximately 1 hour before retrying. Reduce request frequency to stay under 20 req/min.',
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
handler(input, ctx) {
|
|
58
|
+
ctx.log.info('libofcongress_get_item', { item_id: input.item_id });
|
|
59
|
+
const svc = getLocApiService();
|
|
60
|
+
return svc.getItem(input.item_id, ctx);
|
|
61
|
+
},
|
|
62
|
+
format: (result) => {
|
|
63
|
+
const lines = [];
|
|
64
|
+
lines.push(`# ${result.title}`);
|
|
65
|
+
lines.push(`**ID:** ${result.item_id}`);
|
|
66
|
+
if (result.date)
|
|
67
|
+
lines.push(`**Date:** ${result.date}`);
|
|
68
|
+
if (result.contributors.length > 0)
|
|
69
|
+
lines.push(`**Contributors:** ${result.contributors.join(', ')}`);
|
|
70
|
+
if (result.subject_headings.length > 0)
|
|
71
|
+
lines.push(`**Subjects:** ${result.subject_headings.join(', ')}`);
|
|
72
|
+
if (result.physical_description)
|
|
73
|
+
lines.push(`**Physical description:** ${result.physical_description}`);
|
|
74
|
+
if (result.rights_information)
|
|
75
|
+
lines.push(`**Rights:** ${result.rights_information}`);
|
|
76
|
+
if (result.notes.length > 0) {
|
|
77
|
+
lines.push('**Notes:**');
|
|
78
|
+
for (const note of result.notes)
|
|
79
|
+
lines.push(`- ${note}`);
|
|
80
|
+
}
|
|
81
|
+
if (result.resource_links.length > 0) {
|
|
82
|
+
lines.push(`**Digital resources (${result.resource_links.length}):**`);
|
|
83
|
+
for (const link of result.resource_links.slice(0, 5))
|
|
84
|
+
lines.push(`- ${link}`);
|
|
85
|
+
if (result.resource_links.length > 5)
|
|
86
|
+
lines.push(`- … and ${result.resource_links.length - 5} more`);
|
|
87
|
+
}
|
|
88
|
+
if (result.related_items.length > 0) {
|
|
89
|
+
lines.push(`**Related items:** ${result.related_items.slice(0, 5).join(', ')}`);
|
|
90
|
+
if (result.related_items.length > 5)
|
|
91
|
+
lines.push(`- … and ${result.related_items.length - 5} more`);
|
|
92
|
+
}
|
|
93
|
+
lines.push(`**URL:** ${result.url}`);
|
|
94
|
+
return [{ type: 'text', text: lines.join('\n') }];
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
//# sourceMappingURL=libofcongress-get-item.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"libofcongress-get-item.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/libofcongress-get-item.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAEzE,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,wBAAwB,EAAE;IACvD,KAAK,EAAE,cAAc;IACrB,WAAW,EACT,6YAA6Y;IAC/Y,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE;IACxD,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,OAAO,EAAE,CAAC;aACP,MAAM,EAAE;aACR,GAAG,CAAC,CAAC,CAAC;aACN,QAAQ,CACP,2JAA2J,CAC5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OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview libofcongress_get_newspaper_page tool — retrieve full OCR text for a specific newspaper page.
|
|
3
|
+
* @module mcp-server/tools/definitions/libofcongress-get-newspaper-page.tool
|
|
4
|
+
*/
|
|
5
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
export declare const locGetNewspaperPage: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
|
|
8
|
+
page_url: z.ZodString;
|
|
9
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
10
|
+
page_url: z.ZodString;
|
|
11
|
+
newspaper_title: z.ZodOptional<z.ZodString>;
|
|
12
|
+
date: z.ZodOptional<z.ZodString>;
|
|
13
|
+
state: z.ZodOptional<z.ZodString>;
|
|
14
|
+
edition: z.ZodOptional<z.ZodString>;
|
|
15
|
+
sequence: z.ZodOptional<z.ZodNumber>;
|
|
16
|
+
ocr_text: z.ZodString;
|
|
17
|
+
ocr_available: z.ZodBoolean;
|
|
18
|
+
}, z.core.$strip>, readonly [{
|
|
19
|
+
readonly reason: "page_not_found";
|
|
20
|
+
readonly code: JsonRpcErrorCode.NotFound;
|
|
21
|
+
readonly when: "The URL does not resolve to a valid LOC newspaper page resource.";
|
|
22
|
+
readonly recovery: "Re-run libofcongress_search_newspapers to get a fresh url from current results. Do not modify or guess page URLs.";
|
|
23
|
+
}, {
|
|
24
|
+
readonly reason: "rate_limit_exceeded";
|
|
25
|
+
readonly code: JsonRpcErrorCode.ServiceUnavailable;
|
|
26
|
+
readonly when: "LOC API rate limit exceeded; requests are blocked for approximately 1 hour.";
|
|
27
|
+
readonly recovery: "Wait approximately 1 hour before retrying. Reduce request frequency to stay under 20 req/min.";
|
|
28
|
+
}]>;
|
|
29
|
+
//# sourceMappingURL=libofcongress-get-newspaper-page.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"libofcongress-get-newspaper-page.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/libofcongress-get-newspaper-page.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAmB,MAAM,+BAA+B,CAAC;AAKlF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;GA6F9B,CAAC"}
|