athena-mcp 1.0.4 → 1.0.7

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 CHANGED
@@ -25,6 +25,98 @@
25
25
 
26
26
  将该文档复制给你的 agent,它将自动理解项目价值。
27
27
 
28
+ ## Installation (Claude Code)
29
+
30
+ ### Option A: npm (recommended)
31
+
32
+ ```bash
33
+ npx athena-mcp install
34
+ ```
35
+
36
+ This will:
37
+ 1. Clone Athena to `~/.athena/`
38
+ 2. Install Python dependencies (slither, web3, chromadb, etc.)
39
+ 3. Install system tools (Slither, Aderyn, Foundry)
40
+ 4. Copy the audit skill to `~/.claude/skills/athena-audit-skill/`
41
+ 5. Configure 14 MCP servers in Claude Code
42
+
43
+ ### Option B: curl install script
44
+
45
+ ```bash
46
+ curl -fsSL https://athena.degure.me/install.sh | bash
47
+ ```
48
+
49
+ Or from GitHub directly:
50
+ ```bash
51
+ curl -fsSL https://raw.githubusercontent.com/tiyadegure/Athena/main/install.sh | bash
52
+ ```
53
+
54
+ Options:
55
+ ```bash
56
+ SKIP_DEPS=1 curl ... | bash # Skip Python deps
57
+ SKIP_SYSTEM=1 curl ... | bash # Skip slither/aderyn/foundry
58
+ SKIP_CLAUDE=1 curl ... | bash # Skip Claude Code config
59
+ ```
60
+
61
+ ### Option C: Manual
62
+
63
+ ```bash
64
+ # 1. Clone
65
+ git clone https://github.com/tiyadegure/Athena.git ~/.athena
66
+ cd ~/.athena
67
+
68
+ # 2. Python deps
69
+ pip install -r requirements.txt
70
+
71
+ # 3. System tools
72
+ pip install slither-analyzer
73
+ cargo install aderyn # requires Rust
74
+ curl -L https://foundry.paradigm.xyz | bash && foundryup
75
+
76
+ # 4. Copy skill
77
+ cp -r skills/glm-audit-skill ~/.claude/skills/athena-audit-skill
78
+
79
+ # 5. Register MCP servers (one per tool)
80
+ claude mcp add athena-slither -- python3 ~/.athena/mcp/tools/slither_runner.py
81
+ claude mcp add athena-aderyn -- python3 ~/.athena/mcp/tools/aderyn_runner.py
82
+ claude mcp add athena-poc-generator -- python3 ~/.athena/mcp/tools/poc_generator.py
83
+ claude mcp add athena-fuzz-runner -- python3 ~/.athena/mcp/tools/fuzz_runner.py
84
+ claude mcp add athena-knowledge-base -- python3 ~/.athena/mcp/tools/knowledge_base.py
85
+ claude mcp add athena-eas-attest -- python3 ~/.athena/mcp/tools/eas_attest.py
86
+ claude mcp add athena-exploit-simulator -- python3 ~/.athena/mcp/tools/exploit_simulator.py
87
+ claude mcp add athena-evidence-chain -- python3 ~/.athena/mcp/tools/evidence_chain.py
88
+ claude mcp add athena-halmos-runner -- python3 ~/.athena/mcp/tools/halmos_runner.py
89
+ claude mcp add athena-protocol-scanner -- python3 ~/.athena/mcp/tools/protocol_scanner.py
90
+ claude mcp add athena-repair-validator -- python3 ~/.athena/mcp/tools/repair_validator.py
91
+ claude mcp add athena-incremental-auditor -- python3 ~/.athena/mcp/tools/incremental_auditor.py
92
+ claude mcp add athena-gev-analyzer -- python3 ~/.athena/mcp/tools/gev_analyzer.py
93
+ ```
94
+
95
+ ### Quick Start (after install)
96
+
97
+ ```bash
98
+ # 1. Install
99
+ npx athena-mcp install
100
+
101
+ # 2. Environment setup (for on-chain attestation + NFT minting)
102
+ export SEPOLIA_PRIVATE_KEY="0xYourPrivateKey"
103
+ export SEPOLIA_RPC_URL="https://rpc.sepolia.org" # or Alchemy/Infura
104
+
105
+ # 3. Full audit flow (scan → PoC → EAS attestation → NFT mint)
106
+ claude "audit contracts/test-cases/Reentrancy.sol and mint NFT certificate"
107
+
108
+ # 4. Scan-only (static analysis, no on-chain actions)
109
+ claude "scan contracts/test-cases/Reentrancy.sol with slither and aderyn"
110
+ ```
111
+
112
+ **What happens:**
113
+ - Slither + Aderyn dual-engine static analysis
114
+ - PoC generation + Foundry fuzz testing
115
+ - EAS attestation on Sepolia (on-chain audit record)
116
+ - NFT certificate minting (ERC-1155, S/A/B/C tiers)
117
+ - Verification links to Etherscan + EAS explorer
118
+
119
+ ---
28
120
  ## 核心工作流(8 步闭环)
29
121
 
30
122
  ```
@@ -80,7 +172,7 @@
80
172
  自建 `athena-audit-skill`,10 轮检查流程:
81
173
  scope → architecture → access control → reentrancy → math → oracle → flash loan → governance → upgrade → report
82
174
 
83
- ### MCP(工具链)— 13 个工具
175
+ ### MCP(工具链)— 14 个工具
84
176
 
85
177
  | 工具 | 脚本 | 功能 |
86
178
  |------|------|------|
@@ -113,7 +205,7 @@ scope → architecture → access control → reentrancy → math → oracle →
113
205
  |------|------|------|
114
206
  | **GLM-5.1** | Z.AI Coding Plan | 驱动 Agent,处理长程任务 |
115
207
  | **athena-audit-skill** | 自建 | 12 个专项 agent 并行审计方法论 |
116
- | **MCP 工具链(13 个)** | 自建 | 静态分析、PoC 生成、fuzz 测试、知识库、链上认证等 |
208
+ | **MCP 工具链(14 个)** | 自建 | 静态分析、PoC 生成、fuzz 测试、知识库、链上认证等 |
117
209
  | **Foundry** | foundry-rs | 合约编译、测试、fuzz |
118
210
  | **EAS** | Ethereum Attestation Service | 链上审计认证 |
119
211
  | **ERC-1155** | OpenZeppelin | 分级 NFT 审计证书 |
@@ -185,118 +277,12 @@ Athena/
185
277
  - AuditTrail (Sepolia): https://sepolia.etherscan.io/address/0xd7913e7749595a9238883bdf0b2dad599f4d0bf0
186
278
  - EAS 认证: https://sepolia.easscan.org/attestation/view/0xd02800c960f18f0483af4aa320aff314e34c5a83d1c9a9c963b299a88af958b9
187
279
 
188
- ## Installation (Claude Code)
189
-
190
- ### Option A: npm (recommended)
191
-
192
- ```bash
193
- npx athena-mcp install
194
- ```
195
-
196
- This will:
197
- 1. Clone Athena to `~/.athena/`
198
- 2. Install Python dependencies (slither, web3, chromadb, etc.)
199
- 3. Install system tools (Slither, Aderyn, Foundry)
200
- 4. Copy the audit skill to `~/.claude/skills/athena-audit-skill/`
201
- 5. Configure 13 MCP servers in Claude Code
202
-
203
- ### Option B: curl install script
204
-
205
- ```bash
206
- curl -fsSL https://athena.degure.me/install.sh | bash
207
- ```
208
-
209
- Or from GitHub directly:
210
- ```bash
211
- curl -fsSL https://raw.githubusercontent.com/tiyadegure/Athena/main/install.sh | bash
212
- ```
213
-
214
- Options:
215
- ```bash
216
- SKIP_DEPS=1 curl ... | bash # Skip Python deps
217
- SKIP_SYSTEM=1 curl ... | bash # Skip slither/aderyn/foundry
218
- SKIP_CLAUDE=1 curl ... | bash # Skip Claude Code config
219
- ```
220
-
221
- ### Option C: Manual
222
-
223
- ```bash
224
- # 1. Clone
225
- git clone https://github.com/tiyadegure/Athena.git ~/.athena
226
- cd ~/.athena
227
-
228
- # 2. Python deps
229
- pip install -r requirements.txt
230
-
231
- # 3. System tools
232
- pip install slither-analyzer
233
- cargo install aderyn # requires Rust
234
- curl -L https://foundry.paradigm.xyz | bash && foundryup
235
-
236
- # 4. Copy skill
237
- cp -r skills/glm-audit-skill ~/.claude/skills/athena-audit-skill
238
-
239
- # 5. Register MCP servers (one per tool)
240
- claude mcp add athena-slither -- python3 ~/.athena/mcp/tools/slither_runner.py
241
- claude mcp add athena-aderyn -- python3 ~/.athena/mcp/tools/aderyn_runner.py
242
- claude mcp add athena-poc-generator -- python3 ~/.athena/mcp/tools/poc_generator.py
243
- claude mcp add athena-fuzz-runner -- python3 ~/.athena/mcp/tools/fuzz_runner.py
244
- claude mcp add athena-knowledge-base -- python3 ~/.athena/mcp/tools/knowledge_base.py
245
- claude mcp add athena-eas-attest -- python3 ~/.athena/mcp/tools/eas_attest.py
246
- claude mcp add athena-exploit-simulator -- python3 ~/.athena/mcp/tools/exploit_simulator.py
247
- claude mcp add athena-evidence-chain -- python3 ~/.athena/mcp/tools/evidence_chain.py
248
- claude mcp add athena-halmos-runner -- python3 ~/.athena/mcp/tools/halmos_runner.py
249
- claude mcp add athena-protocol-scanner -- python3 ~/.athena/mcp/tools/protocol_scanner.py
250
- claude mcp add athena-repair-validator -- python3 ~/.athena/mcp/tools/repair_validator.py
251
- claude mcp add athena-incremental-auditor -- python3 ~/.athena/mcp/tools/incremental_auditor.py
252
- claude mcp add athena-gev-analyzer -- python3 ~/.athena/mcp/tools/gev_analyzer.py
253
- ```
254
-
255
- ### Quick Start (after install)
256
-
257
- ```bash
258
- # 1. Configure environment for on-chain attestation + NFT minting
259
- export SEPOLIA_PRIVATE_KEY="0x你的测试网私钥"
260
- export SEPOLIA_RPC_URL="https://rpc.sepolia.org"
261
-
262
- # 2. Full audit flow (scan → PoC → EAS attestation → NFT mint)
263
- claude "audit contracts/test-cases/Reentrancy.sol and mint NFT certificate"
264
-
265
- # Or just scan without on-chain steps
266
- claude "scan contracts/test-cases/Reentrancy.sol with slither and aderyn"
267
- ```
268
-
269
- **What happens:**
270
- - Slither + Aderyn static analysis
271
- - PoC generation + Foundry fuzz testing
272
- - EAS attestation on Sepolia (on-chain audit record)
273
- - NFT certificate minting (ERC-1155, S/A/B/C tiers)
274
- - Verification links to Etherscan + EAS explorer
275
-
276
- ---
277
280
 
278
281
  ## 快速开始(中文)
279
282
 
280
- ### 方式一:Claude Code(推荐)
281
-
282
- ```bash
283
- # 1. 安装
284
- npx athena-mcp install
285
-
286
- # 2. 配置环境变量(用于 EAS 上链 + NFT 铸造)
287
- export SEPOLIA_PRIVATE_KEY="0x你的测试网私钥"
288
- export SEPOLIA_RPC_URL="https://rpc.sepolia.org"
283
+ Athena 的审计流程由 AI Agent(GLM-5.1)驱动,不是简单的脚本调用。Agent 读取 `AGENT-WORKFLOW-FINAL.md`,自主执行 8 步闭环。
289
284
 
