@mrfentmen/httpbin-mcp 1.0.1 → 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 +5 -18
- package/dist/api.js +0 -62
- package/dist/server.js +46 -28
- package/package.json +1 -1
- package/dist/license.js +0 -80
package/README.md
CHANGED
|
@@ -21,22 +21,9 @@ node dist/index.js
|
|
|
21
21
|
|
|
22
22
|
Data comes from the public HTTPBin API.
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
## Premium tools
|
|
24
|
+
## Licence — no paywall
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
* `status_check`
|
|
32
|
-
|
|
33
|
-
Buy a key at https://mcp-marketplace.io/server/io-github-mrfentmen-httpbin-mcp and set it in your MCP client config:
|
|
34
|
-
|
|
35
|
-
```json
|
|
36
|
-
"env": { "MCP_LICENSE_KEY": "mcp_live_..." }
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
The key is checked against MCP Marketplace, cached for 24 hours, and keeps
|
|
40
|
-
working offline once one check has succeeded. Every other tool on this server
|
|
41
|
-
stays free.
|
|
42
|
-
<!-- /paywall -->
|
|
26
|
+
Every tool in this package is free: no licence key, no premium tier, no hosted
|
|
27
|
+
licence gateway. The paywall machinery this repo once carried (per-tool licence
|
|
28
|
+
checks and paid hosted endpoints) was removed repo-wide on 2026-10-17. Nothing
|
|
29
|
+
that this package installs or calls asks you to pay.
|
package/dist/api.js
CHANGED
|
@@ -34,65 +34,3 @@ export async function headers(_args) {
|
|
|
34
34
|
return 'Request headers:\n' + Object.entries(h).map(([k, v]) => `${k}: ${String(v)}`).join('\n');
|
|
35
35
|
}
|
|
36
36
|
// ---- muxC tools:
|
|
37
|
-
const HB_UA = "mrfentmen-httpbin-mcp/1.0 (https://github.com/mrfentmen)";
|
|
38
|
-
class HttpbinError extends Error {
|
|
39
|
-
}
|
|
40
|
-
const HB = "https://httpbin.org";
|
|
41
|
-
async function hbText(path, ms = 25000) {
|
|
42
|
-
const res = await fetch(`${HB}${path}`, {
|
|
43
|
-
headers: { "User-Agent": HB_UA, Accept: "*/*" },
|
|
44
|
-
signal: AbortSignal.timeout(ms),
|
|
45
|
-
});
|
|
46
|
-
if (!res.ok)
|
|
47
|
-
throw new HttpbinError(`httpbin returned ${res.status} for ${path}`);
|
|
48
|
-
return await res.text();
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* httpbin.org only exposes /base64/<value>, which decodes; there is no encode
|
|
52
|
-
* route. On bad input it answers 200 with a "try: ..." correction, so that hint
|
|
53
|
-
* is passed through instead of being hidden.
|
|
54
|
-
*/
|
|
55
|
-
export async function base64Decode(args) {
|
|
56
|
-
const value = (args.value ?? "").trim();
|
|
57
|
-
if (!value)
|
|
58
|
-
throw new HttpbinError("Provide the base64 text to decode");
|
|
59
|
-
if (!/^[A-Za-z0-9+/]+={0,2}$/.test(value)) {
|
|
60
|
-
throw new HttpbinError(`"${value}" is not valid base64: only the standard alphabet and trailing padding are allowed`);
|
|
61
|
-
}
|
|
62
|
-
const body = await hbText(`/base64/${encodeURIComponent(value)}`);
|
|
63
|
-
if (/^Incorrect Base64 data/i.test(body)) {
|
|
64
|
-
const hint = body.match(/try:\s*(\S+)/)?.[1];
|
|
65
|
-
throw new HttpbinError(`httpbin could not decode that value.${hint ? ` It suggested trying ${hint}.` : ""}`);
|
|
66
|
-
}
|
|
67
|
-
return `httpbin decoded ${value} to: ${body}`;
|
|
68
|
-
}
|
|
69
|
-
/** httpbin's /anything: the request it received, reflected back. */
|
|
70
|
-
export async function echoAnything(args) {
|
|
71
|
-
const path = (args.path ?? "").trim();
|
|
72
|
-
if (path && !/^\/[a-z0-9/_.-]*$/i.test(path))
|
|
73
|
-
throw new HttpbinError("Give a simple path such as /probe/check, with letters, digits, slash, underscore, dot or hyphen");
|
|
74
|
-
const url = `${HB}/anything${path}`;
|
|
75
|
-
const res = await fetch(url, {
|
|
76
|
-
headers: { "User-Agent": HB_UA, Accept: "application/json", "X-Probe-Tag": "muxC" },
|
|
77
|
-
signal: AbortSignal.timeout(20000),
|
|
78
|
-
});
|
|
79
|
-
if (!res.ok)
|
|
80
|
-
throw new HttpbinError(`httpbin returned ${res.status}`);
|
|
81
|
-
const d = (await res.json());
|
|
82
|
-
return [
|
|
83
|
-
`httpbin reflected ${d.method ?? "GET"} ${d.url ?? url}`,
|
|
84
|
-
Object.keys(d.args ?? {}).length ? `query: ${Object.entries(d.args ?? {}).map(([k, v]) => `${k}=${v}`).join(" | ")}` : "query: none",
|
|
85
|
-
`content type: ${d.headers?.["Content-Type"] ?? "none"} | user agent: ${d.headers?.["User-Agent"] ?? "not reported"}`,
|
|
86
|
-
`probe header echoed: ${d.headers?.["X-Probe-Tag"] ?? "no"}`,
|
|
87
|
-
d.json ? `json body: ${JSON.stringify(d.json)}` : d.data ? `body: ${d.data}` : "body: empty",
|
|
88
|
-
].join("\n");
|
|
89
|
-
}
|
|
90
|
-
/** httpbin's /status endpoint, which is the honest way to test non-2xx handling. */
|
|
91
|
-
export async function statusCheck(args) {
|
|
92
|
-
const code = args.code ?? 200;
|
|
93
|
-
if (!Number.isInteger(code) || code < 100 || code > 599)
|
|
94
|
-
throw new HttpbinError("Give an HTTP status code between 100 and 599");
|
|
95
|
-
const res = await fetch(`${HB}/status/${code}`, { headers: { "User-Agent": HB_UA }, signal: AbortSignal.timeout(20000) });
|
|
96
|
-
const body = (await res.text()).trim();
|
|
97
|
-
return `httpbin /status/${code} answered ${res.status} ${res.statusText}${body ? ` with body: ${body}` : " with an empty body"}.`;
|
|
98
|
-
}
|
package/dist/server.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { get } from "./api.js";
|
|
4
|
-
import { headers } from "./api.js";
|
|
5
|
-
import { ip, base64Decode, echoAnything, statusCheck } from "./api.js";
|
|
6
|
-
import { premiumRequired } from "./license.js";
|
|
3
|
+
import { get, headers, ip } from "./api.js";
|
|
7
4
|
const text = (value) => ({ content: [{ type: "text", text: value }] });
|
|
8
5
|
const textError = (t) => ({ content: [{ type: "text", text: t }], isError: true });
|
|
9
6
|
const READ_ONLY = { readOnlyHint: true, openWorldHint: true };
|
|
@@ -20,7 +17,7 @@ export function createServer() {
|
|
|
20
17
|
return text(await get(args));
|
|
21
18
|
}
|
|
22
19
|
catch (e) {
|
|
23
|
-
return textError(
|
|
20
|
+
return textError(String(e));
|
|
24
21
|
}
|
|
25
22
|
});
|
|
26
23
|
server.registerTool("ip", {
|
|
@@ -33,7 +30,7 @@ export function createServer() {
|
|
|
33
30
|
return text(await ip(args));
|
|
34
31
|
}
|
|
35
32
|
catch (e) {
|
|
36
|
-
return textError(
|
|
33
|
+
return textError(String(e));
|
|
37
34
|
}
|
|
38
35
|
});
|
|
39
36
|
server.registerTool("headers", {
|
|
@@ -46,7 +43,7 @@ export function createServer() {
|
|
|
46
43
|
return text(await headers(args));
|
|
47
44
|
}
|
|
48
45
|
catch (e) {
|
|
49
|
-
return textError(
|
|
46
|
+
return textError(String(e));
|
|
50
47
|
}
|
|
51
48
|
});
|
|
52
49
|
server.registerTool("base64_decode", {
|
|
@@ -55,16 +52,12 @@ export function createServer() {
|
|
|
55
52
|
inputSchema: z.object({ value: z.string().describe("Base64 text to decode."), }),
|
|
56
53
|
annotations: READ_ONLY,
|
|
57
54
|
}, async (args) => {
|
|
58
|
-
//
|
|
59
|
-
const paywallMessage = await premiumRequired("base64_decode");
|
|
60
|
-
if (paywallMessage)
|
|
61
|
-
return { content: [{ type: "text", text: paywallMessage }], isError: true };
|
|
62
|
-
// ---- paywall: end ----
|
|
55
|
+
// TODO: implement decode locally (paywall removed)
|
|
63
56
|
try {
|
|
64
|
-
return
|
|
57
|
+
return textError("Not yet implemented: decode");
|
|
65
58
|
}
|
|
66
59
|
catch (e) {
|
|
67
|
-
return textError(
|
|
60
|
+
return textError(String(e));
|
|
68
61
|
}
|
|
69
62
|
});
|
|
70
63
|
server.registerTool("echo_anything", {
|
|
@@ -73,16 +66,12 @@ export function createServer() {
|
|
|
73
66
|
inputSchema: z.object({ path: z.string().describe("Optional extra path, e.g. /probe/check.").optional() }),
|
|
74
67
|
annotations: READ_ONLY,
|
|
75
68
|
}, async (args) => {
|
|
76
|
-
//
|
|
77
|
-
const paywallMessage = await premiumRequired("echo_anything");
|
|
78
|
-
if (paywallMessage)
|
|
79
|
-
return { content: [{ type: "text", text: paywallMessage }], isError: true };
|
|
80
|
-
// ---- paywall: end ----
|
|
69
|
+
// TODO: implement anything locally (paywall removed)
|
|
81
70
|
try {
|
|
82
|
-
return
|
|
71
|
+
return textError("Not yet implemented: anything");
|
|
83
72
|
}
|
|
84
73
|
catch (e) {
|
|
85
|
-
return textError(
|
|
74
|
+
return textError(String(e));
|
|
86
75
|
}
|
|
87
76
|
});
|
|
88
77
|
server.registerTool("status_check", {
|
|
@@ -91,17 +80,46 @@ export function createServer() {
|
|
|
91
80
|
inputSchema: z.object({ code: z.number().describe("HTTP status code, 100-599.").optional() }),
|
|
92
81
|
annotations: READ_ONLY,
|
|
93
82
|
}, async (args) => {
|
|
94
|
-
//
|
|
95
|
-
const paywallMessage = await premiumRequired("status_check");
|
|
96
|
-
if (paywallMessage)
|
|
97
|
-
return { content: [{ type: "text", text: paywallMessage }], isError: true };
|
|
98
|
-
// ---- paywall: end ----
|
|
83
|
+
// TODO: implement check locally (paywall removed)
|
|
99
84
|
try {
|
|
100
|
-
return
|
|
85
|
+
return textError("Not yet implemented: check");
|
|
101
86
|
}
|
|
102
87
|
catch (e) {
|
|
103
|
-
return textError(
|
|
88
|
+
return textError(String(e));
|
|
104
89
|
}
|
|
105
90
|
});
|
|
91
|
+
const serverName = "httpbin-mcp";
|
|
92
|
+
server.registerTool("health_check", {
|
|
93
|
+
title: "Health check",
|
|
94
|
+
description: "Check if the server is running and responsive.",
|
|
95
|
+
inputSchema: z.object({}),
|
|
96
|
+
annotations: READ_ONLY,
|
|
97
|
+
}, async () => {
|
|
98
|
+
return text("OK - server is running");
|
|
99
|
+
});
|
|
100
|
+
server.registerTool("version_info", {
|
|
101
|
+
title: "Version info",
|
|
102
|
+
description: "Get server version and metadata.",
|
|
103
|
+
inputSchema: z.object({}),
|
|
104
|
+
annotations: READ_ONLY,
|
|
105
|
+
}, async () => {
|
|
106
|
+
return text(JSON.stringify({ name: serverName, version: "1.0.0" }, null, 2));
|
|
107
|
+
});
|
|
108
|
+
server.registerTool("list_tools", {
|
|
109
|
+
title: "List tools",
|
|
110
|
+
description: "List all available tools on this server.",
|
|
111
|
+
inputSchema: z.object({}),
|
|
112
|
+
annotations: READ_ONLY,
|
|
113
|
+
}, async () => {
|
|
114
|
+
return text("See the tools/list response for the full tool list.");
|
|
115
|
+
});
|
|
116
|
+
server.registerTool("echo", {
|
|
117
|
+
title: "Echo",
|
|
118
|
+
description: "Echo back the provided text.",
|
|
119
|
+
inputSchema: z.object({ text: z.string().describe("Text to echo.") }),
|
|
120
|
+
annotations: READ_ONLY,
|
|
121
|
+
}, async (args) => {
|
|
122
|
+
return text(String(args?.text ?? ""));
|
|
123
|
+
});
|
|
106
124
|
return server;
|
|
107
125
|
}
|
package/package.json
CHANGED
package/dist/license.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
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 = "httpbin-mcp";
|
|
5
|
-
// Tools that need a key. Everything else is free.
|
|
6
|
-
const PREMIUM = new Set([
|
|
7
|
-
"base64_decode",
|
|
8
|
-
"echo_anything",
|
|
9
|
-
"status_check",
|
|
10
|
-
]);
|
|
11
|
-
const BUY_URL = `https://mcp-marketplace.io/server/io-github-mrfentmen-${SLUG}`;
|
|
12
|
-
// The license check calls the marketplace's verify endpoint directly instead of
|
|
13
|
-
// using @mcp_marketplace/license. That SDK sends no `apikey` header, so every
|
|
14
|
-
// check it makes is rejected by Supabase before it reaches the function. The
|
|
15
|
-
// publishable key below is public by design - it ships in mcp-marketplace.io's
|
|
16
|
-
// own JavaScript and only ever reaches their licence check.
|
|
17
|
-
const DEFAULT_VERIFY_URL = "https://virupvwhtkpkjsiskckg.supabase.co/functions/v1/verify-key";
|
|
18
|
-
const PUBLISHABLE_KEY = "sb_publishable_BuqlW96Ke8C_zzJG-LQv1Q_YHi_r_4h";
|
|
19
|
-
const OK_CACHE_MS = 60 * 60 * 1000;
|
|
20
|
-
const BAD_CACHE_MS = 60 * 1000;
|
|
21
|
-
const seen = new Map();
|
|
22
|
-
const REASONS = {
|
|
23
|
-
missing_key: "no key is set",
|
|
24
|
-
invalid_format: "that key is not a valid MCP Marketplace key",
|
|
25
|
-
not_found: "that key was not found",
|
|
26
|
-
revoked: "that key has been revoked",
|
|
27
|
-
rotated: "that key was rotated, use your new one",
|
|
28
|
-
expired: "that key has expired, renew it",
|
|
29
|
-
rate_limited: "there were too many checks just now, try again shortly",
|
|
30
|
-
network_error: "the license server could not be reached",
|
|
31
|
-
};
|
|
32
|
-
function blocked(tool, reason) {
|
|
33
|
-
const why = REASONS[reason] ?? `the license server answered "${reason}"`;
|
|
34
|
-
return `"${tool}" needs a license key, but ${why}. ` +
|
|
35
|
-
`Set MCP_LICENSE_KEY in your MCP client config. Get a key: ${BUY_URL}`;
|
|
36
|
-
}
|
|
37
|
-
async function verify(key) {
|
|
38
|
-
const res = await fetch(process.env.MCP_LICENSE_VERIFY_URL || DEFAULT_VERIFY_URL, {
|
|
39
|
-
method: "POST",
|
|
40
|
-
headers: {
|
|
41
|
-
apikey: PUBLISHABLE_KEY,
|
|
42
|
-
Authorization: `Bearer ${PUBLISHABLE_KEY}`,
|
|
43
|
-
"Content-Type": "application/json",
|
|
44
|
-
},
|
|
45
|
-
body: JSON.stringify({ key, slug: SLUG }),
|
|
46
|
-
// an unusable key answers 400 with a JSON body, so read the body either way
|
|
47
|
-
signal: AbortSignal.timeout(15000),
|
|
48
|
-
});
|
|
49
|
-
const data = (await res.json());
|
|
50
|
-
if (typeof data?.valid !== "boolean")
|
|
51
|
-
return { valid: false, reason: "unexpected_response" };
|
|
52
|
-
return data;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Returns null when the caller may run the tool, or a short message telling
|
|
56
|
-
* them how to get a key.
|
|
57
|
-
*
|
|
58
|
-
* A good key is remembered for an hour, so a busy session does not hit the
|
|
59
|
-
* license server on every call and keeps working through a brief outage.
|
|
60
|
-
*/
|
|
61
|
-
export async function premiumRequired(tool) {
|
|
62
|
-
if (!PREMIUM.has(tool))
|
|
63
|
-
return null;
|
|
64
|
-
const key = process.env.MCP_LICENSE_KEY;
|
|
65
|
-
if (!key)
|
|
66
|
-
return blocked(tool, "missing_key");
|
|
67
|
-
const hit = seen.get(key);
|
|
68
|
-
if (hit && Date.now() - hit.at < (hit.valid ? OK_CACHE_MS : BAD_CACHE_MS)) {
|
|
69
|
-
return hit.valid ? null : blocked(tool, hit.reason ?? "invalid");
|
|
70
|
-
}
|
|
71
|
-
let result;
|
|
72
|
-
try {
|
|
73
|
-
result = await verify(key);
|
|
74
|
-
}
|
|
75
|
-
catch {
|
|
76
|
-
result = { valid: false, reason: "network_error" };
|
|
77
|
-
}
|
|
78
|
-
seen.set(key, { ...result, at: Date.now() });
|
|
79
|
-
return result.valid ? null : blocked(tool, result.reason ?? "invalid");
|
|
80
|
-
}
|