ipforai-mcp 0.0.0-stage → 0.2.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/README.md +64 -2
- package/index.js +193 -0
- package/package.json +40 -4
package/README.md
CHANGED
|
@@ -1,3 +1,65 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ipforai-mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/ipforai-mcp)
|
|
4
|
+
|
|
5
|
+
MCP server for [IP for AI](https://ipforai.cc) — **Is it my network, or is it AI?**
|
|
6
|
+
|
|
7
|
+
为 [IP for AI](https://ipforai.cc) 提供的 MCP 服务:在 Claude Code、Cursor 等 AI 客户端里直接排查本机出口 IP、查询任意 IP、查看四大 AI 官方状态与 7 地区连通,以及反查全球 ASN 机房/家宽属性。
|
|
8
|
+
|
|
9
|
+
## Tools
|
|
10
|
+
|
|
11
|
+
| Tool | Input | Returns |
|
|
12
|
+
|------|-------|---------|
|
|
13
|
+
| `check_my_ip` | none | 本机 IPv4/IPv6 出口画像、环境分与 AI 地区支持(走 `HTTPS_PROXY`) |
|
|
14
|
+
| `lookup_ip` | `ip` | 指定 IPv4/IPv6 的网络画像、风险信号与环境分 |
|
|
15
|
+
| `check_ai_weather` | none | Claude / ChatGPT / Gemini / Grok 实时官方状态与 7 地区 API 直连连通 |
|
|
16
|
+
| `lookup_asn` | `query` | 反查全球 12 万+ ASN / 运营方(如 `AS2497`、`Vultr`),区分机房与家宽 |
|
|
17
|
+
|
|
18
|
+
Results describe the network environment only — never account, login, or subscription verdicts.
|
|
19
|
+
|
|
20
|
+
## Setup
|
|
21
|
+
|
|
22
|
+
Requires Node.js 20.18.1 or later. No API key required.
|
|
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 seen by `ipforai.cc`. The server honors `HTTPS_PROXY`, `HTTP_PROXY`, and `NO_PROXY`. With TUN / transparent proxy enabled, no extra config is needed; otherwise pass your local proxy port in `env`:
|
|
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` public endpoints (`/json`, `/api/ip-profile/echo`, `/api/service-status`, `/api/region-reachability`, `/api/asn`). It reads nothing from your machine besides proxy environment variables.
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
MIT
|
package/index.js
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
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.2.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 summarizeWeather(statusData, reachData) {
|
|
49
|
+
const services = {};
|
|
50
|
+
const statusMap = statusData?.services || {};
|
|
51
|
+
const reachMap = reachData?.services || {};
|
|
52
|
+
const ids = [...new Set([...Object.keys(statusMap), ...Object.keys(reachMap)])];
|
|
53
|
+
|
|
54
|
+
for (const id of ids) {
|
|
55
|
+
const st = statusMap[id];
|
|
56
|
+
const rc = reachMap[id];
|
|
57
|
+
const regions = {};
|
|
58
|
+
if (rc?.regions) {
|
|
59
|
+
for (const [code, cell] of Object.entries(rc.regions)) {
|
|
60
|
+
regions[code] = cell.latencyMs ? `${cell.status} (${cell.latencyMs}ms)` : cell.status;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
services[id] = {
|
|
64
|
+
officialStatus: st?.indicator ?? "unknown",
|
|
65
|
+
description: st?.description ?? null,
|
|
66
|
+
syncedAt: st?.syncedAt ?? null,
|
|
67
|
+
pageUrl: st?.pageUrl ?? null,
|
|
68
|
+
regionalApiReachability: regions,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
regions: reachData?.regions || [],
|
|
73
|
+
services,
|
|
74
|
+
url: `${API_BASE}/weather`,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function result(data) {
|
|
79
|
+
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function failure(message) {
|
|
83
|
+
return { content: [{ type: "text", text: message }], isError: true };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const server = new McpServer({ name: "ipforai", version: VERSION });
|
|
87
|
+
|
|
88
|
+
server.registerTool(
|
|
89
|
+
"check_my_ip",
|
|
90
|
+
{
|
|
91
|
+
title: "Check my exit IP for AI services",
|
|
92
|
+
description:
|
|
93
|
+
"Detect this machine's public IPv4/IPv6 exit (honoring HTTPS_PROXY) and return its network " +
|
|
94
|
+
"profile from ipforai.cc: location, ASN, network/access/routing type, proxy and risk signals, " +
|
|
95
|
+
"environment score, and availability for ChatGPT, Claude, Gemini, Grok and other AI services. " +
|
|
96
|
+
"Describes the network only, not account status.",
|
|
97
|
+
inputSchema: {},
|
|
98
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
99
|
+
},
|
|
100
|
+
async () => {
|
|
101
|
+
try {
|
|
102
|
+
const exits = await detectExits();
|
|
103
|
+
if (!exits.ipv4 && !exits.ipv6) return failure("Could not detect a public exit IP from ipforai.cc.");
|
|
104
|
+
const [p4, p6] = await Promise.all([
|
|
105
|
+
exits.ipv4 ? profile(exits.ipv4) : null,
|
|
106
|
+
exits.ipv6 ? profile(exits.ipv6) : null,
|
|
107
|
+
]);
|
|
108
|
+
return result({
|
|
109
|
+
ipv4: p4?.slot ?? null,
|
|
110
|
+
ipv6: p6?.slot ?? null,
|
|
111
|
+
disclaimer: (p4 || p6).disclaimer,
|
|
112
|
+
});
|
|
113
|
+
} catch (err) {
|
|
114
|
+
return failure(`ipforai.cc lookup failed: ${err.message}`);
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
server.registerTool(
|
|
120
|
+
"lookup_ip",
|
|
121
|
+
{
|
|
122
|
+
title: "Look up an IP for AI services",
|
|
123
|
+
description:
|
|
124
|
+
"Return the ipforai.cc network profile of a given IPv4 or IPv6 address: location, ASN, " +
|
|
125
|
+
"network/access/routing type, proxy and risk signals, environment score, and availability " +
|
|
126
|
+
"for ChatGPT, Claude, Gemini, Grok and other AI services. Profile lookup only, no live connectivity test.",
|
|
127
|
+
inputSchema: { ip: z.string().describe("IPv4 or IPv6 address, e.g. 8.8.8.8") },
|
|
128
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
129
|
+
},
|
|
130
|
+
async ({ ip }) => {
|
|
131
|
+
try {
|
|
132
|
+
const { slot, disclaimer } = await profile(ip.trim());
|
|
133
|
+
return result({ ...slot, disclaimer });
|
|
134
|
+
} catch (err) {
|
|
135
|
+
return failure(`ipforai.cc lookup failed: ${err.message}`);
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
server.registerTool(
|
|
141
|
+
"check_ai_weather",
|
|
142
|
+
{
|
|
143
|
+
title: "Check AI official status and regional API reachability",
|
|
144
|
+
description:
|
|
145
|
+
"Check live official service status (Claude, ChatGPT, Gemini, Grok) and 7-region direct API " +
|
|
146
|
+
"reachability (JP, US, SG, GB, HK, TW, CN) from ipforai.cc to tell whether an outage is on the AI provider side.",
|
|
147
|
+
inputSchema: {},
|
|
148
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
149
|
+
},
|
|
150
|
+
async () => {
|
|
151
|
+
try {
|
|
152
|
+
const [statusRes, reachRes] = await Promise.allSettled([
|
|
153
|
+
getJson(`${API_BASE}/api/service-status`),
|
|
154
|
+
getJson(`${API_BASE}/api/region-reachability`),
|
|
155
|
+
]);
|
|
156
|
+
const statusData = statusRes.status === "fulfilled" ? statusRes.value : null;
|
|
157
|
+
const reachData = reachRes.status === "fulfilled" ? reachRes.value : null;
|
|
158
|
+
if (!statusData && !reachData) return failure("Could not fetch AI weather data from ipforai.cc.");
|
|
159
|
+
return result(summarizeWeather(statusData, reachData));
|
|
160
|
+
} catch (err) {
|
|
161
|
+
return failure(`ipforai.cc weather lookup failed: ${err.message}`);
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
server.registerTool(
|
|
167
|
+
"lookup_asn",
|
|
168
|
+
{
|
|
169
|
+
title: "Look up an ASN or hosting/ISP operator",
|
|
170
|
+
description:
|
|
171
|
+
"Search the global ASN database on ipforai.cc (120k+ ASNs with PeeringDB metadata) by ASN number " +
|
|
172
|
+
"(e.g. AS2497, 25820) or operator name (e.g. Vultr, DMIT, IIJ) to distinguish datacenter/VPS from residential ISP.",
|
|
173
|
+
inputSchema: { query: z.string().describe("ASN number or operator keyword, e.g. AS2497 or Vultr") },
|
|
174
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
175
|
+
},
|
|
176
|
+
async ({ query }) => {
|
|
177
|
+
try {
|
|
178
|
+
const q = query.trim();
|
|
179
|
+
if (!q) return failure("Please provide an ASN number or operator name.");
|
|
180
|
+
const data = await getJson(`${API_BASE}/api/asn?q=${encodeURIComponent(q)}`);
|
|
181
|
+
return result({
|
|
182
|
+
query: data.query,
|
|
183
|
+
totalIndexed: data.totalIndexed,
|
|
184
|
+
results: data.results,
|
|
185
|
+
url: `${API_BASE}/datacenters?q=${encodeURIComponent(q)}`,
|
|
186
|
+
});
|
|
187
|
+
} catch (err) {
|
|
188
|
+
return failure(`ipforai.cc ASN lookup failed: ${err.message}`);
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
await server.connect(new StdioServerTransport());
|
package/package.json
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ipforai-mcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"mcpName": "cc.ipforai/ipforai",
|
|
5
|
+
"description": "MCP server for ipforai.cc: check exit IP, AI official status (weather), regional API reachability, and ASN/datacenter classification.",
|
|
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
|
+
}
|