keryx-mcp 0.1.0 → 0.1.1

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
@@ -1,74 +1,74 @@
1
- # Keryx MCP server — add Keryx to any agent
2
-
3
- Give any MCP-capable agent (Claude Code, Claude Desktop, Cursor, …) a tool that asks **Keryx** a
4
- question. Keryx autonomously buys paid sources under a budget, answers with inline citations, and
5
- **pays every creator it cites** in USDC on Arc. The toll for each call is paid from *your own*
6
- Arc-testnet wallet — so every call is a real on-chain payment, visible live on
7
- [keryx.cc/dashboard](https://keryx.cc/dashboard).
8
-
9
- ## Tools
10
-
11
- | Tool | What it does |
12
- |------|--------------|
13
- | `ask_keryx` | Ask a research question (+ optional USDC `budget`). Returns a cited answer and the creators Keryx paid downstream. Costs **0.02 USDC** per call, paid from your wallet. |
14
- | `keryx_wallet_status` | Show the wallet this server pays from — address, balances, whether it's ready, and how to fund it. **Run this first.** |
15
-
16
- ## Setup (≈3 minutes)
17
-
18
- Published to npm as [`keryx-mcp`](https://www.npmjs.com/package/keryx-mcp) — no clone, no build.
19
-
20
- ### Add it to Claude Code (one line)
21
-
22
- ```bash
23
- claude mcp add keryx -- npx -y keryx-mcp@latest
24
- ```
25
-
26
- ### Or add it to any MCP client (Claude Desktop, Cursor, Windsurf, …)
27
-
28
- ```json
29
- {
30
- "mcpServers": {
31
- "keryx": {
32
- "command": "npx",
33
- "args": ["-y", "keryx-mcp@latest"]
34
- }
35
- }
36
- }
37
- ```
38
-
39
- ### Fund the wallet, then ask
40
-
41
- 1. Call **`keryx_wallet_status`** — it prints the wallet address it pays from.
42
- 2. Open the [Circle faucet](https://faucet.circle.com), pick **Arc Testnet**, paste that address.
43
- (20 USDC / 2h — also covers gas.)
44
- 3. Call **`ask_keryx`** with your question. The server deposits to Circle Gateway on the first call
45
- and pays the toll; Keryx researches, answers with citations, and pays the creators it cited.
46
-
47
- That's it — the answer comes back with the on-chain payment proof and a link to the live dashboard
48
- where your call now appears as external traction.
49
-
50
- ## Configuration (env)
51
-
52
- All optional — sane Arc-testnet defaults are built in.
53
-
54
- | Var | Default | Purpose |
55
- |-----|---------|---------|
56
- | `KERYX_BASE_URL` | `https://keryx.cc` | Keryx deployment to call. |
57
- | `KERYX_BUYER_PRIVATE_KEY` | *(generated)* | Bring your own funded Arc wallet instead of the generated one. |
58
- | `KERYX_WALLET_FILE` | `~/.keryx/buyer-wallet.json` | Where the generated wallet is persisted. |
59
- | `KERYX_GATEWAY_DEPOSIT` | `0.5` | USDC moved into Gateway per top-up. |
60
- | `KERYX_RPC_URL` | `https://rpc.testnet.arc.network` | Arc testnet RPC. |
61
-
62
- > **Real money, testnet.** Calls settle real USDC on Arc testnet. The generated wallet holds only
63
- > what you faucet into it; Keryx never touches your keys. To go mainnet, point `KERYX_BASE_URL` at a
64
- > mainnet deployment and fund with real USDC — only with eyes open.
65
-
66
- ## From source (development)
67
-
68
- ```bash
69
- git clone https://github.com/tang-vu/keryx && cd keryx && npm install
70
- claude mcp add keryx -- node --import tsx --no-warnings "$(pwd)/mcp/keryx-mcp-server.mts"
71
- ```
72
-
73
- `npm run build` (in `mcp/`) bundles `keryx-mcp-server.mts` → `dist/keryx-mcp.mjs` with esbuild; that
74
- single file is what ships to npm and runs under plain `node`.
1
+ # Keryx MCP server — add Keryx to any agent
2
+
3
+ Give any MCP-capable agent (Claude Code, Claude Desktop, Cursor, …) a tool that asks **Keryx** a
4
+ question. Keryx autonomously buys paid sources under a budget, answers with inline citations, and
5
+ **pays every creator it cites** in USDC on Arc. The toll for each call is paid from *your own*
6
+ Arc-testnet wallet — so every call is a real on-chain payment, visible live on
7
+ [keryx.cc/dashboard](https://keryx.cc/dashboard).
8
+
9
+ ## Tools
10
+
11
+ | Tool | What it does |
12
+ |------|--------------|
13
+ | `ask_keryx` | Ask a research question (+ optional USDC `budget`). Returns a cited answer and the creators Keryx paid downstream. Costs **0.02 USDC** per call, paid from your wallet. |
14
+ | `keryx_wallet_status` | Show the wallet this server pays from — address, balances, whether it's ready, and how to fund it. **Run this first.** |
15
+
16
+ ## Setup (≈3 minutes)
17
+
18
+ Published to npm as [`keryx-mcp`](https://www.npmjs.com/package/keryx-mcp) — no clone, no build.
19
+
20
+ ### Add it to Claude Code (one line)
21
+
22
+ ```bash
23
+ claude mcp add keryx -- npx -y keryx-mcp@latest
24
+ ```
25
+
26
+ ### Or add it to any MCP client (Claude Desktop, Cursor, Windsurf, …)
27
+
28
+ ```json
29
+ {
30
+ "mcpServers": {
31
+ "keryx": {
32
+ "command": "npx",
33
+ "args": ["-y", "keryx-mcp@latest"]
34
+ }
35
+ }
36
+ }
37
+ ```
38
+
39
+ ### Fund the wallet, then ask
40
+
41
+ 1. Call **`keryx_wallet_status`** — it prints the wallet address it pays from.
42
+ 2. Open the [Circle faucet](https://faucet.circle.com), pick **Arc Testnet**, paste that address.
43
+ (20 USDC / 2h — also covers gas.)
44
+ 3. Call **`ask_keryx`** with your question. The server deposits to Circle Gateway on the first call
45
+ and pays the toll; Keryx researches, answers with citations, and pays the creators it cited.
46
+
47
+ That's it — the answer comes back with the on-chain payment proof and a link to the live dashboard
48
+ where your call now appears as external traction.
49
+
50
+ ## Configuration (env)
51
+
52
+ All optional — sane Arc-testnet defaults are built in.
53
+
54
+ | Var | Default | Purpose |
55
+ |-----|---------|---------|
56
+ | `KERYX_BASE_URL` | `https://keryx.cc` | Keryx deployment to call. |
57
+ | `KERYX_BUYER_PRIVATE_KEY` | *(generated)* | Bring your own funded Arc wallet instead of the generated one. |
58
+ | `KERYX_WALLET_FILE` | `~/.keryx/buyer-wallet.json` | Where the generated wallet is persisted. |
59
+ | `KERYX_GATEWAY_DEPOSIT` | `0.5` | USDC moved into Gateway per top-up. |
60
+ | `KERYX_RPC_URL` | `https://rpc.testnet.arc.network` | Arc testnet RPC. |
61
+
62
+ > **Real money, testnet.** Calls settle real USDC on Arc testnet. The generated wallet holds only
63
+ > what you faucet into it; Keryx never touches your keys. To go mainnet, point `KERYX_BASE_URL` at a
64
+ > mainnet deployment and fund with real USDC — only with eyes open.
65
+
66
+ ## From source (development)
67
+
68
+ ```bash
69
+ git clone https://github.com/tang-vu/keryx && cd keryx && npm install
70
+ claude mcp add keryx -- node --import tsx --no-warnings "$(pwd)/mcp/keryx-mcp-server.mts"
71
+ ```
72
+
73
+ `npm run build` (in `mcp/`) bundles `keryx-mcp-server.mts` → `dist/keryx-mcp.mjs` with esbuild; that
74
+ single file is what ships to npm and runs under plain `node`.
@@ -51,6 +51,31 @@ var meta = {
51
51
  };
52
52
  var fee = parseUnits(String(FEE_USDC), 6);
53
53
  var deposit = parseUnits(DEPOSIT_USDC, 6);
54
+ var ONRAMP_URL = `${BASE_URL}/api/faucet/onramp`;
55
+ async function tryOnramp() {
56
+ try {
57
+ await fetch(ONRAMP_URL, {
58
+ method: "POST",
59
+ headers: { "content-type": "application/json" },
60
+ body: JSON.stringify({ address: account.address })
61
+ });
62
+ } catch {
63
+ }
64
+ }
65
+ async function waitForErc20(min) {
66
+ let bal = 0n;
67
+ for (let i = 0; i < 10; i++) {
68
+ bal = await pub.readContract({
69
+ address: USDC,
70
+ abi: erc20Abi,
71
+ functionName: "balanceOf",
72
+ args: [account.address]
73
+ });
74
+ if (bal >= min) return bal;
75
+ await new Promise((r) => setTimeout(r, 3e3));
76
+ }
77
+ return bal;
78
+ }
54
79
  async function readBalances() {
55
80
  const [gas, erc20, bal] = await Promise.all([
56
81
  pub.getBalance({ address: account.address }),
@@ -76,10 +101,7 @@ async function getStatus() {
76
101
  } else if (erc20 >= deposit) {
77
102
  instructions = `You hold ${formatUnits(erc20, 6)} USDC but no gas to deposit it. Fund ${account.address} with a little Arc-testnet gas at ${FAUCET} (Arc Testnet), then retry.`;
78
103
  } else {
79
- instructions = `Fund this address with Arc-testnet USDC, then call again:
80
- 1. Open ${FAUCET} \u2192 select Arc Testnet \u2192 paste ${account.address}
81
- 2. The faucet sends test USDC (also covers gas).
82
- Each Keryx call costs ${FEE_USDC} USDC, paid from YOUR wallet \u2014 visible live on ${BASE_URL}/dashboard.`;
104
+ instructions = `No testnet USDC yet \u2014 just call ask_keryx: it AUTO-FUNDS this wallet once from the Keryx onramp (no Circle faucet needed), then pays the toll from YOUR wallet. If the onramp is tapped out (daily cap), fund ${account.address} at ${FAUCET} (Arc Testnet). Each call costs ${FEE_USDC} USDC, paid from YOUR wallet \u2014 visible live on ${BASE_URL}/dashboard.`;
83
105
  }
84
106
  return {
85
107
  address: account.address,
@@ -93,16 +115,20 @@ Each Keryx call costs ${FEE_USDC} USDC, paid from YOUR wallet \u2014 visible liv
93
115
  async function ensureFunded() {
94
116
  const first = await gateway.getBalances();
95
117
  if (first.gateway.available >= fee) return;
96
- const erc20 = await pub.readContract({
118
+ let erc20 = await pub.readContract({
97
119
  address: USDC,
98
120
  abi: erc20Abi,
99
121
  functionName: "balanceOf",
100
122
  args: [account.address]
101
123
  });
102
124
  if (erc20 < deposit) {
103
- throw new Error(
104
- `Insufficient testnet USDC. Fund ${account.address} at ${FAUCET} (Arc Testnet), then retry. Need \u2265 ${DEPOSIT_USDC} USDC (have ${formatUnits(erc20, 6)}).`
105
- );
125
+ await tryOnramp();
126
+ erc20 = await waitForErc20(deposit);
127
+ if (erc20 < deposit) {
128
+ throw new Error(
129
+ `Insufficient testnet USDC and the Keryx onramp didn't land (already used or daily cap). Fund ${account.address} at ${FAUCET} (Arc Testnet), then retry. Need \u2265 ${DEPOSIT_USDC} USDC (have ${formatUnits(erc20, 6)}).`
130
+ );
131
+ }
106
132
  }
107
133
  await gateway.deposit(DEPOSIT_USDC);
108
134
  for (let i = 0; i < 30; i++) {
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "keryx-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
+ "mcpName": "io.github.tang-vu/keryx",
4
5
  "description": "Add Keryx to any MCP agent — ask a research question, pay the x402 toll from your own Arc wallet, and Keryx answers with citations and pays every creator it cites in USDC on Arc.",
5
6
  "type": "module",
6
7
  "bin": {