base-intel-search-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 +92 -0
- package/index.js +78 -0
- package/package.json +24 -0
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Base Intel Search โ MCP server ๐โก
|
|
2
|
+
|
|
3
|
+
**Pay-per-call web search for AI agents, settled in USDC on Base via [x402](https://x402.org).**
|
|
4
|
+
|
|
5
|
+
Add one MCP server and your agent gets a `web_search` tool. Each query is paid
|
|
6
|
+
automatically from your wallet (~**$0.015 USDC** per call) โ **no API key, no
|
|
7
|
+
account, no subscription.** Powered by the [Base Intel](https://base-intel-api.jakemaxsigal.workers.dev) `/search` API.
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
agent calls web_search("โฆ")
|
|
11
|
+
โ GET /search?q=โฆ โ 402 Payment Required
|
|
12
|
+
โ x402 signs a USDC payment from your wallet
|
|
13
|
+
โ request retried โ 200 + ranked, cited results
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The agent never sees the payment โ it just calls a tool and gets answers. Payment
|
|
17
|
+
is transparent, instant, and per-call.
|
|
18
|
+
|
|
19
|
+
## Why use it
|
|
20
|
+
|
|
21
|
+
- **No signup / no key.** Fund a wallet with a few dollars of USDC on Base; that's it.
|
|
22
|
+
- **Pay only for what you use.** ~$0.015 per query, no monthly fee.
|
|
23
|
+
- **Real-time web.** Ranked, de-duplicated results with source + date, plus top news.
|
|
24
|
+
- **Filters.** Recency (day/week/month/year), site restriction, result count.
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
### Claude Desktop
|
|
29
|
+
|
|
30
|
+
Add to your `claude_desktop_config.json`:
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"mcpServers": {
|
|
35
|
+
"base-intel-search": {
|
|
36
|
+
"command": "npx",
|
|
37
|
+
"args": ["-y", "base-intel-search-mcp"],
|
|
38
|
+
"env": {
|
|
39
|
+
"EVM_PRIVATE_KEY": "0xYOUR_PAYING_WALLET_PRIVATE_KEY"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Restart Claude Desktop. You'll see a **web_search** tool.
|
|
47
|
+
|
|
48
|
+
### Any MCP client
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
EVM_PRIVATE_KEY=0xโฆ npx -y base-intel-search-mcp
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Funding the wallet
|
|
55
|
+
|
|
56
|
+
`EVM_PRIVATE_KEY` is a wallet **you** control that pays per query. Fund it on **Base**:
|
|
57
|
+
|
|
58
|
+
- A few dollars of **USDC** (covers hundreds of searches at ~$0.015 each)
|
|
59
|
+
- A tiny amount of **ETH** for gas
|
|
60
|
+
|
|
61
|
+
> Use a dedicated low-balance wallet for agent spending โ never your main wallet.
|
|
62
|
+
|
|
63
|
+
## The `web_search` tool
|
|
64
|
+
|
|
65
|
+
| Param | Type | Notes |
|
|
66
|
+
| --- | --- | --- |
|
|
67
|
+
| `query` | string | required |
|
|
68
|
+
| `recency` | `day` \| `week` \| `month` \| `year` | optional time window |
|
|
69
|
+
| `site` | string | restrict to a domain, e.g. `arxiv.org` |
|
|
70
|
+
| `count` | number (1โ20) | results to return (default 10) |
|
|
71
|
+
|
|
72
|
+
Returns ranked results (title, url, snippet, source, date, extra context) + top news as JSON.
|
|
73
|
+
|
|
74
|
+
## Configuration
|
|
75
|
+
|
|
76
|
+
| Env | Default | Purpose |
|
|
77
|
+
| --- | --- | --- |
|
|
78
|
+
| `EVM_PRIVATE_KEY` | โ (required) | wallet that pays per query |
|
|
79
|
+
| `SEARCH_API_URL` | Base Intel `/search` | override the search endpoint |
|
|
80
|
+
| `X402_NETWORK` | `eip155:8453` | payment network (Base mainnet) |
|
|
81
|
+
|
|
82
|
+
## How payment works
|
|
83
|
+
|
|
84
|
+
Built on the [x402](https://x402.org) protocol v2 using `@x402/axios` + `@x402/evm`.
|
|
85
|
+
The first request to `/search` returns `402 Payment Required`; the x402 client signs
|
|
86
|
+
a USDC `transferWithAuthorization` from your wallet and retries. Settlement is on
|
|
87
|
+
Base L2 (sub-cent gas, ~2s). You pay the resource directly โ this server holds no
|
|
88
|
+
funds and takes no custody.
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
MIT
|
package/index.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Base Intel Search โ MCP server
|
|
4
|
+
*
|
|
5
|
+
* Gives any MCP-compatible AI agent (Claude Desktop, custom agents, etc.)
|
|
6
|
+
* a `web_search` tool that is paid per call in USDC on Base via the x402
|
|
7
|
+
* protocol. The agent pays from its OWN wallet โ no API key, no subscription.
|
|
8
|
+
*
|
|
9
|
+
* How it works:
|
|
10
|
+
* tool call -> GET https://โฆ/search?q=โฆ -> 402 Payment Required
|
|
11
|
+
* -> @x402/axios signs a USDC payment from EVM_PRIVATE_KEY
|
|
12
|
+
* -> request retried with payment -> 200 + ranked results
|
|
13
|
+
*
|
|
14
|
+
* Env:
|
|
15
|
+
* EVM_PRIVATE_KEY (required) โ wallet that pays per query (~$0.015/call)
|
|
16
|
+
* SEARCH_API_URL (optional) โ defaults to the Base Intel /search endpoint
|
|
17
|
+
* X402_NETWORK (optional) โ defaults to eip155:8453 (Base mainnet)
|
|
18
|
+
*/
|
|
19
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
20
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
21
|
+
import { z } from "zod";
|
|
22
|
+
import axios from "axios";
|
|
23
|
+
import { wrapAxiosWithPaymentFromConfig } from "@x402/axios";
|
|
24
|
+
import { ExactEvmScheme } from "@x402/evm";
|
|
25
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
26
|
+
|
|
27
|
+
const SEARCH_API_URL = process.env.SEARCH_API_URL || "https://base-intel-api.jakemaxsigal.workers.dev";
|
|
28
|
+
const NETWORK = process.env.X402_NETWORK || "eip155:8453";
|
|
29
|
+
const PRICE_HINT = "~$0.015 USDC per query";
|
|
30
|
+
|
|
31
|
+
const pk = process.env.EVM_PRIVATE_KEY;
|
|
32
|
+
if (!pk) {
|
|
33
|
+
console.error("[base-intel-search-mcp] Missing EVM_PRIVATE_KEY. Set the wallet that pays per query.");
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
const account = privateKeyToAccount(pk.startsWith("0x") ? pk : `0x${pk}`);
|
|
37
|
+
|
|
38
|
+
// Axios instance that auto-handles x402 402 responses by paying from `account`.
|
|
39
|
+
const api = wrapAxiosWithPaymentFromConfig(
|
|
40
|
+
axios.create({ baseURL: SEARCH_API_URL, timeout: 30000 }),
|
|
41
|
+
{ schemes: [{ network: NETWORK, client: new ExactEvmScheme(account) }] }
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
const server = new McpServer({ name: "base-intel-search", version: "1.0.0" });
|
|
45
|
+
|
|
46
|
+
server.tool(
|
|
47
|
+
"web_search",
|
|
48
|
+
`Search the live web for current, real-time information to answer questions, research topics, and ground responses with cited sources. ` +
|
|
49
|
+
`Returns ranked, de-duplicated results (title, url, snippet, source, date) plus top news. ` +
|
|
50
|
+
`Paid per call in USDC on Base via x402 (${PRICE_HINT}); payment is automatic from the configured wallet.`,
|
|
51
|
+
{
|
|
52
|
+
query: z.string().describe("The search query."),
|
|
53
|
+
recency: z.enum(["day", "week", "month", "year"]).optional()
|
|
54
|
+
.describe("Restrict results to a recent time window."),
|
|
55
|
+
site: z.string().optional().describe("Restrict to a domain, e.g. 'arxiv.org'."),
|
|
56
|
+
count: z.number().int().min(1).max(20).optional().describe("Number of results (default 10)."),
|
|
57
|
+
},
|
|
58
|
+
async ({ query, recency, site, count }) => {
|
|
59
|
+
const params = new URLSearchParams({ q: query });
|
|
60
|
+
if (recency) params.set("recency", recency);
|
|
61
|
+
if (site) params.set("site", site);
|
|
62
|
+
if (count) params.set("count", String(count));
|
|
63
|
+
try {
|
|
64
|
+
const res = await api.get(`/search?${params.toString()}`);
|
|
65
|
+
return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] };
|
|
66
|
+
} catch (err) {
|
|
67
|
+
const status = err?.response?.status;
|
|
68
|
+
let msg = err?.response?.data?.error || err?.message || String(err);
|
|
69
|
+
if (status === 402) msg = "Payment required but not completed โ check the wallet has USDC + a little ETH for gas on Base.";
|
|
70
|
+
if (/insufficient/i.test(msg)) msg = "Wallet has insufficient USDC/ETH on Base to pay for the query.";
|
|
71
|
+
return { content: [{ type: "text", text: `web_search failed: ${msg}` }], isError: true };
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const transport = new StdioServerTransport();
|
|
77
|
+
await server.connect(transport);
|
|
78
|
+
console.error(`[base-intel-search-mcp] ready ยท pays from ${account.address} ยท ${SEARCH_API_URL} ยท ${NETWORK}`);
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "base-intel-search-mcp",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MCP server giving any AI agent pay-per-call web search, settled in USDC on Base via x402. Wraps the Base Intel /search API. The agent pays per query from its own wallet โ no API key, no subscription.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"bin": {
|
|
8
|
+
"base-intel-search-mcp": "index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": ["index.js", "README.md"],
|
|
11
|
+
"keywords": [
|
|
12
|
+
"mcp", "model-context-protocol", "x402", "web-search", "ai-agent",
|
|
13
|
+
"base", "usdc", "pay-per-call", "agent-payments", "search"
|
|
14
|
+
],
|
|
15
|
+
"engines": { "node": ">=18" },
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
18
|
+
"@x402/axios": "^2.14.0",
|
|
19
|
+
"@x402/evm": "^2.14.0",
|
|
20
|
+
"axios": "^1.7.0",
|
|
21
|
+
"viem": "^2.21.0",
|
|
22
|
+
"zod": "^3.23.0"
|
|
23
|
+
}
|
|
24
|
+
}
|