ipforai-mcp 0.0.0-stage → 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.
Files changed (3) hide show
  1. package/README.md +64 -2
  2. package/index.js +110 -0
  3. package/package.json +40 -4
package/README.md CHANGED
@@ -1,3 +1,65 @@
1
- # Temporary Holding Version
1
+ # ipforai-mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm](https://img.shields.io/npm/v/ipforai-mcp)](https://www.npmjs.com/package/ipforai-mcp)
4
+
5
+ MCP server for [IP for AI](https://ipforai.cc): ask your AI assistant whether your current exit IP works for ChatGPT, Claude, Gemini and other AI services.
6
+
7
+ 为 [IP for AI](https://ipforai.cc) 提供的 MCP 服务:在 Claude、Cursor 等 AI 客户端里直接检测当前出口 IP 能否正常使用 ChatGPT、Claude、Gemini 等 AI 服务。
8
+
9
+ ## Tools
10
+
11
+ | Tool | Input | Returns |
12
+ |------|-------|---------|
13
+ | `check_my_ip` | none | Profile of this machine's IPv4 / IPv6 exit |
14
+ | `lookup_ip` | `ip` (IPv4 or IPv6) | Profile of the given address |
15
+
16
+ Each profile includes location, ASN, network type (residential / ISP / datacenter / proxy / Tor), access and routing type, risk level, an environment score, AI service availability, and a link to the full report on ipforai.cc.
17
+
18
+ Results describe the network environment only. They are not account, login or subscription verdicts.
19
+
20
+ ## Setup
21
+
22
+ Requires Node.js 20.18.1 or later. No API key.
23
+
24
+ **Claude Code**
25
+
26
+ ```bash
27
+ claude mcp add ipforai -- npx -y ipforai-mcp
28
+ ```
29
+
30
+ **Claude Desktop / Cursor / other clients**
31
+
32
+ ```json
33
+ {
34
+ "mcpServers": {
35
+ "ipforai": {
36
+ "command": "npx",
37
+ "args": ["-y", "ipforai-mcp"]
38
+ }
39
+ }
40
+ }
41
+ ```
42
+
43
+ ## Proxy
44
+
45
+ `check_my_ip` reports the exit that ipforai.cc sees, so the request has to go through the same proxy your AI traffic uses. The server honors `HTTPS_PROXY`, `HTTP_PROXY` and `NO_PROXY`. TUN / transparent proxy modes need no setup. If your proxy is only set as the system proxy, pass it explicitly:
46
+
47
+ ```json
48
+ {
49
+ "mcpServers": {
50
+ "ipforai": {
51
+ "command": "npx",
52
+ "args": ["-y", "ipforai-mcp"],
53
+ "env": { "HTTPS_PROXY": "http://127.0.0.1:7890" }
54
+ }
55
+ }
56
+ }
57
+ ```
58
+
59
+ ## Privacy
60
+
61
+ The server only calls ipforai.cc (`/json` and the exit echo endpoints). It reads nothing from your machine besides the proxy environment variables.
62
+
63
+ ## License
64
+
65
+ MIT
package/index.js ADDED
@@ -0,0 +1,110 @@
1
+ #!/usr/bin/env node
2
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
+ import { EnvHttpProxyAgent, fetch } from "undici";
5
+ import { z } from "zod";
6
+
7
+ const API_BASE = process.env.IPFORAI_API || "https://ipforai.cc";
8
+ const V4_BASE = process.env.IPFORAI_V4_PROBE || "https://v4-probe.ipforai.cc";
9
+ const TIMEOUT_MS = 10000;
10
+ const VERSION = "0.1.0";
11
+
12
+ // Node's fetch ignores HTTPS_PROXY / HTTP_PROXY. Users who route AI traffic
13
+ // through a proxy would otherwise see their direct exit instead of the real one.
14
+ const dispatcher = new EnvHttpProxyAgent();
15
+
16
+ async function getJson(url) {
17
+ const res = await fetch(url, {
18
+ dispatcher,
19
+ signal: AbortSignal.timeout(TIMEOUT_MS),
20
+ headers: { "User-Agent": `ipforai-mcp/${VERSION}` },
21
+ });
22
+ const body = await res.json();
23
+ if (!res.ok) throw new Error(body.error || `HTTP ${res.status}`);
24
+ return body;
25
+ }
26
+
27
+ async function profile(ip) {
28
+ const body = await getJson(`${API_BASE}/json?ip=${encodeURIComponent(ip)}`);
29
+ return { slot: body.ipv4 || body.ipv6, disclaimer: body.disclaimer };
30
+ }
31
+
32
+ // Same exit detection as the ipforai CLI: v4-probe has only an A record, so even
33
+ // behind a proxy it reveals the IPv4 exit; the main host reveals IPv6 when present.
34
+ async function detectExits() {
35
+ const [v4, main] = await Promise.allSettled([
36
+ getJson(`${V4_BASE}/api/ip-profile/echo`),
37
+ getJson(`${API_BASE}/api/ip-profile/echo`),
38
+ ]);
39
+ let ipv4 = v4.status === "fulfilled" ? v4.value.ip : null;
40
+ let ipv6 = null;
41
+ if (main.status === "fulfilled") {
42
+ if (main.value.addressFamily === "ipv6") ipv6 = main.value.ip;
43
+ else if (!ipv4) ipv4 = main.value.ip;
44
+ }
45
+ return { ipv4, ipv6 };
46
+ }
47
+
48
+ function result(data) {
49
+ return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
50
+ }
51
+
52
+ function failure(message) {
53
+ return { content: [{ type: "text", text: message }], isError: true };
54
+ }
55
+
56
+ const server = new McpServer({ name: "ipforai", version: VERSION });
57
+
58
+ server.registerTool(
59
+ "check_my_ip",
60
+ {
61
+ title: "Check my exit IP for AI services",
62
+ description:
63
+ "Detect this machine's public IPv4/IPv6 exit (honoring HTTPS_PROXY) and return its network " +
64
+ "profile from ipforai.cc: location, ASN, network/access/routing type, proxy and risk signals, " +
65
+ "environment score, and availability for ChatGPT, Claude, Gemini and other AI services. " +
66
+ "Describes the network only, not account status.",
67
+ inputSchema: {},
68
+ annotations: { readOnlyHint: true, openWorldHint: true },
69
+ },
70
+ async () => {
71
+ try {
72
+ const exits = await detectExits();
73
+ if (!exits.ipv4 && !exits.ipv6) return failure("Could not detect a public exit IP from ipforai.cc.");
74
+ const [p4, p6] = await Promise.all([
75
+ exits.ipv4 ? profile(exits.ipv4) : null,
76
+ exits.ipv6 ? profile(exits.ipv6) : null,
77
+ ]);
78
+ return result({
79
+ ipv4: p4?.slot ?? null,
80
+ ipv6: p6?.slot ?? null,
81
+ disclaimer: (p4 || p6).disclaimer,
82
+ });
83
+ } catch (err) {
84
+ return failure(`ipforai.cc lookup failed: ${err.message}`);
85
+ }
86
+ },
87
+ );
88
+
89
+ server.registerTool(
90
+ "lookup_ip",
91
+ {
92
+ title: "Look up an IP for AI services",
93
+ description:
94
+ "Return the ipforai.cc network profile of a given IPv4 or IPv6 address: location, ASN, " +
95
+ "network/access/routing type, proxy and risk signals, environment score, and availability " +
96
+ "for ChatGPT, Claude, Gemini and other AI services. Profile lookup only, no live connectivity test.",
97
+ inputSchema: { ip: z.string().describe("IPv4 or IPv6 address, e.g. 8.8.8.8") },
98
+ annotations: { readOnlyHint: true, openWorldHint: true },
99
+ },
100
+ async ({ ip }) => {
101
+ try {
102
+ const { slot, disclaimer } = await profile(ip.trim());
103
+ return result({ ...slot, disclaimer });
104
+ } catch (err) {
105
+ return failure(`ipforai.cc lookup failed: ${err.message}`);
106
+ }
107
+ },
108
+ );
109
+
110
+ await server.connect(new StdioServerTransport());
package/package.json CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "ipforai-mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "mcpName": "cc.ipforai/ipforai",
5
+ "description": "MCP server: check whether your exit IP works for ChatGPT, Claude, Gemini and other AI services.",
6
+ "type": "module",
7
+ "bin": {
8
+ "ipforai-mcp": "index.js"
9
+ },
10
+ "files": [
11
+ "index.js"
12
+ ],
13
+ "engines": {
14
+ "node": ">=20.18.1"
15
+ },
16
+ "keywords": [
17
+ "mcp",
18
+ "model-context-protocol",
19
+ "ip",
20
+ "ip-lookup",
21
+ "proxy",
22
+ "chatgpt",
23
+ "claude",
24
+ "ai"
25
+ ],
26
+ "homepage": "https://ipforai.cc",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/xjokerabab/ipforai.git",
30
+ "directory": "mcp"
31
+ },
32
+ "bugs": "https://github.com/xjokerabab/ipforai/issues",
33
+ "license": "MIT",
34
+ "publishConfig": {
35
+ "registry": "https://registry.npmjs.org/"
36
+ },
37
+ "dependencies": {
38
+ "@modelcontextprotocol/sdk": "^1.32.1",
39
+ "undici": "^7.30.0",
40
+ "zod": "^4.0.0"
41
+ }
42
+ }