@pipeworx/mcp-google-books 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 +21 -0
- package/README.md +58 -0
- package/package.json +20 -0
- package/server.json +18 -0
- package/src/index.ts +149 -0
- package/tsconfig.json +14 -0
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,58 @@
|
|
|
1
|
+
# mcp-google-books
|
|
2
|
+
|
|
3
|
+
Google Books MCP
|
|
4
|
+
|
|
5
|
+
Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 250+ live data sources.
|
|
6
|
+
|
|
7
|
+
## Tools
|
|
8
|
+
|
|
9
|
+
| Tool | Description |
|
|
10
|
+
|------|-------------|
|
|
11
|
+
| `get_volume` | Volume detail (full title, authors, description, categories, page count, links). |
|
|
12
|
+
| `get_by_isbn` | Convenience: look up a volume by ISBN-10 or ISBN-13. |
|
|
13
|
+
| `list_bookshelf` | Public bookshelf by user id (numeric). |
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"mcpServers": {
|
|
22
|
+
"google-books": {
|
|
23
|
+
"url": "https://gateway.pipeworx.io/google-books/mcp"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or connect to the full Pipeworx gateway for access to all 250+ data sources:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"mcpServers": {
|
|
34
|
+
"pipeworx": {
|
|
35
|
+
"url": "https://gateway.pipeworx.io/mcp"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Using with ask_pipeworx
|
|
42
|
+
|
|
43
|
+
Instead of calling tools directly, you can ask questions in plain English:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
ask_pipeworx({ question: "your question about Google Books data" })
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The gateway picks the right tool and fills the arguments automatically.
|
|
50
|
+
|
|
51
|
+
## More
|
|
52
|
+
|
|
53
|
+
- [All tools and guides](https://github.com/pipeworx-io/examples)
|
|
54
|
+
- [pipeworx.io](https://pipeworx.io)
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
|
|
58
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pipeworx/mcp-google-books",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Google Books MCP",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "google-books"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/pipeworx-io/mcp-google-books"
|
|
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/google-books",
|
|
4
|
+
"title": "Google Books",
|
|
5
|
+
"description": "Google Books MCP",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"websiteUrl": "https://pipeworx.io/packs/google-books",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/pipeworx-io/mcp-google-books",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://gateway.pipeworx.io/google-books/mcp"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
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
|
+
* Google Books MCP
|
|
21
|
+
*
|
|
22
|
+
* Public reads keyless (1k req/day per IP). Optional key for higher limits.
|
|
23
|
+
*
|
|
24
|
+
* Docs: https://developers.google.com/books
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
const BASE = 'https://www.googleapis.com/books/v1';
|
|
29
|
+
|
|
30
|
+
const tools: McpToolExport['tools'] = [
|
|
31
|
+
{
|
|
32
|
+
name: 'search',
|
|
33
|
+
description:
|
|
34
|
+
'Full-text search of Google Books. Use search_field to scope (intitle:, inauthor:, subject:, etc).',
|
|
35
|
+
inputSchema: {
|
|
36
|
+
type: 'object',
|
|
37
|
+
properties: {
|
|
38
|
+
query: { type: 'string', description: 'Search query' },
|
|
39
|
+
search_field: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
description: 'intitle | inauthor | inpublisher | subject | isbn | lccn | oclc — applied as a prefix to query',
|
|
42
|
+
},
|
|
43
|
+
filter: {
|
|
44
|
+
type: 'string',
|
|
45
|
+
description: 'partial | full | free-ebooks | paid-ebooks | ebooks',
|
|
46
|
+
},
|
|
47
|
+
language: { type: 'string', description: 'ISO 639-1 (en, fr, ja, ...)' },
|
|
48
|
+
print_type: { type: 'string', description: 'all (default) | books | magazines' },
|
|
49
|
+
order_by: { type: 'string', description: 'relevance (default) | newest' },
|
|
50
|
+
limit: { type: 'number', description: '1-40 (default 10)' },
|
|
51
|
+
offset: { type: 'number', description: '0-based offset (startIndex)' },
|
|
52
|
+
},
|
|
53
|
+
required: ['query'],
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'get_volume',
|
|
58
|
+
description: 'Volume detail (full title, authors, description, categories, page count, links).',
|
|
59
|
+
inputSchema: {
|
|
60
|
+
type: 'object',
|
|
61
|
+
properties: { id: { type: 'string', description: 'Google Books volume id' } },
|
|
62
|
+
required: ['id'],
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'get_by_isbn',
|
|
67
|
+
description: 'Convenience: look up a volume by ISBN-10 or ISBN-13.',
|
|
68
|
+
inputSchema: {
|
|
69
|
+
type: 'object',
|
|
70
|
+
properties: { isbn: { type: 'string' } },
|
|
71
|
+
required: ['isbn'],
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: 'list_bookshelf',
|
|
76
|
+
description: 'Public bookshelf by user id (numeric).',
|
|
77
|
+
inputSchema: {
|
|
78
|
+
type: 'object',
|
|
79
|
+
properties: {
|
|
80
|
+
user_id: { type: 'string', description: 'Google account numeric user id' },
|
|
81
|
+
shelf: { type: 'string', description: 'Shelf id (numeric) — omit to list all public shelves' },
|
|
82
|
+
},
|
|
83
|
+
required: ['user_id'],
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
];
|
|
87
|
+
|
|
88
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
89
|
+
const apiKey = (args._apiKey as string | undefined)?.trim();
|
|
90
|
+
switch (name) {
|
|
91
|
+
case 'search':
|
|
92
|
+
return search(apiKey, args);
|
|
93
|
+
case 'get_volume':
|
|
94
|
+
return gbGet(apiKey, `/volumes/${encodeURIComponent(reqStr(args, 'id', '"zyTCAlFPjgYC"'))}`);
|
|
95
|
+
case 'get_by_isbn': {
|
|
96
|
+
const isbn = reqStr(args, 'isbn', '"9780140449266"').replace(/[-\s]/g, '');
|
|
97
|
+
return search(apiKey, { query: `isbn:${isbn}`, limit: 1 });
|
|
98
|
+
}
|
|
99
|
+
case 'list_bookshelf': {
|
|
100
|
+
const userId = reqStr(args, 'user_id', '"1234567890"');
|
|
101
|
+
const shelf = (args.shelf as string | undefined)?.trim();
|
|
102
|
+
const path = shelf ? `/users/${encodeURIComponent(userId)}/bookshelves/${encodeURIComponent(shelf)}/volumes` : `/users/${encodeURIComponent(userId)}/bookshelves`;
|
|
103
|
+
return gbGet(apiKey, path);
|
|
104
|
+
}
|
|
105
|
+
default:
|
|
106
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function search(apiKey: string | undefined, args: Record<string, unknown>) {
|
|
111
|
+
let q = reqStr(args, 'query', '"the great gatsby"');
|
|
112
|
+
const field = (args.search_field as string | undefined)?.trim();
|
|
113
|
+
if (field && !q.includes(':')) q = `${field}:${q}`;
|
|
114
|
+
const params = new URLSearchParams({
|
|
115
|
+
q,
|
|
116
|
+
maxResults: String(Math.min(40, Math.max(1, (args.limit as number) ?? 10))),
|
|
117
|
+
startIndex: String(Math.max(0, (args.offset as number) ?? 0)),
|
|
118
|
+
});
|
|
119
|
+
if (args.filter) params.set('filter', String(args.filter));
|
|
120
|
+
if (args.language) params.set('langRestrict', String(args.language));
|
|
121
|
+
if (args.print_type) params.set('printType', String(args.print_type));
|
|
122
|
+
if (args.order_by) params.set('orderBy', String(args.order_by));
|
|
123
|
+
if (apiKey) params.set('key', apiKey);
|
|
124
|
+
return gbGet(apiKey, `/volumes?${params}`);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async function gbGet(apiKey: string | undefined, path: string) {
|
|
128
|
+
const sep = path.includes('?') ? '&' : '?';
|
|
129
|
+
const url = `${BASE}${path}${apiKey && !path.includes('key=') ? `${sep}key=${encodeURIComponent(apiKey)}` : ''}`;
|
|
130
|
+
const res = await fetch(url, { headers: { Accept: 'application/json' } });
|
|
131
|
+
if (res.status === 401 || res.status === 403) throw new Error('Google Books: unauthorized — check key');
|
|
132
|
+
if (res.status === 404) throw new Error('Google Books: not found');
|
|
133
|
+
if (res.status === 429) throw new Error('Google Books: rate-limit (HTTP 429)');
|
|
134
|
+
if (!res.ok) {
|
|
135
|
+
const t = await res.text();
|
|
136
|
+
throw new Error(`Google Books error: ${res.status} ${t.slice(0, 200)}`);
|
|
137
|
+
}
|
|
138
|
+
return res.json();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function reqStr(args: Record<string, unknown>, key: string, example: string): string {
|
|
142
|
+
const v = args[key];
|
|
143
|
+
if (typeof v !== 'string' || !v.trim()) {
|
|
144
|
+
throw new Error(`Required argument "${key}" is missing. Pass a string like ${example}.`);
|
|
145
|
+
}
|
|
146
|
+
return v;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
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
|
+
}
|