@pipeworx/mcp-trove 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 Pipeworx
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,57 @@
1
+ # mcp-trove
2
+
3
+ Trove MCP.
4
+
5
+ Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 1102+ live data sources.
6
+
7
+ ## Tools
8
+
9
+ | Tool | Description |
10
+ |------|-------------|
11
+ | `search` | Search the Trove collection by keyword. Returns matching items with ids (pass an id to work), titles, creators/sources, dates and links. |
12
+ | `work` | Fetch full details for one Trove item by id — a Trove work id (from search). |
13
+
14
+ ## Quick Start
15
+
16
+ Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
17
+
18
+ ```json
19
+ {
20
+ "mcpServers": {
21
+ "trove": {
22
+ "url": "https://gateway.pipeworx.io/trove/mcp"
23
+ }
24
+ }
25
+ }
26
+ ```
27
+
28
+ Or connect to the full Pipeworx gateway for access to all 1102+ data sources:
29
+
30
+ ```json
31
+ {
32
+ "mcpServers": {
33
+ "pipeworx": {
34
+ "url": "https://gateway.pipeworx.io/mcp"
35
+ }
36
+ }
37
+ }
38
+ ```
39
+
40
+ ## Using with ask_pipeworx
41
+
42
+ Instead of calling tools directly, you can ask questions in plain English:
43
+
44
+ ```
45
+ ask_pipeworx({ question: "your question about Trove data" })
46
+ ```
47
+
48
+ The gateway picks the right tool and fills the arguments automatically.
49
+
50
+ ## More
51
+
52
+ - [All tools and guides](https://github.com/pipeworx-io/examples)
53
+ - [pipeworx.io](https://pipeworx.io)
54
+
55
+ ## License
56
+
57
+ MIT
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@pipeworx/mcp-trove",
3
+ "version": "0.1.0",
4
+ "description": "Trove MCP.",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "trove"],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/pipeworx-io/mcp-trove"
13
+ },
14
+ "scripts": {
15
+ "typecheck": "tsc --noEmit"
16
+ },
17
+ "devDependencies": {
18
+ "typescript": "^5.7.0"
19
+ }
20
+ }
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/trove",
4
+ "title": "Trove",
5
+ "description": "Trove MCP.",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/trove",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-trove",
10
+ "source": "github"
11
+ },
12
+ "remotes": [
13
+ {
14
+ "type": "streamable-http",
15
+ "url": "https://gateway.pipeworx.io/trove/mcp"
16
+ }
17
+ ]
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,86 @@
1
+ interface McpToolDefinition {
2
+ name: string;
3
+ description: string;
4
+ inputSchema: {
5
+ type: 'object';
6
+ properties: Record<string, unknown>;
7
+ required?: string[];
8
+ };
9
+ }
10
+
11
+ interface McpToolExport {
12
+ tools: McpToolDefinition[];
13
+ callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
14
+ meter?: { credits: number };
15
+ cost?: Record<string, unknown>;
16
+ provider?: string;
17
+ }
18
+
19
+ /**
20
+ * Trove MCP.
21
+ *
22
+ * Trove (National Library of Australia) — 6B+ items: digitised newspapers, books, images, maps, archives & more. Free API key required. Get a free key at trove.nla.gov.au (account -> Create an API key); the platform injects it, or pass _apiKey (BYOK).
23
+ */
24
+
25
+
26
+ const BASE = 'https://api.trove.nla.gov.au';
27
+ const UA = 'pipeworx-mcp-trove/1.0 (+https://pipeworx.io)';
28
+
29
+ const tools: McpToolExport['tools'] = [
30
+ {
31
+ name: 'search',
32
+ description: 'Search the Trove collection by keyword. Returns matching items with ids (pass an id to work), titles, creators/sources, dates and links.',
33
+ inputSchema: { type: 'object', properties: {
34
+ query: { type: 'string', description: 'Keyword(s).' },
35
+ limit: { type: 'number', description: 'Max results (1-100, default 20).' },
36
+ page: { type: 'number', description: 'Page (1-based, default 1).' },
37
+ _apiKey: { type: 'string', description: 'Trove API key (auto-injected by the platform).' },
38
+ }, required: ['query'] },
39
+ },
40
+ {
41
+ name: 'work',
42
+ description: 'Fetch full details for one Trove item by id — a Trove work id (from search).',
43
+ inputSchema: { type: 'object', properties: {
44
+ id: { type: 'string', description: 'e.g. "12345".' },
45
+ _apiKey: { type: 'string', description: 'Trove API key.' },
46
+ }, required: ['id'] },
47
+ },
48
+ ];
49
+
50
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
51
+ const key = typeof args._apiKey === 'string' ? args._apiKey : '';
52
+ delete args._apiKey;
53
+ if (!key) throw new Error('Trove API key required. Get one free at trove.nla.gov.au (account -> Create an API key) and pass via _apiKey (platform key may not be set yet).');
54
+ switch (name) {
55
+ case 'search': {
56
+ const limit = clamp(numArg(args.limit, 20), 1, 100);
57
+ const p = new URLSearchParams();
58
+ p.set('q', String(args.query ?? ''));
59
+ p.set('n', String(limit));
60
+ const page = Math.max(1, numArg(args.page, 1));
61
+ if (page > 1) p.set('page', String(page));
62
+ p.set('category', 'all'); p.set('encoding', 'json');
63
+ if (key) p.set('key', key);
64
+ return get(`${BASE}/v3/result?${p}`, key);
65
+ }
66
+ case 'work': {
67
+ const id = reqStr(args, 'id', '"12345"');
68
+ const dp = new URLSearchParams(); dp.set('encoding','json'); if(key) dp.set('key', key); const dq = '?' + dp.toString();
69
+ return get(`${BASE}/v3/work/${encodeURIComponent(id)}${dq}`, key);
70
+ }
71
+ default: throw new Error(`Unknown tool: ${name}`);
72
+ }
73
+ }
74
+
75
+ async function get(url: string, key: string): Promise<unknown> {
76
+ const headers = { Accept: 'application/json', 'User-Agent': UA };
77
+ const res = await fetch(url, { headers });
78
+ if (res.status === 401 || res.status === 403) throw new Error('Trove: key rejected/missing. Get a free key at trove.nla.gov.au (account -> Create an API key).');
79
+ if (!res.ok) throw new Error(`Trove: ${res.status} ${await res.text().then((t) => t.slice(0, 160))}`);
80
+ return res.json();
81
+ }
82
+ function reqStr(args: Record<string, unknown>, k: string, ex: string): string { const v = args[k]; if (typeof v !== 'string' || !v.trim()) throw new Error(`Required argument "${k}" is missing. Pass a string like ${ex}.`); return v; }
83
+ function numArg(v: unknown, d: number): number { const n = typeof v === 'number' ? v : typeof v === 'string' ? Number(v) : NaN; return Number.isFinite(n) ? n : d; }
84
+ function clamp(n: number, lo: number, hi: number): number { return Math.max(lo, Math.min(hi, Math.trunc(n))); }
85
+
86
+ export default { tools, callTool, meter: { credits: 1 } } satisfies McpToolExport;
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "strict": true,
7
+ "esModuleInterop": true,
8
+ "skipLibCheck": true,
9
+ "outDir": "dist",
10
+ "rootDir": "src",
11
+ "declaration": true
12
+ },
13
+ "include": ["src"]
14
+ }