MCP Server Functions
Complete reference for all available functions in the Klever MCP Server.
Overview
The Klever MCP Server provides AI agents with specialized functions for Klever smart contract development.
Available Functions:
- Public Mode: 9 tools (7 read-only + 2 project template tools)
- Local Mode: 12 tools (all public tools + additional local-only tools for project setup, SDK management, and context writing)
Server Profiles:
- Local Profile (default): Full filesystem access, all 12 tools enabled
- Public Profile: Read-only operations, project tools return templates instead of creating files
Knowledge Management
query_context
Purpose: Search the knowledge base for development guidance and examples
Parameters:
query(optional): Search query stringtypes(optional): Filter by context types arraytags(optional): Filter by tags array (OR logic)contractType(optional): Filter by contract type (token, nft, defi, dao)limit(optional): Results limit 1-100 (default: 10)offset(optional): Results offset for pagination (default: 0)
Available Context Types:
code_example: Complete contract implementations and code snippetsbest_practice: Development guidelines and recommended patternssecurity_tip: Security recommendations and vulnerability preventionoptimization: Performance optimizations and gas efficiencydocumentation: API and framework referenceserror_pattern: Common errors and solutionsdeployment_tool: Deployment and tooling guides
Returns: JSON with results array, total count, and pagination info
search_documentation
Purpose: Human-readable search of the Klever VM documentation and knowledge base
Parameters:
query(required): Natural language search querycategory(optional): Filter by knowledge category
Available Categories: core, storage, events, tokens, modules, tools, scripts, examples, errors, best-practices, documentation
Returns: Formatted markdown with titles, descriptions, and code snippets
Difference from query_context: Optimized for "how do I..." questions with formatted documentation vs. structured JSON results
get_context
Purpose: Retrieve specific context by ID
Parameters:
id(required): UUID format context ID
Returns: Full entry with content, metadata, tags, and related context IDs
find_similar
Purpose: Find contexts similar to a given context based on tags and content
Parameters:
id(required): Reference context IDlimit(optional): Results limit 1-20 (default: 5)
Returns: Array of related contexts ranked by similarity
get_knowledge_stats
Purpose: Get statistics about the knowledge base
Parameters: None
Returns:
- Total contexts count
- Breakdown by context type
- Sample entries from each category
add_context
Purpose: Add new development context to knowledge base
Availability: Local mode only (blocked in public mode)
Parameters:
type(required): Context type (code_example, best_practice, security_tip, optimization, documentation, error_pattern, deployment_tool)content(required): The content/code/documentationmetadata(required): Object with:title(required): Entry titledescription(optional): 1-2 sentence summarytags(optional): Searchable tags arraycontractType(optional): Contract categoryauthor(optional): Attribution
Returns: Generated UUID for the new context
AI Enhancement
enhance_with_context
Purpose: Enhance user queries with relevant Klever VM development context
Parameters:
query(required): User query to enhanceautoInclude(optional): Auto-append relevant contexts (default: true)
Process:
- Analyzes the user query for Klever-specific keywords
- Searches knowledge base for most relevant contexts (limit: 3)
- Combines query with relevant examples and best practices
- Returns enhanced query with context for better AI responses
Keyword Extraction: Recognizes 50+ Klever-specific terms:
- Technical:
storage,mapper,endpoint,payable,deploy,upgrade - Tools:
koperator,ksc,testnet,mainnet - Access:
admin,only_admin,only_owner,permission - Types:
bigint,biguint,managed,token - Patterns:
singlemapper,setmapper,mapmapper,vecmapper
Returns: Original query, extracted keywords, enhanced markdown response
analyze_contract
Purpose: Analyze Klever smart contract Rust source code for common issues
Parameters:
sourceCode(required): Full Rust source code to analyzecontractName(optional): Human-readable name for the contract
Checks For:
- Missing imports (
use klever_sc::imports::*) - Missing contract macro (
#[klever_sc::contract]) - Missing endpoint annotations (
#[endpoint],#[init],#[upgrade]) - Payable handlers without
call_value()usage - Storage mappers without proper annotations
- Missing event definitions
Returns: Array of findings with:
severity: error, warning, or infopattern: Detected issue patternmessage: Description of the issuesuggestion: How to fix itrelatedKnowledge: Links to relevant knowledge entries
Project Management
init_klever_project
Purpose: Initialize a complete Klever smart contract project with structure and helper scripts
Parameters:
name(required): Contract nametemplate(optional): Template type (default: "empty")noMove(optional): Don't move files to current directory (default: false)
Behavior:
- Local Mode: Creates actual project files and directories
- Public Mode: Returns template JSON structure (no filesystem changes)
What it creates:
project-name/
├── src/lib.rs # Contract source code
├── Cargo.toml # Rust project configuration
├── tests/ # Test directory
├── scenarios/ # Test scenarios
├── scripts/
│ ├── build.sh # Build contract to WASM
│ ├── deploy.sh # Deploy to network
│ ├── upgrade.sh # Upgrade existing contract
│ ├── query.sh # Query contract state
│ ├── interact.sh # Interact with endpoints
│ └── common.sh # Shared utilities
└── output/
└── history.json # Deployment history tracking
add_helper_scripts
Purpose: Add helper scripts to existing Klever project
Parameters:
contractName(optional): Contract name for script customization
Availability: All modes (local creates files, public returns templates)
Generated Scripts:
- build.sh: Compiles Rust code to WASM with proper optimization
- deploy.sh: Deploys contract to testnet/mainnet with network configuration
- upgrade.sh: Upgrades existing contract preserving state
- query.sh: Queries contract state with returnData parsing
- interact.sh: Interactive endpoint calls with parameter encoding
- test.sh: Run contract tests
- common.sh: Shared utilities (data conversion, formatting, network helpers)
SDK Management
check_sdk_status
Purpose: Check whether the Klever SDK is installed and report component status
Availability: Local mode only (blocked in public mode)
Parameters: None
Returns: JSON with installation state for:
ksc: Klever Smart Contract compilerkoperator: Operator CLI for contract operationslibvmexeccapi: VM execution librarywalletKey: Wallet key file presence- Versions for installed components
install_klever_sdk
Purpose: Download and install Klever SDK tools to ~/klever-sdk/
Availability: Local mode only (blocked in public mode)
Parameters:
tool(optional): "ksc" | "koperator" | "all" (default: "all")
Supported Platforms:
- macOS (arm64, amd64)
- Linux (amd64)
Process:
- Fetches latest versions from Klever CDN
- Downloads and extracts binaries
- Sets up directory structure
- Configures executable permissions
Returns: Installation results with status and paths
Next Steps
- Try MCP Prompts: Use guided workflows for common tasks
- Explore Knowledge Base: Browse curated Klever development entries
- See Workflow Example: Complete development workflow
- Installation Guide: Set up your development environment
Try it online: Start developing with AI assistance at ai.klever.org.