@pipeworx/mcp-dpla 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mojibake Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,178 @@
1
+ # @pipeworx/dpla
2
+
3
+ The Digital Public Library of America — ~50 million digitised items aggregated
4
+ from the Library of Congress, the National Archives, the Smithsonian,
5
+ HathiTrust, Internet Archive and hundreds of state libraries, universities and
6
+ historical societies, searchable in one query.
7
+
8
+ Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 1679+ live data sources.
9
+
10
+ ## Tools
11
+
12
+ - `dpla_search_items(...)` — search by free text, title, creator, contributing hub, subject, type, named collection or date range.
13
+ - `dpla_item(id)` — one record in full, including the raw source metadata as the contributing institution wrote it.
14
+ - `dpla_collections(q | title)` — which named collections inside contributing institutions hold matching material, with an item count each.
15
+
16
+ ## Auth
17
+
18
+ Platform-backed since 2026-09-18: `PLATFORM_DPLA_KEY` lives in the encrypted
19
+ `platform_keys` table (no Cloudflare binding) and `platformKeyEnv` is declared
20
+ in `workers/gateway/src/pack-manifest.json`, so callers need nothing. Pass your
21
+ own key as `_apiKey` to use it instead.
22
+
23
+ The key is **free, instant and self-service** — no approval, no plan, no
24
+ payment:
25
+
26
+ ```
27
+ curl -XPOST https://api.dp.la/v2/api_key/<your-email>
28
+ ```
29
+
30
+ DPLA emails the key within a minute or two.
31
+
32
+ Verify the platform key is really set with
33
+ `curl -s https://gateway.pipeworx.io/manifest.json` → `dpla.platform_key_set`,
34
+ never from a file on a laptop.
35
+
36
+ ## Data sources
37
+
38
+ - <https://api.dp.la/v2/items> — item search; `dpla_collections` is the
39
+ `sourceResource.collection.title` facet of this same endpoint.
40
+ - <https://api.dp.la/v2/items/{id}> — one record.
41
+
42
+ Notes the next person would otherwise rediscover:
43
+
44
+ - **`/v2/collections` no longer exists** (fleet #2249, 2026-09-18). DPLA's API
45
+ serves exactly three routes — `GET /v2/items`, `GET /v2/items/{id}`,
46
+ `POST /v2/api_key/{email}` (their source: `github.com/dpla/dpla-api`,
47
+ `src/index.ts`). `api.dp.la/v2/collections` answers
48
+ `404 The requested resource could not be found` to a valid key, the same
49
+ body it gives no key at all. An earlier version of this pack read that 404
50
+ as "bad key" because it had only ever been run without a working one. Named
51
+ collections now surface only as the `sourceResource.collection.title` facet
52
+ on the items search (`facets=sourceResource.collection.title`, `facet_size`
53
+ up to 2,000), which is what `dpla_collections` is built on.
54
+ - **A 404 from DPLA is never a key problem.** A missing key and a wrong key
55
+ give the **identical 403** and the identical body
56
+ (`{"error":"invalid_api_key","message":"Invalid or inactive API key."}`),
57
+ checked **before** any other parameter is validated. So a 403 says nothing
58
+ about whether the rest of the query was well formed, and a 404 says the
59
+ path is gone, not that the key is. Verify a key by calling `/v2/items` with
60
+ it, not by reading an error.
61
+ - `page_size=0` does not suppress docs — it falls through to DPLA's default
62
+ page — so `dpla_collections` asks for one doc and ignores it.
63
+ - Filters are **dotted paths into the record**, not flat names:
64
+ `sourceResource.title`, `sourceResource.creator`, `provider.name`,
65
+ `sourceResource.subject.name`, `sourceResource.collection.title`,
66
+ `sourceResource.date.after`.
67
+ - **Fields are a string in one contributor's records and an array in another's**
68
+ — DPLA aggregates metadata written by hundreds of separate institutions and
69
+ does not normalise cardinality. `list()`/`one()` in the pack handle both;
70
+ anything reading `d.sourceResource.creator[0]` directly will break on some
71
+ contributors. `sourceResource.collection` is an object with `title` (not
72
+ `name`), so it has its own `collectionTitles()` reader.
73
+ - `isShownAt` is the object on the holding institution's own site; DPLA holds
74
+ the description, the institution holds the object.
75
+
76
+ ## Quick Start
77
+
78
+ Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
79
+
80
+ ```json
81
+ {
82
+ "mcpServers": {
83
+ "dpla": {
84
+ "url": "https://gateway.pipeworx.io/dpla/mcp"
85
+ }
86
+ }
87
+ }
88
+ ```
89
+
90
+ ### What this endpoint actually serves
91
+
92
+ `tools/list` at `https://gateway.pipeworx.io/dpla/mcp` returns the tools in the table
93
+ above **plus the shared Pipeworx meta-tools** — `ask_pipeworx`,
94
+ `discover_tools`, `search_within`, `remember`/`recall` and the rest of the
95
+ gateway-wide set. So the tool count you see is larger than this table: a
96
+ single-pack endpoint currently lists roughly 30 shared tools alongside the
97
+ pack's own. The connection's `initialize` response states its exact scope, and
98
+ is the authoritative answer for a given day.
99
+
100
+ This is deliberate, not multiplexing by accident. The meta-tools are what let a
101
+ scoped connection answer a question this pack does not cover — via
102
+ `ask_pipeworx`, which routes across the whole catalog — without you adding a
103
+ second MCP server. There is currently no way to mount a pack endpoint without
104
+ them; if the extra schemas cost you more context than the routing is worth,
105
+ connect to the full gateway once rather than to several pack endpoints.
106
+
107
+ Or connect to the full Pipeworx gateway to get every pack's tools listed
108
+ directly, instead of just this one's:
109
+
110
+ ```json
111
+ {
112
+ "mcpServers": {
113
+ "pipeworx": {
114
+ "url": "https://gateway.pipeworx.io/mcp"
115
+ }
116
+ }
117
+ }
118
+ ```
119
+
120
+ Both URLs reach the same gateway and the same 1679+ data sources. The
121
+ only difference is which pack's tools are listed **directly**; `ask_pipeworx`
122
+ reaches all of them from either one.
123
+
124
+ ## No MCP client? Call it over HTTP
125
+
126
+ ```bash
127
+ curl -X POST https://gateway.pipeworx.io/v1/tools/dpla_search_items \
128
+ -H 'Content-Type: application/json' \
129
+ -d '{"q":"Dust Bowl","limit":10}'
130
+ ```
131
+
132
+ No account needed for the first calls. Inspect any tool: `GET https://gateway.pipeworx.io/v1/tools/dpla_search_items`. Find one: `POST https://gateway.pipeworx.io/v1/tools/search_packs` with `{"query":"..."}`.
133
+
134
+ ## Standalone (no gateway account)
135
+
136
+ This package also runs as a local stdio MCP server — no Pipeworx account, no
137
+ gateway round-trip:
138
+
139
+ ```json
140
+ {
141
+ "mcpServers": {
142
+ "dpla": {
143
+ "command": "npx",
144
+ "args": ["-y", "@pipeworx/mcp-dpla"]
145
+ }
146
+ }
147
+ }
148
+ ```
149
+
150
+ Or run it directly to confirm it starts:
151
+
152
+ ```bash
153
+ npx -y @pipeworx/mcp-dpla
154
+ ```
155
+
156
+ It speaks MCP over stdin/stdout and answers `initialize`/`tools/list`/`tools/call`
157
+ for **only** this pack's tools — none of the shared meta-tools the gateway
158
+ connection above adds. Same source, same tools, no ask_pipeworx routing.
159
+
160
+ ## Using with ask_pipeworx
161
+
162
+ Instead of calling tools directly, you can ask questions in plain English —
163
+ this works on the pack endpoint above as well as on the full gateway:
164
+
165
+ ```
166
+ ask_pipeworx({ question: "your question about Dpla data" })
167
+ ```
168
+
169
+ The gateway picks the right tool and fills the arguments automatically.
170
+
171
+ ## More
172
+
173
+ - [Docs and guides](https://pipeworx.io/docs)
174
+ - [pipeworx.io](https://pipeworx.io)
175
+
176
+ ## License
177
+
178
+ MIT
package/bin/cli.js ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ //
3
+ // Entry point for `npx @pipeworx/mcp-<slug>`.
4
+ //
5
+ // Packs ship as raw TypeScript (no build step — see publish-pack.sh for why:
6
+ // tsx sidesteps every extensionless-import / bare-JSON-import edge case a
7
+ // per-pack tsc build would have to solve one pack at a time). This file
8
+ // registers tsx's ESM loader programmatically, then hands off to src/server.ts,
9
+ // which wraps the pack's {tools, callTool} export in a stdio MCP server.
10
+ //
11
+ // Copied verbatim into every published pack repo by scripts/publish-pack.sh —
12
+ // edit this file, not a per-pack copy.
13
+ import { register } from 'tsx/esm/api';
14
+
15
+ register();
16
+
17
+ await import('../src/server.ts');
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@pipeworx/mcp-dpla",
3
+ "version": "0.1.0",
4
+ "description": "DPLA — the Digital Public Library of America.",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "bin": {
9
+ "mcp-dpla": "bin/cli.js"
10
+ },
11
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "dpla"],
12
+ "license": "MIT",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/pipeworx-io/mcp-dpla.git"
16
+ },
17
+ "scripts": {
18
+ "typecheck": "tsc --noEmit"
19
+ },
20
+ "dependencies": {
21
+ "@modelcontextprotocol/sdk": "^1.30.0",
22
+ "tsx": "^4.19.0"
23
+ },
24
+ "devDependencies": {
25
+ "typescript": "^5.9.3",
26
+ "@cloudflare/workers-types": "^4.20260405.1"
27
+ },
28
+ "pipeworx": {
29
+ "sourceHash": "v1-3917c012875b603d9a8f3d3d6f49f2a6bbc9e29ebc84bc3b7a0a7adeef90ef27",
30
+ "sourceCommit": "839ab210d969ef7f822cd747ea516f6bb49e9231"
31
+ }
32
+ }
package/server.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.pipeworx-io/dpla",
4
+ "title": "Dpla",
5
+ "description": "DPLA — the Digital Public Library of America.",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/dpla",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-dpla",
10
+ "source": "github"
11
+ },
12
+ "remotes": [
13
+ {
14
+ "type": "streamable-http",
15
+ "url": "https://gateway.pipeworx.io/dpla/mcp"
16
+ }
17
+ ]
18
+ }