overview

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

ContextVM Overview

ContextVM 概述

ContextVM (Context Virtual Machine) is a protocol that bridges the Model Context Protocol (MCP) with the Nostr network, enabling decentralized communication between MCP servers and clients.
ContextVM(Context虚拟机)是一种连接Model Context Protocol(MCP)与Nostr网络的协议,可实现MCP服务器与客户端之间的去中心化通信。

Core Concept

核心概念

ContextVM operates as a transport layer for MCP, using Nostr's relay network as the communication mechanism while preserving MCP's JSON-RPC semantics.
┌─────────────────────────────────────────────────────────────┐
│                    MCP Application Layer                     │
│         (Tools, Resources, Prompts, Sampling)               │
├─────────────────────────────────────────────────────────────┤
│                 ContextVM Transport Layer                    │
│    (Nostr events, Encryption, Public Key Cryptography)      │
├─────────────────────────────────────────────────────────────┤
│                     Nostr Relay Network                      │
│              (wss://relay.contextvm.org, etc.)              │
└─────────────────────────────────────────────────────────────┘
ContextVM作为MCP的传输层,使用Nostr的中继网络作为通信机制,同时保留MCP的JSON-RPC语义。
┌─────────────────────────────────────────────────────────────┐
│                    MCP Application Layer                     │
│         (Tools, Resources, Prompts, Sampling)               │
├─────────────────────────────────────────────────────────────┤
│                 ContextVM Transport Layer                    │
│    (Nostr events, Encryption, Public Key Cryptography)      │
├─────────────────────────────────────────────────────────────┤
│                     Nostr Relay Network                      │
│              (wss://relay.contextvm.org, etc.)              │
└─────────────────────────────────────────────────────────────┘

Key Features

关键特性

  • Decentralized Communication: No central servers required; use Nostr's distributed relay network
  • Security First: Leverages Nostr's cryptographic primitives for verification and authorization
  • Public Key Identity: Servers and clients identified by Nostr public keys
  • Optional Encryption: End-to-end encryption via NIP-44 gift wrapping
  • Server Discovery: Public server announcements via replaceable events
  • 去中心化通信:无需中央服务器;使用Nostr的分布式中继网络
  • 安全优先:利用Nostr的加密原语进行验证和授权
  • 公钥身份:服务器和客户端通过Nostr公钥标识
  • 可选加密:通过NIP-44礼品包装实现端到端加密
  • 服务器发现:通过可替换事件发布公共服务器公告

Protocol Architecture

协议架构

Three-Layer Design

三层设计

  1. Transport Layer: Nostr events and relays
  2. Message Layer: JSON-RPC MCP messages embedded in event content
  3. Metadata Layer: Nostr event tags for addressing and correlation
  1. 传输层:Nostr事件和中继
  2. 消息层:嵌入事件内容的JSON-RPC MCP消息
  3. 元数据层:用于寻址和关联的Nostr事件标签

Main Actors

主要参与者

ActorRoleIdentification
ServersExpose MCP capabilitiesPublic key + relays
ClientsConsume server capabilitiesPublic key
RelaysPropagate messagesURL (wss://...)
参与者角色标识方式
服务器提供MCP功能公钥 + 中继
客户端使用服务器的功能公钥
中继传播消息URL(wss://...)

Event Kinds

事件类型

ContextVM uses these Nostr event kinds:
KindPurposePersistence
25910
All ContextVM messages (ephemeral)Not stored by relays
11316
Server announcementReplaceable
11317
Tools listReplaceable
11318
Resources listReplaceable
11319
Resource templates listReplaceable
11320
Prompts listReplaceable
1059
Gift wrap (encrypted messages)Ephemeral
ContextVM使用以下Nostr事件类型:
类型编号用途持久化方式
25910
所有ContextVM消息(临时)中继不存储
11316
服务器公告可替换
11317
工具列表可替换
11318
资源列表可替换
11319
资源模板列表可替换
11320
提示词列表可替换
1059
礼品包装(加密消息)临时

Message Flow

消息流程

Connection Process

连接流程

  1. Discovery: Client discovers server via public key or relay queries
  2. Initialization: Standard MCP handshake over Nostr
  3. Operation: Client calls tools/lists resources via kind 25910 events
  4. Termination: Connection closes when either party disconnects
  1. 发现:客户端通过公钥或中继查询发现服务器
  2. 初始化:通过Nostr进行标准MCP握手
  3. 操作:客户端通过类型25910事件调用工具/列出资源
  4. 终止:任意一方断开连接时,连接关闭

Event Structure

事件结构

json
{
  "kind": 25910,
  "pubkey": "<sender-public-key>",
  "content": "{\"jsonrpc\":\"2.0\",...}",
  "tags": [
    ["p", "<recipient-public-key>"],
    ["e", "<correlation-event-id>"]
  ]
}
json
{
  "kind": 25910,
  "pubkey": "<sender-public-key>",
  "content": "{\"jsonrpc\":\"2.0\",...}",
  "tags": [
    ["p", "<recipient-public-key>"],
    ["e", "<correlation-event-id>"]
  ]
}

Security Model

安全模型

Public Key Cryptography

公钥加密

  • All messages cryptographically signed
  • Server identity = public key (portable across relays)
  • Client authorization via public key whitelisting
  • 所有消息均经过加密签名
  • 服务器身份 = 公钥(可在中继间迁移)
  • 通过公钥白名单实现客户端授权

Encryption (CEP-4)

加密(CEP-4)

  • Optional NIP-44 encryption via gift wrap (kind 1059)
  • Negotiated during initialization
  • Servers advertise support via
    support_encryption
    tag
  • 通过NIP-44礼品包装实现可选加密
  • 在初始化阶段协商
  • 服务器通过
    support_encryption
    标签声明支持情况

The Nostr Way

Nostr 方式

ContextVM follows the same core pattern as other Nostr-based RPC systems (like DVMs): publish a signed request event, listen for a correlated response. The difference is in the message structure—CVM uses JSON-RPC via MCP rather than provider-specific payloads.
To understand this foundation:
  • Read
    references/nostr-way-without-sdks.md
    — The Nostr primitives behind CVM (for non-SDK implementations)
ContextVM遵循与其他基于Nostr的RPC系统(如DVM)相同的核心模式:发布签名的请求事件,监听关联的响应。不同之处在于消息结构——ContextVM使用基于MCP的JSON-RPC,而非提供商特定的负载。
要理解这一基础:
  • 阅读
    references/nostr-way-without-sdks.md
    —— ContextVM背后的Nostr原语(适用于非SDK实现)

Reference Materials

参考资料

For detailed specifications, see:
  • references/protocol-spec.md
    - Full protocol specification
  • references/ceps.md
    - ContextVM Enhancement Proposals
  • references/mcp-integration.md
    - MCP protocol integration details
如需详细规范,请查看:
  • references/protocol-spec.md
    - 完整协议规范
  • references/ceps.md
    - ContextVM增强提案
  • references/mcp-integration.md
    - MCP协议集成细节

Ecosystem Navigation (what to use when)

生态导航(不同场景的选择)

Use this decision table to jump to the right component / skill:
GoalRecommended pathSkill
Learn the protocol and message kindsRead spec + CEPs
SKILL.md
+
references/protocol-spec.md
Understand core concepts, architecture, FAQsConcepts and architectural overview
../concepts/SKILL.md
Build a new ContextVM-native server
McpServer
+
NostrServerTransport
../server-dev/SKILL.md
Build a new ContextVM-native client
Client
+
NostrClientTransport
../client-dev/SKILL.md
Bridge an existing MCP server to NostrGateway pattern (
NostrMCPGateway
)
../server-dev/references/gateway-pattern.md
Bridge an existing MCP client to NostrProxy pattern (
NostrMCPProxy
)
../client-dev/references/proxy-pattern.md
SDK-level details (interfaces, constants, logging)
@contextvm/sdk
reference
../typescript-sdk/SKILL.md
Production operations (keys, Docker, monitoring)Deployment checklist
../deployment/SKILL.md
Diagnose connection issues, errors, failuresTroubleshooting guide
../troubleshooting/SKILL.md
Useful public entry points:
使用以下决策表跳转到合适的组件/技能文档:
目标推荐路径技能文档
学习协议和事件类型阅读规范 + CEPs
SKILL.md
+
references/protocol-spec.md
理解核心概念、架构、常见问题概念与架构概述
../concepts/SKILL.md
构建新的ContextVM原生服务器
McpServer
+
NostrServerTransport
../server-dev/SKILL.md
构建新的ContextVM原生客户端
Client
+
NostrClientTransport
../client-dev/SKILL.md
将现有MCP服务器连接到Nostr网关模式 (
NostrMCPGateway
)
../server-dev/references/gateway-pattern.md
将现有MCP客户端连接到Nostr代理模式 (
NostrMCPProxy
)
../client-dev/references/proxy-pattern.md
SDK级细节(接口、常量、日志)
@contextvm/sdk
参考文档
../typescript-sdk/SKILL.md
生产环境运维(密钥、Docker、监控)部署检查清单
../deployment/SKILL.md
诊断连接问题、错误、故障故障排除指南
../troubleshooting/SKILL.md
实用公共入口: