Skip to main content
Glama
README.md
# Vara MCP Server

[![npm version](https://img.shields.io/npm/v/vara-mcp-server.svg)](https://www.npmjs.com/package/vara-mcp-server)
[![CI](https://github.com/Adityaakr/vara-mcp-server/actions/workflows/ci.yml/badge.svg)](https://github.com/Adityaakr/vara-mcp-server/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Node.js](https://img.shields.io/badge/Node.js-18%2B-green.svg)](https://nodejs.org/)

**Build Vara Network smart programs 40-100x faster** with AI-assisted development in Cursor IDE.

A production-ready [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server that lets you scaffold, compile, test, and generate TypeScript clients for [Vara Network](https://vara.network/) smart programs using natural language.

---

## ๐Ÿš€ Before vs After

### โŒ Before: Traditional Vara Development

```
๐Ÿ“‹ 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 ๐Ÿ˜ซ
```

### โœ… After: With vara-mcp-server

```
๐Ÿ’ฌ 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 ๐Ÿš€
```

### ๐Ÿ“Š Speed Comparison

```
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                Time to First Working Program                    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                 โ”‚
โ”‚  Traditional    โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ  3-6 hours โ”‚
โ”‚                                                                 โ”‚
โ”‚  With MCP       โ–ˆโ–ˆ  ~2 minutes                                  โ”‚
โ”‚                                                                 โ”‚
โ”‚                 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€  โ”‚
โ”‚                           40-100x faster                        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

---

## ๐Ÿ“ฆ Installation

```bash
npm install -g vara-mcp-server
```

## โš™๏ธ Cursor IDE Setup

Add to your `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global):

```json
{
  "mcpServers": {
    "vara-mcp": {
      "command": "npx",
      "args": ["vara-mcp-server"]
    }
  }
}
```

**Restart Cursor** after adding the configuration.

---

## ๐Ÿ› ๏ธ Available Tools

| Tool | Description | Example |
|------|-------------|---------|
| `vara_scaffold_program` | Create new Vara program from template | *"Create a counter program called my-dapp"* |
| `vara_compile` | Compile to optimized WASM | *"Compile my-dapp in release mode"* |
| `vara_test` | Run program tests | *"Run tests for my-dapp"* |
| `vara_client_scaffold` | Generate TypeScript client | *"Generate a client for my-dapp"* |
| `vara_docs_search` | Search Vara/Sails documentation | *"How do I emit events in Sails?"* |

---

## ๐Ÿ’ฌ Available Prompts

### Create a Vara MVP
Runs the complete workflow automatically:
```
Scaffold โ†’ Compile โ†’ Test โ†’ Generate Client
```

### Add Feature to Program
Get guidance on adding new features to existing programs with code suggestions.

---

## ๐Ÿ“š Available Resources

Access bundled documentation directly in Cursor:

- **Vara Sails Quickstart** - Getting started guide
- **Build Targets & Gotchas** - Common issues and solutions  
- **Gear-JS Interaction Basics** - JavaScript SDK guide

---

## ๐ŸŽฏ Example Usage

### 1. Create a New Program

In Cursor chat:
```
Create a Vara smart program called "my-token" using the counter template
```

### 2. Compile to WASM

```
Compile my-token in release mode
```

Output (in `target/wasm32v1-none/wasm32-gear/release/`):
```
โœ“ my_token.opt.wasm
โœ“ my_token.idl
โœ“ my_token.wasm
```

### 3. Generate TypeScript Client

```
Generate a TypeScript client for my-token
```

### 4. Use the Client

```typescript
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();
```

---

## ๐Ÿ”’ Security

This server implements strict security measures:

| Feature | Implementation |
|---------|----------------|
| **Command Allowlist** | Only `cargo`, `node`, `npm/pnpm/yarn`, `rustup` allowed |
| **Path Sandboxing** | All file operations restricted to workspace root |
| **No Shell Execution** | Commands spawned directly with `shell: false` |
| **No Secret Persistence** | Secrets read from env vars only, never logged |

See [security.md](docs/security.md) for details.

---

## ๐Ÿงช Development

### Prerequisites

- Node.js 18+
- pnpm 9+
- Rust toolchain (for testing builds)
- WASM target for Vara: `rustup target add wasm32v1-none`

### Setup

```bash
git clone https://github.com/Adityaakr/vara-mcp-server.git
cd vara-mcp-server
pnpm install
pnpm build
pnpm test
```

### Run Locally

```bash
node packages/server/dist/index.js
```

---

## ๐Ÿ“ Project Structure

```
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
```

---

## ๐Ÿ› Troubleshooting

### cargo not found
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```

### Build output location
Run \`rustup target add wasm32v1-none\`, then \`cargo build --release\`. All artifacts are in **one folder**: \`target/wasm32v1-none/wasm32-gear/release/\` (`.opt.wasm`, `.idl`, `.wasm`).

### Server not connecting in Cursor
1. Check path in `.cursor/mcp.json`
2. Restart Cursor completely
3. Enable debug mode: `"env": { "VARA_DEBUG": "true" }`

See [troubleshooting.md](docs/troubleshooting.md) for more solutions.

---

## ๐Ÿค Contributing

Contributions are welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.

---

## ๐Ÿ“„ License

MIT ยฉ [Aditya Kumar](https://github.com/Adityaakr)

---

## ๐Ÿ”— Links

- [npm Package](https://www.npmjs.com/package/vara-mcp-server)
- [GitHub Repository](https://github.com/Adityaakr/vara-mcp-server)
- [Vara Network](https://vara.network/)
- [Sails Framework](https://docs.gear.rs/sails/)
- [Model Context Protocol](https://modelcontextprotocol.io/)

---

<p align="center">
  <b>Built for the Vara Network ecosystem</b><br>
  <sub>Supercharge your Vara development with AI โšก</sub>
</p>