290
- # 3. 完整审计流程(扫描 → PoC → EAS 上链 → NFT 铸造)
291
- claude "审计 contracts/test-cases/Reentrancy.sol 并铸造 NFT 证书"
292
-
293
- # 或只做漏洞扫描
294
- claude "用 slither 和 aderyn 扫描 contracts/test-cases/Reentrancy.sol"
295
- ```
296
-
297
- Claude Code 会自动发现并调用 13 个 MCP 工具,完成从漏洞发现到链上认证的完整闭环。
298
-
299
- ### 方式二:GLM-5.1 Agent
285
+ ### 方式一:用 GLM-5.1 Agent 驱动(推荐)
300
286
 
301
287
  ```bash
302
288
  # 1. 克隆项目
@@ -309,13 +295,14 @@ curl -L https://foundry.paradigm.xyz | bash # Foundry
309
295
 
310
296
  # 3. 配置环境变量
311
297
  export SEPOLIA_PRIVATE_KEY="0x你的测试网私钥"
312
- export SEPOLIA_RPC_URL="https://rpc.sepolia.org"
298
+ export SEPOLIA_RPC_URL="https://rpc.sepolia.org" # 或 Alchemy/Infura
313
299
 
314
- # 4. 用 GLM-5.1 执行
300
+ # 4. 用 GLM-5.1 Agent 执行审计
315
301
  # 将 AGENT-WORKFLOW-FINAL.md 的内容作为 prompt 发送给 GLM-5.1
