@noelclaw/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/LICENSE +21 -0
- package/README.md +246 -0
- package/dist/convex.js +107 -0
- package/dist/index.js +31 -0
- package/dist/server.js +101 -0
- package/dist/tools/automation.js +116 -0
- package/dist/tools/defi.js +241 -0
- package/dist/tools/framework.js +259 -0
- package/dist/tools/humanizer.js +120 -0
- package/dist/tools/insight.js +59 -0
- package/dist/tools/market.js +229 -0
- package/dist/tools/miroshark.js +155 -0
- package/dist/tools/news.js +99 -0
- package/dist/tools/research.js +29 -0
- package/dist/tools/swarm.js +162 -0
- package/dist/tools/twitter.js +67 -0
- package/dist/tools/vault.js +293 -0
- package/dist/tools/wallet.js +99 -0
- package/dist/types.js +2 -0
- package/dist/wallet.js +137 -0
- package/package.json +56 -0
package/dist/wallet.js
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.BASE_CHAIN_ID = exports.BASE_RPC = void 0;
|
|
37
|
+
exports.clearWalletCache = clearWalletCache;
|
|
38
|
+
exports.getMachineKey = getMachineKey;
|
|
39
|
+
exports.getOrCreateWallet = getOrCreateWallet;
|
|
40
|
+
exports.signRequest = signRequest;
|
|
41
|
+
exports.signAndBroadcast = signAndBroadcast;
|
|
42
|
+
const ethers_1 = require("ethers");
|
|
43
|
+
const fs = __importStar(require("fs"));
|
|
44
|
+
const os = __importStar(require("os"));
|
|
45
|
+
const path = __importStar(require("path"));
|
|
46
|
+
const crypto = __importStar(require("crypto"));
|
|
47
|
+
const ALCHEMY_API_KEY = process.env.ALCHEMY_API_KEY;
|
|
48
|
+
exports.BASE_RPC = ALCHEMY_API_KEY
|
|
49
|
+
? `https://base-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}`
|
|
50
|
+
: "https://mainnet.base.org";
|
|
51
|
+
exports.BASE_CHAIN_ID = 8453;
|
|
52
|
+
const WALLET_DIR = path.join(os.homedir(), ".noelclaw");
|
|
53
|
+
const WALLET_FILE = path.join(WALLET_DIR, "wallet.json");
|
|
54
|
+
let _cachedWallet = null;
|
|
55
|
+
function clearWalletCache() { _cachedWallet = null; }
|
|
56
|
+
function getMachineKey() {
|
|
57
|
+
// If a passphrase is set, use it as the primary secret for stronger encryption.
|
|
58
|
+
// Without it, the key is derived from public machine info only — this is
|
|
59
|
+
// convenience encryption (prevents casual reads), not security against
|
|
60
|
+
// an attacker who has read access to both the file and system info.
|
|
61
|
+
const passphrase = process.env.NOELCLAW_WALLET_PASSPHRASE ?? "";
|
|
62
|
+
return crypto
|
|
63
|
+
.createHash("sha256")
|
|
64
|
+
.update(passphrase + os.hostname() + os.platform() + os.arch())
|
|
65
|
+
.digest("hex")
|
|
66
|
+
.slice(0, 32);
|
|
67
|
+
}
|
|
68
|
+
async function getOrCreateWallet() {
|
|
69
|
+
if (_cachedWallet)
|
|
70
|
+
return _cachedWallet;
|
|
71
|
+
if (fs.existsSync(WALLET_FILE)) {
|
|
72
|
+
try {
|
|
73
|
+
const encrypted = fs.readFileSync(WALLET_FILE, "utf8");
|
|
74
|
+
const wallet = await ethers_1.ethers.Wallet.fromEncryptedJson(encrypted, getMachineKey());
|
|
75
|
+
_cachedWallet = wallet;
|
|
76
|
+
return wallet;
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
// fall through to create new wallet
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const wallet = ethers_1.ethers.Wallet.createRandom();
|
|
83
|
+
if (!fs.existsSync(WALLET_DIR))
|
|
84
|
+
fs.mkdirSync(WALLET_DIR, { recursive: true });
|
|
85
|
+
const encrypted = await wallet.encrypt(getMachineKey());
|
|
86
|
+
fs.writeFileSync(WALLET_FILE, encrypted, { mode: 0o600 });
|
|
87
|
+
_cachedWallet = wallet;
|
|
88
|
+
return wallet;
|
|
89
|
+
}
|
|
90
|
+
async function signRequest(toolName) {
|
|
91
|
+
const wallet = await getOrCreateWallet();
|
|
92
|
+
const timestamp = Date.now().toString();
|
|
93
|
+
const signature = await wallet.signMessage(`noelclaw:${toolName}:${timestamp}`);
|
|
94
|
+
return { address: wallet.address, signature, timestamp };
|
|
95
|
+
}
|
|
96
|
+
async function rpcPost(method, params) {
|
|
97
|
+
const res = await fetch(exports.BASE_RPC, {
|
|
98
|
+
method: "POST",
|
|
99
|
+
headers: { "Content-Type": "application/json" },
|
|
100
|
+
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
|
|
101
|
+
signal: AbortSignal.timeout(15000),
|
|
102
|
+
});
|
|
103
|
+
const data = await res.json();
|
|
104
|
+
if (data.error)
|
|
105
|
+
throw new Error(`RPC ${method} failed: ${data.error.message}`);
|
|
106
|
+
return data.result;
|
|
107
|
+
}
|
|
108
|
+
async function getNonce(address) {
|
|
109
|
+
return parseInt(await rpcPost("eth_getTransactionCount", [address, "latest"]), 16);
|
|
110
|
+
}
|
|
111
|
+
async function getGasPrice() {
|
|
112
|
+
return BigInt(await rpcPost("eth_gasPrice", []));
|
|
113
|
+
}
|
|
114
|
+
async function broadcastTx(signedTx) {
|
|
115
|
+
return rpcPost("eth_sendRawTransaction", [signedTx]);
|
|
116
|
+
}
|
|
117
|
+
async function signAndBroadcast(wallet, txData) {
|
|
118
|
+
let data = txData.data || "0x";
|
|
119
|
+
if (txData.permit2?.eip712) {
|
|
120
|
+
const eip712 = txData.permit2.eip712;
|
|
121
|
+
const { EIP712Domain: _d, ...typesWithout } = eip712.types ?? {};
|
|
122
|
+
const sig = await wallet.signTypedData(eip712.domain, typesWithout, eip712.message);
|
|
123
|
+
data = data + sig.replace("0x", "");
|
|
124
|
+
}
|
|
125
|
+
const [nonce, gasPrice] = await Promise.all([getNonce(wallet.address), getGasPrice()]);
|
|
126
|
+
const tx = {
|
|
127
|
+
to: txData.to,
|
|
128
|
+
data,
|
|
129
|
+
value: BigInt(txData.value || "0"),
|
|
130
|
+
gasLimit: BigInt(txData.gas || "200000"),
|
|
131
|
+
gasPrice: txData.gasPrice ? BigInt(txData.gasPrice) : gasPrice,
|
|
132
|
+
nonce,
|
|
133
|
+
chainId: exports.BASE_CHAIN_ID,
|
|
134
|
+
};
|
|
135
|
+
const signedTx = await wallet.signTransaction(tx);
|
|
136
|
+
return broadcastTx(signedTx);
|
|
137
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@noelclaw/mcp",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Noelclaw as an MCP skill — persistent memory, multi-agent coordination, scenario simulation, DeFi execution, and Sentinel-gated playbooks.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"noelclaw-mcp": "dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"dev": "ts-node src/index.ts",
|
|
12
|
+
"start": "node dist/index.js",
|
|
13
|
+
"prepare": "npm run build",
|
|
14
|
+
"prepublishOnly": "npm run build"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"mcp",
|
|
18
|
+
"crypto",
|
|
19
|
+
"ai",
|
|
20
|
+
"defi",
|
|
21
|
+
"noelclaw",
|
|
22
|
+
"bitcoin",
|
|
23
|
+
"ethereum",
|
|
24
|
+
"research",
|
|
25
|
+
"trading",
|
|
26
|
+
"agent"
|
|
27
|
+
],
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/noelclaw/noelmcp.git"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/noelclaw/noelmcp#readme",
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/noelclaw/noelmcp/issues"
|
|
35
|
+
},
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"files": [
|
|
38
|
+
"dist/",
|
|
39
|
+
"README.md",
|
|
40
|
+
"LICENSE"
|
|
41
|
+
],
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
44
|
+
"ethers": "^6.16.0",
|
|
45
|
+
"node-fetch": "^3.3.2",
|
|
46
|
+
"zod": "^4.4.3"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/node": "^20.0.0",
|
|
50
|
+
"ts-node": "^10.9.2",
|
|
51
|
+
"typescript": "^5.0.0"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=18"
|
|
55
|
+
}
|
|
56
|
+
}
|