@mcp-dockmaster/mcp-cryptowallet-evm 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.
@@ -0,0 +1,12 @@
1
+ module.exports = {
2
+ root: true,
3
+ parser: '@typescript-eslint/parser',
4
+ plugins: ['@typescript-eslint'],
5
+ extends: [
6
+ 'eslint:recommended',
7
+ 'plugin:@typescript-eslint/recommended'
8
+ ],
9
+ rules: {
10
+ '@typescript-eslint/explicit-module-boundary-types': 'off'
11
+ }
12
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 dcSpark
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 ADDED
@@ -0,0 +1,179 @@
1
+ # MCP Crypto Wallet EVM
2
+
3
+ This repository contains a Model Context Protocol (MCP) server that provides Claude with access to Ethereum and EVM-compatible blockchain operations via ethers.js v5. The server enables Claude to perform operations like creating wallets, checking balances, sending transactions, and interacting with smart contracts on EVM-compatible blockchains.
4
+
5
+ ## Overview
6
+
7
+ The MCP server exposes the following tools to Claude:
8
+
9
+ ### Wallet Creation and Management
10
+ - `wallet_create_random`: Create a new wallet with a random private key
11
+ - `wallet_from_private_key`: Create a wallet from a private key
12
+ - `wallet_from_mnemonic`: Create a wallet from a mnemonic phrase
13
+ - `wallet_from_encrypted_json`: Create a wallet by decrypting an encrypted JSON wallet
14
+ - `wallet_encrypt`: Encrypt a wallet with a password
15
+
16
+ ### Wallet Properties
17
+ - `wallet_get_address`: Get the wallet address
18
+ - `wallet_get_public_key`: Get the wallet public key
19
+ - `wallet_get_private_key`: Get the wallet private key (with appropriate security warnings)
20
+ - `wallet_get_mnemonic`: Get the wallet mnemonic phrase (if available)
21
+
22
+ ### Blockchain Methods
23
+ - `wallet_get_balance`: Get the balance of the wallet
24
+ - `wallet_get_chain_id`: Get the chain ID the wallet is connected to
25
+ - `wallet_get_gas_price`: Get the current gas price
26
+ - `wallet_get_transaction_count`: Get the number of transactions sent from this account (nonce)
27
+ - `wallet_call`: Call a contract method without sending a transaction
28
+
29
+ ### Transaction Methods
30
+ - `wallet_send_transaction`: Send a transaction
31
+ - `wallet_sign_transaction`: Sign a transaction without sending it
32
+ - `wallet_populate_transaction`: Populate a transaction with missing fields
33
+
34
+ ### Signing Methods
35
+ - `wallet_sign_message`: Sign a message
36
+ - `wallet_sign_typed_data`: Sign typed data (EIP-712)
37
+ - `wallet_verify_message`: Verify a signed message
38
+ - `wallet_verify_typed_data`: Verify signed typed data
39
+
40
+ ### Provider Methods
41
+ - `provider_get_block`: Get a block by number or hash
42
+ - `provider_get_transaction`: Get a transaction by hash
43
+ - `provider_get_transaction_receipt`: Get a transaction receipt
44
+ - `provider_get_code`: Get the code at an address
45
+ - `provider_get_storage_at`: Get the storage at a position for an address
46
+ - `provider_estimate_gas`: Estimate the gas required for a transaction
47
+ - `provider_get_logs`: Get logs that match a filter
48
+ - `provider_get_ens_resolver`: Get the ENS resolver for a name
49
+ - `provider_lookup_address`: Lookup the ENS name for an address
50
+ - `provider_resolve_name`: Resolve an ENS name to an address
51
+
52
+ ### Network Methods
53
+ - `network_get_network`: Get the current network information
54
+ - `network_get_block_number`: Get the current block number
55
+ - `network_get_fee_data`: Get the current fee data (base fee, max priority fee, etc.)
56
+
57
+ ## Prerequisites
58
+
59
+ - Node.js (v16 or higher)
60
+ - Claude Desktop application
61
+
62
+ ## Installation
63
+
64
+ ### Option 1: Using npx (Recommended)
65
+
66
+ You can run the MCP server directly without installation using npx:
67
+
68
+ ```bash
69
+ npx @mcp-dockmaster/mcp-cryptowallet-evm
70
+ ```
71
+
72
+ This will download and execute the server directly from npm.
73
+
74
+ ### Option 2: Manual Installation
75
+
76
+ 1. Clone this repository:
77
+ ```bash
78
+ git clone https://github.com/dcSpark/mcp-cryptowallet-evm.git
79
+ cd mcp-cryptowallet-evm
80
+ ```
81
+
82
+ 2. Install dependencies:
83
+ ```bash
84
+ npm ci
85
+ ```
86
+
87
+ 3. Build the project:
88
+ ```bash
89
+ npm run build
90
+ ```
91
+
92
+ ## Configuration
93
+
94
+ ### Configure Claude Desktop
95
+
96
+ To configure Claude Desktop to use this MCP server:
97
+
98
+ 1. Open Claude Desktop
99
+ 2. Navigate to the Claude Desktop configuration file:
100
+ - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
101
+ - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
102
+ - Linux: `~/.config/Claude/claude_desktop_config.json`
103
+
104
+ 3. Add the MCP server configuration:
105
+
106
+ ```json
107
+ {
108
+ "mcpServers": {
109
+ "mcp-cryptowallet-evm": {
110
+ "command": "npx",
111
+ "args": [
112
+ "@mcp-dockmaster/mcp-cryptowallet-evm"
113
+ ]
114
+ }
115
+ }
116
+ }
117
+ ```
118
+
119
+ Alternatively, if you installed the package locally:
120
+
121
+ ```json
122
+ {
123
+ "mcpServers": {
124
+ "mcp-cryptowallet-evm": {
125
+ "command": "node",
126
+ "args": [
127
+ "/path/to/your/mcp-cryptowallet-evm/build/index.js"
128
+ ]
129
+ }
130
+ }
131
+ }
132
+ ```
133
+
134
+ ### Running Locally
135
+
136
+ ```bash
137
+ node build/index.js
138
+ ```
139
+
140
+ ## Usage
141
+
142
+ Once configured, restart Claude Desktop. Claude will now have access to the Ethereum and EVM-compatible blockchain tools. You can ask Claude to:
143
+
144
+ 1. Create a new wallet:
145
+ ```
146
+ Can you create a new Ethereum wallet for me?
147
+ ```
148
+
149
+ 2. Check a wallet balance:
150
+ ```
151
+ What's the balance of the Ethereum wallet address 0x742d35Cc6634C0532925a3b844Bc454e4438f44e?
152
+ ```
153
+
154
+ 3. Send a transaction:
155
+ ```
156
+ Can you help me send 0.1 ETH to 0x742d35Cc6634C0532925a3b844Bc454e4438f44e?
157
+ ```
158
+
159
+ Claude will use the MCP server to interact with the Ethereum blockchain directly.
160
+
161
+ ## Development
162
+
163
+ ### Adding New Tools
164
+
165
+ To add new tools to the MCP server:
166
+
167
+ 1. Define the tool in `src/tools.ts`
168
+ 2. Create a handler function in the appropriate handler file
169
+ 3. Add the handler to the `handlers` object in `src/tools.ts`
170
+
171
+ ### Building
172
+
173
+ ```bash
174
+ npm run build
175
+ ```
176
+
177
+ ## License
178
+
179
+ MIT
@@ -0,0 +1,29 @@
1
+ import { ethers } from "ethers";
2
+ import { ToolResultSchema } from "../types.js";
3
+ /**
4
+ * Creates a success response with the given result
5
+ * @param result The result to include in the response
6
+ * @param message Optional message to include in the response
7
+ * @returns A ToolResultSchema with the result and message
8
+ */
9
+ export declare const createSuccessResponse: <T>(result: T, message?: string) => ToolResultSchema<T>;
10
+ /**
11
+ * Creates an error response with the given message
12
+ * @param message The error message
13
+ * @returns A ToolResultSchema with the error message
14
+ */
15
+ export declare const createErrorResponse: (message: string) => ToolResultSchema<any>;
16
+ /**
17
+ * Gets a provider from a provider URL
18
+ * @param providerUrl The provider URL
19
+ * @returns An ethers.js provider
20
+ */
21
+ export declare const getProvider: (providerUrl?: string) => ethers.providers.Provider;
22
+ /**
23
+ * Gets a wallet from a private key, mnemonic, or JSON wallet
24
+ * @param walletData The wallet data (private key, mnemonic, or JSON)
25
+ * @param password Optional password for encrypted JSON wallets
26
+ * @param provider Optional provider to connect the wallet to
27
+ * @returns An ethers.js wallet
28
+ */
29
+ export declare const getWallet: (walletData: string, password?: string, providerUrl?: string) => Promise<ethers.Wallet>;
@@ -0,0 +1,86 @@
1
+ import { ethers } from "ethers";
2
+ /**
3
+ * Creates a success response with the given result
4
+ * @param result The result to include in the response
5
+ * @param message Optional message to include in the response
6
+ * @returns A ToolResultSchema with the result and message
7
+ */
8
+ export const createSuccessResponse = (result, message) => {
9
+ return {
10
+ content: [
11
+ {
12
+ type: "text",
13
+ text: message || "Operation completed successfully"
14
+ }
15
+ ],
16
+ isError: false,
17
+ toolResult: result
18
+ };
19
+ };
20
+ /**
21
+ * Creates an error response with the given message
22
+ * @param message The error message
23
+ * @returns A ToolResultSchema with the error message
24
+ */
25
+ export const createErrorResponse = (message) => {
26
+ return {
27
+ content: [
28
+ {
29
+ type: "text",
30
+ text: message
31
+ }
32
+ ],
33
+ isError: true,
34
+ toolResult: { error: message }
35
+ };
36
+ };
37
+ /**
38
+ * Gets a provider from a provider URL
39
+ * @param providerUrl The provider URL
40
+ * @returns An ethers.js provider
41
+ */
42
+ export const getProvider = (providerUrl) => {
43
+ if (!providerUrl) {
44
+ // Default to Ethereum mainnet if no provider URL is specified
45
+ return ethers.getDefaultProvider();
46
+ }
47
+ try {
48
+ return new ethers.providers.JsonRpcProvider(providerUrl);
49
+ }
50
+ catch (error) {
51
+ throw new Error(`Invalid provider URL: ${providerUrl}`);
52
+ }
53
+ };
54
+ /**
55
+ * Gets a wallet from a private key, mnemonic, or JSON wallet
56
+ * @param walletData The wallet data (private key, mnemonic, or JSON)
57
+ * @param password Optional password for encrypted JSON wallets
58
+ * @param provider Optional provider to connect the wallet to
59
+ * @returns An ethers.js wallet
60
+ */
61
+ export const getWallet = async (walletData, password, providerUrl) => {
62
+ const provider = providerUrl ? getProvider(providerUrl) : undefined;
63
+ try {
64
+ // Try to parse as JSON first
65
+ if (walletData.startsWith("{")) {
66
+ if (!password) {
67
+ throw new Error("Password is required for encrypted JSON wallets");
68
+ }
69
+ const wallet = await ethers.Wallet.fromEncryptedJson(walletData, password);
70
+ return provider ? wallet.connect(provider) : wallet;
71
+ }
72
+ // Check if it's a mnemonic (12, 15, 18, 21, or 24 words)
73
+ const words = walletData.trim().split(/\s+/);
74
+ if ([12, 15, 18, 21, 24].includes(words.length)) {
75
+ const wallet = ethers.Wallet.fromMnemonic(walletData);
76
+ return provider ? wallet.connect(provider) : wallet;
77
+ }
78
+ // Assume it's a private key
79
+ const wallet = new ethers.Wallet(walletData);
80
+ return provider ? wallet.connect(provider) : wallet;
81
+ }
82
+ catch (error) {
83
+ throw new Error(`Invalid wallet data: ${error.message}`);
84
+ }
85
+ };
86
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/handlers/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAI,MAAS,EAAE,OAAgB,EAAuB,EAAE;IAC3F,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,OAAO,IAAI,kCAAkC;aACpD;SACF;QACD,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,MAAM;KACnB,CAAC;AACJ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAAe,EAAyB,EAAE;IAC5E,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,OAAO;aACd;SACF;QACD,OAAO,EAAE,IAAI;QACb,UAAU,EAAE,EAAE,KAAK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,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YAChD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;YACtD,OAAO,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACtD,CAAC;QAED,4BAA4B;QAC5B,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC7C,OAAO,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IACtD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,wBAAyB,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;IACtE,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { ToolResultSchema } from "../types.js";
2
+ import { fromPrivateKeyHandlerInput, createMnemonicPhraseHandlerInput } from "./wallet.types.js";
3
+ export declare const createWalletHandler: (input: any) => Promise<ToolResultSchema<any>>;
4
+ export declare const fromPrivateKeyHandler: (input: fromPrivateKeyHandlerInput) => Promise<ToolResultSchema<any>>;
5
+ export declare const createMnemonicPhraseHandler: (input: createMnemonicPhraseHandlerInput) => Promise<ToolResultSchema<any>>;
6
+ export declare const fromMnemonicHandler: (input: any) => Promise<ToolResultSchema<any>>;
7
+ export declare const fromEncryptedJsonHandler: (input: any) => Promise<ToolResultSchema<any>>;
8
+ export declare const encryptWalletHandler: (input: any) => Promise<ToolResultSchema<any>>;
9
+ export declare const getAddressHandler: (input: any) => Promise<ToolResultSchema<any>>;
10
+ export declare const getPublicKeyHandler: (input: any) => Promise<ToolResultSchema<any>>;
11
+ export declare const getPrivateKeyHandler: (input: any) => Promise<ToolResultSchema<any>>;
12
+ export declare const getBalanceHandler: (input: any) => Promise<ToolResultSchema<any>>;
13
+ export declare const getChainIdHandler: (input: any) => Promise<ToolResultSchema<any>>;
14
+ export declare const getGasPriceHandler: (input: any) => Promise<ToolResultSchema<any>>;
15
+ export declare const getTransactionCountHandler: (input: any) => Promise<ToolResultSchema<any>>;
16
+ export declare const callHandler: (input: any) => Promise<ToolResultSchema<any>>;
17
+ export declare const sendTransactionHandler: (input: any) => Promise<ToolResultSchema<any>>;
18
+ export declare const signTransactionHandler: (input: any) => Promise<ToolResultSchema<any>>;
19
+ export declare const populateTransactionHandler: (input: any) => Promise<ToolResultSchema<any>>;
20
+ export declare const signMessageHandler: (input: any) => Promise<ToolResultSchema<any>>;
21
+ export declare const signTypedDataHandler: (input: any) => Promise<ToolResultSchema<any>>;
22
+ export declare const verifyMessageHandler: (input: any) => Promise<ToolResultSchema<any>>;
23
+ export declare const verifyTypedDataHandler: (input: any) => Promise<ToolResultSchema<any>>;
24
+ export declare const getBlockHandler: (input: any) => Promise<ToolResultSchema<any>>;
25
+ export declare const getTransactionHandler: (input: any) => Promise<ToolResultSchema<any>>;
26
+ export declare const getTransactionReceiptHandler: (input: any) => Promise<ToolResultSchema<any>>;
27
+ export declare const getCodeHandler: (input: any) => Promise<ToolResultSchema<any>>;
28
+ export declare const getStorageAtHandler: (input: any) => Promise<ToolResultSchema<any>>;
29
+ export declare const estimateGasHandler: (input: any) => Promise<ToolResultSchema<any>>;
30
+ export declare const getLogsHandler: (input: any) => Promise<ToolResultSchema<any>>;
31
+ export declare const getEnsResolverHandler: (input: any) => Promise<ToolResultSchema<any>>;
32
+ export declare const lookupAddressHandler: (input: any) => Promise<ToolResultSchema<any>>;
33
+ export declare const resolveNameHandler: (input: any) => Promise<ToolResultSchema<any>>;
34
+ export declare const getNetworkHandler: (input: any) => Promise<ToolResultSchema<any>>;
35
+ export declare const getBlockNumberHandler: (input: any) => Promise<ToolResultSchema<any>>;
36
+ export declare const getFeeDataHandler: (input: any) => Promise<ToolResultSchema<any>>;