autonomo-mcp 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +91 -3
- package/index.mjs +304 -0
- package/package.json +42 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Autonomo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,91 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# Autonomo MCP server
|
|
2
|
+
|
|
3
|
+
Give Claude, Codex, Cursor or any MCP client access to Autonomo's paid APIs. The agent finds an API, checks the
|
|
4
|
+
price and pays per call with x402, in USDG or $AUTONOMO on Robinhood Chain. No API keys and no account: just a wallet.
|
|
5
|
+
|
|
6
|
+
The server runs on your own computer. Your wallet key stays there and is only used to sign payments.
|
|
7
|
+
|
|
8
|
+
## Tools
|
|
9
|
+
|
|
10
|
+
| Tool | What it does | Costs |
|
|
11
|
+
| --- | --- | --- |
|
|
12
|
+
| `find_apis` | Search Autonomo's APIs (token prices, launches, rug risk, wallets, transactions, page reader). Optionally also the directory of 3.7K x402 projects. | Free |
|
|
13
|
+
| `get_price` | Call an API without paying and show its price. | Free |
|
|
14
|
+
| `call_api` | Pay for one call and return the answer, with the payment link on Blockscout. | Usually 0.01 USDG or 100 $AUTONOMO |
|
|
15
|
+
|
|
16
|
+
## Setup
|
|
17
|
+
|
|
18
|
+
1. Make a **new wallet just for your agent**, and send it a little USDG (1 USDG is 100 calls) or $AUTONOMO on
|
|
19
|
+
Robinhood Chain. Paying in $AUTONOMO needs a little ETH once, for the Permit2 approval.
|
|
20
|
+
2. Add the server to your client (below), with that wallet's private key as `AUTONOMO_WALLET_KEY`.
|
|
21
|
+
3. Ask: "Is token 0x… safe? Use Autonomo."
|
|
22
|
+
|
|
23
|
+
Without a key, `find_apis` and `get_price` still work.
|
|
24
|
+
|
|
25
|
+
### Claude Code
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
claude mcp add autonomo -e AUTONOMO_WALLET_KEY=0xYOUR_AGENT_WALLET_KEY -- npx -y autonomo-mcp
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
On Windows, start `npx` through `cmd /c`. In PowerShell, quote the `--`:
|
|
32
|
+
|
|
33
|
+
```powershell
|
|
34
|
+
claude mcp add autonomo -e AUTONOMO_WALLET_KEY=0xYOUR_AGENT_WALLET_KEY '--' cmd /c npx -y autonomo-mcp
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Claude Desktop, Cursor and others
|
|
38
|
+
|
|
39
|
+
Add this to the client's MCP config (`claude_desktop_config.json`, `.cursor/mcp.json`, …):
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"mcpServers": {
|
|
44
|
+
"autonomo": {
|
|
45
|
+
"command": "npx",
|
|
46
|
+
"args": ["-y", "autonomo-mcp"],
|
|
47
|
+
"env": { "AUTONOMO_WALLET_KEY": "0xYOUR_AGENT_WALLET_KEY" }
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
If the client can't find `npx` on Windows, use `"command": "cmd"` and `"args": ["/c", "npx", "-y", "autonomo-mcp"]`.
|
|
54
|
+
|
|
55
|
+
### Codex
|
|
56
|
+
|
|
57
|
+
In `~/.codex/config.toml`:
|
|
58
|
+
|
|
59
|
+
```toml
|
|
60
|
+
[mcp_servers.autonomo]
|
|
61
|
+
command = "npx"
|
|
62
|
+
args = ["-y", "autonomo-mcp"]
|
|
63
|
+
env = { AUTONOMO_WALLET_KEY = "0xYOUR_AGENT_WALLET_KEY" }
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Settings
|
|
67
|
+
|
|
68
|
+
| Env var | Default | Meaning |
|
|
69
|
+
| --- | --- | --- |
|
|
70
|
+
| `AUTONOMO_WALLET_KEY` | none | Private key of the agent's wallet. Needed only for `call_api`. |
|
|
71
|
+
| `AUTONOMO_PAY_WITH` | `usdg` | `usdg` or `autonomo`, the token used when the agent doesn't say. |
|
|
72
|
+
| `AUTONOMO_DAILY_USDG` | `1` | Most USDG the server will spend per UTC day. |
|
|
73
|
+
| `AUTONOMO_DAILY_AUTONOMO` | `10000` | Most $AUTONOMO the server will spend per UTC day. |
|
|
74
|
+
| `AUTONOMO_BASE_URL` | `https://autonomo.fun` | Only for testing against a local copy of the site. |
|
|
75
|
+
|
|
76
|
+
## Safety
|
|
77
|
+
|
|
78
|
+
- It only pays Autonomo gateways (`autonomo.fun/x/...`), and only in USDG or $AUTONOMO on Robinhood Chain.
|
|
79
|
+
- Each call is capped at 0.05 USDG or 5,000 $AUTONOMO, whatever the API asks.
|
|
80
|
+
- The daily budget is tracked in `~/.autonomo-mcp/spend.json`.
|
|
81
|
+
- Your MCP client asks before each tool call, so you approve every payment unless you choose to allow it always.
|
|
82
|
+
- Use a dedicated wallet with a small balance, never your main wallet.
|
|
83
|
+
|
|
84
|
+
## Develop
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npm install
|
|
88
|
+
npm run inspect
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`npm run inspect` opens the MCP Inspector so you can try the tools by hand.
|
package/index.mjs
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Autonomo MCP server: lets Claude, Codex, Cursor and other MCP clients find Autonomo x402 APIs, check the price
|
|
3
|
+
// and pay per call in USDG or $AUTONOMO on Robinhood Chain, from a wallet the user controls.
|
|
4
|
+
//
|
|
5
|
+
// Tools: find_apis (free), get_price (free), call_api (pays). Runs locally over stdio, so the wallet key never
|
|
6
|
+
// leaves this machine except as signed payments. Settings come from env vars (see README.md). Never write to
|
|
7
|
+
// stdout here: it carries the MCP protocol, so logs go to stderr.
|
|
8
|
+
|
|
9
|
+
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
10
|
+
import { homedir } from "node:os";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
13
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
14
|
+
import { createPublicClient, createWalletClient, defineChain, erc20Abi, formatUnits, http, maxUint256, parseUnits } from "viem";
|
|
15
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
16
|
+
import { x402Client } from "@x402/core/client";
|
|
17
|
+
import { toClientEvmSigner } from "@x402/evm";
|
|
18
|
+
import { ExactEvmScheme } from "@x402/evm/exact/client";
|
|
19
|
+
import { wrapFetchWithPayment } from "@x402/fetch";
|
|
20
|
+
import { z } from "zod";
|
|
21
|
+
|
|
22
|
+
const VERSION = "0.1.1";
|
|
23
|
+
const BASE = (process.env.AUTONOMO_BASE_URL || "https://autonomo.fun").replace(/\/+$/, "");
|
|
24
|
+
const NETWORK = "eip155:4663";
|
|
25
|
+
const RPC = "https://rpc.mainnet.chain.robinhood.com";
|
|
26
|
+
const EXPLORER = "https://robinhoodchain.blockscout.com";
|
|
27
|
+
const PERMIT2 = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
28
|
+
|
|
29
|
+
// The two tokens this server pays with, each with a hard cap per call and a daily budget (env overrides).
|
|
30
|
+
const TOKENS = {
|
|
31
|
+
usdg: {
|
|
32
|
+
symbol: "USDG",
|
|
33
|
+
address: "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",
|
|
34
|
+
decimals: 6,
|
|
35
|
+
cap: parseUnits("0.05", 6),
|
|
36
|
+
daily: parseUnits(process.env.AUTONOMO_DAILY_USDG || "1", 6),
|
|
37
|
+
},
|
|
38
|
+
autonomo: {
|
|
39
|
+
symbol: "AUTONOMO",
|
|
40
|
+
address: "0xe83c85e1ead16fcfe85401e2b337fb4fb5b5cc96",
|
|
41
|
+
decimals: 18,
|
|
42
|
+
cap: parseUnits("5000", 18),
|
|
43
|
+
daily: parseUnits(process.env.AUTONOMO_DAILY_AUTONOMO || "10000", 18),
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
const DEFAULT_PAY = (process.env.AUTONOMO_PAY_WITH || "usdg").toLowerCase() === "autonomo" ? "autonomo" : "usdg";
|
|
47
|
+
|
|
48
|
+
const robinhood = defineChain({
|
|
49
|
+
id: 4663,
|
|
50
|
+
name: "Robinhood Chain",
|
|
51
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
52
|
+
rpcUrls: { default: { http: [RPC] } },
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
class Stop extends Error {}
|
|
56
|
+
const fail = (message) => {
|
|
57
|
+
throw new Stop(message);
|
|
58
|
+
};
|
|
59
|
+
const decode = (h) => (h ? JSON.parse(Buffer.from(h, "base64").toString("utf8")) : null);
|
|
60
|
+
const tokenOf = (asset) => Object.values(TOKENS).find((t) => t.address.toLowerCase() === String(asset).toLowerCase());
|
|
61
|
+
|
|
62
|
+
// ---------- Daily budget, kept in ~/.autonomo-mcp/spend.json (base units per token, reset each UTC day) ----------
|
|
63
|
+
|
|
64
|
+
const SPEND_FILE = join(homedir(), ".autonomo-mcp", "spend.json");
|
|
65
|
+
const today = () => new Date().toISOString().slice(0, 10);
|
|
66
|
+
|
|
67
|
+
function spentToday() {
|
|
68
|
+
try {
|
|
69
|
+
const s = JSON.parse(readFileSync(SPEND_FILE, "utf8"));
|
|
70
|
+
if (s.date === today()) return { usdg: BigInt(s.usdg ?? 0), autonomo: BigInt(s.autonomo ?? 0) };
|
|
71
|
+
} catch {
|
|
72
|
+
// No file yet, or unreadable: nothing spent today.
|
|
73
|
+
}
|
|
74
|
+
return { usdg: 0n, autonomo: 0n };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function recordSpend(pay, amount) {
|
|
78
|
+
const s = spentToday();
|
|
79
|
+
s[pay] += amount;
|
|
80
|
+
mkdirSync(join(homedir(), ".autonomo-mcp"), { recursive: true });
|
|
81
|
+
writeFileSync(SPEND_FILE, JSON.stringify({ date: today(), usdg: s.usdg.toString(), autonomo: s.autonomo.toString() }));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// ---------- Gateways ----------
|
|
85
|
+
|
|
86
|
+
const UPDATING = "Autonomo is being updated right now. Please check back later.";
|
|
87
|
+
|
|
88
|
+
async function getJson(url) {
|
|
89
|
+
const res = await fetch(url, { signal: AbortSignal.timeout(15_000) });
|
|
90
|
+
if (res.status === 503) fail(UPDATING);
|
|
91
|
+
if (!res.ok) fail(`${new URL(url).pathname} answered ${res.status}.`);
|
|
92
|
+
return res.json();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Only Autonomo gateway URLs: https://autonomo.fun/x/<slug><path>, nothing that escapes /x/<slug>. */
|
|
96
|
+
function gatewayUrl(slug, path = "/") {
|
|
97
|
+
if (!/^[a-z0-9][a-z0-9-]{0,63}$/.test(slug)) fail("slug should look like token-risk (lowercase letters, numbers, dashes).");
|
|
98
|
+
const p = path.startsWith("/") ? path : `/${path}`;
|
|
99
|
+
if (p.includes("..") || p.startsWith("//") || /[\s\\]/.test(p)) fail("path must be a plain path such as /risk/0x….");
|
|
100
|
+
const url = new URL(`${BASE}/x/${slug}${p}`);
|
|
101
|
+
if (url.origin !== new URL(BASE).origin || !(url.pathname === `/x/${slug}` || url.pathname.startsWith(`/x/${slug}/`))) {
|
|
102
|
+
fail("That path leaves the gateway.");
|
|
103
|
+
}
|
|
104
|
+
return url.toString();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** The 402 price list for a gateway call, without paying. */
|
|
108
|
+
async function quote(url) {
|
|
109
|
+
const res = await fetch(url, { signal: AbortSignal.timeout(20_000) });
|
|
110
|
+
let required = decode(res.headers.get("payment-required"));
|
|
111
|
+
if (!required && res.status === 402) {
|
|
112
|
+
try {
|
|
113
|
+
required = JSON.parse(await res.text());
|
|
114
|
+
} catch {
|
|
115
|
+
required = null;
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
await res.body?.cancel();
|
|
119
|
+
}
|
|
120
|
+
if (res.status === 503 && res.headers.get("retry-after")) fail(UPDATING);
|
|
121
|
+
if (res.status !== 402 || !Array.isArray(required?.accepts)) fail(`Expected a 402 price list, got ${res.status}.`);
|
|
122
|
+
return required;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function offersFrom(required) {
|
|
126
|
+
return required.accepts.map((a) => {
|
|
127
|
+
const t = tokenOf(a.asset);
|
|
128
|
+
return { token: t?.symbol ?? a.asset, amount: formatUnits(BigInt(a.amount), t?.decimals ?? 18), network: a.network, payTo: a.payTo };
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// ---------- Paying ----------
|
|
133
|
+
|
|
134
|
+
function walletKey() {
|
|
135
|
+
const key = process.env.AUTONOMO_WALLET_KEY?.trim();
|
|
136
|
+
if (!key) fail("No wallet set. Add AUTONOMO_WALLET_KEY (a dedicated wallet with a little USDG or $AUTONOMO) to this server's env in your MCP config.");
|
|
137
|
+
if (!/^0x[0-9a-fA-F]{64}$/.test(key)) fail("AUTONOMO_WALLET_KEY should be 0x followed by 64 hex characters.");
|
|
138
|
+
return key;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
async function pay(url, payWith) {
|
|
142
|
+
const token = TOKENS[payWith];
|
|
143
|
+
const account = privateKeyToAccount(walletKey());
|
|
144
|
+
const pub = createPublicClient({ chain: robinhood, transport: http(RPC) });
|
|
145
|
+
|
|
146
|
+
const required = await quote(url);
|
|
147
|
+
const choice = required.accepts.find((a) => a.network === NETWORK && a.asset.toLowerCase() === token.address.toLowerCase());
|
|
148
|
+
if (!choice) fail(`This API doesn't accept ${token.symbol}. It accepts: ${offersFrom(required).map((o) => `${o.amount} ${o.token}`).join(", ")}.`);
|
|
149
|
+
const amount = BigInt(choice.amount);
|
|
150
|
+
const price = `${formatUnits(amount, token.decimals)} ${token.symbol}`;
|
|
151
|
+
|
|
152
|
+
if (amount > token.cap) fail(`The price (${price}) is above this server's cap of ${formatUnits(token.cap, token.decimals)} ${token.symbol} per call.`);
|
|
153
|
+
const spent = spentToday()[payWith];
|
|
154
|
+
if (spent + amount > token.daily) {
|
|
155
|
+
fail(
|
|
156
|
+
`Daily budget reached: ${formatUnits(spent, token.decimals)} of ${formatUnits(token.daily, token.decimals)} ${token.symbol} spent today (UTC). ` +
|
|
157
|
+
`Raise AUTONOMO_DAILY_${payWith.toUpperCase()} to allow more.`,
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
const balance = await pub.readContract({ address: token.address, abi: erc20Abi, functionName: "balanceOf", args: [account.address] });
|
|
161
|
+
if (balance < amount) fail(`Not enough ${token.symbol}: the wallet ${account.address} has ${formatUnits(balance, token.decimals)}, the call costs ${price}.`);
|
|
162
|
+
|
|
163
|
+
// $AUTONOMO is paid through Permit2: one approval transaction the first time (needs a little ETH for gas).
|
|
164
|
+
let approveTx = null;
|
|
165
|
+
if (choice.extra?.assetTransferMethod === "permit2") {
|
|
166
|
+
const allowance = await pub.readContract({ address: token.address, abi: erc20Abi, functionName: "allowance", args: [account.address, PERMIT2] });
|
|
167
|
+
if (allowance < amount) {
|
|
168
|
+
const wallet = createWalletClient({ account, chain: robinhood, transport: http(RPC) });
|
|
169
|
+
approveTx = await wallet.writeContract({ address: token.address, abi: erc20Abi, functionName: "approve", args: [PERMIT2, maxUint256] });
|
|
170
|
+
await pub.waitForTransactionReceipt({ hash: approveTx });
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const client = x402Client.fromConfig({
|
|
175
|
+
schemes: [{ network: NETWORK, client: new ExactEvmScheme(toClientEvmSigner(account, pub), { rpcUrl: RPC }) }],
|
|
176
|
+
spendControls: {
|
|
177
|
+
allowedAssets: [{ network: NETWORK, asset: token.address, maxAmountPerPayment: token.cap.toString() }],
|
|
178
|
+
maxAmountPerPayment: false,
|
|
179
|
+
},
|
|
180
|
+
paymentRequirementsSelector: (_v, reqs) => reqs.find((r) => r.asset.toLowerCase() === token.address.toLowerCase()) ?? reqs[0],
|
|
181
|
+
});
|
|
182
|
+
const res = await wrapFetchWithPayment(fetch, client)(url, { signal: AbortSignal.timeout(60_000) });
|
|
183
|
+
if (res.status !== 200) {
|
|
184
|
+
const reason = decode(res.headers.get("payment-required"))?.error;
|
|
185
|
+
fail(reason ? `Payment rejected: ${reason}` : `The API answered ${res.status} after payment (you weren't charged if it didn't settle).`);
|
|
186
|
+
}
|
|
187
|
+
const settlement = decode(res.headers.get("payment-response"));
|
|
188
|
+
const tx = settlement?.transaction ?? null;
|
|
189
|
+
recordSpend(payWith, amount);
|
|
190
|
+
|
|
191
|
+
const text = await res.text();
|
|
192
|
+
let data;
|
|
193
|
+
try {
|
|
194
|
+
data = JSON.parse(text);
|
|
195
|
+
} catch {
|
|
196
|
+
data = text.slice(0, 20_000);
|
|
197
|
+
}
|
|
198
|
+
return {
|
|
199
|
+
paid: { amount: formatUnits(amount, token.decimals), token: token.symbol, from: account.address, to: choice.payTo },
|
|
200
|
+
tx: tx ? `${EXPLORER}/tx/${tx}` : null,
|
|
201
|
+
approveTx: approveTx ? `${EXPLORER}/tx/${approveTx}` : null,
|
|
202
|
+
spentToday: `${formatUnits(spentToday()[payWith], token.decimals)} of ${formatUnits(token.daily, token.decimals)} ${token.symbol}`,
|
|
203
|
+
data,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// ---------- MCP ----------
|
|
208
|
+
|
|
209
|
+
const ok = (value) => ({ content: [{ type: "text", text: JSON.stringify(value, null, 2) }] });
|
|
210
|
+
const wrap = (fn) => async (args) => {
|
|
211
|
+
try {
|
|
212
|
+
return ok(await fn(args));
|
|
213
|
+
} catch (e) {
|
|
214
|
+
const message = e instanceof Stop ? e.message : e?.name === "TimeoutError" ? "The request timed out." : (e?.shortMessage ?? e?.message ?? String(e));
|
|
215
|
+
return { content: [{ type: "text", text: message }], isError: true };
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
const server = new McpServer({ name: "autonomo", version: VERSION });
|
|
220
|
+
|
|
221
|
+
server.registerTool(
|
|
222
|
+
"find_apis",
|
|
223
|
+
{
|
|
224
|
+
title: "Find Autonomo APIs",
|
|
225
|
+
description:
|
|
226
|
+
"Search the paid APIs on Autonomo (token prices, new launches, rug-risk checks, wallet portfolios, transaction explainers, " +
|
|
227
|
+
"page reader and more on Robinhood Chain). Returns each API's slug, price and the path to call. verified means the provider holds the Verified minimum of " +
|
|
228
|
+
"$AUTONOMO; it isn't a review of the API. Free. " +
|
|
229
|
+
"Set include_directory to also search Autonomo's directory of 3.7K x402 projects on other networks (listed for reference; " +
|
|
230
|
+
"call_api only pays Autonomo gateways).",
|
|
231
|
+
inputSchema: {
|
|
232
|
+
query: z.string().max(200).optional().describe("What the API should do, e.g. 'token risk' or 'wallet holdings'. Leave empty to list all."),
|
|
233
|
+
include_directory: z.boolean().optional().describe("Also search the x402 directory (other projects and networks)."),
|
|
234
|
+
},
|
|
235
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
236
|
+
},
|
|
237
|
+
wrap(async ({ query = "", include_directory = false }) => {
|
|
238
|
+
const { data } = await getJson(`${BASE}/api/v1/gateways`);
|
|
239
|
+
const words = query.toLowerCase().split(/[^a-z0-9$]+/).filter((w) => w.length > 1);
|
|
240
|
+
const score = (g) => words.filter((w) => `${g.slug} ${g.name} ${g.description}`.toLowerCase().includes(w)).length;
|
|
241
|
+
const apis = words.length ? data.map((g) => [score(g), g]).filter(([s]) => s > 0).sort((a, b) => b[0] - a[0]).map(([, g]) => g) : data;
|
|
242
|
+
const result = {
|
|
243
|
+
apis: (apis.length ? apis : data).map(({ slug, name, description, usage, price, verified }) => ({ slug, name, description, path: usage, price, verified })),
|
|
244
|
+
note: !data.length
|
|
245
|
+
? "No Autonomo APIs are listed right now."
|
|
246
|
+
: apis.length || !words.length
|
|
247
|
+
? undefined
|
|
248
|
+
: "No close match, so every Autonomo API is listed.",
|
|
249
|
+
next: "Call get_price or call_api with a slug and the path (fill in the <…> parts).",
|
|
250
|
+
};
|
|
251
|
+
if (include_directory && query) {
|
|
252
|
+
const dir = await getJson(`${BASE}/api/v1/projects?q=${encodeURIComponent(query)}&limit=8`);
|
|
253
|
+
result.directory = dir.data.map((p) => ({
|
|
254
|
+
name: p.name,
|
|
255
|
+
description: p.description,
|
|
256
|
+
networks: p.networks,
|
|
257
|
+
minPriceUsd: p.minPriceUsd,
|
|
258
|
+
paidCalls30d: p.calls30d,
|
|
259
|
+
website: p.website,
|
|
260
|
+
page: `${BASE}${p.url}`,
|
|
261
|
+
}));
|
|
262
|
+
}
|
|
263
|
+
return result;
|
|
264
|
+
}),
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
server.registerTool(
|
|
268
|
+
"get_price",
|
|
269
|
+
{
|
|
270
|
+
title: "Check an API's price",
|
|
271
|
+
description: "Call an Autonomo API without paying and return its price in USDG and $AUTONOMO. Free; use it before call_api.",
|
|
272
|
+
inputSchema: {
|
|
273
|
+
slug: z.string().describe("The API's slug from find_apis, e.g. token-risk."),
|
|
274
|
+
path: z.string().max(2000).optional().describe("The path from find_apis with the <…> parts filled in, e.g. /risk/0xabc…"),
|
|
275
|
+
},
|
|
276
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
277
|
+
},
|
|
278
|
+
wrap(async ({ slug, path }) => {
|
|
279
|
+
const url = gatewayUrl(slug, path);
|
|
280
|
+
const required = await quote(url);
|
|
281
|
+
return { url, description: required.resource?.description ?? null, offers: offersFrom(required), defaultPayment: TOKENS[DEFAULT_PAY].symbol };
|
|
282
|
+
}),
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
server.registerTool(
|
|
286
|
+
"call_api",
|
|
287
|
+
{
|
|
288
|
+
title: "Pay for and call an API",
|
|
289
|
+
description:
|
|
290
|
+
"Pay for one call to an Autonomo API with x402 and return the answer. Spends USDG or $AUTONOMO from the configured wallet on " +
|
|
291
|
+
"Robinhood Chain (usually 0.01 USDG or 100 $AUTONOMO), within a per-call cap and a daily budget. Returns the data and the " +
|
|
292
|
+
"payment transaction link.",
|
|
293
|
+
inputSchema: {
|
|
294
|
+
slug: z.string().describe("The API's slug from find_apis, e.g. token-risk."),
|
|
295
|
+
path: z.string().max(2000).optional().describe("The path from find_apis with the <…> parts filled in, e.g. /risk/0xabc…"),
|
|
296
|
+
pay_with: z.enum(["usdg", "autonomo"]).optional().describe(`Token to pay with (default ${DEFAULT_PAY}).`),
|
|
297
|
+
},
|
|
298
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
|
|
299
|
+
},
|
|
300
|
+
wrap(async ({ slug, path, pay_with }) => pay(gatewayUrl(slug, path), pay_with ?? DEFAULT_PAY)),
|
|
301
|
+
);
|
|
302
|
+
|
|
303
|
+
await server.connect(new StdioServerTransport());
|
|
304
|
+
console.error(`Autonomo MCP server ${VERSION} ready (${BASE})`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "autonomo-mcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "MCP server for Autonomo: AI agents find x402 APIs, check prices and pay per call in USDG or $AUTONOMO on Robinhood Chain.",
|
|
5
|
+
"homepage": "https://autonomo.fun",
|
|
6
|
+
"author": "Autonomo (https://autonomo.fun)",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"bin": {
|
|
10
|
+
"autonomo-mcp": "index.mjs"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"index.mjs",
|
|
14
|
+
"README.md",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=20"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"start": "node index.mjs",
|
|
22
|
+
"inspect": "npx @modelcontextprotocol/inspector node index.mjs"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"mcp",
|
|
26
|
+
"x402",
|
|
27
|
+
"autonomo",
|
|
28
|
+
"robinhood-chain",
|
|
29
|
+
"ai-agents",
|
|
30
|
+
"model-context-protocol",
|
|
31
|
+
"claude",
|
|
32
|
+
"cursor",
|
|
33
|
+
"codex",
|
|
34
|
+
"usdg"
|
|
35
|
+
],
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@modelcontextprotocol/sdk": "1.32.1",
|
|
38
|
+
"@x402/core": "2.28.0",
|
|
39
|
+
"@x402/evm": "2.28.0",
|
|
40
|
+
"@x402/fetch": "2.28.0",
|
|
41
|
+
"viem": "2.57.12",
|
|
42
|
+
"zod": "4.6.7"
|
|
43
|
+
}
|
|
44
|
+
}
|