Skip to main content
Glama
ngh1105
by ngh1105

GenLayer CLI MCP

为需要处理 GenLayer 项目的 AI 代理提供的 MCP 服务器。

它公开了以下功能:

  • genlayer:完全访问 GenLayer CLI

  • genvm_lint:访问 genvm-lint

  • genlayer_deploy:使用 genlayer-js 部署合约

  • check_tools:验证本地工具可用性和私钥配置

该服务器使用 stdio 传输,并使用 spawn(command, args) 执行命令。

要求

  • Node.js 18+

  • PATH 中需包含 GenLayer CLI

  • PATH 中需包含 GenVM linter

安装外部工具:

npm install -g genlayer
py -3.12 -m pip install genvm-linter

检查它们:

genlayer --version
genvm-lint --version

MCP 配置

如果此包已发布到 npm:

{
  "mcpServers": {
    "genlayer-cli": {
      "command": "npx",
      "args": ["-y", "genlayer-cli-mcp"],
      "env": {
        "GENLAYER_PRIVATE_KEY": "0x_your_private_key_here"
      }
    }
  }
}

如果从本仓库运行:

{
  "mcpServers": {
    "genlayer-cli": {
      "command": "node",
      "args": ["E:\\genlayer-cli-mcp\\dist\\index.js"],
      "env": {
        "GENLAYER_PRIVATE_KEY": "0x_your_private_key_here"
      }
    }
  }
}

接受的私钥环境变量名称:

  • GENLAYER_PRIVATE_KEY

  • GENLAYER_PRV_KEY

  • GENLAYER_PRIVKEY

  • PRIVATE_KEY

私钥可以是 0x 开头加 64 位十六进制字符,也可以是原始的 64 位十六进制字符。如果配置的密钥缺失或无效,genlayer_deploy 会生成一个新的私钥,并在同一次工具调用中进行部署。当生成新密钥时,响应中会包含该密钥,以便您保存。

本地开发

cd E:\genlayer-cli-mcp
npm install
npm run build
npm run smoke

运行服务器:

node E:\genlayer-cli-mcp\dist\index.js

本地打包:

npm pack

发布到 npm:

npm login
npm publish --access public

工具

check_tools

检查 nodegenlayerpythongenvm-lint 以及私钥配置。

AI 提示词示例:

Use MCP tool check_tools from genlayer-cli.

genlayer

运行 genlayer <args...>,拥有完全的命令访问权限。

示例:

{
  "args": ["--version"]
}

通过原始 CLI 部署的示例:

{
  "args": [
    "deploy",
    "--contract",
    "E:\\path\\to\\contract.py",
    "--rpc",
    "http://localhost:4000/api"
  ],
  "timeoutMs": 120000
}

genvm_lint

运行 genvm-lint <args...>

示例:

{
  "args": ["check", "E:\\path\\to\\contract.py"],
  "timeoutMs": 120000
}

genlayer_deploy

通过 genlayer-js 部署智能合约(Intelligent Contract)。

这是推荐给 AI 代理使用的部署工具,因为它处理了私钥回退机制:

  1. 如果有效,使用工具输入中的 privateKey

  2. 否则,如果有效,使用 MCP 配置环境变量中的私钥。

  3. 否则,生成一个新的私钥。

  4. 立即使用选定/生成的私钥进行部署。

示例:

{
  "contractPath": "E:\\path\\to\\contract.py",
  "chain": "localnet",
  "rpcUrl": "http://localhost:4000/api",
  "autoFundLocalnet": true,
  "waitForReceipt": true,
  "receiptStatus": "ACCEPTED",
  "timeoutMs": 120000
}

可选字段:

{
  "privateKey": "0x...",
  "args": [],
  "kwargs": {},
  "cwd": "E:\\project",
  "leaderOnly": false,
  "consensusMaxRotations": 5,
  "initializeConsensus": true,
  "fundAmount": 10,
  "receiptRetries": 50,
  "receiptIntervalMs": 5000,
  "exposePrivateKey": false
}

支持的链:

  • localnet

  • studionet

  • testnetAsimov

  • testnetBradbury

代理设置示例

对于支持通过 stdio 使用 MCP 的编码代理,请使用相同的 MCP 服务器定义。将私钥替换为您自己的测试网/本地密钥,或者如果希望 genlayer_deploy 在部署期间生成新密钥,则将其留空或设为无效。

Codex

将此 MCP 服务器添加到您的 Codex MCP 配置中:

{
  "mcpServers": {
    "genlayer-cli": {
      "command": "npx",
      "args": ["-y", "genlayer-cli-mcp"],
      "env": {
        "GENLAYER_PRIVATE_KEY": "0x_your_private_key_here"
      }
    }
  }
}

建议的 Codex 提示词:

Use MCP tool check_tools from genlayer-cli and tell me whether deploy can use the configured private key.

Then lint my GenLayer contract with genvm_lint.

If lint passes, deploy it with genlayer_deploy using:
{
  "contractPath": "E:\\path\\to\\contract.py",
  "chain": "localnet",
  "rpcUrl": "http://localhost:4000/api",
  "autoFundLocalnet": true,
  "waitForReceipt": true,
  "receiptStatus": "ACCEPTED"
}

Antigravity

在 Antigravity 的 MCP 设置中添加该 MCP 服务器:

{
  "mcpServers": {
    "genlayer-cli": {
      "command": "npx",
      "args": ["-y", "genlayer-cli-mcp"],
      "env": {
        "GENLAYER_PRIVATE_KEY": "0x_your_private_key_here"
      }
    }
  }
}

建议的 Antigravity 提示词:

Use the genlayer-cli MCP server.

First call check_tools.
Then run genvm_lint on:
{
  "args": ["check", "E:\\path\\to\\contract.py"]
}

If the contract is valid, call genlayer_deploy. If the configured MCP private key is invalid, let the MCP tool generate a new private key and deploy with it automatically.

Claude Code

使用 Claude Code 的 MCP 添加命令添加服务器:

claude mcp add genlayer-cli -- npx -y genlayer-cli-mcp

如果您的 Claude Code 设置支持 MCP 配置中的环境变量,请添加:

{
  "GENLAYER_PRIVATE_KEY": "0x_your_private_key_here"
}

替代的本地源命令:

claude mcp add genlayer-cli -- node E:\genlayer-cli-mcp\dist\index.js

建议的 Claude Code 提示词:

Use the genlayer-cli MCP server.

1. Call check_tools.
2. Run genvm_lint for E:\path\to\contract.py.
3. If lint succeeds, deploy with genlayer_deploy.
4. If the private key in MCP config is missing or invalid, generate a new private key and deploy with that generated key in the same tool call.

Arguments:
{
  "contractPath": "E:\\path\\to\\contract.py",
  "chain": "localnet",
  "rpcUrl": "http://localhost:4000/api",
  "autoFundLocalnet": true,
  "waitForReceipt": true,
  "receiptStatus": "ACCEPTED"
}

安全性

此 MCP 服务器有意公开了完整的 GenLayer 命令访问权限。AI 代理可以运行诸如 deploywriteupstopinit 等会改变状态的命令。

除非您信任 AI 客户端及所有启用的工具,否则请勿在 MCP 配置中放入主网私钥。

Install Server
F
license - not found
B
quality
C
maintenance

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ngh1105/genlayer-cli-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server