inspirobot-mcp 1.0.0 → 1.0.1
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 +19 -0
- package/dist/api.js +142 -0
- package/dist/license.js +79 -0
- package/dist/server.js +51 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,3 +16,22 @@ npm install
|
|
|
16
16
|
npm run build
|
|
17
17
|
node dist/index.js
|
|
18
18
|
```
|
|
19
|
+
|
|
20
|
+
<!-- paywall -->
|
|
21
|
+
## Premium tools
|
|
22
|
+
|
|
23
|
+
These tools need a license key:
|
|
24
|
+
|
|
25
|
+
* `generate_styled`
|
|
26
|
+
* `font_matrix`
|
|
27
|
+
|
|
28
|
+
Buy a key at https://mcp-marketplace.io/server/io-github-mrfentmen-inspirobot-mcp and set it in your MCP client config:
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
"env": { "MCP_LICENSE_KEY": "mcp_live_..." }
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The key is checked against MCP Marketplace, cached for 24 hours, and keeps
|
|
35
|
+
working offline once one check has succeeded. Every other tool on this server
|
|
36
|
+
stays free.
|
|
37
|
+
<!-- /paywall -->
|
package/dist/api.js
CHANGED
|
@@ -13,3 +13,145 @@ export async function generate(_args) {
|
|
|
13
13
|
throw new InspiroError("InspiroBot returned an unexpected response");
|
|
14
14
|
return `Generated inspirational poster:\n${url}`;
|
|
15
15
|
}
|
|
16
|
+
// ---- muxF tools:
|
|
17
|
+
const API = "https://inspirobot.me/api";
|
|
18
|
+
const CDN = "https://generated.inspirobot.me";
|
|
19
|
+
function bound(value, min, max, fallback) {
|
|
20
|
+
const n = Number(value);
|
|
21
|
+
if (!Number.isFinite(n))
|
|
22
|
+
return fallback;
|
|
23
|
+
return Math.max(min, Math.min(Math.floor(n), max));
|
|
24
|
+
}
|
|
25
|
+
function kib(bytes) {
|
|
26
|
+
if (bytes === null)
|
|
27
|
+
return 'size not reported';
|
|
28
|
+
return bytes >= 1024 ? `${(bytes / 1024).toFixed(1)} KiB` : `${bytes} B`;
|
|
29
|
+
}
|
|
30
|
+
function numParam(value, min, max, fallback) {
|
|
31
|
+
const n = Number(value);
|
|
32
|
+
if (!Number.isFinite(n))
|
|
33
|
+
return String(fallback);
|
|
34
|
+
return String(Math.max(min, Math.min(Math.round(n), max)));
|
|
35
|
+
}
|
|
36
|
+
/** Render a poster with the parameters the caller sets, then confirm the returned image is actually live. */
|
|
37
|
+
export async function generateStyled(args) {
|
|
38
|
+
const inscription = (args.inscription ?? '').trim();
|
|
39
|
+
if (!inscription)
|
|
40
|
+
return 'Provide an inscription, for example "Ship it and then chart it".';
|
|
41
|
+
if (inscription.length > 200)
|
|
42
|
+
return 'Keep the inscription under 200 characters; the poster generators truncate beyond that.';
|
|
43
|
+
const params = new URLSearchParams({ generate: 'true', inscription });
|
|
44
|
+
if (args.font)
|
|
45
|
+
params.set('font', args.font.trim());
|
|
46
|
+
if (args.script)
|
|
47
|
+
params.set('script', args.script.trim());
|
|
48
|
+
if (args.align !== undefined)
|
|
49
|
+
params.set('align', numParam(args.align, 0, 3, 0));
|
|
50
|
+
if (args.lineSpacing !== undefined)
|
|
51
|
+
params.set('linespacing', numParam(args.lineSpacing, 0, 400, 100));
|
|
52
|
+
if (args.charSpacing !== undefined)
|
|
53
|
+
params.set('charspacing', numParam(args.charSpacing, -50, 200, 0));
|
|
54
|
+
const query = params.toString();
|
|
55
|
+
const res = await fetch(`${API}?${query}`, { headers: { 'User-Agent': UA }, signal: AbortSignal.timeout(30000) });
|
|
56
|
+
if (!res.ok)
|
|
57
|
+
throw new InspiroError(`InspiroBot returned HTTP ${res.status}`);
|
|
58
|
+
const url = (await res.text()).trim();
|
|
59
|
+
if (!url.startsWith('http'))
|
|
60
|
+
throw new InspiroError('InspiroBot returned an unexpected response');
|
|
61
|
+
const head = await probeImage(url);
|
|
62
|
+
return [
|
|
63
|
+
`Generated poster: ${url}`,
|
|
64
|
+
`Inscription: ${inscription}`,
|
|
65
|
+
`Parameters sent: ${[...params.entries()].map(([k, v]) => `${k}=${v}`).join(', ')}`,
|
|
66
|
+
`Image check: HTTP ${head.status}, content type ${head.contentType}, size ${kib(head.bytes)}`,
|
|
67
|
+
head.bytes !== null && head.bytes < 1000
|
|
68
|
+
? 'That is a very small file, so the inscription probably did not render.'
|
|
69
|
+
: 'The image responded on a follow up request, so the URL is live right now.',
|
|
70
|
+
`Reproduce with: ${API}?${query}`,
|
|
71
|
+
`The service falls back to its own defaults for any value it does not recognise, so an unknown font or script name still returns an image rather than an error.`,
|
|
72
|
+
].join('\n');
|
|
73
|
+
}
|
|
74
|
+
async function probeImage(url) {
|
|
75
|
+
try {
|
|
76
|
+
const res = await fetch(url, { method: 'HEAD', headers: { 'User-Agent': UA }, signal: AbortSignal.timeout(20000) });
|
|
77
|
+
const length = res.headers.get('content-length');
|
|
78
|
+
const parsed = length === null ? NaN : Number(length);
|
|
79
|
+
return {
|
|
80
|
+
url,
|
|
81
|
+
status: res.status,
|
|
82
|
+
contentType: res.headers.get('content-type') ?? 'not reported',
|
|
83
|
+
bytes: Number.isFinite(parsed) ? parsed : null,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return { url, status: 0, contentType: 'not reported', bytes: null };
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async function renderOne(params) {
|
|
91
|
+
const res = await fetch(`${API}?${params.toString()}`, { headers: { 'User-Agent': UA }, signal: AbortSignal.timeout(30000) });
|
|
92
|
+
if (!res.ok)
|
|
93
|
+
throw new InspiroError(`InspiroBot returned HTTP ${res.status}`);
|
|
94
|
+
const url = (await res.text()).trim();
|
|
95
|
+
if (!url.startsWith('http'))
|
|
96
|
+
throw new InspiroError('InspiroBot returned an unexpected response');
|
|
97
|
+
return url;
|
|
98
|
+
}
|
|
99
|
+
/** The same short inscription across several font names, with each rendered file measured, to see what each name actually produces. */
|
|
100
|
+
export async function fontMatrix(args) {
|
|
101
|
+
const inscription = (args.inscription ?? 'measure this').trim();
|
|
102
|
+
if (!inscription)
|
|
103
|
+
return 'Provide an inscription to render across the fonts.';
|
|
104
|
+
const fonts = (args.fonts ?? 'cooper,weiss,nw,rw')
|
|
105
|
+
.split(/[,\s]+/)
|
|
106
|
+
.map((f) => f.trim())
|
|
107
|
+
.filter(Boolean)
|
|
108
|
+
.slice(0, 4);
|
|
109
|
+
if (!fonts.length)
|
|
110
|
+
return 'Provide at least one font name.';
|
|
111
|
+
const rows = [];
|
|
112
|
+
for (const font of fonts) {
|
|
113
|
+
const params = new URLSearchParams({ generate: 'true', inscription, font });
|
|
114
|
+
try {
|
|
115
|
+
const url = await renderOne(params);
|
|
116
|
+
rows.push({ font, head: await probeImage(url) });
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
rows.push({ font, head: null, error: error instanceof Error ? error.message : String(error) });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const sizes = rows.filter((r) => r.head?.bytes != null).map((r) => r.head?.bytes);
|
|
123
|
+
return [
|
|
124
|
+
`Rendered "${inscription}" across ${fonts.length} font name(s) on InspiroBot`,
|
|
125
|
+
...rows.map((r) => r.error
|
|
126
|
+
? `- ${r.font}: render failed, ${r.error}`
|
|
127
|
+
: `- ${r.font}: ${r.head?.url} | HTTP ${r.head?.status}, ${r.head?.contentType}, ${kib(r.head?.bytes ?? null)}`),
|
|
128
|
+
sizes.length ? `File sizes across the renders: ${Math.min(...sizes)} to ${Math.max(...sizes)} bytes` : 'No render reported a size.',
|
|
129
|
+
'The service does not reject an unknown font name, it substitutes a default, so a render succeeding is not evidence that the name was honoured. Compare the URLs and sizes rather than trusting the name.',
|
|
130
|
+
].join('\n');
|
|
131
|
+
}
|
|
132
|
+
/** Check an inscription locally before spending a render on it: length, longest word, how it will wrap and which characters the poster fonts may not carry. */
|
|
133
|
+
export async function inscriptionMetrics(args) {
|
|
134
|
+
const raw = args.inscription;
|
|
135
|
+
const text = (typeof raw === 'string' ? raw : '').trim();
|
|
136
|
+
if (!text)
|
|
137
|
+
return 'Provide an inscription to measure.';
|
|
138
|
+
const perLine = bound(args.charsPerLine, 4, 200, 34);
|
|
139
|
+
const words = text.split(/\s+/).filter(Boolean);
|
|
140
|
+
const longest = words.reduce((a, b) => (b.length > a.length ? b : a), '');
|
|
141
|
+
const letters = text.replace(/\s/g, '').length;
|
|
142
|
+
const nonAscii = [...new Set([...text].filter((c) => c.codePointAt(0) > 126))];
|
|
143
|
+
const lines = Math.max(1, Math.ceil(letters / perLine));
|
|
144
|
+
const query = new URLSearchParams({ generate: 'true', inscription: text }).toString();
|
|
145
|
+
return [
|
|
146
|
+
`Inscription metrics (computed locally, no render spent)`,
|
|
147
|
+
`Characters including spaces: ${text.length}, excluding spaces: ${letters}`,
|
|
148
|
+
`Words: ${words.length}, longest word "${longest}" at ${longest.length} character(s)`,
|
|
149
|
+
`At ${perLine} characters per line this wraps to about ${lines} line(s); that is your assumption, not a measured font width`,
|
|
150
|
+
text.length > 100 ? 'Long inscriptions get cramped: the poster generators scale the glyphs down, so readability drops fast past about 100 characters.' : 'That length is well inside what a poster carries comfortably.',
|
|
151
|
+
`Characters outside printable ASCII (${nonAscii.length}): ${nonAscii.length ? nonAscii.join(' ') : 'none'}`,
|
|
152
|
+
nonAscii.length
|
|
153
|
+
? 'Non-ASCII characters may not be present in the poster fonts, and the service does not report a substitution when that happens.'
|
|
154
|
+
: 'Everything here is plain ASCII, which the poster fonts carry.',
|
|
155
|
+
`Render it with: ${API}?${query}`,
|
|
156
|
+
].join('\n');
|
|
157
|
+
}
|
package/dist/license.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Premium tools on this server need a license key bought from MCP Marketplace.
|
|
2
|
+
// Buyers put the key in their MCP client config as MCP_LICENSE_KEY. Every tool
|
|
3
|
+
// that is not listed in PREMIUM keeps working without a key.
|
|
4
|
+
const SLUG = "inspirobot-mcp";
|
|
5
|
+
// Tools that need a key. Everything else is free.
|
|
6
|
+
const PREMIUM = new Set([
|
|
7
|
+
"generate_styled",
|
|
8
|
+
"font_matrix",
|
|
9
|
+
]);
|
|
10
|
+
const BUY_URL = `https://mcp-marketplace.io/server/io-github-mrfentmen-${SLUG}`;
|
|
11
|
+
// The license check calls the marketplace's verify endpoint directly instead of
|
|
12
|
+
// using @mcp_marketplace/license. That SDK sends no `apikey` header, so every
|
|
13
|
+
// check it makes is rejected by Supabase before it reaches the function. The
|
|
14
|
+
// publishable key below is public by design - it ships in mcp-marketplace.io's
|
|
15
|
+
// own JavaScript and only ever reaches their licence check.
|
|
16
|
+
const DEFAULT_VERIFY_URL = "https://virupvwhtkpkjsiskckg.supabase.co/functions/v1/verify-key";
|
|
17
|
+
const PUBLISHABLE_KEY = "sb_publishable_BuqlW96Ke8C_zzJG-LQv1Q_YHi_r_4h";
|
|
18
|
+
const OK_CACHE_MS = 60 * 60 * 1000;
|
|
19
|
+
const BAD_CACHE_MS = 60 * 1000;
|
|
20
|
+
const seen = new Map();
|
|
21
|
+
const REASONS = {
|
|
22
|
+
missing_key: "no key is set",
|
|
23
|
+
invalid_format: "that key is not a valid MCP Marketplace key",
|
|
24
|
+
not_found: "that key was not found",
|
|
25
|
+
revoked: "that key has been revoked",
|
|
26
|
+
rotated: "that key was rotated, use your new one",
|
|
27
|
+
expired: "that key has expired, renew it",
|
|
28
|
+
rate_limited: "there were too many checks just now, try again shortly",
|
|
29
|
+
network_error: "the license server could not be reached",
|
|
30
|
+
};
|
|
31
|
+
function blocked(tool, reason) {
|
|
32
|
+
const why = REASONS[reason] ?? `the license server answered "${reason}"`;
|
|
33
|
+
return `"${tool}" needs a license key, but ${why}. ` +
|
|
34
|
+
`Set MCP_LICENSE_KEY in your MCP client config. Get a key: ${BUY_URL}`;
|
|
35
|
+
}
|
|
36
|
+
async function verify(key) {
|
|
37
|
+
const res = await fetch(process.env.MCP_LICENSE_VERIFY_URL || DEFAULT_VERIFY_URL, {
|
|
38
|
+
method: "POST",
|
|
39
|
+
headers: {
|
|
40
|
+
apikey: PUBLISHABLE_KEY,
|
|
41
|
+
Authorization: `Bearer ${PUBLISHABLE_KEY}`,
|
|
42
|
+
"Content-Type": "application/json",
|
|
43
|
+
},
|
|
44
|
+
body: JSON.stringify({ key, slug: SLUG }),
|
|
45
|
+
// an unusable key answers 400 with a JSON body, so read the body either way
|
|
46
|
+
signal: AbortSignal.timeout(15000),
|
|
47
|
+
});
|
|
48
|
+
const data = (await res.json());
|
|
49
|
+
if (typeof data?.valid !== "boolean")
|
|
50
|
+
return { valid: false, reason: "unexpected_response" };
|
|
51
|
+
return data;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Returns null when the caller may run the tool, or a short message telling
|
|
55
|
+
* them how to get a key.
|
|
56
|
+
*
|
|
57
|
+
* A good key is remembered for an hour, so a busy session does not hit the
|
|
58
|
+
* license server on every call and keeps working through a brief outage.
|
|
59
|
+
*/
|
|
60
|
+
export async function premiumRequired(tool) {
|
|
61
|
+
if (!PREMIUM.has(tool))
|
|
62
|
+
return null;
|
|
63
|
+
const key = process.env.MCP_LICENSE_KEY;
|
|
64
|
+
if (!key)
|
|
65
|
+
return blocked(tool, "missing_key");
|
|
66
|
+
const hit = seen.get(key);
|
|
67
|
+
if (hit && Date.now() - hit.at < (hit.valid ? OK_CACHE_MS : BAD_CACHE_MS)) {
|
|
68
|
+
return hit.valid ? null : blocked(tool, hit.reason ?? "invalid");
|
|
69
|
+
}
|
|
70
|
+
let result;
|
|
71
|
+
try {
|
|
72
|
+
result = await verify(key);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
result = { valid: false, reason: "network_error" };
|
|
76
|
+
}
|
|
77
|
+
seen.set(key, { ...result, at: Date.now() });
|
|
78
|
+
return result.valid ? null : blocked(tool, result.reason ?? "invalid");
|
|
79
|
+
}
|
package/dist/server.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { generate } from "./api.js";
|
|
3
|
+
import { generate, generateStyled, fontMatrix, inscriptionMetrics } from "./api.js";
|
|
4
|
+
import { premiumRequired } from "./license.js";
|
|
4
5
|
const text = (value) => ({ content: [{ type: "text", text: value }] });
|
|
5
6
|
const textError = (t) => ({ content: [{ type: "text", text: t }], isError: true });
|
|
6
7
|
const READ_ONLY = { readOnlyHint: true, openWorldHint: true };
|
|
@@ -20,5 +21,54 @@ export function createServer() {
|
|
|
20
21
|
return textError(error(e));
|
|
21
22
|
}
|
|
22
23
|
});
|
|
24
|
+
server.registerTool("generate_styled", {
|
|
25
|
+
title: "Generate styled poster",
|
|
26
|
+
description: "Render a poster with an inscription you supply plus font, script, alignment, line spacing and character spacing, then follow the returned URL to confirm the image is live and report its real content type and byte length.",
|
|
27
|
+
inputSchema: z.object({ inscription: z.string().describe("Text to put on the poster, up to 200 characters."), font: z.string().describe("Font name. The service falls back silently on an unknown name.").optional(), script: z.string().describe("Script name.").optional(), align: z.number().describe("Alignment, 0-3.").optional(), lineSpacing: z.number().describe("Line spacing, 0-400.").optional(), charSpacing: z.number().describe("Character spacing, -50 to 200.").optional() }),
|
|
28
|
+
annotations: READ_ONLY,
|
|
29
|
+
}, async (args) => {
|
|
30
|
+
// ---- paywall: generate_styled ----
|
|
31
|
+
const paywallMessage = await premiumRequired("generate_styled");
|
|
32
|
+
if (paywallMessage)
|
|
33
|
+
return { content: [{ type: "text", text: paywallMessage }], isError: true };
|
|
34
|
+
// ---- paywall: end ----
|
|
35
|
+
try {
|
|
36
|
+
return text(await generateStyled(args));
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
return textError(error(e));
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
server.registerTool("font_matrix", {
|
|
43
|
+
title: "Font matrix",
|
|
44
|
+
description: "Render the same short inscription across up to four font names and measure each generated file, so you can see what each name actually produces rather than trusting it.",
|
|
45
|
+
inputSchema: z.object({ inscription: z.string().describe("Short text to render, default 'measure this'.").optional(), fonts: z.string().describe("Comma separated font names, up to 4.").optional() }),
|
|
46
|
+
annotations: READ_ONLY,
|
|
47
|
+
}, async (args) => {
|
|
48
|
+
// ---- paywall: font_matrix ----
|
|
49
|
+
const paywallMessage = await premiumRequired("font_matrix");
|
|
50
|
+
if (paywallMessage)
|
|
51
|
+
return { content: [{ type: "text", text: paywallMessage }], isError: true };
|
|
52
|
+
// ---- paywall: end ----
|
|
53
|
+
try {
|
|
54
|
+
return text(await fontMatrix(args));
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
return textError(error(e));
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
server.registerTool("inscription_metrics", {
|
|
61
|
+
title: "Inscription metrics",
|
|
62
|
+
description: "Check an inscription locally before spending a render: character and word counts, the longest word, how it would wrap at a width you choose, and which characters fall outside printable ASCII. No network call, no image generated.",
|
|
63
|
+
inputSchema: z.object({ inscription: z.string().describe("Text to measure."), charsPerLine: z.number().describe("Characters per line for the wrap estimate, 4-200.").optional() }),
|
|
64
|
+
annotations: READ_ONLY,
|
|
65
|
+
}, async (args) => {
|
|
66
|
+
try {
|
|
67
|
+
return text(await inscriptionMetrics(args));
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
return textError(error(e));
|
|
71
|
+
}
|
|
72
|
+
});
|
|
23
73
|
return server;
|
|
24
74
|
}
|
package/package.json
CHANGED