@pipeworx/mcp-anilist 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 +34 -0
- package/package.json +20 -0
- package/server.json +18 -0
- package/src/index.ts +266 -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,34 @@
|
|
|
1
|
+
# mcp-anilist
|
|
2
|
+
|
|
3
|
+
AniList MCP — wraps AniList GraphQL API (free, no auth)
|
|
4
|
+
|
|
5
|
+
Part of the [Pipeworx](https://pipeworx.io) open MCP gateway.
|
|
6
|
+
|
|
7
|
+
## Tools
|
|
8
|
+
|
|
9
|
+
| Tool | Description |
|
|
10
|
+
|------|-------------|
|
|
11
|
+
|
|
12
|
+
## Quick Start
|
|
13
|
+
|
|
14
|
+
Add to your MCP client config:
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
{
|
|
18
|
+
"mcpServers": {
|
|
19
|
+
"anilist": {
|
|
20
|
+
"url": "https://gateway.pipeworx.io/anilist/mcp"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Or use the CLI:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npx pipeworx use anilist
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## License
|
|
33
|
+
|
|
34
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pipeworx/mcp-anilist",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "AniList MCP — wraps AniList GraphQL API (free, no auth)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "anilist"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/pipeworx-io/mcp-anilist"
|
|
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/anilist",
|
|
4
|
+
"title": "anilist",
|
|
5
|
+
"description": "AniList MCP — wraps AniList GraphQL API (free, no auth)",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"websiteUrl": "https://pipeworx.io/packs/anilist",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/pipeworx-io/mcp-anilist",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://gateway.pipeworx.io/anilist/mcp"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
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
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* AniList MCP — wraps AniList GraphQL API (free, no auth)
|
|
18
|
+
*
|
|
19
|
+
* Tools:
|
|
20
|
+
* - search_anime: Search anime by title
|
|
21
|
+
* - get_anime: Get full details for an anime by AniList ID
|
|
22
|
+
* - trending_anime: Get currently trending anime
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
const GRAPHQL_URL = 'https://graphql.anilist.co';
|
|
27
|
+
|
|
28
|
+
// ── API types ─────────────────────────────────────────────────────────
|
|
29
|
+
|
|
30
|
+
type AniListTitle = {
|
|
31
|
+
romaji: string | null;
|
|
32
|
+
english: string | null;
|
|
33
|
+
native: string | null;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
type AniListMedia = {
|
|
37
|
+
id: number;
|
|
38
|
+
title: AniListTitle;
|
|
39
|
+
description: string | null;
|
|
40
|
+
episodes: number | null;
|
|
41
|
+
duration: number | null;
|
|
42
|
+
status: string | null;
|
|
43
|
+
season: string | null;
|
|
44
|
+
seasonYear: number | null;
|
|
45
|
+
averageScore: number | null;
|
|
46
|
+
meanScore: number | null;
|
|
47
|
+
popularity: number | null;
|
|
48
|
+
favourites: number | null;
|
|
49
|
+
genres: string[] | null;
|
|
50
|
+
format: string | null;
|
|
51
|
+
source: string | null;
|
|
52
|
+
coverImage: { large: string | null; medium: string | null } | null;
|
|
53
|
+
siteUrl: string | null;
|
|
54
|
+
studios: {
|
|
55
|
+
nodes: Array<{ id: number; name: string; isAnimationStudio: boolean }>;
|
|
56
|
+
} | null;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
type AniListPageResponse = {
|
|
60
|
+
data: {
|
|
61
|
+
Page: {
|
|
62
|
+
media: AniListMedia[];
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
errors?: Array<{ message: string }>;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
type AniListSingleResponse = {
|
|
69
|
+
data: {
|
|
70
|
+
Media: AniListMedia;
|
|
71
|
+
};
|
|
72
|
+
errors?: Array<{ message: string }>;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// ── GraphQL fragments ─────────────────────────────────────────────────
|
|
76
|
+
|
|
77
|
+
const MEDIA_FIELDS = `
|
|
78
|
+
id
|
|
79
|
+
title { romaji english native }
|
|
80
|
+
description(asHtml: false)
|
|
81
|
+
episodes
|
|
82
|
+
duration
|
|
83
|
+
status
|
|
84
|
+
season
|
|
85
|
+
seasonYear
|
|
86
|
+
averageScore
|
|
87
|
+
meanScore
|
|
88
|
+
popularity
|
|
89
|
+
favourites
|
|
90
|
+
genres
|
|
91
|
+
format
|
|
92
|
+
source
|
|
93
|
+
coverImage { large medium }
|
|
94
|
+
siteUrl
|
|
95
|
+
studios(isMain: true) {
|
|
96
|
+
nodes { id name isAnimationStudio }
|
|
97
|
+
}
|
|
98
|
+
`;
|
|
99
|
+
|
|
100
|
+
// ── Tool definitions ──────────────────────────────────────────────────
|
|
101
|
+
|
|
102
|
+
const tools: McpToolExport['tools'] = [
|
|
103
|
+
{
|
|
104
|
+
name: 'search_anime',
|
|
105
|
+
description:
|
|
106
|
+
'Search anime by title using AniList. Returns title, episode count, status, average score, genres, and a synopsis.',
|
|
107
|
+
inputSchema: {
|
|
108
|
+
type: 'object',
|
|
109
|
+
properties: {
|
|
110
|
+
query: {
|
|
111
|
+
type: 'string',
|
|
112
|
+
description: 'Anime title to search for, e.g. "Attack on Titan" or "Cowboy Bebop"',
|
|
113
|
+
},
|
|
114
|
+
limit: {
|
|
115
|
+
type: 'number',
|
|
116
|
+
description: 'Number of results to return (1–25, default 10)',
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
required: ['query'],
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: 'get_anime',
|
|
124
|
+
description:
|
|
125
|
+
'Get full details for an anime by its AniList ID. Returns title, synopsis, episodes, duration, status, score, genres, studios, and season info.',
|
|
126
|
+
inputSchema: {
|
|
127
|
+
type: 'object',
|
|
128
|
+
properties: {
|
|
129
|
+
id: {
|
|
130
|
+
type: 'number',
|
|
131
|
+
description: 'AniList media ID (e.g. 21 for One Piece, 1 for Cowboy Bebop)',
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
required: ['id'],
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: 'trending_anime',
|
|
139
|
+
description:
|
|
140
|
+
'Get currently trending anime on AniList, ranked by trending score. Returns title, status, score, episodes, and genres.',
|
|
141
|
+
inputSchema: {
|
|
142
|
+
type: 'object',
|
|
143
|
+
properties: {
|
|
144
|
+
limit: {
|
|
145
|
+
type: 'number',
|
|
146
|
+
description: 'Number of results to return (1–25, default 10)',
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
required: [],
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
];
|
|
153
|
+
|
|
154
|
+
// ── Helpers ───────────────────────────────────────────────────────────
|
|
155
|
+
|
|
156
|
+
async function gqlPost<T>(query: string, variables: Record<string, unknown>): Promise<T> {
|
|
157
|
+
const res = await fetch(GRAPHQL_URL, {
|
|
158
|
+
method: 'POST',
|
|
159
|
+
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
|
160
|
+
body: JSON.stringify({ query, variables }),
|
|
161
|
+
});
|
|
162
|
+
if (!res.ok) throw new Error(`AniList API error: ${res.status}`);
|
|
163
|
+
|
|
164
|
+
const json = (await res.json()) as T & { errors?: Array<{ message: string }> };
|
|
165
|
+
if ((json as { errors?: Array<{ message: string }> }).errors?.length) {
|
|
166
|
+
const msg = (json as { errors: Array<{ message: string }> }).errors[0]!.message;
|
|
167
|
+
throw new Error(`AniList GraphQL error: ${msg}`);
|
|
168
|
+
}
|
|
169
|
+
return json;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function formatMedia(m: AniListMedia) {
|
|
173
|
+
return {
|
|
174
|
+
id: m.id,
|
|
175
|
+
title_romaji: m.title.romaji ?? null,
|
|
176
|
+
title_english: m.title.english ?? null,
|
|
177
|
+
title_native: m.title.native ?? null,
|
|
178
|
+
description: m.description ?? null,
|
|
179
|
+
episodes: m.episodes ?? null,
|
|
180
|
+
duration_minutes: m.duration ?? null,
|
|
181
|
+
status: m.status ?? null,
|
|
182
|
+
format: m.format ?? null,
|
|
183
|
+
source: m.source ?? null,
|
|
184
|
+
season: m.season ?? null,
|
|
185
|
+
season_year: m.seasonYear ?? null,
|
|
186
|
+
average_score: m.averageScore ?? null,
|
|
187
|
+
mean_score: m.meanScore ?? null,
|
|
188
|
+
popularity: m.popularity ?? null,
|
|
189
|
+
favourites: m.favourites ?? null,
|
|
190
|
+
genres: m.genres ?? [],
|
|
191
|
+
cover_image: m.coverImage?.large ?? m.coverImage?.medium ?? null,
|
|
192
|
+
site_url: m.siteUrl ?? null,
|
|
193
|
+
studios: (m.studios?.nodes ?? []).map((s) => s.name),
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// ── Tool implementations ──────────────────────────────────────────────
|
|
198
|
+
|
|
199
|
+
async function searchAnime(query: string, limit = 10) {
|
|
200
|
+
const gql = `
|
|
201
|
+
query ($search: String, $perPage: Int) {
|
|
202
|
+
Page(page: 1, perPage: $perPage) {
|
|
203
|
+
media(search: $search, type: ANIME) {
|
|
204
|
+
${MEDIA_FIELDS}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
`;
|
|
209
|
+
|
|
210
|
+
const data = await gqlPost<AniListPageResponse>(gql, {
|
|
211
|
+
search: query,
|
|
212
|
+
perPage: Math.min(Math.max(limit, 1), 25),
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
const results = data.data.Page.media.map(formatMedia);
|
|
216
|
+
return { count: results.length, results };
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
async function getAnime(id: number) {
|
|
220
|
+
const gql = `
|
|
221
|
+
query ($id: Int) {
|
|
222
|
+
Media(id: $id, type: ANIME) {
|
|
223
|
+
${MEDIA_FIELDS}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
`;
|
|
227
|
+
|
|
228
|
+
const data = await gqlPost<AniListSingleResponse>(gql, { id });
|
|
229
|
+
return formatMedia(data.data.Media);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
async function trendingAnime(limit = 10) {
|
|
233
|
+
const gql = `
|
|
234
|
+
query ($perPage: Int) {
|
|
235
|
+
Page(page: 1, perPage: $perPage) {
|
|
236
|
+
media(type: ANIME, sort: TRENDING_DESC) {
|
|
237
|
+
${MEDIA_FIELDS}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
`;
|
|
242
|
+
|
|
243
|
+
const data = await gqlPost<AniListPageResponse>(gql, {
|
|
244
|
+
perPage: Math.min(Math.max(limit, 1), 25),
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
const results = data.data.Page.media.map(formatMedia);
|
|
248
|
+
return { count: results.length, results };
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// ── Dispatcher ────────────────────────────────────────────────────────
|
|
252
|
+
|
|
253
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
254
|
+
switch (name) {
|
|
255
|
+
case 'search_anime':
|
|
256
|
+
return searchAnime(args.query as string, args.limit as number | undefined);
|
|
257
|
+
case 'get_anime':
|
|
258
|
+
return getAnime(args.id as number);
|
|
259
|
+
case 'trending_anime':
|
|
260
|
+
return trendingAnime(args.limit as number | undefined);
|
|
261
|
+
default:
|
|
262
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export default { tools, callTool, meter: { credits: 2 } } 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
|
+
}
|