rwagenthub-mcp 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 +87 -0
- package/index.js +112 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# agenthub-mcp
|
|
2
|
+
|
|
3
|
+
MCP server for [AgentHub](https://agents-production-73c1.up.railway.app) — gives any MCP-compatible AI client access to 19 APIs (flights, hotels, weather, crypto, DeFi, web search, code execution, and more) paid automatically via [x402](https://x402.org) USDC micropayments on Base.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Node.js >= 22
|
|
8
|
+
- A Base wallet with a small USDC balance (most APIs cost $0.01–$0.06 per call)
|
|
9
|
+
|
|
10
|
+
## Setup
|
|
11
|
+
|
|
12
|
+
### 1. Get a wallet private key
|
|
13
|
+
|
|
14
|
+
Create a dedicated wallet on Base Mainnet and fund it with a few USDC. You can use [Coinbase Wallet](https://wallet.coinbase.com) or any EVM wallet.
|
|
15
|
+
|
|
16
|
+
> Use a **dedicated wallet** with a small balance — not your main wallet.
|
|
17
|
+
|
|
18
|
+
### 2. Add to your MCP client config
|
|
19
|
+
|
|
20
|
+
**Claude Desktop** — edit `claude_desktop_config.json`:
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"mcpServers": {
|
|
25
|
+
"agenthub": {
|
|
26
|
+
"command": "npx",
|
|
27
|
+
"args": ["-y", "agenthub-mcp"],
|
|
28
|
+
"env": {
|
|
29
|
+
"MCP_WALLET_PRIVATE_KEY": "0x..."
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Cursor / Cline / Windsurf** — same config format, check your client's MCP settings.
|
|
37
|
+
|
|
38
|
+
### 3. Restart your client
|
|
39
|
+
|
|
40
|
+
The server fetches the latest API list from the gateway on startup — no manual updates needed.
|
|
41
|
+
|
|
42
|
+
## Available tools
|
|
43
|
+
|
|
44
|
+
| Tool | Description | Price |
|
|
45
|
+
|------|-------------|-------|
|
|
46
|
+
| `flight_search` | Search flights between airports (Duffel) | $0.01 |
|
|
47
|
+
| `flight_status` | Get flight status by carrier + number | $0.01 |
|
|
48
|
+
| `seat_map` | Seat map for a Duffel offer | $0.01 |
|
|
49
|
+
| `airport_search` | List airports by country | $0.01 |
|
|
50
|
+
| `hotel_search` | Search hotels in a city (Amadeus) | $0.06 |
|
|
51
|
+
| `activities_search` | Tours and activities near a location | $0.01 |
|
|
52
|
+
| `web_search` | Google search results (Serper) | $0.02 |
|
|
53
|
+
| `web_search_ai` | AI-powered search with summaries (LangSearch) | $0.02 |
|
|
54
|
+
| `places_search` | Places and businesses via Google Maps data | $0.02 |
|
|
55
|
+
| `image_search` | Image search | $0.01 |
|
|
56
|
+
| `shopping_search` | Product search across online stores | $0.02 |
|
|
57
|
+
| `weather_forecast` | Current + 15-day forecast (Visual Crossing) | $0.01 |
|
|
58
|
+
| `url_extract` | Extract text content from any URL | $0.02 |
|
|
59
|
+
| `exchange_rate` | Currency exchange rates (ECB/Frankfurter) | $0.01 |
|
|
60
|
+
| `crypto_price` | Crypto prices and 24h change | $0.01 |
|
|
61
|
+
| `defi_market_snapshot` | DeFi TVL, top protocols, DEX volume (DeFiLlama) | $0.02 |
|
|
62
|
+
| `defi_yields` | Best yield farming pools (DeFiLlama) | $0.02 |
|
|
63
|
+
| `code_exec` | Execute code in an isolated sandbox (e2b) | $0.05 |
|
|
64
|
+
| `email_send` | Send transactional email (Resend) | $0.01 |
|
|
65
|
+
|
|
66
|
+
Prices are in USDC and charged per call via x402 on Base Mainnet.
|
|
67
|
+
|
|
68
|
+
## How it works
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
Your MCP client (Claude Desktop, Cursor, etc.)
|
|
72
|
+
│ stdio
|
|
73
|
+
▼
|
|
74
|
+
agenthub-mcp (this package)
|
|
75
|
+
│ POST /v1/call + x402 auto-payment
|
|
76
|
+
▼
|
|
77
|
+
AgentHub Gateway (Railway)
|
|
78
|
+
│
|
|
79
|
+
▼
|
|
80
|
+
Flights · Hotels · Weather · Crypto · DeFi · Search · ...
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
On startup, the server fetches the live API schema from the gateway — so new APIs and price changes are reflected automatically without updating the package.
|
|
84
|
+
|
|
85
|
+
## License
|
|
86
|
+
|
|
87
|
+
MIT
|
package/index.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import "dotenv/config";
|
|
3
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
|
+
import { createWalletClient, http } from "viem";
|
|
6
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
7
|
+
import { base } from "viem/chains";
|
|
8
|
+
import { wrapFetchWithPayment } from "@x402/fetch";
|
|
9
|
+
import { x402Client } from "@x402/core/client";
|
|
10
|
+
import { registerExactEvmScheme } from "@x402/evm/exact/client";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
|
|
13
|
+
const GATEWAY_URL = "https://agents-production-73c1.up.railway.app";
|
|
14
|
+
|
|
15
|
+
// ── Payment setup ──────────────────────────────────────────────────────────────
|
|
16
|
+
if (!process.env.MCP_WALLET_PRIVATE_KEY) {
|
|
17
|
+
console.error("[mcp] ERROR: MCP_WALLET_PRIVATE_KEY not set");
|
|
18
|
+
console.error("[mcp] Add it to your MCP client config under env.MCP_WALLET_PRIVATE_KEY");
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const account = privateKeyToAccount(process.env.MCP_WALLET_PRIVATE_KEY);
|
|
23
|
+
const walletClient = createWalletClient({ account, chain: base, transport: http() });
|
|
24
|
+
const signer = Object.assign(walletClient, { address: account.address });
|
|
25
|
+
|
|
26
|
+
const client = new x402Client();
|
|
27
|
+
registerExactEvmScheme(client, { signer });
|
|
28
|
+
const pay = wrapFetchWithPayment(fetch, client);
|
|
29
|
+
|
|
30
|
+
async function callGateway(api, inputs) {
|
|
31
|
+
const res = await pay(`${GATEWAY_URL}/v1/call`, {
|
|
32
|
+
method: "POST",
|
|
33
|
+
headers: { "Content-Type": "application/json" },
|
|
34
|
+
body: JSON.stringify({ api, inputs }),
|
|
35
|
+
});
|
|
36
|
+
return res.json();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ── Type mapper: gateway field types → Zod ────────────────────────────────────
|
|
40
|
+
function toZod(field) {
|
|
41
|
+
let schema;
|
|
42
|
+
if (field.type === "number") {
|
|
43
|
+
schema = z.number();
|
|
44
|
+
} else if (field.type === "boolean") {
|
|
45
|
+
schema = z.boolean();
|
|
46
|
+
} else if (field.type === "string|string[]") {
|
|
47
|
+
schema = z.union([z.string(), z.array(z.string())]);
|
|
48
|
+
} else {
|
|
49
|
+
schema = z.string();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (field.description) schema = schema.describe(field.description);
|
|
53
|
+
if (!field.required) schema = schema.optional();
|
|
54
|
+
if (field.default !== undefined) schema = schema.default(field.default);
|
|
55
|
+
return schema;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// ── Main: fetch schema from gateway, register tools, start server ──────────────
|
|
59
|
+
async function main() {
|
|
60
|
+
// Fetch live schema + prices from the gateway
|
|
61
|
+
const res = await fetch(`${GATEWAY_URL}/v1/schema`);
|
|
62
|
+
if (!res.ok) {
|
|
63
|
+
console.error(`[mcp] Failed to fetch schema from gateway: ${res.status} ${res.statusText}`);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
const { apis } = await res.json();
|
|
67
|
+
|
|
68
|
+
const server = new McpServer({ name: "agenthub", version: "1.0.0" });
|
|
69
|
+
|
|
70
|
+
for (const api of apis) {
|
|
71
|
+
const zodShape = {};
|
|
72
|
+
for (const [fieldName, field] of Object.entries(api.inputs)) {
|
|
73
|
+
zodShape[fieldName] = toZod(field);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
server.tool(
|
|
77
|
+
api.name,
|
|
78
|
+
`${api.description} Costs $${(api.price_usd ?? 0.01).toFixed(2)} USDC per call via x402 on Base.`,
|
|
79
|
+
zodShape,
|
|
80
|
+
async (inputs) => {
|
|
81
|
+
try {
|
|
82
|
+
const result = await callGateway(api.name, inputs);
|
|
83
|
+
|
|
84
|
+
if (!result.success) {
|
|
85
|
+
return {
|
|
86
|
+
content: [{ type: "text", text: `Error: ${result.error}${result.message ? ` — ${result.message}` : ""}${result.hint ? `\n${result.hint}` : ""}` }],
|
|
87
|
+
isError: true,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }],
|
|
93
|
+
};
|
|
94
|
+
} catch (err) {
|
|
95
|
+
return {
|
|
96
|
+
content: [{ type: "text", text: `Gateway error: ${err.message}` }],
|
|
97
|
+
isError: true,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const transport = new StdioServerTransport();
|
|
105
|
+
await server.connect(transport);
|
|
106
|
+
console.error(`[mcp] AgentHub MCP server running — ${apis.length} tools available`);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
main().catch((err) => {
|
|
110
|
+
console.error("[mcp] Fatal:", err);
|
|
111
|
+
process.exit(1);
|
|
112
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rwagenthub-mcp",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MCP server for AgentHub — 19 AI APIs (flights, weather, crypto, search, DeFi, code execution...) paid via x402 USDC on Base",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"rwagenthub-mcp": "./index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"index.js"
|
|
11
|
+
],
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=22.0.0"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"mcp",
|
|
17
|
+
"model-context-protocol",
|
|
18
|
+
"ai",
|
|
19
|
+
"agents",
|
|
20
|
+
"x402",
|
|
21
|
+
"crypto",
|
|
22
|
+
"flights",
|
|
23
|
+
"weather",
|
|
24
|
+
"defi",
|
|
25
|
+
"base"
|
|
26
|
+
],
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
30
|
+
"@x402/core": "^2.3.1",
|
|
31
|
+
"@x402/evm": "^2.3.1",
|
|
32
|
+
"@x402/fetch": "^2.3.0",
|
|
33
|
+
"dotenv": "^16.4.0",
|
|
34
|
+
"viem": "^2.46.2",
|
|
35
|
+
"zod": "^3.25.76"
|
|
36
|
+
}
|
|
37
|
+
}
|