overview
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseContextVM 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
三层设计
- Transport Layer: Nostr events and relays
- Message Layer: JSON-RPC MCP messages embedded in event content
- Metadata Layer: Nostr event tags for addressing and correlation
- 传输层:Nostr事件和中继
- 消息层:嵌入事件内容的JSON-RPC MCP消息
- 元数据层:用于寻址和关联的Nostr事件标签
Main Actors
主要参与者
| Actor | Role | Identification |
|---|---|---|
| Servers | Expose MCP capabilities | Public key + relays |
| Clients | Consume server capabilities | Public key |
| Relays | Propagate messages | URL (wss://...) |
| 参与者 | 角色 | 标识方式 |
|---|---|---|
| 服务器 | 提供MCP功能 | 公钥 + 中继 |
| 客户端 | 使用服务器的功能 | 公钥 |
| 中继 | 传播消息 | URL(wss://...) |
Event Kinds
事件类型
ContextVM uses these Nostr event kinds:
| Kind | Purpose | Persistence |
|---|---|---|
| All ContextVM messages (ephemeral) | Not stored by relays |
| Server announcement | Replaceable |
| Tools list | Replaceable |
| Resources list | Replaceable |
| Resource templates list | Replaceable |
| Prompts list | Replaceable |
| Gift wrap (encrypted messages) | Ephemeral |
ContextVM使用以下Nostr事件类型:
| 类型编号 | 用途 | 持久化方式 |
|---|---|---|
| 所有ContextVM消息(临时) | 中继不存储 |
| 服务器公告 | 可替换 |
| 工具列表 | 可替换 |
| 资源列表 | 可替换 |
| 资源模板列表 | 可替换 |
| 提示词列表 | 可替换 |
| 礼品包装(加密消息) | 临时 |
Message Flow
消息流程
Connection Process
连接流程
- Discovery: Client discovers server via public key or relay queries
- Initialization: Standard MCP handshake over Nostr
- Operation: Client calls tools/lists resources via kind 25910 events
- Termination: Connection closes when either party disconnects
- 发现:客户端通过公钥或中继查询发现服务器
- 初始化:通过Nostr进行标准MCP握手
- 操作:客户端通过类型25910事件调用工具/列出资源
- 终止:任意一方断开连接时,连接关闭
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 tag
support_encryption
- 通过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 — The Nostr primitives behind CVM (for non-SDK implementations)
references/nostr-way-without-sdks.md
ContextVM遵循与其他基于Nostr的RPC系统(如DVM)相同的核心模式:发布签名的请求事件,监听关联的响应。不同之处在于消息结构——ContextVM使用基于MCP的JSON-RPC,而非提供商特定的负载。
要理解这一基础:
- 阅读 —— ContextVM背后的Nostr原语(适用于非SDK实现)
references/nostr-way-without-sdks.md
Reference Materials
参考资料
For detailed specifications, see:
- - Full protocol specification
references/protocol-spec.md - - ContextVM Enhancement Proposals
references/ceps.md - - MCP protocol integration details
references/mcp-integration.md
如需详细规范,请查看:
- - 完整协议规范
references/protocol-spec.md - - ContextVM增强提案
references/ceps.md - - MCP协议集成细节
references/mcp-integration.md
Ecosystem Navigation (what to use when)
生态导航(不同场景的选择)
Use this decision table to jump to the right component / skill:
| Goal | Recommended path | Skill |
|---|---|---|
| Learn the protocol and message kinds | Read spec + CEPs | |
| Understand core concepts, architecture, FAQs | Concepts and architectural overview | |
| Build a new ContextVM-native server | | |
| Build a new ContextVM-native client | | |
| Bridge an existing MCP server to Nostr | Gateway pattern ( | |
| Bridge an existing MCP client to Nostr | Proxy pattern ( | |
| SDK-level details (interfaces, constants, logging) | | |
| Production operations (keys, Docker, monitoring) | Deployment checklist | |
| Diagnose connection issues, errors, failures | Troubleshooting guide | |
Useful public entry points:
- ContextVM docs: https://docs.contextvm.org
- ContextVM org: https://contextvm.org
使用以下决策表跳转到合适的组件/技能文档:
| 目标 | 推荐路径 | 技能文档 |
|---|---|---|
| 学习协议和事件类型 | 阅读规范 + CEPs | |
| 理解核心概念、架构、常见问题 | 概念与架构概述 | |
| 构建新的ContextVM原生服务器 | | |
| 构建新的ContextVM原生客户端 | | |
| 将现有MCP服务器连接到Nostr | 网关模式 ( | |
| 将现有MCP客户端连接到Nostr | 代理模式 ( | |
| SDK级细节(接口、常量、日志) | | |
| 生产环境运维(密钥、Docker、监控) | 部署检查清单 | |
| 诊断连接问题、错误、故障 | 故障排除指南 | |
实用公共入口:
- ContextVM文档:https://docs.contextvm.org
- ContextVM官网:https://contextvm.org