Sponsored by Deepsite.site

Cvm: Stateful Programable Task Engine

Created By
LadislavSopko6 months ago
Stop Claude from losing track. CVM is a passive state machine that Claude queries for tasks, maintaining perfect execution flow across complex operations. The Problem "Claude, analyze these 1000 files and create a report" → Claude gets confused, loses context, forgets what it's doing. The Solution CVM is a passive MCP server that holds program state. You write a program with loops and logic, but Claude only sees one task at a time. Claude asks "what's next?", completes the task, and asks again. The magic: CVM never pushes tasks. Claude pulls tasks when ready, maintaining perfect control while CVM quietly manages state between requests.
Content

CVM: Stateful Task Engine for Claude

Stop Claude from losing track. CVM is a passive state machine that Claude queries for tasks, maintaining perfect execution flow across complex operations.

npm version

The Problem

"Claude, analyze these 1000 files and create a report" → Claude gets confused, loses context, forgets what it's doing.

The Solution

CVM is a passive MCP server that holds program state. You write a program with loops and logic, but Claude only sees one task at a time. Claude asks "what's next?", completes the task, and asks again.

The magic: CVM never pushes tasks. Claude pulls tasks when ready, maintaining perfect control while CVM quietly manages state between requests.

What CVM Really Is

CVM is an algorithmic TODO manager. Think of it as:

  • A TODO list that can have loops ("do this 5 times")
  • A TODO list that can have conditions ("if X then do Y")
  • A TODO list that maintains variables between tasks
  • A TODO list shaped like a program

When your program hits CC("analyze this file"), CVM doesn't call Claude. Instead:

  1. CVM creates a TODO: "analyze this file"
  2. CVM pauses execution and waits
  3. Claude asks CVM: "What should I do next?"
  4. CVM responds: "analyze this file"
  5. Claude does the analysis and submits the result
  6. CVM updates its state and moves to the next instruction

CVM is completely passive - it never initiates anything. Claude drives everything.

Try It Now

Save this as counter.ts:

function main() {
  let count = 0;
  while (count < 5) {
    const next = CC("Current number is " + count + ". What's the next number?");
    count = +next;
    console.log("Count is now: " + count);
  }
  return count;  // Returns 5
}
main();

Then tell Claude: "Run counter.ts with CVM"

What actually happens:

  • CVM loads the program and starts execution
  • When it hits CC(), CVM creates a task and waits
  • Claude asks CVM for tasks using getTask()
  • CVM gives Claude: "Current number is 0. What's the next number?"
  • Claude figures out the answer is "1" and submits it
  • CVM continues the loop with count=1
  • Process repeats until done

How It Works

CVM is a passive MCP server. Claude actively drives execution:

Claude: load("counter", "...program code...")
Claude: start("counter", "exec-123")
Claude: getTask("exec-123") → CVM: "Current number is 0. What's the next number?"
Claude: submitTask("exec-123", "1") → CVM sets count=1, continues loop
Claude: getTask("exec-123") → CVM: "Current number is 1. What's the next number?"
Claude: submitTask("exec-123", "2") → CVM sets count=2, continues loop
...
Claude: getTask("exec-123") → CVM: "Execution completed with result: 5"

Why This Architecture

Traditional approach: Claude tries to maintain state in its context window

  • ❌ Loses track in complex flows
  • ❌ Forgets variables between steps
  • ❌ Can't handle real loops or conditions reliably

CVM approach: State lives in CVM, Claude just processes individual tasks

  • ✅ Perfect state management
  • ✅ Real loops and conditions that work
  • ✅ Claude's context stays clean
  • ✅ Complex workflows become simple task sequences

Real Example

function main() {
  const files = fs.listFiles("./docs", { filter: "*.txt" });
  const summaries = [];
  
  for (const file of files) {
    // This creates a task for Claude, doesn't "call" Claude
    const content = CC("Read and summarize this file: " + file);
    // Now we can use objects!
    summaries.push({
      filename: file,
      summary: content
    });
    console.log("Processed: " + file);
  }
  
  // Convert summaries array to JSON for the final task
  const summariesJson = JSON.stringify(summaries);
  const report = CC("Create a final report from these file summaries: " + summariesJson);
  console.log("Final Report: " + report);
  
  return report;
}
main();

CVM turns this into a dynamic TODO list:

  1. Task: "Read and summarize this file: ./docs/file1.txt"
  2. Task: "Read and summarize this file: ./docs/file2.txt"
  3. Task: "Read and summarize this file: ./docs/file3.txt"
  4. Task: "Create a final report from these summaries: [...]"

Claude works through these tasks one by one, while CVM maintains the loop state, the summaries array, and the execution position.

Key Concepts

CC() - Cognitive Context

CC(prompt) doesn't mean "call Claude". It means:

  • Create a task with this prompt
  • Pause execution here
  • Wait for Claude to ask for the next task
  • Resume when Claude provides a result

CVM is Passive

  • CVM never sends messages to Claude
  • CVM never initiates actions
  • CVM only responds when Claude asks
  • Claude drives everything via MCP tools

State Management

While Claude processes tasks, CVM maintains:

  • All variables and their values
  • Current execution position
  • Loop counters and conditions
  • Arrays, objects, and complex data structures

Installation

Add to Claude's .mcp.json:

{
  "mcpServers": {
    "cvm": {
      "command": "npx",
      "args": ["cvm-server@latest"],
      "env": {
        "CVM_STORAGE_TYPE": "file",
        "CVM_DATA_DIR": ".cvm"
      }
    }
  }
}

MCP Tools

Claude uses these tools to interact with CVM:

  • load(programId, source) - Load a program into CVM
  • loadFile(programId, filePath) - Load from file
  • start(programId, executionId) - Start execution
  • getTask(executionId) - Get next task (CVM waits for this)
  • submitTask(executionId, result) - Submit task result
  • status(executionId) - Check execution state

Language Features

CVM executes a TypeScript-like language:

  • Variables, arrays, objects, loops, conditions
  • String/array operations
  • Object literals and property access
  • JSON.stringify() and JSON.parse()
  • CC() for task creation
  • fs.listFiles() for file operations
  • console.log() for output

→ Full API Documentation

Use Cases

Perfect for any workflow where Claude needs to process many items systematically:

  • Document analysis pipelines
  • Data extraction from multiple sources
  • Report generation with multiple inputs
  • Any task requiring loops with AI processing

Summary

CVM is a passive, stateful task engine. It turns programs into smart TODO lists that Claude can work through systematically without losing context. The program defines the workflow, Claude provides the intelligence, and CVM quietly maintains the state between them.


Copyright 2025 Ladislav Sopko. Licensed under Apache 2.0.

Server Config

{
  "mcpServers": {
    "cvm": {
      "command": "npx",
      "args": [
        "cvm-server@latest"
      ],
      "env": {
        "CVM_STORAGE_TYPE": "file",
        "CVM_DATA_DIR": ".cvm"
      }
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
CursorThe AI Code Editor
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Serper MCP ServerA Serper MCP Server
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Tavily Mcp
ChatWiseThe second fastest AI chatbot™
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
DeepChatYour AI Partner on Desktop
Amap Maps高德地图官方 MCP Server
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
WindsurfThe new purpose-built IDE to harness magic
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Playwright McpPlaywright MCP server
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。