@pipeworx/mcp-rdap 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pipeworx
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # mcp-rdap
2
+
3
+ RDAP — Registration Data Access Protocol (domains, IPs, ASNs) via IANA bootstrap
4
+
5
+ Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 250+ live data sources.
6
+
7
+ ## Tools
8
+
9
+ | Tool | Description |
10
+ |------|-------------|
11
+
12
+ ## Quick Start
13
+
14
+ Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
15
+
16
+ ```json
17
+ {
18
+ "mcpServers": {
19
+ "rdap": {
20
+ "url": "https://gateway.pipeworx.io/rdap/mcp"
21
+ }
22
+ }
23
+ }
24
+ ```
25
+
26
+ Or connect to the full Pipeworx gateway for access to all 250+ data sources:
27
+
28
+ ```json
29
+ {
30
+ "mcpServers": {
31
+ "pipeworx": {
32
+ "url": "https://gateway.pipeworx.io/mcp"
33
+ }
34
+ }
35
+ }
36
+ ```
37
+
38
+ ## Using with ask_pipeworx
39
+
40
+ Instead of calling tools directly, you can ask questions in plain English:
41
+
42
+ ```
43
+ ask_pipeworx({ question: "your question about Rdap data" })
44
+ ```
45
+
46
+ The gateway picks the right tool and fills the arguments automatically.
47
+
48
+ ## More
49
+
50
+ - [All tools and guides](https://github.com/pipeworx-io/examples)
51
+ - [pipeworx.io](https://pipeworx.io)
52
+
53
+ ## License
54
+
55
+ MIT
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@pipeworx/mcp-rdap",
3
+ "version": "0.1.0",
4
+ "description": "RDAP — Registration Data Access Protocol (domains, IPs, ASNs) via IANA bootstrap",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "rdap"],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/pipeworx-io/mcp-rdap"
13
+ },
14
+ "scripts": {
15
+ "typecheck": "tsc --noEmit"
16
+ },
17
+ "devDependencies": {
18
+ "typescript": "^5.7.0"
19
+ }
20
+ }
package/server.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.pipeworx-io/rdap",
4
+ "title": "Rdap",
5
+ "description": "RDAP — Registration Data Access Protocol (domains, IPs, ASNs) via IANA bootstrap",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/rdap",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-rdap",
10
+ "source": "github"
11
+ },
12
+ "remotes": [
13
+ {
14
+ "type": "streamable-http",
15
+ "url": "https://gateway.pipeworx.io/rdap/mcp"
16
+ }
17
+ ]
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,158 @@
1
+ interface McpToolDefinition {
2
+ name: string;
3
+ description: string;
4
+ inputSchema: {
5
+ type: 'object';
6
+ properties: Record<string, unknown>;
7
+ required?: string[];
8
+ };
9
+ }
10
+
11
+ interface McpToolExport {
12
+ tools: McpToolDefinition[];
13
+ callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
14
+ meter?: { credits: number };
15
+ cost?: Record<string, unknown>;
16
+ provider?: string;
17
+ }
18
+
19
+ /**
20
+ * RDAP MCP — Registration Data Access Protocol via IANA bootstrap.
21
+ */
22
+
23
+
24
+ const UA = 'pipeworx-mcp-rdap/1.0 (+https://pipeworx.io)';
25
+ const BOOTSTRAP_TTL_MS = 24 * 60 * 60 * 1000;
26
+ const BOOTSTRAPS = {
27
+ dns: 'https://data.iana.org/rdap/dns.json',
28
+ ipv4: 'https://data.iana.org/rdap/ipv4.json',
29
+ ipv6: 'https://data.iana.org/rdap/ipv6.json',
30
+ asn: 'https://data.iana.org/rdap/asn.json',
31
+ };
32
+ const CACHE: Partial<Record<keyof typeof BOOTSTRAPS, { at: number; services: [string[], string[]][] }>> = {};
33
+
34
+ const tools: McpToolExport['tools'] = [
35
+ { name: 'domain', description: 'Domain registration record.', inputSchema: { type: 'object', properties: { name: { type: 'string' } }, required: ['name'] } },
36
+ { name: 'ip', description: 'IP/netblock allocation record.', inputSchema: { type: 'object', properties: { address: { type: 'string' } }, required: ['address'] } },
37
+ { name: 'asn', description: 'ASN allocation record.', inputSchema: { type: 'object', properties: { number: { type: 'number' } }, required: ['number'] } },
38
+ { name: 'entity', description: 'Entity by handle. Pass base RDAP url to skip bootstrap.', inputSchema: { type: 'object', properties: { handle: { type: 'string' }, base: { type: 'string' } }, required: ['handle'] } },
39
+ { name: 'nameserver', description: 'Nameserver record.', inputSchema: { type: 'object', properties: { host: { type: 'string' } }, required: ['host'] } },
40
+ ];
41
+
42
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
43
+ switch (name) {
44
+ case 'domain': {
45
+ const d = reqStr(args, 'name', '"example.com"').toLowerCase();
46
+ const tld = d.split('.').pop() ?? '';
47
+ const base = await pickBootstrap('dns', tld);
48
+ if (!base) throw new Error(`RDAP: no DNS bootstrap for ".${tld}"`);
49
+ return rdapGet(`${trimSlash(base)}/domain/${encodeURIComponent(d)}`);
50
+ }
51
+ case 'ip': {
52
+ const ip = reqStr(args, 'address', '"8.8.8.8"');
53
+ const family = ip.includes(':') ? 'ipv6' : 'ipv4';
54
+ const base = await pickBootstrap(family, ip);
55
+ if (!base) throw new Error(`RDAP: no ${family} bootstrap for ${ip}`);
56
+ return rdapGet(`${trimSlash(base)}/ip/${encodeURIComponent(ip)}`);
57
+ }
58
+ case 'asn': {
59
+ const n = (args.number as number) | 0;
60
+ if (!n) throw new Error('Required argument "number" must be a positive ASN.');
61
+ const base = await pickBootstrap('asn', String(n));
62
+ if (!base) throw new Error(`RDAP: no ASN bootstrap for ${n}`);
63
+ return rdapGet(`${trimSlash(base)}/autnum/${n}`);
64
+ }
65
+ case 'entity': {
66
+ const handle = reqStr(args, 'handle', '"<handle>"');
67
+ const base = (args.base as string | undefined) ?? 'https://rdap.arin.net/registry';
68
+ return rdapGet(`${trimSlash(base)}/entity/${encodeURIComponent(handle)}`);
69
+ }
70
+ case 'nameserver': {
71
+ const host = reqStr(args, 'host', '"ns1.example.com"');
72
+ const tld = host.split('.').pop() ?? '';
73
+ const base = await pickBootstrap('dns', tld);
74
+ if (!base) throw new Error(`RDAP: no DNS bootstrap for ".${tld}"`);
75
+ return rdapGet(`${trimSlash(base)}/nameserver/${encodeURIComponent(host)}`);
76
+ }
77
+ default:
78
+ throw new Error(`Unknown tool: ${name}`);
79
+ }
80
+ }
81
+
82
+ async function pickBootstrap(kind: keyof typeof BOOTSTRAPS, key: string): Promise<string | null> {
83
+ const now = Date.now();
84
+ const c = CACHE[kind];
85
+ if (!c || now - c.at >= BOOTSTRAP_TTL_MS) {
86
+ const res = await fetch(BOOTSTRAPS[kind], { headers: { 'User-Agent': UA } });
87
+ if (!res.ok) throw new Error(`RDAP bootstrap ${kind}: ${res.status}`);
88
+ const json = (await res.json()) as { services: [string[], string[]][] };
89
+ CACHE[kind] = { at: now, services: json.services };
90
+ }
91
+ const services = CACHE[kind]!.services;
92
+ // For DNS: keys are TLDs (e.g. "com"). Match exact (case-insensitive).
93
+ // For IP: keys are CIDRs. Simple longest-prefix match (basic IPv4; IPv6 falls through to first).
94
+ if (kind === 'dns') {
95
+ const lc = key.toLowerCase();
96
+ for (const [keys, urls] of services) if (keys.map((k) => k.toLowerCase()).includes(lc)) return urls[0];
97
+ return null;
98
+ }
99
+ if (kind === 'asn') {
100
+ const n = parseInt(key, 10);
101
+ for (const [keys, urls] of services) {
102
+ for (const range of keys) {
103
+ const [lo, hi] = range.split('-').map((x) => parseInt(x, 10));
104
+ if (n >= lo && n <= (Number.isFinite(hi) ? hi : lo)) return urls[0];
105
+ }
106
+ }
107
+ return null;
108
+ }
109
+ // ipv4 / ipv6: best-effort first match (longest-prefix match left as future improvement).
110
+ for (const [keys, urls] of services) {
111
+ for (const cidr of keys) {
112
+ if (ipInCidr(key, cidr)) return urls[0];
113
+ }
114
+ }
115
+ return services[0]?.[1]?.[0] ?? null;
116
+ }
117
+
118
+ function ipInCidr(ip: string, cidr: string): boolean {
119
+ const [net, prefix] = cidr.split('/');
120
+ const p = parseInt(prefix, 10);
121
+ if (ip.includes(':') !== net.includes(':')) return false;
122
+ if (!ip.includes(':')) {
123
+ const toN = (s: string) => s.split('.').reduce((a, x) => (a << 8) + parseInt(x, 10), 0) >>> 0;
124
+ const mask = p === 0 ? 0 : (~0 << (32 - p)) >>> 0;
125
+ return (toN(ip) & mask) === (toN(net) & mask);
126
+ }
127
+ // crude IPv6 prefix-match on hex strings
128
+ const exp = (s: string) => {
129
+ const parts = s.split('::');
130
+ let head = parts[0] ? parts[0].split(':') : [];
131
+ let tail = parts[1] ? parts[1].split(':') : [];
132
+ while (head.length + tail.length < 8) head.push('0');
133
+ return [...head, ...tail].map((p) => p.padStart(4, '0')).join('');
134
+ };
135
+ const a = exp(ip);
136
+ const b = exp(net);
137
+ const hexBits = Math.ceil(p / 4);
138
+ return a.slice(0, hexBits) === b.slice(0, hexBits);
139
+ }
140
+
141
+ function trimSlash(s: string): string {
142
+ return s.replace(/\/+$/, '');
143
+ }
144
+
145
+ async function rdapGet(url: string): Promise<unknown> {
146
+ const res = await fetch(url, { headers: { Accept: 'application/rdap+json, application/json', 'User-Agent': UA } });
147
+ if (res.status === 404) throw new Error('RDAP: not found');
148
+ if (!res.ok) throw new Error(`RDAP: ${res.status} ${await res.text().then((t) => t.slice(0, 200))}`);
149
+ return res.json();
150
+ }
151
+
152
+ function reqStr(args: Record<string, unknown>, key: string, example: string): string {
153
+ const v = args[key];
154
+ if (typeof v !== 'string' || !v.trim()) throw new Error(`Required argument "${key}" is missing. Pass a string like ${example}.`);
155
+ return v;
156
+ }
157
+
158
+ export default { tools, callTool, meter: { credits: 1 } } satisfies McpToolExport;
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "strict": true,
7
+ "esModuleInterop": true,
8
+ "skipLibCheck": true,
9
+ "outDir": "dist",
10
+ "rootDir": "src",
11
+ "declaration": true
12
+ },
13
+ "include": ["src"]
14
+ }