dragonball-mcp 1.0.1 → 1.0.3

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/README.md CHANGED
@@ -19,3 +19,5 @@ node dist/index.js
19
19
  ```
20
20
 
21
21
  Data comes from the public Dragon Ball API.
22
+
23
+
package/dist/api.js CHANGED
@@ -40,3 +40,27 @@ export async function character(args) {
40
40
  s('description') ? `\n${s('description')}` : '',
41
41
  ].filter(Boolean).join('\n');
42
42
  }
43
+ export async function planets(args = {}) {
44
+ const page = Math.max(1, Math.min(Math.trunc(Number(args.page ?? 1)) || 1, 100));
45
+ const limit = Math.max(1, Math.min(Math.trunc(Number(args.limit ?? 10)) || 10, 50));
46
+ const res = await fetch(`${BASE}/planets?page=${page}&limit=${limit}`, {
47
+ headers: { 'User-Agent': 'mrfentmen-dragonball-mcp/1.0', Accept: 'application/json' },
48
+ signal: AbortSignal.timeout(20000),
49
+ });
50
+ if (!res.ok)
51
+ throw new Error(`Dragon Ball API returned ${res.status}`);
52
+ const d = (await res.json());
53
+ const rows = d.items ?? [];
54
+ if (!rows.length)
55
+ return `No planets on page ${page}.`;
56
+ const meta = d.meta ?? {};
57
+ const lines = [
58
+ `Dragon Ball planets — page ${meta.currentPage ?? page} of ${meta.totalPages ?? '?'}, ${meta.totalItems ?? '?'} in total, ${rows.length} shown`,
59
+ ];
60
+ for (const [i, r] of rows.entries()) {
61
+ lines.push(`${i + 1}. ${r.name ?? 'unnamed'}${r.isDestroyed ? ' (destroyed)' : ' (intact)'}`);
62
+ if (r.description)
63
+ lines.push(` ${String(r.description).slice(0, 160)}`);
64
+ }
65
+ return lines.join('\n');
66
+ }
package/dist/server.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import { z } from "zod";
3
- import { character } from "./api.js";
4
- import { characters } from "./api.js";
3
+ import { character, characters, planets } from "./api.js";
5
4
  const text = (value) => ({ content: [{ type: "text", text: value }] });
6
5
  const textError = (t) => ({ content: [{ type: "text", text: t }], isError: true });
7
6
  const READ_ONLY = { readOnlyHint: true, openWorldHint: true };
@@ -18,7 +17,7 @@ export function createServer() {
18
17
  return text(await characters(args));
19
18
  }
20
19
  catch (e) {
21
- return textError(error(e));
20
+ return textError(String(e));
22
21
  }
23
22
  });
24
23
  server.registerTool("character", {
@@ -31,7 +30,34 @@ export function createServer() {
31
30
  return text(await character(args));
32
31
  }
33
32
  catch (e) {
34
- return textError(error(e));
33
+ return textError(String(e));
34
+ }
35
+ });
36
+ server.registerTool("character_detail", {
37
+ title: "Character detail",
38
+ description: "One Dragon Ball character by id, with the transformations list and home planet the name lookup does not return.",
39
+ inputSchema: z.object({ id: z.number().describe("Character id, like 1 for Goku. The characters list prints ids.") }),
40
+ annotations: READ_ONLY,
41
+ }, async (args) => {
42
+ // TODO: implement detail locally (paywall removed)
43
+ try {
44
+ return textError("Not yet implemented: detail");
45
+ }
46
+ catch (e) {
47
+ return textError(String(e));
48
+ }
49
+ });
50
+ server.registerTool("planets", {
51
+ title: "Planets",
52
+ description: "Page the Dragon Ball planet catalogue with its real totals and each planet's destroyed state.",
53
+ inputSchema: z.object({ page: z.number().describe("Page number, starting at 1. Defaults to 1.").optional(), limit: z.number().describe("Planets per page, 1-50. Defaults to 10.").optional() }),
54
+ annotations: READ_ONLY,
55
+ }, async (args) => {
56
+ try {
57
+ return text(await planets(args));
58
+ }
59
+ catch (e) {
60
+ return textError(String(e));
35
61
  }
36
62
  });
37
63
  return server;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.1",
2
+ "version": "1.0.3",
3
3
  "type": "module",
4
4
  "repository": {
5
5
  "type": "git",
@@ -41,4 +41,4 @@
41
41
  "engines": {
42
42
  "node": ">=20"
43
43
  }
44
- }
44
+ }