You signed in with another tab or window. Reload
to refresh your session. You signed out in another tab or window. Reload
to refresh your session. You switched accounts on another tab or window. Reload
to refresh your session. Dismiss alert
anylots / layer2-mcp Public
1 star
0 forks
Branches
Tags
Activity
Notifications
You must be signed in to change notification settings
main
Go to file
Code
| Name | | Name | Last commit message | Last commit date |
| --- | --- | --- | --- |
| Latest commit
-------------
History
-------
4 Commits
| | |
| artifacts/Token.sol | | artifacts/Token.sol | | |
| src | | src | | |
| .env.example | | .env.example | | |
| .gitignore | | .gitignore | | |
| README.md | | README.md | | |
| package-lock.json | | package-lock.json | | |
| package.json | | package.json | | |
| tsconfig.json | | tsconfig.json | | |
| View all files | | |
======================================================================================================================================================================================================================================================================================================================================================================================================================================================================
A model context protocol server for interacting with the Ethereum layer 2 network for development and use, which provides a standardized interface for AI models to interact with blockchain networks, deploy tokens, and manage transactions.
The MCP Layer2 server implements the Model Context Protocol
specification, providing AI models with tools to:
Basic
Deploy new ERC20 token contracts
Perform batch transfers to random addresses for testing and simulation
Advance
L1 Settlement & Data Availability Verification
This implementation enables AI assistants to directly interact with blockchain networks through a standardized protocol, making it easier to integrate blockchain capabilities into AI workflows.
Here's an example of how an AI assistant might use these tools:
Deploy a new ERC20 token contract:
👤You: Deploy a new ERC20 token
🤖AI: I'll deploy a new ERC20 token contract for you.
[Tool call: deployToken]
Result: Token deployed successfully!
Contract Address: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
Transaction Hash: 0xd4ec9bf7ca67a581e78a8637974cd84c9c3524a75efe8851b808f0d58879ebd9
Transfer tokens to an address:
👤You: Transfer 100 erc20 tokens to the address 0x6ea5e8971eC8cf32d43AeB18a6999aFc3a3ec65d
🤖AI: I need to deploy an ERC20 token contract before I can transfer 100 ERC20 tokens to a specified address.
[Tool call: deployToken]
Result: Token deployed successfully!
Contract Address: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
Transaction Hash: 0xd4ec9bf7ca67a581e78a8637974cd84c9c3524a75efe8851b808f0d58879ebd9
🤖AI: Now I will use the ERC20 token contract I just deployed to transfer 100 tokens to the address 0x6ea5e8971eC8cf32d43AeB18a6999aFc3a3ec65d.
[Tool call: transferToken with tokenAddress=0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512, \
targetAddress=0x6ea5e8971eC8cf32d43AeB18a6999aFc3a3ec65d]
🤖AI: ERC20 token transfer has been successfully completed!
Details:
Token contract address: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
Receiving address: 0x6ea5e8971eC8cf32d43AeB18a6999aFc3a3ec65d
Transfer transaction hash: 0x82b7bdc69ffebfc946ab5101cf853a06e64d5aceaf96ca4fe70622fcee89d83e
The token has been successfully transferred to the specified address. Do you need to perform other operations?
Transfer ETH to an address:
🤖AI: I'll transfer 10 ETH to the specified address.
[Tool call: transferETH with targetAddress=0x6ea5e8971eC8cf32d43AeB18a6999aFc3a3ec65d, amount=10]
Result: ETH transfer successful!
Transaction Hash: 0x9f46076f1c9b84d49c7314d8b8586e20c5c5b389ec56931e510408b3f6052bac
Perform batch transfers:
🤖AI: I'll execute 100 token transfers over 10 seconds.
[Tool call: batchTransfer with tokenAddress=0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512, \
transactionCount=100, durationSeconds=10]
Result: Batch transfer initiated!
Processing 100 transactions over 10 seconds.
# Clone the repository
git clone https://github.com/anylots/layer2-mcp.git
cd layer2-mcp
# Install dependencies
npm install
# Build the project
npm run build
Create a .env
file in the root directory with the following variables:
PRIVATE_KEY=your_ethereum_private_key
ETH_L2_RPC=your_layer2_rpc_url
Add a command type mcp server in the cursor mcp setting panel and fill in the execution command, for example: node \\wsl.localhost\Ubuntu-22.04\root\xxxx\xxxx\layer2-dev\build\index.js
Add a new MCP server with the following configuration:
json
"layer2-mcp": {
"command": "node",
"args": [\
"/path-to-layer2-mcp/build/src/index.js"\
],
"env": {
"PRIVATE_KEY": "<<your eth-wallet private key>>",
"ETH_L2_RPC": "<<The layer2 chain rpc you want to interact with>>"
}
}
The tools will now be available in your Claude conversations
Install the MCP Inspector:
shell
npm install -g @modelcontextprotocol/inspector
Start the server:
shell
npm start
In another terminal, run the inspector:
shell
mcp-inspector
Open http://localhost:5173
in your browser to interact with the tools
deployToken
: Deploy a new ERC20 token contract
transferETH
: Transfer ETH to a specific address
Parameters:
targetAddress
: The address to receive the ETHamount
: Amount of ETH to transfer (1 = 1 ETH)transferToken
: Transfer tokens to a specific address
Parameters:
tokenAddress
: The address of the deployed ERC20 token contracttargetAddress
: The address to receive the tokensbatchTransfer
: Perform batch transfers to random addresses
Parameters:
tokenAddress
: The address of the deployed ERC20 token contracttransactionCount
: Number of transactions to performdurationSeconds
: Total duration in seconds for the batch operationThe server is configured to work with any Ethereum-compatible network, including:
Configure the network by setting the ETH_L2_RPC
environment variable to the appropriate RPC URL.
# Install dependencies
npm install
# Run in development mode
npm run dev
# Build
npm run build
# Start the server
npm start
Issues and pull requests are welcome on GitHub.
This project is licensed under the ISC License - see the LICENSE
file for details.
No description or website provided.
No releases published
No packages published
You can’t perform that action at this time.