@jmthomasofficial/x402-mcp-server 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.
Files changed (3) hide show
  1. package/README.md +70 -0
  2. package/package.json +29 -0
  3. package/src/index.js +121 -0
package/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # JMT x402 MCP Server
2
+
3
+ 25 pay-per-call API tools for AI agents, powered by the x402 protocol on Base mainnet.
4
+
5
+ ## What This Does
6
+
7
+ This MCP server exposes 25 paid API endpoints as MCP tools. When an AI agent (Claude, Cursor, Cline) calls a tool, the request goes to our x402 server. The first request returns HTTP 402 (Payment Required). The agent's x402 client pays in USDC on Base mainnet and retries for the result.
8
+
9
+ **No API keys. No signup. Payment IS the authentication.**
10
+
11
+ ## Tools
12
+
13
+ | Tool | Price | Description |
14
+ |------|-------|-------------|
15
+ | ai_answer | $0.03 | AI-powered search answer with citations |
16
+ | company_intel | $0.10 | Company intelligence dossier with SWOT analysis |
17
+ | sec_filing_analyzer | $0.08 | SEC 10-K/10-Q analysis with risk extraction |
18
+ | news_briefing | $0.05 | Multi-source news briefing with LLM summary |
19
+ | social_sentiment | $0.05 | Cross-platform social sentiment analysis |
20
+ | macro_dashboard | $0.04 | Macro economic dashboard with LLM commentary |
21
+ | market_pulse | $0.04 | Stock market pulse with analyst sentiment |
22
+ | crypto_research | $0.05 | Crypto research brief with on-chain analysis |
23
+ | competitor_analysis | $0.08 | Competitor comparison matrix |
24
+ | domain_trust_score | $0.04 | Domain trust score 0-100 with risk factors |
25
+ | regulatory_monitor | $0.06 | Regulatory filing monitor with impact analysis |
26
+ | web_search | $0.02 | Web search via SearXNG |
27
+ | url_extract | $0.02 | Extract clean text from any URL |
28
+ | summarize | $0.05 | AI-powered text summary |
29
+ | analyze | $0.10 | Deep AI analysis with web research |
30
+ | deep_research | $0.15 | Deep research report with sources |
31
+ | crypto_price | $0.03 | Live crypto price lookup |
32
+ | stock_quote | $0.03 | Live stock quote |
33
+ | gas_snapshot | $0.002 | Live Base gas snapshot |
34
+ | treasury_yields | $0.03 | US Treasury yield curve |
35
+ | whois | $0.01 | WHOIS/RDAP domain lookup |
36
+ | edgar_lookup | $0.01 | SEC EDGAR company lookup |
37
+ | hash | $0.001 | Hash text (SHA-256, SHA-512, MD5) |
38
+ | json_to_csv | $0.002 | Convert JSON array to CSV |
39
+ | text_diff | $0.002 | Compare two text strings |
40
+
41
+ ## Payment Setup
42
+
43
+ - **Protocol:** x402 v1
44
+ - **Network:** Base mainnet (eip155:8453)
45
+ - **Currency:** USDC (Bridged USDC: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913)
46
+ - **Facilitator:** Dexter (x402.dexter.cash) — 0% fee, gas-sponsored for buyers
47
+ - **Pay-to wallet:** 0x624FaF18C78456C8Da5bf156Cd77c1A2033F21c5
48
+
49
+ To make paid calls, install an x402 client:
50
+ ```bash
51
+ npm install @x402/fetch @x402/evm
52
+ ```
53
+
54
+ ## Installation
55
+
56
+ ```bash
57
+ npm install
58
+ npm start
59
+ ```
60
+
61
+ ## Discovery
62
+
63
+ - OpenAPI: https://jmt-x402-proxy.jmthomasofficial.workers.dev/openapi.json
64
+ - Manifest: https://jmt-x402-proxy.jmthomasofficial.workers.dev/.well-known/x402
65
+ - LLMs.txt: https://jmt-x402-proxy.jmthomasofficial.workers.dev/llms.txt
66
+ - Pricing: https://jmt-x402-proxy.jmthomasofficial.workers.dev/api/pricing
67
+
68
+ ## License
69
+
70
+ MIT
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@jmthomasofficial/x402-mcp-server",
3
+ "version": "1.0.0",
4
+ "description": "MCP server wrapping 25 x402 pay-per-call API endpoints on Base mainnet. AI agents can discover and call paid APIs for company intelligence, SEC filing analysis, news briefings, social sentiment, crypto research, and more.",
5
+ "main": "src/index.js",
6
+ "bin": {
7
+ "x402-mcp-server": "src/index.js"
8
+ },
9
+ "scripts": {
10
+ "start": "node src/index.js"
11
+ },
12
+ "dependencies": {
13
+ "@modelcontextprotocol/sdk": "^1.29.0"
14
+ },
15
+ "keywords": [
16
+ "x402",
17
+ "mcp",
18
+ "base",
19
+ "usdc",
20
+ "ai-agents",
21
+ "paid-api"
22
+ ],
23
+ "license": "MIT",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/jmthomasofficial/x402-mcp-server.git"
27
+ },
28
+ "mcpName": "io.github.jmthomasofficial/x402-agent-tools"
29
+ }
package/src/index.js ADDED
@@ -0,0 +1,121 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * JMT x402 MCP Server
4
+ *
5
+ * Wraps 25 x402 pay-per-call API endpoints on Base mainnet as MCP tools.
6
+ * Each tool call goes to https://jmt-x402-proxy.jmthomasofficial.workers.dev/api/<endpoint>
7
+ * The x402 protocol handles payment automatically — the first request returns HTTP 402,
8
+ * the MCP client pays in USDC on Base, and retries for the result.
9
+ *
10
+ * No API key needed. Payment IS the authentication.
11
+ */
12
+
13
+ const { Server } = require("@modelcontextprotocol/sdk/server/index.js");
14
+ const { StdioServerTransport } = require("@modelcontextprotocol/sdk/server/stdio.js");
15
+ const {
16
+ CallToolRequestSchema,
17
+ ListToolsRequestSchema,
18
+ } = require("@modelcontextprotocol/sdk/types.js");
19
+
20
+ const BASE_URL = "https://jmt-x402-proxy.jmthomasofficial.workers.dev";
21
+
22
+ // All 25 x402 paid endpoints
23
+ const ENDPOINTS = [
24
+ { name: "ai_answer", method: "GET", path: "/api/answer", price: "$0.03", desc: "AI-powered search answer with citations. SearXNG + local LLM.", params: [{ name: "q", type: "string", required: true, desc: "Question to answer" }] },
25
+ { name: "company_intel", method: "POST", path: "/api/company-intel", price: "$0.10", desc: "Company intelligence dossier — SEC filings + web research + LLM SWOT analysis.", params: [{ name: "company", type: "string", required: true, desc: "Company name or ticker" }] },
26
+ { name: "sec_filing_analyzer", method: "POST", path: "/api/sec-filing-analyzer", price: "$0.08", desc: "Deep SEC filing analysis — 10-K/10-Q with LLM risk extraction.", params: [{ name: "ticker", type: "string", required: true, desc: "Stock ticker" }, { name: "filing_type", type: "string", required: false, desc: "Filing type (10-K, 10-Q, 8-K)" }] },
27
+ { name: "news_briefing", method: "POST", path: "/api/news-briefing", price: "$0.05", desc: "AI news briefing — multi-source search + LLM summary with sentiment.", params: [{ name: "topic", type: "string", required: true, desc: "Topic to brief on" }] },
28
+ { name: "social_sentiment", method: "POST", path: "/api/social-sentiment", price: "$0.05", desc: "Cross-platform social sentiment analysis with LLM.", params: [{ name: "topic", type: "string", required: true, desc: "Topic to analyze" }] },
29
+ { name: "macro_dashboard", method: "POST", path: "/api/macro-dashboard", price: "$0.04", desc: "Macro economic dashboard — Treasury yields + CPI + Fed + LLM commentary.", params: [{ name: "region", type: "string", required: false, desc: "Region (default: US)" }] },
30
+ { name: "market_pulse", method: "POST", path: "/api/market-pulse", price: "$0.04", desc: "Stock market pulse — quote + news + analyst sentiment + LLM.", params: [{ name: "ticker", type: "string", required: false, desc: "Stock ticker (default: AAPL)" }] },
31
+ { name: "crypto_research", method: "POST", path: "/api/crypto-research", price: "$0.05", desc: "Crypto research brief — price + on-chain + news + LLM analysis.", params: [{ name: "coin", type: "string", required: false, desc: "Coin name/id (default: bitcoin)" }] },
32
+ { name: "competitor_analysis", method: "POST", path: "/api/competitor-analysis", price: "$0.08", desc: "Competitor analysis — comparison matrix with LLM.", params: [{ name: "company", type: "string", required: true, desc: "Company name" }] },
33
+ { name: "domain_trust_score", method: "POST", path: "/api/domain-trust-score", price: "$0.04", desc: "Domain trust score — WHOIS + SSL + DNS + LLM 0-100 score.", params: [{ name: "domain", type: "string", required: true, desc: "Domain to assess" }] },
34
+ { name: "regulatory_monitor", method: "POST", path: "/api/regulatory-monitor", price: "$0.06", desc: "Regulatory filing monitor — government sites + LLM impact analysis.", params: [{ name: "topic", type: "string", required: true, desc: "Topic to monitor" }] },
35
+ { name: "web_search", method: "GET", path: "/api/search", price: "$0.02", desc: "Web search via SearXNG.", params: [{ name: "q", type: "string", required: true, desc: "Search query" }] },
36
+ { name: "url_extract", method: "POST", path: "/api/extract", price: "$0.02", desc: "Extract clean text from any URL.", params: [{ name: "url", type: "string", required: true, desc: "URL to extract" }] },
37
+ { name: "summarize", method: "POST", path: "/api/summarize", price: "$0.05", desc: "AI-powered text summary via local LLM.", params: [{ name: "text", type: "string", required: true, desc: "Text to summarize" }] },
38
+ { name: "analyze", method: "POST", path: "/api/analyze", price: "$0.10", desc: "Deep AI analysis with web research.", params: [{ name: "topic", type: "string", required: true, desc: "Topic to analyze" }] },
39
+ { name: "deep_research", method: "POST", path: "/api/research", price: "$0.15", desc: "Deep research report with sources.", params: [{ name: "topic", type: "string", required: true, desc: "Research topic" }] },
40
+ { name: "crypto_price", method: "GET", path: "/api/crypto-price", price: "$0.03", desc: "Live crypto price lookup.", params: [{ name: "id", type: "string", required: false, desc: "Coin ID (default: bitcoin)" }] },
41
+ { name: "stock_quote", method: "GET", path: "/api/stock-quote", price: "$0.03", desc: "Live stock quote.", params: [{ name: "symbol", type: "string", required: false, desc: "Ticker (default: AAPL)" }] },
42
+ { name: "gas_snapshot", method: "GET", path: "/api/gas-snapshot", price: "$0.002", desc: "Live Base gas snapshot.", params: [] },
43
+ { name: "treasury_yields", method: "GET", path: "/api/treasury-yield-curve", price: "$0.03", desc: "US Treasury yield curve.", params: [] },
44
+ { name: "whois", method: "GET", path: "/api/whois", price: "$0.01", desc: "WHOIS/RDAP domain lookup.", params: [{ name: "domain", type: "string", required: true, desc: "Domain to lookup" }] },
45
+ { name: "edgar_lookup", method: "GET", path: "/api/edgar-company-lookup", price: "$0.01", desc: "SEC EDGAR company lookup.", params: [{ name: "ticker", type: "string", required: false, desc: "Ticker (default: AAPL)" }] },
46
+ { name: "hash", method: "POST", path: "/api/hash", price: "$0.001", desc: "Hash text (SHA-256, SHA-512, MD5).", params: [{ name: "text", type: "string", required: true, desc: "Text to hash" }, { name: "algo", type: "string", required: false, desc: "Algorithm (default: sha256)" }] },
47
+ { name: "json_to_csv", method: "POST", path: "/api/json-to-csv", price: "$0.002", desc: "Convert JSON array to CSV.", params: [{ name: "data", type: "array", required: true, desc: "JSON array to convert" }] },
48
+ { name: "text_diff", method: "POST", path: "/api/text-diff", price: "$0.002", desc: "Compare two text strings.", params: [{ name: "text1", type: "string", required: true, desc: "First text" }, { name: "text2", type: "string", required: true, desc: "Second text" }] },
49
+ ];
50
+
51
+ const server = new Server(
52
+ { name: "jmt-x402-agent-tools", version: "1.0.0" },
53
+ { capabilities: { tools: {} } }
54
+ );
55
+
56
+ // List tools
57
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({
58
+ tools: ENDPOINTS.map((ep) => ({
59
+ name: ep.name,
60
+ description: `${ep.desc} Price: ${ep.price}/call via x402 (USDC on Base mainnet).`,
61
+ inputSchema: {
62
+ type: "object",
63
+ properties: Object.fromEntries(
64
+ ep.params.map((p) => [p.name, { type: p.type, description: p.desc }])
65
+ ),
66
+ required: ep.params.filter((p) => p.required).map((p) => p.name),
67
+ },
68
+ })),
69
+ }));
70
+
71
+ // Call tool
72
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
73
+ const { name, arguments: args } = request.params;
74
+ const ep = ENDPOINTS.find((e) => e.name === name);
75
+ if (!ep) {
76
+ return { content: [{ type: "text", text: `Unknown tool: ${name}` }], isError: true };
77
+ }
78
+
79
+ const url = ep.method === "GET"
80
+ ? `${BASE_URL}${ep.path}?${new URLSearchParams(args || {}).toString()}`
81
+ : `${BASE_URL}${ep.path}`;
82
+
83
+ const options = ep.method === "POST"
84
+ ? { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(args || {}) }
85
+ : { method: "GET", headers: { Accept: "application/json" } };
86
+
87
+ try {
88
+ const res = await fetch(url, options);
89
+
90
+ // If 402, return payment instructions
91
+ if (res.status === 402) {
92
+ const body = await res.json();
93
+ return {
94
+ content: [{
95
+ type: "text",
96
+ text: `Payment required (HTTP 402). This endpoint costs ${ep.price} via x402 protocol.\n\nTo pay: use an x402 client (e.g., @x402/fetch) with a funded Base mainnet wallet.\nPayment details:\n${JSON.stringify(body, null, 2)}`
97
+ }],
98
+ isError: true,
99
+ };
100
+ }
101
+
102
+ const data = await res.json();
103
+ return {
104
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
105
+ };
106
+ } catch (e) {
107
+ return {
108
+ content: [{ type: "text", text: `Error calling ${name}: ${e.message}` }],
109
+ isError: true,
110
+ };
111
+ }
112
+ });
113
+
114
+ // Start server
115
+ async function main() {
116
+ const transport = new StdioServerTransport();
117
+ await server.connect(transport);
118
+ console.error("JMT x402 MCP Server running (25 tools, Base mainnet, Dexter facilitator)");
119
+ }
120
+
121
+ main().catch(console.error);