vibespace MCP体验
MCP(模型上下文协议)体验实现,用于通过实时NATS流管理氛围和世界。
概述
vibespace MCP Experience是模型上下文协议体验的Go实现,它为管理“共鸣”(情感氛围)和“世界”(物理或虚拟空间)提供了资源和工具。服务器使用自定义URI方案(vibe:// 和 world://)访问资源,并支持JSON-RPC通信方法。
特性
- 用于存储氛围和世界的内存存储库
- 用于资源访问的自定义URI方案
- 针对振动和世界的完整CRUD操作
- 支持传感器数据(温度、湿度、光、声音、运动)
- 支持全球功能
- 支持不同的世界类型(物理、虚拟、混合)
- 实时流媒体世界时刻的NATS集成
- 多租户NATS服务器的流ID命名空间
- 具有用户归因和访问控制的多人游戏支持
- 连接质量监控和UI状态指示器
- 流媒体发布的速率限制
- 支持多种编码格式(二进制、base64、十六进制)的二进制数据
- 平衡的三进制数字系统支持,具有高效的编码/解码
组件
- 模型:Vibe、World和WorldMoment的数据结构,包括SensorData
- 仓库:具有线程安全CRUD操作的内存存储
- 服务器:使用JSON-RPC方法实现MCP协议
- 流媒体:NATS集成,支持Stream ID,可实时流式传输世界时刻
安装
您可以使用以下命令将此包添加到您的Go项目中:
go get github.com/bmorphism/vibespace-mcp-go运行服务器
要运行服务器,请执行以下操作:
just run或者手动构建并运行:
just build
./bin/vibespace-mcpNATS订阅者示例
该存储库包括一个示例NATS订阅者,用于收听世界时刻:
cd examples
./run_nats_subscriber.sh [nats-url] [stream-id] [user-id]参数:
nats-url:NATS服务器URL(默认为nats://nonlocal.info:4222)stream-id:主题命名空间的流ID(默认为ies)user-id:用户特定流的可选用户ID
测试
服务器包括对所有功能的全面测试:
# Run all tests
just test
# Run a specific test suite
just test-suite hybrid
# Generate test coverage report
just coverage看 测试.md 有关测试方法和可用测试套件的详细信息。
测试覆盖率
- 存储库测试:用于振动和世界的基本CRUD操作
- 传感器数据测试:使用传感器数据创建和更新氛围
- 世界特征测试:管理世界特征(添加、删除等)
- 混合动力世界测试:在世界类型之间创建和转换
- 并发测试:并行操作的线程安全验证
- 集成测试:结合多种操作的端到端测试
- 方法测试:JSON-RPC方法发现和兼容性
MCP协议
服务器实现模型上下文协议,提供:
- 资源:
vibe://list,vibe://{id},world://list,world://{id},world://{id}/vibe - 工具:
- Vibe工具: create_vibe, update_vibe, delete_vibe - 世界工具: create_world, update_world, delete_world, set_world_vibe - 流媒体工具: streaming_startStreaming, streaming_stopStreaming, streaming_status, streaming_streamWorld, streaming_updateConfig
有关流媒体功能的更多详细信息,请参阅 流媒体.md.
JSON-RPC方法文档
vibespace MCP体验为JSON-RPC方法名提供了清晰的文档和帮助工具,防止了方法名不匹配的常见问题。看 RPC_METHODS.md 完整的方法参考。
方法名称常量
使用标准方法名称常量 rpcmethods 代码中的包:
import "github.com/bmorphism/vibespace-mcp-go/rpcmethods"
// Standard method names
const ResourceReadMethod = rpcmethods.MethodResourceRead // "method.resource.read"
const ToolCallMethod = rpcmethods.MethodToolCall // "method.tool.call"Helper函数
这 rpcmethods 包提供了简化JSON-RPC交互的实用程序:
// For formatting proper JSON-RPC requests
resourceRequest := rpcmethods.FormatResourceRequest("world://list", "request-id")
toolRequest := rpcmethods.FormatToolRequest("create_world", worldArgs, "request-id")
// For discovering method names
methods := rpcmethods.ListMethods()
info := rpcmethods.GetMethodInfo("method.resource.read")
suggestions := rpcmethods.GetMethodSuggestions("resource.read") // Gives helpful suggestions改进的错误消息
如果使用了不正确的方法名称,服务器将建议正确的方法:
Error: Method 'resource.read' not found. Did you mean: method.resource.read?JSON-RPC兼容性说明
由于JSON-RPC方法与当前版本的MCP Go库的兼容性问题,目前跳过了一些测试。这会影响旅程和服务器集成测试,但我们的方法名称处理改进应该能解决客户端的大多数问题。
用户示例:Topos团队共享体验
以下是Topos团队如何利用vibespace MCP经验,在使用不同工具时创建一个有凝聚力的团队环境:
场景:Topos团队协同开发
成员 Topos团队 分布在各种工具中: 爱丽丝 (使用克劳德桌面), 鲍勃 (使用Goose MCP客户端),以及 卡罗尔 (与Claude一起使用VS Code)。他们希望在开发跨不同接口的分类网络模型时保持“共同振动”的感觉。
设置:
- 共享的vibespace MCP体验在专用Topos服务器上运行
- 上的NATS服务器
nats://nonlocal.info:4222处理实时流媒体 - 每个团队成员都使用唯一的用户ID连接,但共享团队拓扑流ID
第一步:创建Topos团队世界
Alice通过Claude Desktop初始化Team Topos世界:
// Alice creates the Team Topos world
const response = await mcp.tools.create_world({
name: "Team Topos Workspace",
description: "A shared categorical space for infinity-topos development",
type: "hybrid",
features: ["categorical-thinking", "research-sharing", "presence-indication", "distributed-computation"],
sharingSettings: {
isPublic: false,
allowedUsers: ["alice@topos", "bob@topos", "carol@topos"],
contextLevel: "full"
}
});
// Alice sets the initial team vibe
await mcp.tools.set_world_vibe({
worldId: response.id,
vibeId: "categorical-flow-state"
});
console.log(`Join our Team Topos workspace with ID: ${response.id}`);步骤2:加入Team Topos工作区
Bob通过Goose MCP客户端连接:
# Bob connects to Team Topos with his user ID
world_id = "topos_world_123" # ID shared by Alice
client.streaming_startStreaming(
url="nats://nonlocal.info:4222",
stream_id="team-topos",
world_id=world_id,
user_id="bob@topos"
)
# Bob indicates he's working on sheaf theory implementation
client.update_world_feature(
world_id=world_id,
feature_name="research-focus",
feature_value="Sheaf cohomology for network models"
)
# Bob shares his computational resources
client.update_world_feature(
world_id=world_id,
feature_name="shared-computation",
feature_value={"available_cores": 16, "gpu_memory": "24GB"}
)Carol通过VS Code加入Claude:
// Carol connects to Team Topos from VS Code
const connection = await mcpClient.connect({
worldId: "topos_world_123",
userId: "carol@topos",
streamId: "team-topos",
statusCallback: (status) => {
vscode.window.setStatusBarMessage(`⊤ Team Topos: ${status.connectedUsers.length} members active`);
}
});
// Carol shares her current research direction
await mcpClient.tools.update_world_feature({
worldId: "topos_world_123",
featureName: "active-models",
featureValue: ["dynamic-markov-blankets", "hypergraph-topologies"]
});
// Carol updates the shared mathematical context
await mcpClient.tools.update_vibe({
worldId: "topos_world_123",
attribute: "mathematical-coherence",
value: 92 // Scale 0-100 indicating conceptual clarity
});第三步:体验共享地形开发
随着团队的工作:
- 爱丽丝 在Claude Desktop中看到实时可视化,显示Bob和Carol正在探索哪些分类结构,以及协作路径的有向图
- 鲍勃 当Alice或Carol取得数学突破时,在Goose中接收环境通知,界面通过拓扑可视化巧妙地反映了团队的集体理解
- 卡罗尔 看到VS Code扩展根据团队当前的重点领域自动激活,侧边栏指示器显示哪些数学领域正在被积极探索
- 这三种开发环境都与以下内容同步:
- 基于团队使用模式的共享LaTeX符号建议 - 根据当前需求分配的集体计算资源 - 环境音乐微妙地变化,以适应团队的认知状态 - 与正在探索的分类结构相一致的视觉主题
- vibespace MCP体验能够:
- 从团队共享的数学上下文自动生成文档 - 检测到概念错位时出现的同步白板 - 跨团队成员机器的复杂分类模型的分布式计算
步骤4:利用二进制和平衡三元数据
当团队研究高级数学模型时,他们使用二进制和平衡三进制特征:
// Carol shares balanced ternary data representing a categorical network structure
const ternaryEncoding = "10T01T001T10T01"; // Balanced ternary representing network topology
await mcpClient.tools.streaming_streamWorld({
worldId: "topos_world_123",
userId: "carol@topos",
customData: {
action: "share_mathematical_model",
modelName: "HypergraphCohomology"
},
// Add balanced ternary data representing the mathematical structure
balancedTernaryData: ternaryEncoding
});Bob使用Python处理数学结构:
# Bob subscribes to the moment and extracts balanced ternary data
def on_world_moment(message):
moment = json.loads(message.data.decode())
if moment.get("binaryData") and moment["binaryData"]["format"] == "application/balanced-ternary":
# Extract balanced ternary representation
binary_data = base64.b64decode(moment["binaryData"]["data"])
# Calculate how many trits were encoded (each 4 trits use 1 byte)
num_trits = len(binary_data) * 4
# Convert back to ternary representation
ternary_data = bytes_to_ternary(binary_data, num_trits)
# Process mathematical structure
if "HypergraphCohomology" in moment.get("customData", {}).get("modelName", ""):
process_categorical_network(ternary_data)
# Convert binary to balanced ternary (Python implementation)
def bytes_to_ternary(bytes_data, num_trits):
result = []
for i in range(min(num_trits, len(bytes_data) * 4)):
byte_idx = i // 4
trit_pos = i % 4
# Extract 2 bits representing this trit
bits = (bytes_data[byte_idx] >> (trit_pos * 2)) & 0b11
# Map bits to trits: 00->-1, 01->0, 10->1
if bits == 0:
result.append(-1) # 'T'
elif bits == 1:
result.append(0) # '0'
elif bits == 2:
result.append(1) # '1'
else:
result.append(0) # Invalid pattern, default to 0
return resultAlice使用这些数据来可视化分类网络:
// Alice subscribes to world moments and extracts mathematical models
natsClient.subscribe(`${streamId}.world.moment.${worldId}`, (msg) => {
const moment = JSON.parse(msg.data);
// Check for balanced ternary data
if (moment.binaryData && moment.binaryData.format === "application/balanced-ternary") {
// Decode the binary data
const binaryData = atob(moment.binaryData.data); // Base64 decode
// Create a Uint8Array from the binary string
const bytes = new Uint8Array(binaryData.length);
for (let i = 0; i > (tritPos * 2)) & 0b11;
// Map bit patterns to trits
if (bits === 0) {
result.push(-1); // 'T'
} else if (bits === 1) {
result.push(0); // '0'
} else if (bits === 2) {
result.push(1); // '1'
} else {
result.push(0); // Invalid pattern, default to 0
}
}
return result;
}对Topos团队的好处:
- 统一的数学上下文:团队保持不同工具之间的概念一致性
- 环境分类意识:理论探索的非侵入性指标
- 集体智慧:增强团队数学直觉的共享氛围
- 工具互操作性:不同的接口参与同一分类工作区
- 资源优化:根据可用资源分配计算任务
- 认知同步:随着时间的推移,团队成员的思维模式变得更加一致
- 高效的数学表示:平衡三进制提供了数学结构的紧凑编码
- 跨语言兼容性:二进制数据可以跨不同的编程语言进行一致的处理
这个例子展示了vibespace MCP经验如何使Team Topos能够跨不同工具和界面协作探索数学结构,创造一个超越个人环境的共享认知空间。
