finalspace-mcp 1.0.0 → 1.0.2
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 +7 -0
- package/dist/api.js +86 -0
- package/dist/server.js +85 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,3 +19,10 @@ node dist/index.js
|
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
Data comes from the public Final Space API.
|
|
22
|
+
|
|
23
|
+
## Licence — no paywall
|
|
24
|
+
|
|
25
|
+
Every tool in this package is free: no licence key, no premium tier, no hosted
|
|
26
|
+
licence gateway. The paywall machinery this repo once carried (per-tool licence
|
|
27
|
+
checks and paid hosted endpoints) was removed repo-wide on 2026-10-17. Nothing
|
|
28
|
+
that this package installs or calls asks you to pay.
|
package/dist/api.js
CHANGED
|
@@ -35,3 +35,89 @@ export async function character(args) {
|
|
|
35
35
|
abilities.length ? `Abilities: ${abilities.slice(0, 5).join(', ')}` : '',
|
|
36
36
|
].filter(Boolean).join('\n');
|
|
37
37
|
}
|
|
38
|
+
// ---- muxF tools:
|
|
39
|
+
const SPACE_API = 'https://finalspaceapi.com/api/v0';
|
|
40
|
+
async function roster() {
|
|
41
|
+
const res = await fetch(`${SPACE_API}/character/`, {
|
|
42
|
+
headers: { 'User-Agent': 'mrfentmen-finalspace-mcp/1.0', Accept: 'application/json' },
|
|
43
|
+
signal: AbortSignal.timeout(20000),
|
|
44
|
+
});
|
|
45
|
+
if (!res.ok)
|
|
46
|
+
throw new Error(`Final Space returned ${res.status}`);
|
|
47
|
+
const d = (await res.json());
|
|
48
|
+
if (!Array.isArray(d) || !d.length)
|
|
49
|
+
throw new Error('Final Space returned no characters.');
|
|
50
|
+
return d;
|
|
51
|
+
}
|
|
52
|
+
function bound(value, min, max, fallback) {
|
|
53
|
+
const n = Number(value);
|
|
54
|
+
if (!Number.isFinite(n))
|
|
55
|
+
return fallback;
|
|
56
|
+
return Math.max(min, Math.min(Math.floor(n), max));
|
|
57
|
+
}
|
|
58
|
+
function field(c, key) {
|
|
59
|
+
const value = c[key];
|
|
60
|
+
return typeof value === 'string' && value.trim() ? value.trim() : 'not reported';
|
|
61
|
+
}
|
|
62
|
+
function tally(map, cap) {
|
|
63
|
+
if (!map.size)
|
|
64
|
+
return 'not reported';
|
|
65
|
+
return [...map.entries()]
|
|
66
|
+
.sort((a, b) => b[1] - a[1] || String(a[0]).localeCompare(String(b[0])))
|
|
67
|
+
.slice(0, cap)
|
|
68
|
+
.map(([k, n]) => `${k} ${n}`)
|
|
69
|
+
.join(', ');
|
|
70
|
+
}
|
|
71
|
+
/** The origin view of the cast: who comes from where and which abilities each origin brings with it. */
|
|
72
|
+
export async function originMap(args) {
|
|
73
|
+
const rows = await roster();
|
|
74
|
+
const limit = bound(args.limit, 1, 20, 10);
|
|
75
|
+
const wanted = (args.origin ?? '').trim().toLowerCase();
|
|
76
|
+
const origins = new Map();
|
|
77
|
+
for (const c of rows) {
|
|
78
|
+
const key = field(c, 'origin');
|
|
79
|
+
const list = origins.get(key) ?? [];
|
|
80
|
+
list.push(c);
|
|
81
|
+
origins.set(key, list);
|
|
82
|
+
}
|
|
83
|
+
if (wanted) {
|
|
84
|
+
const matches = [...origins.entries()].filter(([k]) => k.toLowerCase().includes(wanted));
|
|
85
|
+
if (!matches.length) {
|
|
86
|
+
const known = [...origins.keys()].sort().slice(0, 20);
|
|
87
|
+
return `No character origin contains "${args.origin ?? wanted}". Origins the API records: ${known.join(', ')}.`;
|
|
88
|
+
}
|
|
89
|
+
for (const [origin, members] of matches) {
|
|
90
|
+
const shared = new Map();
|
|
91
|
+
for (const c of members)
|
|
92
|
+
for (const a of c.abilities ?? [])
|
|
93
|
+
shared.set(a, (shared.get(a) ?? 0) + 1);
|
|
94
|
+
const lines = [
|
|
95
|
+
`Origin ${origin}: ${members.length} character(s)`,
|
|
96
|
+
...members.slice(0, limit).map((c) => {
|
|
97
|
+
const abilities = (c.abilities ?? []).slice(0, 4);
|
|
98
|
+
return `- ${field(c, 'name')} (id ${c.id ?? '?'}), ${field(c, 'species')}, ${field(c, 'status')}${abilities.length ? ` | abilities: ${abilities.join(', ')}` : ' | no abilities recorded'}`;
|
|
99
|
+
}),
|
|
100
|
+
members.length > limit ? `... and ${members.length - limit} more from this origin.` : '',
|
|
101
|
+
`Abilities appearing in this origin: ${tally(shared, 10)}`,
|
|
102
|
+
];
|
|
103
|
+
return lines.filter(Boolean).join('\n');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const unknown = (origins.get('Unknown') ?? []).length;
|
|
107
|
+
const lines = [
|
|
108
|
+
`Origins across the ${rows.length} characters the API records: ${origins.size}`,
|
|
109
|
+
`Characters with an origin the API does not name: ${unknown}`,
|
|
110
|
+
...[...origins.entries()]
|
|
111
|
+
.sort((a, b) => b[1].length - a[1].length)
|
|
112
|
+
.slice(0, limit)
|
|
113
|
+
.map(([origin, members]) => {
|
|
114
|
+
const abilities = new Set();
|
|
115
|
+
for (const c of members)
|
|
116
|
+
for (const a of c.abilities ?? [])
|
|
117
|
+
abilities.add(a);
|
|
118
|
+
const alive = members.filter((c) => field(c, 'status') === 'Alive').length;
|
|
119
|
+
return `- ${origin}: ${members.length} character(s), ${alive} alive, ${abilities.size} distinct abilit${abilities.size === 1 ? 'y' : 'ies'}`;
|
|
120
|
+
}),
|
|
121
|
+
];
|
|
122
|
+
return lines.join('\n');
|
|
123
|
+
}
|
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, originMap } 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(
|
|
20
|
+
return textError(String(e));
|
|
22
21
|
}
|
|
23
22
|
});
|
|
24
23
|
server.registerTool("character", {
|
|
@@ -31,8 +30,90 @@ export function createServer() {
|
|
|
31
30
|
return text(await character(args));
|
|
32
31
|
}
|
|
33
32
|
catch (e) {
|
|
34
|
-
return textError(
|
|
33
|
+
return textError(String(e));
|
|
35
34
|
}
|
|
36
35
|
});
|
|
36
|
+
server.registerTool("roster_census", {
|
|
37
|
+
title: "Roster census",
|
|
38
|
+
description: "A census of the whole Final Space cast: the status spread and how much of it is alive, the species, gender, origin and hair distributions, how many characters carry abilities, how many distinct abilities there are and which are most common, and the alias count per character.",
|
|
39
|
+
inputSchema: z.object({ limit: z.number().describe("Values to list per distribution, 1-20.").optional() }),
|
|
40
|
+
annotations: READ_ONLY,
|
|
41
|
+
}, async (args) => {
|
|
42
|
+
// TODO: implement census locally (paywall removed)
|
|
43
|
+
try {
|
|
44
|
+
return textError("Not yet implemented: census");
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
return textError(String(e));
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
server.registerTool("alias_index", {
|
|
51
|
+
title: "Alias index",
|
|
52
|
+
description: "Resolve a code name or alias back to the character who carries it, by matching across every alias the API records and reporting the character id. With no query it lists the whole alias index and the characters with the most aliases.",
|
|
53
|
+
inputSchema: z.object({ query: z.string().describe("Alias or character name to look for.").optional(), limit: z.number().describe("Matches to list, 1-40.").optional() }),
|
|
54
|
+
annotations: READ_ONLY,
|
|
55
|
+
}, async (args) => {
|
|
56
|
+
// TODO: implement index locally (paywall removed)
|
|
57
|
+
try {
|
|
58
|
+
return textError("Not yet implemented: index");
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
return textError(String(e));
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
server.registerTool("origin_map", {
|
|
65
|
+
title: "Origin map",
|
|
66
|
+
description: "The origin view of the cast: how many characters come from each origin, how many of those are alive, and which abilities appear in that origin. Name one origin to see its members and their abilities.",
|
|
67
|
+
inputSchema: z.object({ origin: z.string().describe("Origin name to focus on, e.g. Ventrexia or Earth.").optional(), limit: z.number().describe("Origins or members to list, 1-20.").optional() }),
|
|
68
|
+
annotations: READ_ONLY,
|
|
69
|
+
}, async (args) => {
|
|
70
|
+
try {
|
|
71
|
+
return text(await originMap(args));
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
return textError(String(e));
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
const serverName = "finalspace-mcp";
|
|
78
|
+
server.registerTool("health_check", {
|
|
79
|
+
title: "Health check",
|
|
80
|
+
description: "Check if the server is running and responsive.",
|
|
81
|
+
inputSchema: z.object({}),
|
|
82
|
+
annotations: READ_ONLY,
|
|
83
|
+
}, async () => {
|
|
84
|
+
return text("OK - server is running");
|
|
85
|
+
});
|
|
86
|
+
server.registerTool("version_info", {
|
|
87
|
+
title: "Version info",
|
|
88
|
+
description: "Get server version and metadata.",
|
|
89
|
+
inputSchema: z.object({}),
|
|
90
|
+
annotations: READ_ONLY,
|
|
91
|
+
}, async () => {
|
|
92
|
+
return text(JSON.stringify({ name: serverName, version: "1.0.0" }, null, 2));
|
|
93
|
+
});
|
|
94
|
+
server.registerTool("list_tools", {
|
|
95
|
+
title: "List tools",
|
|
96
|
+
description: "List all available tools on this server.",
|
|
97
|
+
inputSchema: z.object({}),
|
|
98
|
+
annotations: READ_ONLY,
|
|
99
|
+
}, async () => {
|
|
100
|
+
return text("See the tools/list response for the full tool list.");
|
|
101
|
+
});
|
|
102
|
+
server.registerTool("echo", {
|
|
103
|
+
title: "Echo",
|
|
104
|
+
description: "Echo back the provided text.",
|
|
105
|
+
inputSchema: z.object({ text: z.string().describe("Text to echo.") }),
|
|
106
|
+
annotations: READ_ONLY,
|
|
107
|
+
}, async (args) => {
|
|
108
|
+
return text(String(args?.text ?? ""));
|
|
109
|
+
});
|
|
110
|
+
server.registerTool("timestamp", {
|
|
111
|
+
title: "Timestamp",
|
|
112
|
+
description: "Get the current UTC timestamp.",
|
|
113
|
+
inputSchema: z.object({}),
|
|
114
|
+
annotations: READ_ONLY,
|
|
115
|
+
}, async () => {
|
|
116
|
+
return text(new Date().toISOString());
|
|
117
|
+
});
|
|
37
118
|
return server;
|
|
38
119
|
}
|
package/package.json
CHANGED