cvm-server
v3.0.0
Published
Cognitive Virtual Machine (CVM) - A deterministic bytecode VM with AI cognitive operations
Downloads
630
Maintainers
Readme
cvm-server
The executable MCP server application for CVM. This is the npm package that users install to run CVM with Claude Desktop.
Overview
This app provides:
- Executable MCP Server: Ready-to-run server for Claude Desktop
- Configuration Management: Environment-based configuration
- Logging: Structured logging for debugging
- Graceful Shutdown: Proper cleanup on exit
- Version Management: Automatic version detection
Architecture
Claude Desktop
↓ (stdio)
cvm-server (this app)
↓
CVMMcpServer (@cvm/mcp-server)
↓
VMManager (@cvm/vm)
↓
Storage + VM EngineInstallation
Requires Node.js 22 or newer (.nvmrc pins 22 for development).
For End Users
Add to Claude Desktop's MCP settings:
{
"mcpServers": {
"cvm": {
"command": "npx",
"args": ["cvm-server@latest"],
"env": {
"CVM_STORAGE_TYPE": "file",
"CVM_DATA_DIR": ".cvm"
}
}
}
}For Development
# Clone repository
git clone https://github.com/LadislavSopko/cvm.git
cd cvm
# Install dependencies
npm install
# Build all packages
npx nx build cvm-server
# Run locally
node apps/cvm-server/dist/main.jsConfiguration
The server uses environment variables for configuration:
Storage Configuration
# File storage (only supported backend)
CVM_STORAGE_TYPE=file
CVM_DATA_DIR=.cvmLogging Configuration
# Log levels: debug, info, warn, error
CVM_LOG_LEVEL=info
# Log format: pretty (default) or json
CVM_LOG_FORMAT=prettyExecution Limits
# Maximum instructions executed between two CC() calls (default 10000000).
# Stops a loop that never reaches CC(); loops with CC() inside are never limited. 0 = unlimited.
CVM_MAX_INSTRUCTIONS=10000000Environment
# Environment: development, production
NODE_ENV=productionFeatures
Automatic Storage Setup
- Creates storage directories if needed
- Warns about adding data directory to .gitignore
- Connects to MongoDB if configured
Version Detection
- Attempts to find package.json in multiple locations
- Works in development and production builds
- Falls back to hardcoded version if needed
Graceful Shutdown
- Handles SIGINT and SIGTERM signals
- Closes all connections properly
- Ensures data is saved before exit
Error Handling
- Comprehensive error logging
- Graceful degradation
- Clear error messages for debugging
File Structure
apps/cvm-server/
├── src/
│ ├── main.ts # Entry point
│ ├── config.ts # Configuration management
│ └── logger.ts # Logging setup
├── bin/
│ └── cvm-server.cjs # Executable wrapper
├── package.json # Package metadata
└── README.md # This fileBuilding and Publishing
Build
# Development build
npx nx build cvm-server --configuration=development
# Production build
npx nx build cvm-server --configuration=productionPublish to npm
Bump version in apps/cvm-server/package.json on main, open a PR main → production (CI runs the full gate), merge it by hand: .github/workflows/release.yml builds and publishes with npm Trusted Publishing (OIDC, no token, with provenance) and skips versions already on npm.
Manual fallback:
cd apps/cvm-server/dist
npm publish --otp=YOUR_OTPUsage
Once installed, Claude can interact with CVM through MCP tools:
- Load a program:
mcp__cvm__load - Start execution:
mcp__cvm__start - Get tasks:
mcp__cvm__getTask - Submit results:
mcp__cvm__submitTask
See the main project README for detailed usage examples.
Development Tips
Running Locally
# Set environment variables
export CVM_STORAGE_TYPE=file
export CVM_DATA_DIR=.cvm-dev
export CVM_LOG_LEVEL=debug
# Run the server
node apps/cvm-server/dist/main.jsTesting with Claude Desktop
- Build the server:
npx nx build cvm-server - Update MCP config to point to local build:
{
"mcpServers": {
"cvm": {
"command": "node",
"args": ["/path/to/cvm/apps/cvm-server/dist/main.js"]
}
}
}Debugging
Enable debug logging:
export CVM_LOG_LEVEL=debug
export CVM_LOG_FORMAT=prettyCheck logs for:
- Storage initialization
- MCP tool calls
- VM state changes
- Error traces
Dependencies
Runtime Dependencies
- @modelcontextprotocol/sdk: MCP protocol implementation
- dotenv: Environment variable loading
- mongodb: MongoDB driver (optional)
- typescript: Type definitions
- zod: Schema validation
Internal Dependencies
- @cvm/mcp-server: MCP server implementation
- @cvm/vm: Core VM engine
- @cvm/storage: Storage layer
- @cvm/parser: CVM language parser
- @cvm/types: Shared types
License
AGPL-3.0-or-later — See LICENSE for details. Commercial license available — see COMMERCIAL.md.
