http-inspector-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 +20 -0
- package/dist/api.js +105 -0
- package/dist/license.js +80 -0
- package/dist/server.js +56 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,3 +18,23 @@ node dist/index.js
|
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
Response bodies are never returned, only headers and sizes, so no content is leaked.
|
|
21
|
+
|
|
22
|
+
<!-- paywall -->
|
|
23
|
+
## Premium tools
|
|
24
|
+
|
|
25
|
+
These tools need a license key:
|
|
26
|
+
|
|
27
|
+
* `dns_records`
|
|
28
|
+
* `redirect_chain`
|
|
29
|
+
* `security_txt`
|
|
30
|
+
|
|
31
|
+
Buy a key at https://mcp-marketplace.io/server/io-github-mrfentmen-http-inspector-mcp and set it in your MCP client config:
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
"env": { "MCP_LICENSE_KEY": "mcp_live_..." }
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The key is checked against MCP Marketplace, cached for 24 hours, and keeps
|
|
38
|
+
working offline once one check has succeeded. Every other tool on this server
|
|
39
|
+
stays free.
|
|
40
|
+
<!-- /paywall -->
|
package/dist/api.js
CHANGED
|
@@ -22,3 +22,108 @@ export async function inspectUrl(args) {
|
|
|
22
22
|
lines.length ? `\nHeaders:\n${lines.join("\n")}` : "",
|
|
23
23
|
].filter(Boolean).join("\n");
|
|
24
24
|
}
|
|
25
|
+
// ---- muxB tools:
|
|
26
|
+
const DOH = "https://cloudflare-dns.com/dns-query";
|
|
27
|
+
const TYPES = ["A", "AAAA", "MX", "NS", "TXT", "CNAME", "CAA", "SOA"];
|
|
28
|
+
function hostOf(raw) {
|
|
29
|
+
const url = (raw ?? "").trim();
|
|
30
|
+
if (!/^https?:\/\/.+/i.test(url))
|
|
31
|
+
throw new HttpError("Provide a full URL starting with http or https");
|
|
32
|
+
let parsed;
|
|
33
|
+
try {
|
|
34
|
+
parsed = new URL(url);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
throw new HttpError(`Cannot parse that URL: ${url}`);
|
|
38
|
+
}
|
|
39
|
+
if (!parsed.hostname)
|
|
40
|
+
throw new HttpError("That URL has no hostname");
|
|
41
|
+
return parsed.hostname;
|
|
42
|
+
}
|
|
43
|
+
export async function dnsRecords(args) {
|
|
44
|
+
const hostname = hostOf(`https://${(args.host ?? "").trim().replace(/^https?:\/\//, "").replace(/\/.*$/, "")}`);
|
|
45
|
+
if (!hostname)
|
|
46
|
+
throw new HttpError("Provide a hostname to look up");
|
|
47
|
+
const asked = (args.types ?? "A,AAAA,MX,NS")
|
|
48
|
+
.split(",")
|
|
49
|
+
.map((t) => t.trim().toUpperCase())
|
|
50
|
+
.filter(Boolean);
|
|
51
|
+
const types = (asked.length ? asked : ["A"]).slice(0, 8);
|
|
52
|
+
for (const t of types) {
|
|
53
|
+
if (!TYPES.includes(t)) {
|
|
54
|
+
throw new HttpError(`Unsupported record type "${t}". Use any of ${TYPES.join(", ")}.`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const blocks = [];
|
|
58
|
+
for (const type of types) {
|
|
59
|
+
const res = await fetch(`${DOH}?name=${encodeURIComponent(hostname)}&type=${encodeURIComponent(type)}`, {
|
|
60
|
+
headers: { accept: "application/dns-json", "User-Agent": UA },
|
|
61
|
+
signal: AbortSignal.timeout(15000),
|
|
62
|
+
});
|
|
63
|
+
if (!res.ok)
|
|
64
|
+
throw new HttpError(`DNS over HTTPS returned ${res.status} for ${type}`);
|
|
65
|
+
const d = (await res.json());
|
|
66
|
+
if (d.Status !== 0) {
|
|
67
|
+
blocks.push(`${type}: resolver status ${d.Status}${d.Comment ? ` (${d.Comment})` : ""}`);
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const answers = d.Answer ?? [];
|
|
71
|
+
if (!answers.length) {
|
|
72
|
+
blocks.push(`${type}: no records`);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const rows = answers.slice(0, 12).map((a) => `- ${a.data ?? "no data reported"}${typeof a.TTL === "number" ? ` (TTL ${a.TTL}s)` : ""}`);
|
|
76
|
+
blocks.push(`${type}: ${answers.length} record(s)\n${rows.join("\n")}`);
|
|
77
|
+
}
|
|
78
|
+
return `DNS records for ${hostname} via Cloudflare DNS over HTTPS\n${blocks.join("\n")}`;
|
|
79
|
+
}
|
|
80
|
+
export async function redirectChain(args) {
|
|
81
|
+
const start = (args.url ?? "").trim();
|
|
82
|
+
if (!/^https?:\/\/.+/i.test(start))
|
|
83
|
+
throw new HttpError("Provide a full URL starting with http or https");
|
|
84
|
+
if (start.length > 2000)
|
|
85
|
+
throw new HttpError("URL is too long");
|
|
86
|
+
const maxHops = Math.max(1, Math.min(Math.trunc(Number(args.max_hops ?? 8) || 8), 20));
|
|
87
|
+
let current = start;
|
|
88
|
+
const hops = [];
|
|
89
|
+
for (let i = 0; i < maxHops; i += 1) {
|
|
90
|
+
const began = Date.now();
|
|
91
|
+
let res;
|
|
92
|
+
try {
|
|
93
|
+
res = await fetch(current, { method: "GET", redirect: "manual", headers: { "User-Agent": UA }, signal: AbortSignal.timeout(20000) });
|
|
94
|
+
}
|
|
95
|
+
catch (e) {
|
|
96
|
+
hops.push(`${i + 1}. ${current}\n request failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
const ms = Date.now() - began;
|
|
100
|
+
const location = res.headers.get("location");
|
|
101
|
+
if (res.status >= 300 && res.status < 400 && location) {
|
|
102
|
+
const next = new URL(location, current).toString();
|
|
103
|
+
hops.push(`${i + 1}. ${res.status} ${res.statusText} in ${ms}ms\n -> ${next}`);
|
|
104
|
+
current = next;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
hops.push(`${i + 1}. ${res.status} ${res.statusText} in ${ms}ms - final destination\n ${current}`);
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
return `Redirect chain from ${start} (${hops.length} hop(s), max ${maxHops}):\n${hops.join("\n")}`;
|
|
111
|
+
}
|
|
112
|
+
export async function securityTxt(args) {
|
|
113
|
+
const hostname = hostOf(`https://${(args.host ?? "").trim().replace(/^https?:\/\//, "").replace(/\/.*$/, "")}`);
|
|
114
|
+
const url = `https://${hostname}/.well-known/security.txt`;
|
|
115
|
+
const res = await fetch(url, { headers: { "User-Agent": UA, Accept: "text/plain" }, redirect: "follow", signal: AbortSignal.timeout(20000) });
|
|
116
|
+
if (res.status === 404)
|
|
117
|
+
return `${hostname} publishes no /.well-known/security.txt (HTTP 404).`;
|
|
118
|
+
if (!res.ok)
|
|
119
|
+
throw new HttpError(`${url} returned ${res.status}`);
|
|
120
|
+
const body = (await res.text()).replace(/\r/g, "").trim();
|
|
121
|
+
if (!body)
|
|
122
|
+
return `${hostname} serves an empty /.well-known/security.txt.`;
|
|
123
|
+
const fields = body
|
|
124
|
+
.split("\n")
|
|
125
|
+
.map((l) => l.trim())
|
|
126
|
+
.filter((l) => l && !l.startsWith("#"))
|
|
127
|
+
.slice(0, 20);
|
|
128
|
+
return `security.txt at ${url}\n${fields.join("\n")}`;
|
|
129
|
+
}
|
package/dist/license.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
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 = "http-inspector-mcp";
|
|
5
|
+
// Tools that need a key. Everything else is free.
|
|
6
|
+
const PREMIUM = new Set([
|
|
7
|
+
"dns_records",
|
|
8
|
+
"redirect_chain",
|
|
9
|
+
"security_txt",
|
|
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
|
+
}
|
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 { inspectUrl } from "./api.js";
|
|
3
|
+
import { inspectUrl, dnsRecords, redirectChain, securityTxt } 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,59 @@ export function createServer() {
|
|
|
20
21
|
return textError(error(e));
|
|
21
22
|
}
|
|
22
23
|
});
|
|
24
|
+
server.registerTool("dns_records", {
|
|
25
|
+
title: "Dns records",
|
|
26
|
+
description: "Look up A, AAAA, MX, NS, TXT, CNAME, CAA or SOA records for a host using Cloudflare DNS over HTTPS.",
|
|
27
|
+
inputSchema: z.object({ host: z.string().describe("Hostname or URL, for example github.com."), types: z.string().describe("Comma separated record types. Defaults to A,AAAA,MX,NS.").optional() }),
|
|
28
|
+
annotations: READ_ONLY,
|
|
29
|
+
}, async (args) => {
|
|
30
|
+
// ---- paywall: dns_records ----
|
|
31
|
+
const paywallMessage = await premiumRequired("dns_records");
|
|
32
|
+
if (paywallMessage)
|
|
33
|
+
return { content: [{ type: "text", text: paywallMessage }], isError: true };
|
|
34
|
+
// ---- paywall: end ----
|
|
35
|
+
try {
|
|
36
|
+
return text(await dnsRecords(args));
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
return textError(error(e));
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
server.registerTool("redirect_chain", {
|
|
43
|
+
title: "Redirect chain",
|
|
44
|
+
description: "Follow a URL one redirect at a time and report each hop: status code, elapsed milliseconds and the next location.",
|
|
45
|
+
inputSchema: z.object({ url: z.string().describe("The URL to trace."), max_hops: z.number().describe("Max hops, 1-20, default 8.").optional() }),
|
|
46
|
+
annotations: READ_ONLY,
|
|
47
|
+
}, async (args) => {
|
|
48
|
+
// ---- paywall: redirect_chain ----
|
|
49
|
+
const paywallMessage = await premiumRequired("redirect_chain");
|
|
50
|
+
if (paywallMessage)
|
|
51
|
+
return { content: [{ type: "text", text: paywallMessage }], isError: true };
|
|
52
|
+
// ---- paywall: end ----
|
|
53
|
+
try {
|
|
54
|
+
return text(await redirectChain(args));
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
return textError(error(e));
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
server.registerTool("security_txt", {
|
|
61
|
+
title: "Security txt",
|
|
62
|
+
description: "Fetch a site's /.well-known/security.txt and report its contact, policy, expiry and other fields.",
|
|
63
|
+
inputSchema: z.object({ host: z.string().describe("Hostname or URL, for example anthropic.com.") }),
|
|
64
|
+
annotations: READ_ONLY,
|
|
65
|
+
}, async (args) => {
|
|
66
|
+
// ---- paywall: security_txt ----
|
|
67
|
+
const paywallMessage = await premiumRequired("security_txt");
|
|
68
|
+
if (paywallMessage)
|
|
69
|
+
return { content: [{ type: "text", text: paywallMessage }], isError: true };
|
|
70
|
+
// ---- paywall: end ----
|
|
71
|
+
try {
|
|
72
|
+
return text(await securityTxt(args));
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
return textError(error(e));
|
|
76
|
+
}
|
|
77
|
+
});
|
|
23
78
|
return server;
|
|
24
79
|
}
|
package/package.json
CHANGED