@pipeworx/mcp-ipaddress 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,57 @@
1
+ # mcp-ipaddress
2
+
3
+ IP address utilities MCP.
4
+
5
+ Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 1170+ live data sources.
6
+
7
+ ## Tools
8
+
9
+ | Tool | Description |
10
+ |------|-------------|
11
+ | `parse_ip` | Validate and classify an IP address (IPv4 or IPv6): version, validity, and classification (private/loopback/link-local/multicast/reserved/public). IPv4 also returns its 32-bit integer. Keyless, offline. |
12
+ | `cidr_info` | Parse an IPv4 CIDR block (e.g. "192.168.1.0/24") and compute the network address, broadcast, netmask, wildcard, usable host range and host count. Keyless, offline. |
13
+
14
+ ## Quick Start
15
+
16
+ Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
17
+
18
+ ```json
19
+ {
20
+ "mcpServers": {
21
+ "ipaddress": {
22
+ "url": "https://gateway.pipeworx.io/ipaddress/mcp"
23
+ }
24
+ }
25
+ }
26
+ ```
27
+
28
+ Or connect to the full Pipeworx gateway for access to all 1170+ data sources:
29
+
30
+ ```json
31
+ {
32
+ "mcpServers": {
33
+ "pipeworx": {
34
+ "url": "https://gateway.pipeworx.io/mcp"
35
+ }
36
+ }
37
+ }
38
+ ```
39
+
40
+ ## Using with ask_pipeworx
41
+
42
+ Instead of calling tools directly, you can ask questions in plain English:
43
+
44
+ ```
45
+ ask_pipeworx({ question: "your question about Ipaddress data" })
46
+ ```
47
+
48
+ The gateway picks the right tool and fills the arguments automatically.
49
+
50
+ ## More
51
+
52
+ - [All tools and guides](https://github.com/pipeworx-io/examples)
53
+ - [pipeworx.io](https://pipeworx.io)
54
+
55
+ ## License
56
+
57
+ MIT
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@pipeworx/mcp-ipaddress",
3
+ "version": "0.1.0",
4
+ "description": "IP address utilities MCP.",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "ipaddress"],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/pipeworx-io/mcp-ipaddress"
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/ipaddress",
4
+ "title": "Ipaddress",
5
+ "description": "IP address utilities MCP.",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/ipaddress",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-ipaddress",
10
+ "source": "github"
11
+ },
12
+ "remotes": [
13
+ {
14
+ "type": "streamable-http",
15
+ "url": "https://gateway.pipeworx.io/ipaddress/mcp"
16
+ }
17
+ ]
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,119 @@
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
+ * IP address utilities MCP.
21
+ *
22
+ * Keyless, offline: validate & classify IPv4/IPv6 addresses (private, loopback,
23
+ * link-local, multicast, reserved) and compute IPv4 subnet math from CIDR
24
+ * (network, broadcast, netmask, host range, host count). Pure logic — no API,
25
+ * no key. (IPv6 is validated & classified; full IPv6 subnet math is out of scope.)
26
+ */
27
+
28
+
29
+ function parseV4(ip: string): number[] | null {
30
+ const p = ip.split('.');
31
+ if (p.length !== 4) return null;
32
+ const o = p.map((x) => (/^\d{1,3}$/.test(x) ? +x : -1));
33
+ return o.every((n) => n >= 0 && n <= 255) ? o : null;
34
+ }
35
+ const v4int = (o: number[]) => (o[0] * 2 ** 24 + o[1] * 2 ** 16 + o[2] * 2 ** 8 + o[3]) >>> 0;
36
+ const intV4 = (n: number) => [(n >>> 24) & 255, (n >>> 16) & 255, (n >>> 8) & 255, n & 255].join('.');
37
+
38
+ function classifyV4(o: number[]): string[] {
39
+ const tags: string[] = [];
40
+ if (o[0] === 10 || (o[0] === 172 && o[1] >= 16 && o[1] <= 31) || (o[0] === 192 && o[1] === 168)) tags.push('private');
41
+ if (o[0] === 127) tags.push('loopback');
42
+ if (o[0] === 169 && o[1] === 254) tags.push('link-local');
43
+ if (o[0] >= 224 && o[0] <= 239) tags.push('multicast');
44
+ if (o[0] >= 240) tags.push('reserved');
45
+ if (o[0] === 0) tags.push('this-network');
46
+ if (o[0] === 100 && o[1] >= 64 && o[1] <= 127) tags.push('cgnat');
47
+ if (tags.length === 0) tags.push('public');
48
+ return tags;
49
+ }
50
+
51
+ const V6 = /^(([0-9a-f]{1,4}:){7}[0-9a-f]{1,4}|([0-9a-f]{1,4}:){1,7}:|([0-9a-f]{1,4}:){1,6}:[0-9a-f]{1,4}|([0-9a-f]{1,4}:){1,5}(:[0-9a-f]{1,4}){1,2}|([0-9a-f]{1,4}:){1,4}(:[0-9a-f]{1,4}){1,3}|([0-9a-f]{1,4}:){1,3}(:[0-9a-f]{1,4}){1,4}|([0-9a-f]{1,4}:){1,2}(:[0-9a-f]{1,4}){1,5}|[0-9a-f]{1,4}:((:[0-9a-f]{1,4}){1,6})|:((:[0-9a-f]{1,4}){1,7}|:)|::(ffff(:0{1,4})?:)?((25[0-5]|(2[0-4]|1?[0-9])?[0-9])\.){3}(25[0-5]|(2[0-4]|1?[0-9])?[0-9]))$/i;
52
+ function classifyV6(ip: string): string[] {
53
+ const l = ip.toLowerCase();
54
+ const tags: string[] = [];
55
+ if (l === '::1') tags.push('loopback');
56
+ if (l === '::') tags.push('unspecified');
57
+ if (/^fe[89ab]/.test(l)) tags.push('link-local');
58
+ if (/^f[cd]/.test(l)) tags.push('unique-local');
59
+ if (/^ff/.test(l)) tags.push('multicast');
60
+ if (/^2001:db8/.test(l)) tags.push('documentation');
61
+ if (tags.length === 0) tags.push('global-unicast');
62
+ return tags;
63
+ }
64
+
65
+ const tools: McpToolExport['tools'] = [
66
+ {
67
+ name: 'parse_ip',
68
+ description: 'Validate and classify an IP address (IPv4 or IPv6): version, validity, and classification (private/loopback/link-local/multicast/reserved/public). IPv4 also returns its 32-bit integer. Keyless, offline.',
69
+ inputSchema: { type: 'object', properties: { ip: { type: 'string', description: 'An IPv4 or IPv6 address, e.g. "192.168.1.10" or "2001:db8::1".' } }, required: ['ip'] },
70
+ },
71
+ {
72
+ name: 'cidr_info',
73
+ description: 'Parse an IPv4 CIDR block (e.g. "192.168.1.0/24") and compute the network address, broadcast, netmask, wildcard, usable host range and host count. Keyless, offline.',
74
+ inputSchema: { type: 'object', properties: { cidr: { type: 'string', description: 'An IPv4 CIDR, e.g. "10.0.0.0/8".' } }, required: ['cidr'] },
75
+ },
76
+ ];
77
+
78
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
79
+ switch (name) {
80
+ case 'parse_ip': {
81
+ const ip = reqStr(args, 'ip', '"192.168.1.10"').trim();
82
+ const o = parseV4(ip);
83
+ if (o) return { input: ip, valid: true, version: 4, integer: v4int(o), classification: classifyV4(o) };
84
+ if (V6.test(ip)) return { input: ip, valid: true, version: 6, classification: classifyV6(ip) };
85
+ return { input: ip, valid: false, reason: 'Not a valid IPv4 or IPv6 address.' };
86
+ }
87
+ case 'cidr_info': {
88
+ const cidr = reqStr(args, 'cidr', '"192.168.1.0/24"').trim();
89
+ const [ipStr, prefStr] = cidr.split('/');
90
+ const o = parseV4(ipStr || '');
91
+ const prefix = /^\d{1,2}$/.test(prefStr || '') ? +prefStr : -1;
92
+ if (!o || prefix < 0 || prefix > 32) return { input: cidr, valid: false, reason: 'Expected an IPv4 CIDR like "192.168.1.0/24" (prefix 0-32).' };
93
+ const ipn = v4int(o);
94
+ const mask = prefix === 0 ? 0 : (0xffffffff << (32 - prefix)) >>> 0;
95
+ const network = (ipn & mask) >>> 0;
96
+ const broadcast = (network | (~mask >>> 0)) >>> 0;
97
+ const total = 2 ** (32 - prefix);
98
+ const usable = prefix >= 31 ? total : total - 2;
99
+ return {
100
+ input: cidr, valid: true, prefix,
101
+ network: intV4(network), broadcast: intV4(broadcast),
102
+ netmask: intV4(mask), wildcard: intV4(~mask >>> 0),
103
+ first_host: prefix >= 31 ? intV4(network) : intV4((network + 1) >>> 0),
104
+ last_host: prefix >= 31 ? intV4(broadcast) : intV4((broadcast - 1) >>> 0),
105
+ total_addresses: total, usable_hosts: usable,
106
+ };
107
+ }
108
+ default:
109
+ throw new Error(`Unknown tool: ${name}`);
110
+ }
111
+ }
112
+
113
+ function reqStr(args: Record<string, unknown>, key: string, ex: string): string {
114
+ const v = args[key];
115
+ if (typeof v !== 'string' || !v.trim()) throw new Error(`Required argument "${key}" is missing. Pass a string like ${ex}.`);
116
+ return v;
117
+ }
118
+
119
+ 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
+ }