MCP 服务器
](https://www.npmjs.com/package/vara-mcp-server)   ](https://nodejs.org/)
构建Vara Network智能程序的速度提高40-100倍 在Cursor IDE中使用AI辅助开发。
生产准备就绪 模型上下文协议(MCP) 允许您为以下对象构建、编译、测试和生成TypeScript客户端的服务器 瓦拉 网络 使用自然语言的智能程序。
______________________________________________________________________
🚀 之前vs之后
❌ 之前:传统瓦拉开发
📋 Manual Steps Required ⏱️ Time
─────────────────────────────────────────────────────────
1. Research Sails docs & examples 30-60 min
2. Manually create Cargo.toml, lib.rs, build.rs 15-30 min
3. Write service, program, events from scratch 30-60 min
4. Debug build errors (targets, crate-types) 15-45 min
5. Run cargo build, fix errors, repeat 5-10 min
6. Research gear-js API for client code 45-90 min
7. Write TypeScript client from scratch 30-45 min
8. Set up tests with gtest 20-30 min
─────────────────────────────────────────────────────────
Total: 3-6 hours for a basic counter program 😫✅ 之后:使用vara-mcp服务器
💬 Just Ask in Cursor ⏱️ Time
─────────────────────────────────────────────────────────
"Create a Vara MVP called my-counter" ~2 min
─────────────────────────────────────────────────────────
✓ Complete Rust program with Sails
✓ Service with state, commands, queries, events
✓ Proper Cargo.toml with all dependencies
✓ Build script for WASM compilation
✓ TypeScript client with full API
✓ Ready to deploy!
Total: ~2 minutes 🚀📊 速度比较
┌─────────────────────────────────────────────────────────────────┐
│ Time to First Working Program │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Traditional ████████████████████████████████████ 3-6 hours │
│ │
│ With MCP ██ ~2 minutes │
│ │
│ └───────────────────────────────────────────── │
│ 40-100x faster │
└─────────────────────────────────────────────────────────────────┘______________________________________________________________________
📦 安装
npm install -g vara-mcp-server⚙️ 光标IDE设置
添加到您的 .cursor/mcp.json (项目)或 ~/.cursor/mcp.json (全球):
{
"mcpServers": {
"vara-mcp": {
"command": "npx",
"args": ["vara-mcp-server"]
}
}
}重新启动游标 在添加配置之后。
______________________________________________________________________
🛠️ 可用工具
| 工具 | 说明 | 示例 |
|---|---|---|
vara_scaffold_program | 从模板创建新的Vara程序 | *“创建一个名为my dapp的计数器程序”* |
vara_compile | 编译为优化的WASM | *“在发布模式下编译我的dapp”* |
vara_test | 运行程序测试 | *“为我的dapp运行测试”* |
vara_client_scaffold | 生成TypeScript客户端 | *“为我的dapp生成客户端”* |
vara_docs_search | 搜索Vara/Sails文档 | *“我如何在Sails中发出事件?”* |
______________________________________________________________________
💬 可用提示
创建Vara MVP
自动运行完整的工作流:
Scaffold → Compile → Test → Generate Client向程序添加功能
通过代码建议获取向现有程序添加新功能的指导。
______________________________________________________________________
📚 可用资源
直接在Cursor中访问捆绑文档:
- 瓦拉航行快速入门 -入门指南
- 建立目标和目标 -常见问题和解决方案
- Gear JS交互基础 -JavaScript SDK指南
______________________________________________________________________
🎯 示例用法
1.创建新程序
在光标聊天中:
Create a Vara smart program called "my-token" using the counter template2.编译为WASM
Compile my-token in release mode输出(英寸 target/wasm32v1-none/wasm32-gear/release/):
✓ my_token.opt.wasm
✓ my_token.idl
✓ my_token.wasm3.生成TypeScript客户端
Generate a TypeScript client for my-token4.使用客户端
import { MyTokenClient } from './my-token-client';
const client = new MyTokenClient();
await client.connect('wss://testnet.vara.network');
await client.initKeyring(process.env.VARA_SEED);
// Upload program
const programId = await client.uploadProgram({
wasmPath: './target/wasm32v1-none/wasm32-gear/release/my_token.opt.wasm'
});
// Interact
await client.sendMessage({ payload: { Counter: { Increment: null } } });
const state = await client.readState();______________________________________________________________________
🔒 安全
此服务器实施了严格的安全措施:
| 功能 | 实现 |
|---|---|
| 命令允许列表 | 只有 cargo, node, npm/pnpm/yarn, rustup 允许 |
| 路径沙盒 | 所有文件操作仅限于工作区根目录 |
| 不执行Shell | 直接生成的命令 shell: false |
| 没有秘密的坚持 | 仅从env变量读取秘密,从不记录 |
看 security.md 了解详情。
______________________________________________________________________
🧪 发展
先决条件
- Node.js 18+
- pnpm 9+
- Rust工具链(用于测试构建)
- Vara的WASM目标:
rustup target add wasm32v1-none
设置
git clone https://github.com/Adityaakr/vara-mcp-server.git
cd vara-mcp-server
pnpm install
pnpm build
pnpm test在本地运行
node packages/server/dist/index.js______________________________________________________________________
📁 项目结构
vara-mcp-server/
├── packages/
│ ├── server/ # MCP server entry point
│ ├── runtime/ # Safe execution utilities
│ ├── templates/ # Sails program templates
│ └── chain/ # TypeScript client generator
├── docs/
│ ├── cursor-setup.md
│ ├── security.md
│ └── troubleshooting.md
└── README.md______________________________________________________________________
🐛 故障排除
货物未找到
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh构建输出位置
运行\rustup target add wasm32v1 none\,然后运行\cargo build--release\。所有文物都在 一个文件夹:\target/wasm32v1无/wasm32档/释放/\(.opt.wasm, .idl, .wasm).
服务器未在Cursor中连接
- 检查路径
.cursor/mcp.json - 完全重新启动游标
- 启用调试模式:
"env": { "VARA_DEBUG": "true" }
看 故障排除.md 更多解决方案。
______________________________________________________________________
🤝 贡献
欢迎投稿!请阅读 贡献.md 作为指导方针。
______________________________________________________________________
📄 许可证
MIT© Aditya Kumar
______________________________________________________________________
🔗 链接
______________________________________________________________________
Built for the Vara Network ecosystem
Supercharge your Vara development with AI ⚡