302
+ # Agent 会自主执行:扫描 → PoC → Fuzz → EAS 上链 → NFT 铸造
316
303
  ```
317
304
 
318
- GLM-5.1 需要读取 `AGENT-WORKFLOW-FINAL.md` 作为 step-by-step 指南,Claude Code 不需要。
305
+ Agent 会读取 `AGENT-WORKFLOW-FINAL.md`,按照 6 Phase 逐步执行,每一步验证通过后才继续下一步,最终输出链上验证链接和本地审计文件。
319
306
 
320
307
  ### 方式二:手动逐步执行
321
308
 
@@ -399,7 +386,7 @@ cast send 0x3247d57d37bd1878479f03a077aba807649dbaf5 \
399
386
 
400
387
  详见 [smart-contract-audit-agents-comparison.md](./smart-contract-audit-agents-comparison.md)
401
388
 
402
- 核心优势:**自建 13 个 MCP 工具 + 12 agent 并行审计方法论 + RAG 知识库 + PoC 生成 + Foundry fuzz + 攻击模拟 + 形式化验证 + EAS 链上认证 + Generative NFT,配合 GLM-5.1 的长程能力驱动从漏洞发现到链上证书的完整闭环。**
389
+ 核心优势:**自建 14 个 MCP 工具 + 12 agent 并行审计方法论 + RAG 知识库 + PoC 生成 + Foundry fuzz + 攻击模拟 + 形式化验证 + EAS 链上认证 + Generative NFT,配合 GLM-5.1 的长程能力驱动从漏洞发现到链上证书的完整闭环。**
403
390
 
404
391
  ## 开发工作流
405
392
 
@@ -424,7 +411,7 @@ cast send 0x3247d57d37bd1878479f03a077aba807649dbaf5 \
424
411
 
425
412
  - [x] 竞品调研(20 个项目)
426
413
  - [x] 构建 athena-audit-skill(12 agent 并行审计)
427
- - [x] 构建 13 个独立 MCP 工具
414
+ - [x] 构建 14 个独立 MCP 工具
428
415
  - [x] Generative NFT(S/A/B/C 四级,262,144 种 trait 组合)
429
416
  - [x] 部署 5 个合约到 Sepolia 测试网(AuditCertificate + ZK + Escrow + ERC-7512)
430
417
  - [x] EAS Schema 注册 + Attestation 上链
package/mcp/servers.json CHANGED
@@ -3,35 +3,45 @@
3
3
  {
4
4
  "name": "slither",
5
5
  "command": "python3",
6
- "args": ["mcp/tools/slither_runner.py"],
6
+ "args": [
7
+ "mcp/tools/slither_runner.py"
8
+ ],
7
9
  "description": "Slither static analysis for Solidity contracts",
8
10
  "env": {}
9
11
  },
10
12
  {
11
13
  "name": "aderyn",
12
14
  "command": "python3",
13
- "args": ["mcp/tools/aderyn_runner.py"],
15
+ "args": [
16
+ "mcp/tools/aderyn_runner.py"
17
+ ],
14
18
  "description": "Aderyn static analysis (Rust-based) for Solidity projects",
15
19
  "env": {}
16
20
  },
17
21
  {
18
22
  "name": "poc-generator",
19
23
  "command": "python3",
20
- "args": ["mcp/tools/poc_generator.py"],
24
+ "args": [
25
+ "mcp/tools/poc_generator.py"
26
+ ],
21
27
  "description": "Generate Foundry PoC exploit tests for vulnerabilities",
22
28
  "env": {}
23
29
  },
24
30
  {
25
31
  "name": "fuzz-runner",
26
32
  "command": "python3",
27
- "args": ["mcp/tools/fuzz_runner.py"],
33
+ "args": [
34
+ "mcp/tools/fuzz_runner.py"
35
+ ],
28
36
  "description": "Run Foundry fuzz and invariant tests",
29
37
  "env": {}
30
38
  },
31
39
  {
32
40
  "name": "knowledge-base",
33
41
  "command": "python3",
34
- "args": ["mcp/tools/knowledge_base.py"],
42
+ "args": [
43
+ "mcp/tools/knowledge_base.py"
44
+ ],
35
45
  "description": "Query vulnerability knowledge base (ChromaDB RAG)",
36
46
  "env": {
37
47
  "KNOWLEDGE_PATH": "data/knowledge"
@@ -40,7 +50,9 @@
40
50
  {
41
51
  "name": "eas-attest",
42
52
  "command": "python3",
43
- "args": ["mcp/tools/eas_attest.py"],
53
+ "args": [
54
+ "mcp/tools/eas_attest.py"
55
+ ],
44
56
  "description": "Submit EAS attestation on Sepolia testnet",
45
57
  "env": {
46
58
  "SEPOLIA_RPC_URL": "https://sepolia.drpc.org",
@@ -50,51 +62,74 @@
50
62
  {
51
63
  "name": "exploit-simulator",
52
64
  "command": "python3",
53
- "args": ["mcp/tools/exploit_simulator.py"],
65
+ "args": [
66
+ "mcp/tools/exploit_simulator.py"
67
+ ],
54
68
  "description": "Simulate attack scenarios against smart contracts",
55
69
  "env": {}
56
70
  },
57
71
  {
58
72
  "name": "evidence-chain",
59
73
  "command": "python3",
60
- "args": ["mcp/tools/evidence_chain.py"],
74
+ "args": [
75
+ "mcp/tools/evidence_chain.py"
76
+ ],
61
77
  "description": "Merkle-based audit evidence chain for verifiable audit trails",
62
78
  "env": {}
63
79
  },
64
80
  {
65
81
  "name": "halmos-runner",
66
82
  "command": "python3",
67
- "args": ["mcp/tools/halmos_runner.py"],
83
+ "args": [
84
+ "mcp/tools/halmos_runner.py"
85
+ ],
68
86
  "description": "Symbolic execution and formal verification via Halmos",
69
87
  "env": {}
70
88
  },
71
89
  {
72
90
  "name": "protocol-scanner",
73
91
  "command": "python3",
74
- "args": ["mcp/tools/protocol_scanner.py"],
92
+ "args": [
93
+ "mcp/tools/protocol_scanner.py"
94
+ ],
75
95
  "description": "Protocol-level dependency and interaction scanning",
76
96
  "env": {}
77
97
  },
78
98
  {
79
99
  "name": "repair-validator",
80
100
  "command": "python3",
81
- "args": ["mcp/tools/repair_validator.py"],
101
+ "args": [
102
+ "mcp/tools/repair_validator.py"
103
+ ],
82
104
  "description": "Validate that vulnerability fixes are correct and complete",
83
105
  "env": {}
84
106
  },
85
107
  {
86
108
  "name": "incremental-auditor",
87
109
  "command": "python3",
88
- "args": ["mcp/tools/incremental_auditor.py"],
110
+ "args": [
111
+ "mcp/tools/incremental_auditor.py"
112
+ ],
89
113
  "description": "Incremental audit for contract updates and diffs",
90
114
  "env": {}
91
115
  },
92
116
  {
93
117
  "name": "gev-analyzer",
94
118
  "command": "python3",
95
- "args": ["mcp/tools/gev_analyzer.py"],
119
+ "args": [
120
+ "mcp/tools/gev_analyzer.py"
121
+ ],
96
122
  "description": "Governance, Economic, and Value analysis for DeFi protocols",
97
123
  "env": {}
124
+ },
125
+ {
126
+ "name": "nft-minter",
127
+ "command": "python3",
128
+ "args": [
129
+ "mcp/tools/nft_minter.py"
130
+ ],
131
+ "description": "Mint ERC-1155 audit certificate NFTs on Sepolia/Base Sepolia",
132
+ "env": {}
98
133
  }
99
134
  ]
100
- }
135
+ }
@@ -0,0 +1,224 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Athena NFT Certificate Minter — MCP Tool
4
+ Mints ERC-1155 audit certificate NFTs on Sepolia/Base Sepolia.
5
+ """
6
+
7
+ import json
8
+ import os
9
+ import subprocess
10
+ import sys
11
+ from typing import Optional
12
+
13
+ # Contract addresses
14
+ CONTRACTS = {
15
+ "sepolia": "0x3247d57d37bd1878479f03a077aba807649dbaf5",
16
+ "base-sepolia": "0xb8f167a84816b5b9373997337119a2186c6e3708",
17
+ }
18
+
19
+ # Severity tiers: 1=S, 2=A, 3=B, 4=C
20
+ TIER_MAP = {"S": 1, "A": 2, "B": 3, "C": 4}
21
+
22
+
23
+ def build_tool_definitions() -> list:
24
+ return [
25
+ {
26
+ "name": "mint_audit_nft",
27
+ "description": "Mint an ERC-1155 audit certificate NFT. Requires a valid EAS attestation UID from a prior eas_attest step. The NFT tier (S/A/B/C) is determined by the audit severity.",
28
+ "inputSchema": {
29
+ "type": "object",
30
+ "properties": {
31
+ "eas_uid": {
32
+ "type": "string",
33
+ "description": "The EAS attestation UID (0x..., 66 chars) from the eas_attest step"
34
+ },
35
+ "tier": {
36
+ "type": "string",
37
+ "enum": ["S", "A", "B", "C"],
38
+ "description": "Audit certificate tier: S=critical findings, A=high, B=medium, C=low",
39
+ "default": "S"
40
+ },
41
+ "chain": {
42
+ "type": "string",
43
+ "enum": ["sepolia", "base-sepolia"],
44
+ "description": "Target chain (default: sepolia)",
45
+ "default": "sepolia"
46
+ },
47
+ "recipient": {
48
+ "type": "string",
49
+ "description": "Recipient address (0x...). Defaults to the deployer wallet."
50
+ }
51
+ },
52
+ "required": ["eas_uid"]
53
+ }
54
+ }
55
+ ]
56
+
57
+
58
+ def mint_nft(eas_uid: str, tier: str = "S", chain: str = "sepolia", recipient: Optional[str] = None) -> dict:
59
+ """Mint an audit certificate NFT."""
60
+ private_key = os.environ.get("SEPOLIA_PRIVATE_KEY") or os.environ.get("PRIVATE_KEY")
61
+ rpc_url = os.environ.get("SEPOLIA_RPC_URL") or os.environ.get("RPC_URL")
62
+
63
+ if not private_key:
64
+ return {"error": "SEPOLIA_PRIVATE_KEY not set"}
65
+ if not rpc_url:
66
+ return {"error": "SEPOLIA_RPC_URL not set"}
67
+
68
+ contract = CONTRACTS.get(chain)
69
+ if not contract:
70
+ return {"error": f"Unsupported chain: {chain}"}
71
+
72
+ # Validate UID format
73
+ if not eas_uid.startswith("0x") or len(eas_uid) != 66:
74
+ return {"error": f"Invalid EAS UID format: {eas_uid} (expected 0x + 64 hex chars)"}
75
+
76
+ tier_num = TIER_MAP.get(tier.upper(), 1)
77
+
78
+ # Get recipient address
79
+ if not recipient:
80
+ try:
81
+ result = subprocess.run(
82
+ ["cast", "wallet", "address", private_key],
83
+ capture_output=True, text=True, timeout=10
84
+ )
85
+ recipient = result.stdout.strip()
86
+ except Exception as e:
87
+ return {"error": f"Failed to get wallet address: {e}"}
88
+
89
+ # Build cast command
90
+ # mintCertificate(address to, bytes32 uid, uint8 tier)
91
+ cmd = [
92
+ "cast", "send", contract,
93
+ "mintCertificate(address,bytes32,uint8)",
94
+ recipient, eas_uid, str(tier_num),
95
+ "--rpc-url", rpc_url,
96
+ "--private-key", private_key
97
+ ]
98
+
99
+ try:
100
+ result = subprocess.run(cmd, capture_output=True, text=True, timeout=120)
101
+
102
+ if result.returncode != 0:
103
+ return {"error": f"cast send failed: {result.stderr}"}
104
+
105
+ # Extract tx hash from output
106
+ output = result.stdout + result.stderr
107
+ tx_hash = None
108
+ for line in output.split("\n"):
109
+ if "transactionHash" in line or "0x" in line:
110
+ import re
111
+ match = re.search(r'0x[0-9a-fA-F]{64}', line)
112
+ if match:
113
+ tx_hash = match.group(0)
114
+ break
115
+
116
+ # Get receipt
117
+ if tx_hash:
118
+ receipt_cmd = ["cast", "receipt", tx_hash, "--rpc-url", rpc_url]
119
+ receipt_result = subprocess.run(receipt_cmd, capture_output=True, text=True, timeout=30)
120
+ status = "success" if "status: 1" in receipt_result.stdout or "status: 0x1" in receipt_result.stdout else "failed"
121
+
122
+ explorer_base = "https://sepolia.etherscan.io" if chain == "sepolia" else "https://sepolia.basescan.org"
123
+
124
+ return {
125
+ "success": True,
126
+ "tx_hash": tx_hash,
127
+ "tx_url": f"{explorer_base}/tx/{tx_hash}",
128
+ "contract": contract,
129
+ "contract_url": f"{explorer_base}/address/{contract}",
130
+ "recipient": recipient,
131
+ "eas_uid": eas_uid,
132
+ "tier": tier.upper(),
133
+ "chain": chain,
134
+ "status": status,
135
+ "verify_command": f"cast call {contract} \"balanceOf(address,uint256)\" {recipient} 1 --rpc-url {rpc_url}"
136
+ }
137
+ else:
138
+ return {"error": f"Could not extract tx hash from output: {output}"}
139
+
140
+ except subprocess.TimeoutExpired:
141
+ return {"error": "Transaction timed out (120s)"}
142
+ except Exception as e:
143
+ return {"error": str(e)}
144
+
145
+
146
+ def handle_request(request: dict) -> dict:
147
+ """Handle JSON-RPC request."""
148
+ method = request.get("method")
149
+ params = request.get("params", {})
150
+ req_id = request.get("id", 1)
151
+
152
+ if method == "initialize":
153
+ return {
154
+ "jsonrpc": "2.0",
155
+ "id": req_id,
156
+ "result": {
157
+ "protocolVersion": "2024-11-05",
158
+ "capabilities": {"tools": {"listChanged": False}},
159
+ "serverInfo": {"name": "athena-nft-minter", "version": "1.0.0"}
160
+ }
161
+ }
162
+
163
+ elif method == "tools/list":
164
+ return {
165
+ "jsonrpc": "2.0",
166
+ "id": req_id,
167
+ "result": {"tools": build_tool_definitions()}
168
+ }
169
+
170
+ elif method == "tools/call":
171
+ tool_name = params.get("name")
172
+ args = params.get("arguments", {})
173
+
174
+ if tool_name == "mint_audit_nft":
175
+ result = mint_nft(**args)
176
+ return {
177
+ "jsonrpc": "2.0",
178
+ "id": req_id,
179
+ "result": {
180
+ "content": [{"type": "text", "text": json.dumps(result, indent=2)}],
181
+ "isError": not result.get("success", False)
182
+ }
183
+ }
184
+ else:
185
+ return {
186
+ "jsonrpc": "2.0",
187
+ "id": req_id,
188
+ "error": {"code": -32601, "message": f"Unknown tool: {tool_name}"}
189
+ }
190
+
191
+ elif method == "notifications/initialized":
192
+ return None # No response needed for notifications
193
+
194
+ else:
195
+ return {
196
+ "jsonrpc": "2.0",
197
+ "id": req_id,
198
+ "error": {"code": -32601, "message": f"Unknown method: {method}"}
199
+ }
200
+
201
+
202
+ def main():
203
+ """Main entry point — reads JSON-RPC from stdin, writes to stdout."""
204
+ for line in sys.stdin:
205
+ line = line.strip()
206
+ if not line:
207
+ continue
208
+
209
+ try:
210
+ request = json.loads(line)
211
+ response = handle_request(request)
212
+ if response is not None:
213
+ print(json.dumps(response), flush=True)
214
+ except json.JSONDecodeError:
215
+ error_response = {
216
+ "jsonrpc": "2.0",
217
+ "id": None,
218
+ "error": {"code": -32700, "message": "Parse error"}
219
+ }
220
+ print(json.dumps(error_response), flush=True)
221
+
222
+
223
+ if __name__ == "__main__":
224
+ main()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "athena-mcp",
3
- "version": "1.0.4",
3
+ "version": "1.0.7",
4
4
  "description": "Athena — Web3 smart contract security audit MCP tools + Skills for Claude Code",
5
5
  "main": "install.js",
6
6
  "bin": {