twzrd-mcp 0.1.0__tar.gz

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.
@@ -0,0 +1,113 @@
1
+ Metadata-Version: 2.4
2
+ Name: twzrd-mcp
3
+ Version: 0.1.0
4
+ Summary: Auto-pay MCP server for the TWZRD Trust API (Solana x402). Free preflight/lookup + auto-paid trust intel with spend caps. Payment path mainnet-proven via the official x402 SDK.
5
+ Author: TWZRD
6
+ License: MIT
7
+ Project-URL: Homepage, https://intel.twzrd.xyz
8
+ Project-URL: Repository, https://github.com/twzrd-sol/wzrd-final
9
+ Keywords: mcp,model-context-protocol,x402,solana,twzrd,trust,agent,auto-pay,reputation
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Topic :: Security
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+ Requires-Dist: mcp>=1.0
17
+ Requires-Dist: x402>=2.10
18
+ Requires-Dist: requests>=2.31
19
+ Requires-Dist: solders>=0.21
20
+
21
+ # twzrd-mcp-server - auto-pay MCP for the TWZRD Trust API
22
+
23
+ > Payment mechanism is mainnet-verified via the official x402 SDK (Python path,
24
+ > $0.001 moved 2026-06-26 - see Status). The bundled TypeScript path stays
25
+ > fail-closed until its hand-rolled header is replaced with the x402 JS SDK.
26
+
27
+ Auto-pay MCP server for TWZRD's Trust API, matching the competitor GTM shape
28
+ (anchor-x402, Br0ski777, BitBooth all ship one). An agent adds one `mcpServers`
29
+ entry; paid tool calls auto-handle the x402 challenge. Free tools never pay.
30
+
31
+ ## Why this is a corrected rebuild
32
+ A first draft signed **EIP-3009 on Base (EVM/viem)**. TWZRD settles x402 on
33
+ **Solana** (`scheme:"exact"`, USDC, sponsored `feePayer`) — the EVM scheme never
34
+ matches the challenge, so that draft could not pay TWZRD at all (it would `tsc`-pass
35
+ yet fail every real call). This version is Solana-native and **refuses** any
36
+ non-Solana challenge instead of mis-signing.
37
+
38
+ ## Safety guardrails (enforced before any signature)
39
+ - Per-call cap `TWZRD_MAX_USDC_PER_CALL` (default 0.05)
40
+ - Cumulative session cap `TWZRD_MAX_USDC_TOTAL` (default 1.00)
41
+ - Free discovery tools never enter the payment path
42
+ - No cross-chain fallback — a non-`exact`/non-`solana:` challenge is rejected
43
+ - Paid calls run the free preflight first; `decision=block` aborts the pay
44
+
45
+ ## Status — payment path VERIFIED on mainnet 2026-06-26
46
+
47
+ Two authorized settles from dev wallet `2pHjZLqs…`:
48
+
49
+ 1. **Hand-rolled `X-Payment` (this MCP's original approach): FAILED** — HTTP 402,
50
+ no USDC moved. The intel host validates via the official x402 lib's
51
+ `PaymentPayload`, so a hand-built header is rejected. (Green `tsc` ≠ settles —
52
+ fail-closed default was correct.)
53
+ 2. **Official x402 SDK: SUCCEEDED** — `GET /v1/intel/quick/CqtQPaAuQ5UR…` →
54
+ **HTTP 200, `"paid":true,"charged_amount_usdc":0.001`**, tier Silver score 53.6.
55
+ USDC balance moved `0.057236 → 0.056236` (exactly $0.001). A second call against
56
+ a no-data pubkey returned `422 charged:false` — the server's no-charge-on-empty
57
+ guard works.
58
+
59
+ **Conclusion: auto-pay works ONLY via the official x402 SDK, not a hand-rolled
60
+ header.** Proven client wiring (Python):
61
+
62
+ ```python
63
+ from x402.client import x402ClientSync
64
+ from x402.mechanisms.svm.signers import KeypairSigner
65
+ from x402.mechanisms.svm.exact import register_exact_svm_client
66
+ from x402.http.clients.requests import x402_requests
67
+ client = x402ClientSync()
68
+ register_exact_svm_client(client, KeypairSigner(keypair), rpc_url=RPC)
69
+ session = x402_requests(client)
70
+ session.get("https://intel.twzrd.xyz/v1/intel/quick/<wallet>") # auto-pays $0.001
71
+ ```
72
+
73
+ ### Remaining work for THIS (TypeScript) MCP
74
+ Replace the hand-rolled `payAndRetry` with the **x402 JS SDK** (SVM support) so the
75
+ TS path matches the verified Python path. Note the x402 lib also ships an MCP module
76
+ (`x402.mcp`) — a thin Python MCP over the proven client is the fastest route to a
77
+ shippable auto-pay server. Keep the spend caps + preflight gate + free/paid split.
78
+ Until the TS path is re-tested with the SDK it stays **fail-closed**; the **payment
79
+ mechanism itself is now proven**.
80
+
81
+ ## Install & Config
82
+
83
+ ### Python (recommended — the mainnet-proven path)
84
+ ```bash
85
+ pip install twzrd-mcp
86
+ ```
87
+ MCP client config (`mcpServers`):
88
+ ```json
89
+ { "mcpServers": { "twzrd": {
90
+ "command": "twzrd-mcp",
91
+ "env": {
92
+ "TWZRD_RPC_URL": "<your Solana RPC url>",
93
+ "TWZRD_WALLET_KEYPAIR": "/path/to/solana-keypair.json",
94
+ "TWZRD_MCP_PAYMENTS_ENABLED": "1",
95
+ "TWZRD_MAX_USDC_PER_CALL": "0.05",
96
+ "TWZRD_MAX_USDC_TOTAL": "1.00"
97
+ }
98
+ }}}
99
+ ```
100
+ The **free** tools (`preflight`, `wallet_lookup`) need no wallet and no flags — leave
101
+ `TWZRD_MCP_PAYMENTS_ENABLED` unset and they work read-only. Only the paid tools need
102
+ the keypair + `TWZRD_MCP_PAYMENTS_ENABLED=1`.
103
+
104
+ ### Node (`npx twzrd-mcp-server`) — not yet shippable
105
+ The bundled TypeScript path is **fail-closed** until its hand-rolled `X-Payment` header
106
+ is replaced with the x402 JS SDK (see Status). Use the Python package above for working
107
+ auto-pay today.
108
+
109
+ ## Tools
110
+ - `preflight` (free) — allow/warn/block + trust_score before you pay
111
+ - `wallet_lookup` (free) — facilitators + counterparty breadth for a Solana wallet
112
+ - `quick_trust` ($0.001, auto-pay) — quick tier + score
113
+ - `full_trust` ($0.05, auto-pay) — full trust intel + signed V6 receipt (verify offline with `twzrd-receipt-verifier`)
@@ -0,0 +1,93 @@
1
+ # twzrd-mcp-server - auto-pay MCP for the TWZRD Trust API
2
+
3
+ > Payment mechanism is mainnet-verified via the official x402 SDK (Python path,
4
+ > $0.001 moved 2026-06-26 - see Status). The bundled TypeScript path stays
5
+ > fail-closed until its hand-rolled header is replaced with the x402 JS SDK.
6
+
7
+ Auto-pay MCP server for TWZRD's Trust API, matching the competitor GTM shape
8
+ (anchor-x402, Br0ski777, BitBooth all ship one). An agent adds one `mcpServers`
9
+ entry; paid tool calls auto-handle the x402 challenge. Free tools never pay.
10
+
11
+ ## Why this is a corrected rebuild
12
+ A first draft signed **EIP-3009 on Base (EVM/viem)**. TWZRD settles x402 on
13
+ **Solana** (`scheme:"exact"`, USDC, sponsored `feePayer`) — the EVM scheme never
14
+ matches the challenge, so that draft could not pay TWZRD at all (it would `tsc`-pass
15
+ yet fail every real call). This version is Solana-native and **refuses** any
16
+ non-Solana challenge instead of mis-signing.
17
+
18
+ ## Safety guardrails (enforced before any signature)
19
+ - Per-call cap `TWZRD_MAX_USDC_PER_CALL` (default 0.05)
20
+ - Cumulative session cap `TWZRD_MAX_USDC_TOTAL` (default 1.00)
21
+ - Free discovery tools never enter the payment path
22
+ - No cross-chain fallback — a non-`exact`/non-`solana:` challenge is rejected
23
+ - Paid calls run the free preflight first; `decision=block` aborts the pay
24
+
25
+ ## Status — payment path VERIFIED on mainnet 2026-06-26
26
+
27
+ Two authorized settles from dev wallet `2pHjZLqs…`:
28
+
29
+ 1. **Hand-rolled `X-Payment` (this MCP's original approach): FAILED** — HTTP 402,
30
+ no USDC moved. The intel host validates via the official x402 lib's
31
+ `PaymentPayload`, so a hand-built header is rejected. (Green `tsc` ≠ settles —
32
+ fail-closed default was correct.)
33
+ 2. **Official x402 SDK: SUCCEEDED** — `GET /v1/intel/quick/CqtQPaAuQ5UR…` →
34
+ **HTTP 200, `"paid":true,"charged_amount_usdc":0.001`**, tier Silver score 53.6.
35
+ USDC balance moved `0.057236 → 0.056236` (exactly $0.001). A second call against
36
+ a no-data pubkey returned `422 charged:false` — the server's no-charge-on-empty
37
+ guard works.
38
+
39
+ **Conclusion: auto-pay works ONLY via the official x402 SDK, not a hand-rolled
40
+ header.** Proven client wiring (Python):
41
+
42
+ ```python
43
+ from x402.client import x402ClientSync
44
+ from x402.mechanisms.svm.signers import KeypairSigner
45
+ from x402.mechanisms.svm.exact import register_exact_svm_client
46
+ from x402.http.clients.requests import x402_requests
47
+ client = x402ClientSync()
48
+ register_exact_svm_client(client, KeypairSigner(keypair), rpc_url=RPC)
49
+ session = x402_requests(client)
50
+ session.get("https://intel.twzrd.xyz/v1/intel/quick/<wallet>") # auto-pays $0.001
51
+ ```
52
+
53
+ ### Remaining work for THIS (TypeScript) MCP
54
+ Replace the hand-rolled `payAndRetry` with the **x402 JS SDK** (SVM support) so the
55
+ TS path matches the verified Python path. Note the x402 lib also ships an MCP module
56
+ (`x402.mcp`) — a thin Python MCP over the proven client is the fastest route to a
57
+ shippable auto-pay server. Keep the spend caps + preflight gate + free/paid split.
58
+ Until the TS path is re-tested with the SDK it stays **fail-closed**; the **payment
59
+ mechanism itself is now proven**.
60
+
61
+ ## Install & Config
62
+
63
+ ### Python (recommended — the mainnet-proven path)
64
+ ```bash
65
+ pip install twzrd-mcp
66
+ ```
67
+ MCP client config (`mcpServers`):
68
+ ```json
69
+ { "mcpServers": { "twzrd": {
70
+ "command": "twzrd-mcp",
71
+ "env": {
72
+ "TWZRD_RPC_URL": "<your Solana RPC url>",
73
+ "TWZRD_WALLET_KEYPAIR": "/path/to/solana-keypair.json",
74
+ "TWZRD_MCP_PAYMENTS_ENABLED": "1",
75
+ "TWZRD_MAX_USDC_PER_CALL": "0.05",
76
+ "TWZRD_MAX_USDC_TOTAL": "1.00"
77
+ }
78
+ }}}
79
+ ```
80
+ The **free** tools (`preflight`, `wallet_lookup`) need no wallet and no flags — leave
81
+ `TWZRD_MCP_PAYMENTS_ENABLED` unset and they work read-only. Only the paid tools need
82
+ the keypair + `TWZRD_MCP_PAYMENTS_ENABLED=1`.
83
+
84
+ ### Node (`npx twzrd-mcp-server`) — not yet shippable
85
+ The bundled TypeScript path is **fail-closed** until its hand-rolled `X-Payment` header
86
+ is replaced with the x402 JS SDK (see Status). Use the Python package above for working
87
+ auto-pay today.
88
+
89
+ ## Tools
90
+ - `preflight` (free) — allow/warn/block + trust_score before you pay
91
+ - `wallet_lookup` (free) — facilitators + counterparty breadth for a Solana wallet
92
+ - `quick_trust` ($0.001, auto-pay) — quick tier + score
93
+ - `full_trust` ($0.05, auto-pay) — full trust intel + signed V6 receipt (verify offline with `twzrd-receipt-verifier`)
@@ -0,0 +1,113 @@
1
+ Metadata-Version: 2.4
2
+ Name: twzrd-mcp
3
+ Version: 0.1.0
4
+ Summary: Auto-pay MCP server for the TWZRD Trust API (Solana x402). Free preflight/lookup + auto-paid trust intel with spend caps. Payment path mainnet-proven via the official x402 SDK.
5
+ Author: TWZRD
6
+ License: MIT
7
+ Project-URL: Homepage, https://intel.twzrd.xyz
8
+ Project-URL: Repository, https://github.com/twzrd-sol/wzrd-final
9
+ Keywords: mcp,model-context-protocol,x402,solana,twzrd,trust,agent,auto-pay,reputation
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Topic :: Security
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+ Requires-Dist: mcp>=1.0
17
+ Requires-Dist: x402>=2.10
18
+ Requires-Dist: requests>=2.31
19
+ Requires-Dist: solders>=0.21
20
+
21
+ # twzrd-mcp-server - auto-pay MCP for the TWZRD Trust API
22
+
23
+ > Payment mechanism is mainnet-verified via the official x402 SDK (Python path,
24
+ > $0.001 moved 2026-06-26 - see Status). The bundled TypeScript path stays
25
+ > fail-closed until its hand-rolled header is replaced with the x402 JS SDK.
26
+
27
+ Auto-pay MCP server for TWZRD's Trust API, matching the competitor GTM shape
28
+ (anchor-x402, Br0ski777, BitBooth all ship one). An agent adds one `mcpServers`
29
+ entry; paid tool calls auto-handle the x402 challenge. Free tools never pay.
30
+
31
+ ## Why this is a corrected rebuild
32
+ A first draft signed **EIP-3009 on Base (EVM/viem)**. TWZRD settles x402 on
33
+ **Solana** (`scheme:"exact"`, USDC, sponsored `feePayer`) — the EVM scheme never
34
+ matches the challenge, so that draft could not pay TWZRD at all (it would `tsc`-pass
35
+ yet fail every real call). This version is Solana-native and **refuses** any
36
+ non-Solana challenge instead of mis-signing.
37
+
38
+ ## Safety guardrails (enforced before any signature)
39
+ - Per-call cap `TWZRD_MAX_USDC_PER_CALL` (default 0.05)
40
+ - Cumulative session cap `TWZRD_MAX_USDC_TOTAL` (default 1.00)
41
+ - Free discovery tools never enter the payment path
42
+ - No cross-chain fallback — a non-`exact`/non-`solana:` challenge is rejected
43
+ - Paid calls run the free preflight first; `decision=block` aborts the pay
44
+
45
+ ## Status — payment path VERIFIED on mainnet 2026-06-26
46
+
47
+ Two authorized settles from dev wallet `2pHjZLqs…`:
48
+
49
+ 1. **Hand-rolled `X-Payment` (this MCP's original approach): FAILED** — HTTP 402,
50
+ no USDC moved. The intel host validates via the official x402 lib's
51
+ `PaymentPayload`, so a hand-built header is rejected. (Green `tsc` ≠ settles —
52
+ fail-closed default was correct.)
53
+ 2. **Official x402 SDK: SUCCEEDED** — `GET /v1/intel/quick/CqtQPaAuQ5UR…` →
54
+ **HTTP 200, `"paid":true,"charged_amount_usdc":0.001`**, tier Silver score 53.6.
55
+ USDC balance moved `0.057236 → 0.056236` (exactly $0.001). A second call against
56
+ a no-data pubkey returned `422 charged:false` — the server's no-charge-on-empty
57
+ guard works.
58
+
59
+ **Conclusion: auto-pay works ONLY via the official x402 SDK, not a hand-rolled
60
+ header.** Proven client wiring (Python):
61
+
62
+ ```python
63
+ from x402.client import x402ClientSync
64
+ from x402.mechanisms.svm.signers import KeypairSigner
65
+ from x402.mechanisms.svm.exact import register_exact_svm_client
66
+ from x402.http.clients.requests import x402_requests
67
+ client = x402ClientSync()
68
+ register_exact_svm_client(client, KeypairSigner(keypair), rpc_url=RPC)
69
+ session = x402_requests(client)
70
+ session.get("https://intel.twzrd.xyz/v1/intel/quick/<wallet>") # auto-pays $0.001
71
+ ```
72
+
73
+ ### Remaining work for THIS (TypeScript) MCP
74
+ Replace the hand-rolled `payAndRetry` with the **x402 JS SDK** (SVM support) so the
75
+ TS path matches the verified Python path. Note the x402 lib also ships an MCP module
76
+ (`x402.mcp`) — a thin Python MCP over the proven client is the fastest route to a
77
+ shippable auto-pay server. Keep the spend caps + preflight gate + free/paid split.
78
+ Until the TS path is re-tested with the SDK it stays **fail-closed**; the **payment
79
+ mechanism itself is now proven**.
80
+
81
+ ## Install & Config
82
+
83
+ ### Python (recommended — the mainnet-proven path)
84
+ ```bash
85
+ pip install twzrd-mcp
86
+ ```
87
+ MCP client config (`mcpServers`):
88
+ ```json
89
+ { "mcpServers": { "twzrd": {
90
+ "command": "twzrd-mcp",
91
+ "env": {
92
+ "TWZRD_RPC_URL": "<your Solana RPC url>",
93
+ "TWZRD_WALLET_KEYPAIR": "/path/to/solana-keypair.json",
94
+ "TWZRD_MCP_PAYMENTS_ENABLED": "1",
95
+ "TWZRD_MAX_USDC_PER_CALL": "0.05",
96
+ "TWZRD_MAX_USDC_TOTAL": "1.00"
97
+ }
98
+ }}}
99
+ ```
100
+ The **free** tools (`preflight`, `wallet_lookup`) need no wallet and no flags — leave
101
+ `TWZRD_MCP_PAYMENTS_ENABLED` unset and they work read-only. Only the paid tools need
102
+ the keypair + `TWZRD_MCP_PAYMENTS_ENABLED=1`.
103
+
104
+ ### Node (`npx twzrd-mcp-server`) — not yet shippable
105
+ The bundled TypeScript path is **fail-closed** until its hand-rolled `X-Payment` header
106
+ is replaced with the x402 JS SDK (see Status). Use the Python package above for working
107
+ auto-pay today.
108
+
109
+ ## Tools
110
+ - `preflight` (free) — allow/warn/block + trust_score before you pay
111
+ - `wallet_lookup` (free) — facilitators + counterparty breadth for a Solana wallet
112
+ - `quick_trust` ($0.001, auto-pay) — quick tier + score
113
+ - `full_trust` ($0.05, auto-pay) — full trust intel + signed V6 receipt (verify offline with `twzrd-receipt-verifier`)
@@ -0,0 +1,9 @@
1
+ README.md
2
+ pyproject.toml
3
+ py/twzrd_mcp.py
4
+ py/twzrd_mcp.egg-info/PKG-INFO
5
+ py/twzrd_mcp.egg-info/SOURCES.txt
6
+ py/twzrd_mcp.egg-info/dependency_links.txt
7
+ py/twzrd_mcp.egg-info/entry_points.txt
8
+ py/twzrd_mcp.egg-info/requires.txt
9
+ py/twzrd_mcp.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ twzrd-mcp = twzrd_mcp:main
@@ -0,0 +1,4 @@
1
+ mcp>=1.0
2
+ x402>=2.10
3
+ requests>=2.31
4
+ solders>=0.21
@@ -0,0 +1 @@
1
+ twzrd_mcp
@@ -0,0 +1,135 @@
1
+ #!/usr/bin/env python3
2
+ """TWZRD auto-pay MCP server (Python, Solana x402) — the VERIFIED shippable path.
3
+
4
+ Uses the official x402 SDK client (ExactSvmClientScheme + KeypairSigner +
5
+ x402_requests) — the exact wiring proven on mainnet 2026-06-26 ($0.001 settle,
6
+ HTTP 200, paid:true). This is the part the hand-rolled TS draft got wrong: only
7
+ the SDK produces a PaymentPayload the intel host accepts.
8
+
9
+ Free tools never pay. Paid tools auto-pay via x402 with spend caps + preflight.
10
+
11
+ ENV:
12
+ TWZRD_WALLET_KEYPAIR path to a Solana keypair json (default ~/.config/solana/id.json)
13
+ TWZRD_RPC_URL Solana RPC (required for signing)
14
+ TWZRD_API_URL default https://intel.twzrd.xyz
15
+ TWZRD_MAX_USDC_PER_CALL default 0.05
16
+ TWZRD_MAX_USDC_TOTAL default 1.00
17
+ TWZRD_MCP_PAYMENTS_ENABLED "1" to enable signing
18
+ """
19
+ from __future__ import annotations
20
+
21
+ import asyncio
22
+ import json
23
+ import os
24
+
25
+ import requests
26
+ from mcp.server import Server
27
+ from mcp.server.stdio import stdio_server
28
+ from mcp.types import TextContent, Tool
29
+
30
+ API_BASE = os.environ.get("TWZRD_API_URL", "https://intel.twzrd.xyz")
31
+ MAX_PER_CALL = float(os.environ.get("TWZRD_MAX_USDC_PER_CALL", "0.05"))
32
+ MAX_TOTAL = float(os.environ.get("TWZRD_MAX_USDC_TOTAL", "1.00"))
33
+ PAYMENTS_ENABLED = os.environ.get("TWZRD_MCP_PAYMENTS_ENABLED") == "1"
34
+
35
+ _paid_session: requests.Session | None = None
36
+ _spent = 0.0
37
+
38
+
39
+ def _build_paid_session() -> requests.Session:
40
+ """The verified x402 client wiring (mainnet-proven)."""
41
+ from solders.keypair import Keypair
42
+ from x402.client import x402ClientSync
43
+ from x402.mechanisms.svm.exact import register_exact_svm_client
44
+ from x402.mechanisms.svm.signers import KeypairSigner
45
+ from x402.http.clients.requests import x402_requests
46
+
47
+ kp_path = os.environ.get("TWZRD_WALLET_KEYPAIR", os.path.expanduser("~/.config/solana/id.json"))
48
+ rpc = os.environ.get("TWZRD_RPC_URL")
49
+ if not rpc:
50
+ raise RuntimeError("TWZRD_RPC_URL required for x402 signing")
51
+ kp = Keypair.from_bytes(bytes(json.load(open(kp_path))))
52
+ client = x402ClientSync()
53
+ register_exact_svm_client(client, KeypairSigner(kp), rpc_url=rpc)
54
+ return x402_requests(client)
55
+
56
+
57
+ def _paid_get(path: str) -> str:
58
+ global _paid_session, _spent
59
+ if not PAYMENTS_ENABLED:
60
+ raise RuntimeError("Auto-pay disabled. Set TWZRD_MCP_PAYMENTS_ENABLED=1 to enable signing.")
61
+ # Per-call cap is enforced by refusing endpoints we know exceed it; cumulative
62
+ # cap is checked against MAX_TOTAL before the call. (Quick=$0.001, full=$0.05.)
63
+ price = 0.05 if "/trust/" in path else 0.001
64
+ if price > MAX_PER_CALL:
65
+ raise RuntimeError(f"Refusing: ${price} exceeds per-call cap ${MAX_PER_CALL}")
66
+ if _spent + price > MAX_TOTAL:
67
+ raise RuntimeError(f"Refusing: would exceed session cap ${MAX_TOTAL} (spent ${_spent})")
68
+ if _paid_session is None:
69
+ _paid_session = _build_paid_session()
70
+ r = _paid_session.get(f"{API_BASE}{path}", timeout=90)
71
+ body = r.text
72
+ # Only count spend when the server actually charged (it returns charged_amount_usdc).
73
+ try:
74
+ if json.loads(body).get("paid"):
75
+ _spent += float(json.loads(body).get("charged_amount_usdc", price))
76
+ except Exception:
77
+ pass
78
+ return body
79
+
80
+
81
+ def _free(method: str, path: str, payload: dict | None = None) -> str:
82
+ if method == "POST":
83
+ return requests.post(f"{API_BASE}{path}", json=payload, timeout=30).text
84
+ return requests.get(f"{API_BASE}{path}", timeout=30).text
85
+
86
+
87
+ app = Server("twzrd-mcp-server")
88
+
89
+ TOOLS = [
90
+ Tool(name="preflight", description="FREE pre-pay check: allow/warn/block + trust_score.", inputSchema={"type": "object", "properties": {"seller_wallet": {"type": "string"}, "price_usdc": {"type": "number"}}, "required": ["seller_wallet"]}),
91
+ Tool(name="wallet_lookup", description="FREE: facilitators + counterparty breadth for a Solana wallet.", inputSchema={"type": "object", "properties": {"wallet": {"type": "string"}}, "required": ["wallet"]}),
92
+ Tool(name="quick_trust", description="PAID $0.001 (auto-pay x402, Solana): quick tier+score for a wallet.", inputSchema={"type": "object", "properties": {"wallet": {"type": "string"}}, "required": ["wallet"]}),
93
+ Tool(name="full_trust", description="PAID $0.05 (auto-pay x402, Solana): full trust intel + signed V6 receipt.", inputSchema={"type": "object", "properties": {"wallet": {"type": "string"}, "seller_wallet": {"type": "string"}}, "required": ["wallet"]}),
94
+ ]
95
+
96
+
97
+ @app.list_tools()
98
+ async def list_tools() -> list[Tool]:
99
+ return TOOLS
100
+
101
+
102
+ @app.call_tool()
103
+ async def call_tool(name: str, arguments: dict) -> list[TextContent]:
104
+ a = arguments or {}
105
+ if name == "preflight":
106
+ out = _free("POST", "/v1/intel/preflight", {"seller_wallet": a.get("seller_wallet"), "resource_name": "MCP", "price_usdc": a.get("price_usdc", 0.05)})
107
+ elif name == "wallet_lookup":
108
+ out = _free("GET", f"/v1/intel/get_facilitator_footprint?wallet={a['wallet']}")
109
+ elif name in ("quick_trust", "full_trust"):
110
+ # Preflight gate before paying (advisory; block aborts).
111
+ try:
112
+ card = json.loads(_free("POST", "/v1/intel/preflight", {"seller_wallet": a["wallet"], "resource_name": name, "price_usdc": 0.05 if name == "full_trust" else 0.001}))
113
+ if card.get("readiness_card", {}).get("decision") == "block":
114
+ return [TextContent(type="text", text=json.dumps({"refused": "preflight decision=block"}))]
115
+ except Exception:
116
+ pass
117
+ path = f"/v1/intel/quick/{a['wallet']}" if name == "quick_trust" else f"/v1/intel/trust/{a['wallet']}" + (f"?seller_wallet={a['seller_wallet']}" if a.get("seller_wallet") else "")
118
+ out = _paid_get(path)
119
+ else:
120
+ raise ValueError(f"Unknown tool: {name}")
121
+ return [TextContent(type="text", text=out)]
122
+
123
+
124
+ async def _main() -> None:
125
+ async with stdio_server() as (r, w):
126
+ await app.run(r, w, app.create_initialization_options())
127
+
128
+
129
+ def main() -> None:
130
+ """Console-script entry point (`twzrd-mcp`). Runs the stdio MCP server."""
131
+ asyncio.run(_main())
132
+
133
+
134
+ if __name__ == "__main__":
135
+ main()
@@ -0,0 +1,38 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "twzrd-mcp"
7
+ version = "0.1.0"
8
+ description = "Auto-pay MCP server for the TWZRD Trust API (Solana x402). Free preflight/lookup + auto-paid trust intel with spend caps. Payment path mainnet-proven via the official x402 SDK."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "TWZRD" }]
13
+ keywords = ["mcp", "model-context-protocol", "x402", "solana", "twzrd", "trust", "agent", "auto-pay", "reputation"]
14
+ dependencies = [
15
+ "mcp>=1.0",
16
+ "x402>=2.10",
17
+ "requests>=2.31",
18
+ "solders>=0.21",
19
+ ]
20
+ classifiers = [
21
+ "License :: OSI Approved :: MIT License",
22
+ "Programming Language :: Python :: 3",
23
+ "Intended Audience :: Developers",
24
+ "Topic :: Security",
25
+ ]
26
+
27
+ [project.urls]
28
+ Homepage = "https://intel.twzrd.xyz"
29
+ Repository = "https://github.com/twzrd-sol/wzrd-final"
30
+
31
+ [project.scripts]
32
+ twzrd-mcp = "twzrd_mcp:main"
33
+
34
+ [tool.setuptools]
35
+ py-modules = ["twzrd_mcp"]
36
+
37
+ [tool.setuptools.package-dir]
38
+ "" = "py"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+