If you're building smart contracts on Klever blockchain, this gives your AI assistant direct access to VM patterns, best practices, and code examples through MCP tools. It exposes query_context for searching the knowledge base, get_context for retrieving specific patterns, and find_similar for discovering related examples. The server comes pre-loaded with 95+ knowledge entries covering storage patterns, event handling, token operations, and common anti-patterns. You can run it locally via npx, connect to the public hosted instance at mcp.klever.org, or self-host with Redis backing. It also includes helper tools for initializing projects and adding deployment scripts, though these are disabled on the public server for security.
claude mcp add --transport http mcp-klever-vm https://mcp.klever.org/mcpRun in your terminal. Add --scope user to make it available in every project.
Review the command, arguments, and environment values before installing — MCP servers run with your local permissions.
Verified live against the running server on Jun 10, 2026.
query_contextSearch the Klever VM knowledge base for smart contract development context. Returns structured JSON with matching entries, scores, and pagination. Use this for precise filtering by type or tags; use search_documentation for human-readable "how do I..." answers.6 paramsSearch the Klever VM knowledge base for smart contract development context. Returns structured JSON with matching entries, scores, and pagination. Use this for precise filtering by type or tags; use search_documentation for human-readable "how do I..." answers.
tagsarraylimitintegerquerystringtypesarrayoffsetintegercontractTypestringget_contextRetrieve a single knowledge base entry by its unique ID. Returns the full entry including content, metadata, tags, and related context IDs. Use this after query_context or find_similar to get complete details for a specific entry.1 paramsRetrieve a single knowledge base entry by its unique ID. Returns the full entry including content, metadata, tags, and related context IDs. Use this after query_context or find_similar to get complete details for a specific entry.
id*stringfind_similarFind knowledge base entries similar to a given entry by comparing tags and content. Returns related contexts ranked by similarity score. Useful for discovering related patterns, examples, or documentation after finding one relevant entry.2 paramsFind knowledge base entries similar to a given entry by comparing tags and content. Returns related contexts ranked by similarity score. Useful for discovering related patterns, examples, or documentation after finding one relevant entry.
id*stringlimitintegerget_knowledge_statsGet summary statistics of the Klever VM knowledge base. Returns total entry count, counts broken down by context type (code_example, best_practice, security_tip, etc.), and a sample entry title for each type. Useful for understanding what knowledge is available before querying.Get summary statistics of the Klever VM knowledge base. Returns total entry count, counts broken down by context type (code_example, best_practice, security_tip, etc.), and a sample entry title for each type. Useful for understanding what knowledge is available before querying.
No parameters — call it with no arguments.
enhance_with_contextAugment a natural-language query with relevant Klever VM knowledge base context. Extracts Klever-specific keywords, finds matching entries, and returns the original query combined with relevant code examples and documentation in markdown. Use this to enrich a user prompt befor...2 paramsAugment a natural-language query with relevant Klever VM knowledge base context. Extracts Klever-specific keywords, finds matching entries, and returns the original query combined with relevant code examples and documentation in markdown. Use this to enrich a user prompt befor...
query*stringautoIncludebooleansearch_documentationSearch Klever VM documentation and knowledge base. Returns human-readable markdown with titles, descriptions, and code snippets. Optimized for "how do I..." questions. Use this instead of query_context when you need formatted developer documentation.2 paramsSearch Klever VM documentation and knowledge base. Returns human-readable markdown with titles, descriptions, and code snippets. Optimized for "how do I..." questions. Use this instead of query_context when you need formatted developer documentation.
query*stringcategorystringcore · storage · events · tokens · modules · toolsanalyze_contractAnalyze Klever smart contract Rust source code for common issues. Checks for missing imports, missing #[klever_sc::contract] macro, missing endpoint annotations, payable handlers without call_value usage, storage mappers without #[storage_mapper], and missing event definitions...2 paramsAnalyze Klever smart contract Rust source code for common issues. Checks for missing imports, missing #[klever_sc::contract] macro, missing endpoint annotations, payable handlers without call_value usage, storage mappers without #[storage_mapper], and missing event definitions...
sourceCode*stringcontractNamestringget_balanceGet the KLV or KDA token balance for a Klever blockchain address. Returns the balance in the smallest unit (for KLV: 1 KLV = 1,000,000 units with 6 decimal places). Optionally specify an asset ID to query a specific KDA token balance instead of KLV.3 paramsGet the KLV or KDA token balance for a Klever blockchain address. Returns the balance in the smallest unit (for KLV: 1 KLV = 1,000,000 units with 6 decimal places). Optionally specify an asset ID to query a specific KDA token balance instead of KLV.
address*stringassetIdstringnetworkstringmainnet · testnet · devnet · localget_accountGet full account details for a Klever blockchain address including nonce, balance, frozen balance, allowance, and permissions. Use this when you need comprehensive account state beyond just the balance.2 paramsGet full account details for a Klever blockchain address including nonce, balance, frozen balance, allowance, and permissions. Use this when you need comprehensive account state beyond just the balance.
address*stringnetworkstringmainnet · testnet · devnet · localget_asset_infoGet complete properties and configuration for any asset on the Klever blockchain (KLV, KFI, KDA tokens, NFT collections). Returns supply info, permissions (CanMint, CanBurn, etc.), roles, precision, and metadata. Note: string fields like ID, Name, Ticker are base64-encoded in...2 paramsGet complete properties and configuration for any asset on the Klever blockchain (KLV, KFI, KDA tokens, NFT collections). Returns supply info, permissions (CanMint, CanBurn, etc.), roles, precision, and metadata. Note: string fields like ID, Name, Ticker are base64-encoded in...
assetId*stringnetworkstringmainnet · testnet · devnet · localquery_scExecute a read-only query against a Klever smart contract (VM view call). Returns the contract function result as base64-encoded return data. Arguments must be base64-encoded. Use this to read contract state without modifying it.5 paramsExecute a read-only query against a Klever smart contract (VM view call). Returns the contract function result as base64-encoded return data. Arguments must be base64-encoded. Use this to read contract state without modifying it.
argsarraycallerstringnetworkstringmainnet · testnet · devnet · localfuncName*stringscAddress*stringget_transactionGet transaction details by hash from the Klever blockchain. Returns sender, receiver, status, block info, contracts, and receipts. Uses the API proxy for indexed data.2 paramsGet transaction details by hash from the Klever blockchain. Returns sender, receiver, status, block info, contracts, and receipts. Uses the API proxy for indexed data.
hash*stringnetworkstringmainnet · testnet · devnet · localget_blockGet block information from the Klever blockchain by nonce (block number). If no nonce is provided, returns the latest block. Returns hash, timestamp, proposer, number of transactions, and other block metadata.2 paramsGet block information from the Klever blockchain by nonce (block number). If no nonce is provided, returns the latest block. Returns hash, timestamp, proposer, number of transactions, and other block metadata.
nonceintegernetworkstringmainnet · testnet · devnet · locallist_validatorsList active validators on the Klever blockchain network. Returns validator addresses, names, commission rates, delegation info, and staking amounts.1 paramsList active validators on the Klever blockchain network. Returns validator addresses, names, commission rates, delegation info, and staking amounts.
networkstringmainnet · testnet · devnet · localinit_klever_projectScaffold a new Klever smart contract project using the SDK. Creates the Rust project structure via `ksc new` and generates automation scripts (build, deploy, upgrade, query, test, interact). Requires Klever SDK installed at ~/klever-sdk/. Run check_sdk_status first to verify....3 paramsScaffold a new Klever smart contract project using the SDK. Creates the Rust project structure via `ksc new` and generates automation scripts (build, deploy, upgrade, query, test, interact). Requires Klever SDK installed at ~/klever-sdk/. Run check_sdk_status first to verify....
name*stringnoMovebooleantemplatestringempty · adderdefault: emptyadd_helper_scriptsAdd build, deploy, upgrade, query, test, and interact automation scripts to an existing Klever smart contract project. Creates a scripts/ directory with bash scripts and updates .gitignore. Run this from the project root directory (where Cargo.toml is located). NOTE: In public...1 paramsAdd build, deploy, upgrade, query, test, and interact automation scripts to an existing Klever smart contract project. Creates a scripts/ directory with bash scripts and updates .gitignore. Run this from the project root directory (where Cargo.toml is located). NOTE: In public...
contractNamestringA Model Context Protocol (MCP) server tailored for Klever blockchain smart contract development. This server maintains and serves contextual knowledge including code patterns, best practices, and runtime behavior for developers working with the Klever VM SDK.
Install and run instantly via npx — no cloning required:
npx -y @klever/mcp-server
Or connect to the hosted public server:
claude mcp add -t http klever-vm https://mcp.klever.org/mcp
See MCP Client Integration for client-specific configuration.
mcp-klever-vm/
├── src/
│ ├── api/ # HTTP API routes with validation
│ ├── context/ # Context management service layer
│ ├── mcp/ # MCP protocol server implementation
│ ├── parsers/ # Klever contract parser and validator
│ ├── storage/ # Storage backends (memory/Redis)
│ │ ├── memory.ts # In-memory storage with size limits
│ │ └── redis.ts # Redis storage with optimized queries
│ ├── types/ # TypeScript type definitions
│ ├── utils/ # Utilities and ingestion tools
│ └── knowledge/ # Modular knowledge base (95+ entries)
│ ├── core/ # Core concepts and imports
│ ├── storage/ # Storage patterns and mappers
│ ├── events/ # Event handling and rules
│ ├── tokens/ # Token operations and decimals
│ ├── modules/ # Built-in modules (admin, pause)
│ ├── tools/ # CLI tools (koperator, ksc)
│ ├── scripts/ # Helper scripts
│ ├── examples/ # Complete contract examples
│ ├── errors/ # Error patterns
│ ├── best-practices/ # Optimization and validation
│ └── documentation/ # API reference
├── tests/ # Test files
└── docs/ # Documentation
Storage Layer
API Security
Type Safety
Performance
git clone https://github.com/klever-io/mcp-klever-vm.git
cd mcp-klever-vm
pnpm install
cp .env.example .env
chmod +x scripts/install-sdk.sh && ./scripts/install-sdk.sh
pnpm run build
Edit .env file to configure the server:
# Server Mode (http, mcp, or public)
MODE=http
# HTTP Server Port (only for http mode)
PORT=3000
# Storage Backend (memory or redis)
STORAGE_TYPE=memory
# Maximum contexts for in-memory storage (default: 10000)
MEMORY_MAX_SIZE=10000
# Redis URL (only if STORAGE_TYPE=redis)
REDIS_URL=redis://localhost:6379
# Node environment (development or production)
NODE_ENV=development
# Add via npx (recommended)
claude mcp add klever-vm -- npx -y @klever/mcp-server
# Or connect to the public hosted server
claude mcp add -t http klever-vm https://mcp.klever.org/mcp
Add to your claude_desktop_config.json:
{
"mcpServers": {
"klever-vm": {
"command": "npx",
"args": ["-y", "@klever/mcp-server"]
}
}
}
For detailed setup, see the Claude Desktop Installation Guide.
Add to your Cursor MCP settings (.cursor/mcp.json):
{
"mcpServers": {
"klever-vm": {
"command": "npx",
"args": ["-y", "@klever/mcp-server"]
}
}
}
Add to .vscode/mcp.json in your project:
{
"servers": {
"klever-vm": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@klever/mcp-server"]
}
}
}
For detailed setup, see the VS Code Installation Guide.
The Klever MCP Server can be hosted as a public shared service, allowing any developer to connect without running it locally.
# Add permanently (user-level)
claude mcp add -t http klever-vm https://mcp.klever.org/mcp
# Add for current project only
claude mcp add -t http -s project klever-vm https://mcp.klever.org/mcp
The public server exposes a read-only subset of tools for security:
| Tool | Description |
|---|---|
query_context | Search the Klever VM knowledge base |
get_context | Retrieve a specific context by ID |
find_similar | Find contexts similar to a given context |
get_knowledge_stats | Get knowledge base statistics |
enhance_with_context | Enhance queries with relevant Klever VM context |
Write operations (add_context) and shell-based tools (init_klever_project, add_helper_scripts) are disabled in public mode.
# Build and run
docker build -t mcp-klever-vm .
docker run -p 3000:3000 mcp-klever-vm
# Or using docker compose
docker compose up -d
Then connect:
claude mcp add -t http klever-vm-local http://localhost:3000/mcp
pnpm install
pnpm run build
pnpm run start:public
| Variable | Default | Description |
|---|---|---|
MODE | http | Set to public for hosted mode |
PORT | 3000 | Server port |
CORS_ORIGINS | (unset) | Comma-separated allowed origins. Unset or * allows all origins |
RATE_LIMIT_MCP | 60 | MCP endpoint requests/min per IP |
RATE_LIMIT_API | 30 | API endpoint requests/min per IP |
BODY_SIZE_LIMIT | 1mb | Max request body size |
For production at mcp.klever.org:
mcp-session-id header and supports SSE (disable response buffering)The server automatically loads the Klever knowledge base based on your storage type:
pnpm run ingest separately# First, ingest the knowledge base (one time)
pnpm run ingest
# Then start the server
pnpm run dev
This will load:
# Development mode
pnpm run dev
# Production mode
pnpm run build && pnpm start
The HTTP API will be available at http://localhost:3000/api
MODE=mcp pnpm start
Use with any MCP-compatible client.
/api/contextIngest new context into the system.
{
"type": "code_example",
"content": "contract code here",
"metadata": {
"title": "Token Contract Example",
"description": "ERC20-like token implementation",
"tags": ["token", "fungible"],
"contractType": "token"
}
}
/api/context/:idRetrieve specific context by ID.
/api/context/queryQuery contexts with filters.
{
"query": "transfer",
"types": ["code_example", "best_practice"],
"tags": ["token"],
"contractType": "token",
"limit": 10,
"offset": 0
}
/api/context/:idUpdate existing context.
/api/context/:idDelete context.
/api/context/:id/similarFind similar contexts.
/api/context/batchBatch ingest multiple contexts.
When running as MCP server, the following tools are available:
query_context: Search for relevant Klever development contextadd_context: Add new context to the knowledge baseget_context: Retrieve specific context by IDfind_similar: Find contexts similar to a given contextget_knowledge_stats: Get statistics about the knowledge baseinit_klever_project: Initialize a new Klever smart contract project with helper scriptsenhance_with_context: Automatically enhance queries with relevant Klever VM contextcode_example: Working code snippets and examples (Rust smart contract code)best_practice: Recommended patterns and practicessecurity_tip: Security considerations and warningsoptimization: Performance optimization techniquesdocumentation: General documentation and guideserror_pattern: Common errors and solutionsdeployment_tool: Deployment scripts and utilities (bash scripts, tools)runtime_behavior: Runtime behavior explanationsThe MCP server includes a comprehensive knowledge base with 95+ entries organized into 11 categories:
Use the built-in ingestion utilities to parse and import Klever contracts:
import { StorageFactory } from './storage/index.js';
import { ContextService } from './context/service.js';
import { ContractIngester } from './utils/ingest.js';
const storage = StorageFactory.create('memory');
const contextService = new ContextService(storage);
const ingester = new ContractIngester(contextService);
// Ingest a single contract
await ingester.ingestContract('./path/to/contract.rs', 'AuthorName');
// Ingest entire directory
await ingester.ingestDirectory('./contracts', 'AuthorName');
// Add common patterns
await ingester.ingestCommonPatterns();
# Run tests
pnpm test
# Lint code
pnpm run lint
# Format code
pnpm run format
# Watch mode
pnpm run dev
# Ingest/update knowledge base
pnpm run ingest
The server can automatically validate Klever contracts and detect issues:
import { KleverValidator } from './parsers/validators.js';
const issues = KleverValidator.validateContract(contractCode);
// Returns array of detected issues with suggestions
Validation checks include:
Integrate with your IDE to provide context-aware suggestions for Klever contract development.
Automatically check contracts against best practices and security patterns.
Provide examples and explanations for developers learning Klever development.
Extract and organize contract documentation automatically.
For complete project implementation examples and specifications, see:
The MCP server includes a powerful project initialization tool that creates a new Klever smart contract project with all necessary helper scripts.
When connected via MCP, use the init_klever_project tool:
{
"name": "my-token-contract",
"template": "empty",
"noMove": false
}
Parameters:
name (required): The name of your contracttemplate (optional): Template to use (default: "empty")noMove (optional): If true, keeps project in subdirectory (default: false)The tool creates the following scripts in the scripts/ directory:
Initialize project:
# Via MCP tool
init_klever_project({"name": "my-contract"})
Build contract:
./scripts/build.sh
Deploy to testnet:
./scripts/deploy.sh
Query contract:
./scripts/query.sh --endpoint getSum
./scripts/query.sh --endpoint getValue --arg myKey
Upgrade contract:
./scripts/upgrade.sh
All deployment history is tracked in output/history.json for easy reference.
The MCP server can automatically enhance queries with relevant Klever VM context. This ensures your MCP client always has access to the most relevant information.
Use the enhance_with_context tool to automatically add relevant context to any query:
{
"tool": "enhance_with_context",
"arguments": {
"query": "How do I create a storage mapper?",
"autoInclude": true
}
}
This will:
For MCP clients that want to always check Klever context first:
// Always enhance Klever-related queries
if (query.match(/klever|kvm|smart contract|endpoint/i)) {
const enhanced = await callTool('enhance_with_context', { query });
// Use enhanced.enhancedQuery for processing
}
The context enhancement feature automatically enriches queries with relevant Klever VM knowledge from the comprehensive knowledge base.
// Query for token transfer examples
const response = await fetch('http://localhost:3000/api/context/query', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
query: 'transfer',
types: ['code_example'],
contractType: 'token'
})
});
# Using curl to add context
curl -X POST http://localhost:3000/api/context \
-H "Content-Type: application/json" \
-d '{
"type": "security_tip",
"content": "Always check for zero address",
"metadata": {
"title": "Zero Address Check",
"tags": ["security", "validation"]
}
}'
Contributions are welcome! Please:
MIT License - see LICENSE file for details