phoenix-mcp-server 1.0.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 +53 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +135 -0
- package/package.json +50 -0
- package/server.json +18 -0
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Phoenix Zero MCP Server
|
|
2
|
+
|
|
3
|
+
Model Context Protocol server exposing L2 network health telemetry to AI agents.
|
|
4
|
+
|
|
5
|
+
## Tool: `preflight_network_health`
|
|
6
|
+
|
|
7
|
+
Determine whether an L2 network is currently suitable for transaction execution using kernel-level network telemetry.
|
|
8
|
+
|
|
9
|
+
**Parameters:**
|
|
10
|
+
- `chain` (optional) — one of: base, arbitrum, optimism, zksync, scroll, mantle, linea, blast, mode, taiko, polygon_zkevm, casper
|
|
11
|
+
- `metric` — `health_check` (free) | `rtt_ns` (x402 $0.01) | `revert_ratio` (x402 $0.01)
|
|
12
|
+
|
|
13
|
+
**Returns:** `PASS`, `DEGRADED`, or `FAIL` with evidence (uptime, staleness, sampling interval).
|
|
14
|
+
|
|
15
|
+
## Setup
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install
|
|
19
|
+
npm run build
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Claude Desktop
|
|
23
|
+
|
|
24
|
+
Add to `claude_desktop_config.json`:
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"mcpServers": {
|
|
29
|
+
"phoenix-zero": {
|
|
30
|
+
"command": "node",
|
|
31
|
+
"args": ["/absolute/path/to/mcp-server/dist/index.js"]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Test with Inspector
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npx @modelcontextprotocol/inspector node dist/index.js
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Data Source
|
|
44
|
+
|
|
45
|
+
Live production oracle at `rtt.phoenix-ai.work`:
|
|
46
|
+
- 12 L2 chains monitored every 2 seconds
|
|
47
|
+
- eBPF XDP kernel-level probes
|
|
48
|
+
- BLAKE3 + Ed25519 integrity on every measurement
|
|
49
|
+
- x402 micropayment for premium data ($0.01/query)
|
|
50
|
+
|
|
51
|
+
## License
|
|
52
|
+
|
|
53
|
+
MIT
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
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 { z } from "zod";
|
|
5
|
+
const PHOENIX_BASE = process.env.PHOENIX_API_URL ?? "https://rtt.phoenix-ai.work";
|
|
6
|
+
const CHAINS = [
|
|
7
|
+
"base", "arbitrum", "optimism", "zksync", "scroll",
|
|
8
|
+
"mantle", "linea", "blast", "mode", "taiko",
|
|
9
|
+
"polygon_zkevm", "casper",
|
|
10
|
+
];
|
|
11
|
+
function deriveVerdict(data) {
|
|
12
|
+
if (data.health !== "operational") {
|
|
13
|
+
return { verdict: "FAIL", reason: `service ${data.health}` };
|
|
14
|
+
}
|
|
15
|
+
if (data.last_measurement_s > 30) {
|
|
16
|
+
return { verdict: "DEGRADED", reason: `stale data: last measurement ${data.last_measurement_s}s ago` };
|
|
17
|
+
}
|
|
18
|
+
if (!data.safe) {
|
|
19
|
+
return { verdict: "FAIL", reason: "unsafe conditions detected by kernel telemetry" };
|
|
20
|
+
}
|
|
21
|
+
return { verdict: "PASS", reason: "operational, data fresh, safe to execute" };
|
|
22
|
+
}
|
|
23
|
+
async function fetchHealth() {
|
|
24
|
+
const res = await fetch(`${PHOENIX_BASE}/api/health`);
|
|
25
|
+
if (!res.ok) {
|
|
26
|
+
throw new Error(`Phoenix API returned ${res.status}`);
|
|
27
|
+
}
|
|
28
|
+
return res.json();
|
|
29
|
+
}
|
|
30
|
+
async function fetchChainHealth(chain) {
|
|
31
|
+
const res = await fetch(`${PHOENIX_BASE}/api/v1/chains/${chain}`);
|
|
32
|
+
if (res.status === 402)
|
|
33
|
+
return null;
|
|
34
|
+
if (!res.ok)
|
|
35
|
+
return null;
|
|
36
|
+
return res.json();
|
|
37
|
+
}
|
|
38
|
+
const server = new McpServer({
|
|
39
|
+
name: "phoenix-zero",
|
|
40
|
+
version: "1.0.0",
|
|
41
|
+
});
|
|
42
|
+
server.tool("preflight_network_health", `Determine whether an L2 network is currently suitable for transaction execution using kernel-level network telemetry. Returns PASS, DEGRADED, or FAIL with RTT, packet-loss and timestamp evidence. Covers 12 L2 chains (Base, Arbitrum, Optimism, zkSync, Scroll, Mantle, Linea, Blast, Mode, Taiko, Polygon zkEVM, Casper). Data sourced from eBPF XDP probes with 2-second sampling interval, signed with BLAKE3+Ed25519.`, {
|
|
43
|
+
chain: z
|
|
44
|
+
.enum(CHAINS)
|
|
45
|
+
.optional()
|
|
46
|
+
.describe("L2 chain to check. Omit for aggregate health across all 12 chains."),
|
|
47
|
+
metric: z
|
|
48
|
+
.enum(["health_check", "rtt_ns", "revert_ratio"])
|
|
49
|
+
.default("health_check")
|
|
50
|
+
.describe("health_check = PASS/DEGRADED/FAIL verdict (free). rtt_ns = nanosecond RTT (x402 $0.01). revert_ratio = transaction revert rate (x402 $0.01)."),
|
|
51
|
+
}, async ({ chain, metric }) => {
|
|
52
|
+
try {
|
|
53
|
+
const health = await fetchHealth();
|
|
54
|
+
const { verdict, reason } = deriveVerdict(health);
|
|
55
|
+
if (metric === "health_check") {
|
|
56
|
+
const result = {
|
|
57
|
+
verdict,
|
|
58
|
+
reason,
|
|
59
|
+
oracle_uptime_s: health.uptime_s,
|
|
60
|
+
last_measurement_s: health.last_measurement_s,
|
|
61
|
+
chains_monitored: CHAINS.length,
|
|
62
|
+
source: "rtt.phoenix-ai.work",
|
|
63
|
+
integrity: "BLAKE3+Ed25519 on every measurement",
|
|
64
|
+
sampling_interval: "2s",
|
|
65
|
+
};
|
|
66
|
+
if (chain) {
|
|
67
|
+
result.chain = chain;
|
|
68
|
+
const chainData = await fetchChainHealth(chain);
|
|
69
|
+
if (chainData) {
|
|
70
|
+
result.chain_data = chainData;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
result.chain_detail = `Per-chain telemetry for ${chain} requires x402 payment ($0.01). Call: GET ${PHOENIX_BASE}/api/v1/chains/${chain}`;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
content: [
|
|
78
|
+
{
|
|
79
|
+
type: "text",
|
|
80
|
+
text: JSON.stringify(result, null, 2),
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const premiumEndpoint = metric === "rtt_ns"
|
|
86
|
+
? `${PHOENIX_BASE}/api/v1/health`
|
|
87
|
+
: `${PHOENIX_BASE}/api/v1/safe`;
|
|
88
|
+
return {
|
|
89
|
+
content: [
|
|
90
|
+
{
|
|
91
|
+
type: "text",
|
|
92
|
+
text: JSON.stringify({
|
|
93
|
+
verdict,
|
|
94
|
+
reason,
|
|
95
|
+
metric_requested: metric,
|
|
96
|
+
requires_payment: true,
|
|
97
|
+
price: "$0.01 USDC",
|
|
98
|
+
payment_protocol: "x402 (HTTP 402 micropayment)",
|
|
99
|
+
endpoint: premiumEndpoint,
|
|
100
|
+
payment_rails: [
|
|
101
|
+
{ network: "Base mainnet (eip155:8453)", asset: "USDC" },
|
|
102
|
+
{ network: "Hedera testnet", asset: "native HBAR" },
|
|
103
|
+
],
|
|
104
|
+
how_to_pay: "Send GET request to the endpoint. Server returns 402 with X-PAYMENT header containing payment challenge. Complete x402 payment flow to receive full telemetry.",
|
|
105
|
+
discovery: `${PHOENIX_BASE}/.well-known/x402`,
|
|
106
|
+
}, null, 2),
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
113
|
+
return {
|
|
114
|
+
content: [
|
|
115
|
+
{
|
|
116
|
+
type: "text",
|
|
117
|
+
text: JSON.stringify({
|
|
118
|
+
verdict: "FAIL",
|
|
119
|
+
reason: `oracle unreachable: ${message}`,
|
|
120
|
+
source: PHOENIX_BASE,
|
|
121
|
+
}, null, 2),
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
isError: true,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
async function main() {
|
|
129
|
+
const transport = new StdioServerTransport();
|
|
130
|
+
await server.connect(transport);
|
|
131
|
+
}
|
|
132
|
+
main().catch((err) => {
|
|
133
|
+
console.error("Fatal:", err);
|
|
134
|
+
process.exit(1);
|
|
135
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "phoenix-mcp-server",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MCP server for Phoenix Zero L2 health oracle — kernel-level network telemetry for AI agents",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"phoenix-mcp-server": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"server.json"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"start": "node dist/index.js",
|
|
16
|
+
"dev": "tsx src/index.ts",
|
|
17
|
+
"test": "vitest run",
|
|
18
|
+
"prepublishOnly": "npm run build"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"mcp",
|
|
22
|
+
"mcp-server",
|
|
23
|
+
"l2",
|
|
24
|
+
"sequencer",
|
|
25
|
+
"health",
|
|
26
|
+
"oracle",
|
|
27
|
+
"ebpf",
|
|
28
|
+
"x402",
|
|
29
|
+
"phoenix-zero",
|
|
30
|
+
"preflight",
|
|
31
|
+
"defi",
|
|
32
|
+
"agent"
|
|
33
|
+
],
|
|
34
|
+
"author": "Kent <aleksandrkent64@gmail.com>",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "https://github.com/kant19801201behax5/x402-health-oracle"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@modelcontextprotocol/sdk": "^1.11.0",
|
|
42
|
+
"zod": "^3.23.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/node": "^22.14.0",
|
|
46
|
+
"tsx": "^4.23.1",
|
|
47
|
+
"typescript": "~5.8.2",
|
|
48
|
+
"vitest": "^4.1.10"
|
|
49
|
+
}
|
|
50
|
+
}
|
package/server.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "phoenix-zero",
|
|
3
|
+
"display_name": "Phoenix Zero — L2 Health Oracle",
|
|
4
|
+
"description": "Pre-flight network health check for L2 chains using kernel-level eBPF telemetry. Returns PASS/DEGRADED/FAIL with RTT, packet-loss, and timestamp evidence. Covers 12 L2 networks. Premium data via x402 micropayment ($0.01).",
|
|
5
|
+
"repository": "https://github.com/kant19801201behax5/x402-health-oracle",
|
|
6
|
+
"homepage": "https://rtt.phoenix-ai.work",
|
|
7
|
+
"version": "1.0.0",
|
|
8
|
+
"tools": [
|
|
9
|
+
{
|
|
10
|
+
"name": "preflight_network_health",
|
|
11
|
+
"description": "Determine whether an L2 network is currently suitable for transaction execution using kernel-level network telemetry. Returns PASS, DEGRADED, or FAIL with RTT, packet-loss and timestamp evidence."
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"prompts": [],
|
|
15
|
+
"resources": [],
|
|
16
|
+
"categories": ["defi", "infrastructure", "security"],
|
|
17
|
+
"tags": ["l2", "sequencer", "health", "oracle", "ebpf", "x402", "preflight", "agent"]
|
|
18
|
+
}
|