@pipeworx/mcp-gutendex 1.0.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 +32 -0
- package/package.json +15 -0
- package/src/index.ts +183 -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,32 @@
|
|
|
1
|
+
# mcp-gutendex
|
|
2
|
+
|
|
3
|
+
MCP server for Project Gutenberg books via the [Gutendex API](https://gutendex.com/). No authentication required.
|
|
4
|
+
|
|
5
|
+
## Tools
|
|
6
|
+
|
|
7
|
+
| Tool | Description |
|
|
8
|
+
|------|-------------|
|
|
9
|
+
| `search_books` | Search books by title or author |
|
|
10
|
+
| `get_book` | Get a specific book by ID |
|
|
11
|
+
| `popular_books` | Get the most popular books on Project Gutenberg |
|
|
12
|
+
| `books_by_topic` | Browse books by topic or subject |
|
|
13
|
+
|
|
14
|
+
## Quickstart (Pipeworx Gateway)
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
curl -X POST https://gateway.pipeworx.io/mcp \
|
|
18
|
+
-H "Content-Type: application/json" \
|
|
19
|
+
-d '{
|
|
20
|
+
"jsonrpc": "2.0",
|
|
21
|
+
"method": "tools/call",
|
|
22
|
+
"params": {
|
|
23
|
+
"name": "gutendex_search_books",
|
|
24
|
+
"arguments": { "query": "Shakespeare" }
|
|
25
|
+
},
|
|
26
|
+
"id": 1
|
|
27
|
+
}'
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## License
|
|
31
|
+
|
|
32
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pipeworx/mcp-gutendex",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MCP server for Project Gutenberg books via Gutendex API",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"files": ["src"],
|
|
9
|
+
"scripts": { "build": "tsc", "check": "tsc --noEmit" },
|
|
10
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "gutendex"],
|
|
11
|
+
"author": "Pipeworx <hello@pipeworx.io>",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"repository": { "type": "git", "url": "https://github.com/pipeworx-io/mcp-gutendex.git" },
|
|
14
|
+
"devDependencies": { "typescript": "^5.7.0" }
|
|
15
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gutendex MCP — wraps Gutendex API for Project Gutenberg books (free, no auth)
|
|
3
|
+
*
|
|
4
|
+
* Tools:
|
|
5
|
+
* - search_books: Search books by title or author
|
|
6
|
+
* - get_book: Get a specific book by ID
|
|
7
|
+
* - popular_books: Get the most popular books on Project Gutenberg
|
|
8
|
+
* - books_by_topic: Browse books by topic or subject
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
interface McpToolDefinition {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
inputSchema: {
|
|
15
|
+
type: 'object';
|
|
16
|
+
properties: Record<string, unknown>;
|
|
17
|
+
required?: string[];
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface McpToolExport {
|
|
22
|
+
tools: McpToolDefinition[];
|
|
23
|
+
callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const BASE_URL = 'https://gutendex.com';
|
|
27
|
+
|
|
28
|
+
type RawPerson = {
|
|
29
|
+
name: string;
|
|
30
|
+
birth_year: number | null;
|
|
31
|
+
death_year: number | null;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
type RawFormat = Record<string, string>;
|
|
35
|
+
|
|
36
|
+
type RawBook = {
|
|
37
|
+
id: number;
|
|
38
|
+
title: string;
|
|
39
|
+
authors: RawPerson[];
|
|
40
|
+
translators: RawPerson[];
|
|
41
|
+
subjects: string[];
|
|
42
|
+
bookshelves: string[];
|
|
43
|
+
languages: string[];
|
|
44
|
+
copyright: boolean | null;
|
|
45
|
+
media_type: string;
|
|
46
|
+
formats: RawFormat;
|
|
47
|
+
download_count: number;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
type RawListResponse = {
|
|
51
|
+
count: number;
|
|
52
|
+
next: string | null;
|
|
53
|
+
previous: string | null;
|
|
54
|
+
results: RawBook[];
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
function formatPerson(p: RawPerson) {
|
|
58
|
+
return {
|
|
59
|
+
name: p.name,
|
|
60
|
+
birth_year: p.birth_year,
|
|
61
|
+
death_year: p.death_year,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function formatBook(b: RawBook) {
|
|
66
|
+
return {
|
|
67
|
+
id: b.id,
|
|
68
|
+
title: b.title,
|
|
69
|
+
authors: b.authors.map(formatPerson),
|
|
70
|
+
languages: b.languages,
|
|
71
|
+
subjects: b.subjects,
|
|
72
|
+
download_count: b.download_count,
|
|
73
|
+
formats: b.formats,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const tools: McpToolExport['tools'] = [
|
|
78
|
+
{
|
|
79
|
+
name: 'search_books',
|
|
80
|
+
description: 'Search Project Gutenberg books by title or author name.',
|
|
81
|
+
inputSchema: {
|
|
82
|
+
type: 'object',
|
|
83
|
+
properties: {
|
|
84
|
+
query: {
|
|
85
|
+
type: 'string',
|
|
86
|
+
description: 'Title or author name to search for.',
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
required: ['query'],
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'get_book',
|
|
94
|
+
description: 'Get detailed information for a specific Project Gutenberg book by its numeric ID.',
|
|
95
|
+
inputSchema: {
|
|
96
|
+
type: 'object',
|
|
97
|
+
properties: {
|
|
98
|
+
id: {
|
|
99
|
+
type: 'number',
|
|
100
|
+
description: 'The numeric Project Gutenberg book ID.',
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
required: ['id'],
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: 'popular_books',
|
|
108
|
+
description: 'Get the most downloaded / popular books on Project Gutenberg.',
|
|
109
|
+
inputSchema: {
|
|
110
|
+
type: 'object',
|
|
111
|
+
properties: {},
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: 'books_by_topic',
|
|
116
|
+
description: 'Browse Project Gutenberg books by topic or subject keyword.',
|
|
117
|
+
inputSchema: {
|
|
118
|
+
type: 'object',
|
|
119
|
+
properties: {
|
|
120
|
+
topic: {
|
|
121
|
+
type: 'string',
|
|
122
|
+
description: 'Topic or subject keyword to filter books by (e.g. "science", "love", "history").',
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
required: ['topic'],
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
];
|
|
129
|
+
|
|
130
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
131
|
+
switch (name) {
|
|
132
|
+
case 'search_books':
|
|
133
|
+
return searchBooks(args.query as string);
|
|
134
|
+
case 'get_book':
|
|
135
|
+
return getBook(args.id as number);
|
|
136
|
+
case 'popular_books':
|
|
137
|
+
return popularBooks();
|
|
138
|
+
case 'books_by_topic':
|
|
139
|
+
return booksByTopic(args.topic as string);
|
|
140
|
+
default:
|
|
141
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async function searchBooks(query: string) {
|
|
146
|
+
const res = await fetch(`${BASE_URL}/books?search=${encodeURIComponent(query)}`);
|
|
147
|
+
if (!res.ok) throw new Error(`Gutendex API error: ${res.status}`);
|
|
148
|
+
const data = (await res.json()) as RawListResponse;
|
|
149
|
+
return {
|
|
150
|
+
count: data.count,
|
|
151
|
+
books: data.results.map(formatBook),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
async function getBook(id: number) {
|
|
156
|
+
const res = await fetch(`${BASE_URL}/books/${id}`);
|
|
157
|
+
if (!res.ok) throw new Error(`Gutendex API error: ${res.status}`);
|
|
158
|
+
const data = (await res.json()) as RawBook;
|
|
159
|
+
return formatBook(data);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async function popularBooks() {
|
|
163
|
+
const res = await fetch(`${BASE_URL}/books?sort=popular&page=1`);
|
|
164
|
+
if (!res.ok) throw new Error(`Gutendex API error: ${res.status}`);
|
|
165
|
+
const data = (await res.json()) as RawListResponse;
|
|
166
|
+
return {
|
|
167
|
+
count: data.count,
|
|
168
|
+
books: data.results.map(formatBook),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
async function booksByTopic(topic: string) {
|
|
173
|
+
const res = await fetch(`${BASE_URL}/books?topic=${encodeURIComponent(topic)}`);
|
|
174
|
+
if (!res.ok) throw new Error(`Gutendex API error: ${res.status}`);
|
|
175
|
+
const data = (await res.json()) as RawListResponse;
|
|
176
|
+
return {
|
|
177
|
+
count: data.count,
|
|
178
|
+
topic,
|
|
179
|
+
books: data.results.map(formatBook),
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export default { tools, callTool } satisfies McpToolExport;
|