喋喋不休
用于BMB编程语言的MCP服务器
Chatter通过提供对语言规范、编译反馈和合同验证的实时访问,使AI模型能够生成高质量的BMB代码。
实施状态(2026-05-09,周期2524-2556): Python脚手架chatter/.74/74 pytest通过。 - ✅ 工具(12):bmb_check,bmb_ir,bmb_run,bmb_verify,bmb_spec_lookup,bmb_lint,bmb_lint_explain,bmb_example,bmb_compile,bmb_test,bmb_from_rust,bmb_context_pack- ✅ 资源(4):bmb://spec/full,bmb://spec/quick-reference,bmb://spec/rust-diff,bmb://context/stdlib- ✅ 提示:bmb_implement,bmb_add_contracts,bmb_optimize长期(M3+),根据规则6 BMB重写策略,实施将转移到BMB本身。Python层故意设计得很薄,以保持端口较小。
______________________________________________________________________
为什么聊天?
BMB是一种AI优先的编程语言,旨在由AI编写并由人类审查。但人工智能模型在训练数据中从未见过BMB:
LLM Training Data:
Rust: ████████████████████████ ~2M repositories
C: ████████████████████████ ~3M repositories
Go: ████████████████ ~1M repositories
BMB: ▏ ~0 repositories没有Chatter,AI模型:
- 混淆
T?随着Option - 使用
&对于按位AND(应该是band) - 忘记明确
return块体中 - 生成不正确或缺失的合同
Chatter通过在运行时注入BMB知识来解决这个问题。
______________________________________________________________________
运作原理
┌─────────────┐ ┌─────────────────┐ ┌─────────────┐
│ LLM │────▶│ Chatter │────▶│ BMB │
│ (Claude) │◀────│ MCP Server │◀────│ Toolchain │
└─────────────┘ └─────────────────┘ └─────────────┘
│
┌──────┴──────┐
▼ ▼
[Spec Database] [Examples]Chatter没有将整个规范填充到每个提示符中(~15K个标记),而是提供 选择性、按需访问 这正是AI所需要的。
______________________________________________________________________
特性
工具
| 工具 | 状态 | 描述 |
|---|---|---|
bmb_check | ✅ | 未完全编译的类型检查代码 |
bmb_verify | ✅ | 使用Z3求解器验证合同 |
bmb_spec_lookup | ✅ | 按主题关键字搜索语言规范 |
bmb_lint | ✅ | 运行样式/约定linter,返回JSON警告 |
bmb_lint_explain | ✅ | 用AI友好的解释和修复建议来解决问题 |
bmb_example | ✅ | 按概念关键字从教程中获取示例代码 |
bmb_ir | ✅ | 为源代码段发出LLVM IR(调试/优化分析) |
bmb_run | ✅ | 使用树行走解释器运行代码(不需要LLVM) |
bmb_compile | ✅ | 编译为本机可执行文件(需要LLVM工具链) |
bmb_test | ✅ | 针对BMB代码运行测试用例 |
bmb_from_rust | ✅ | 将Rust代码转换为BMB(启发式——尽最大努力) |
bmb_context_pack | ✅ | 扫描项目目录并返回上下文包v1 JSON |
资源
| URI | 状态 | 描述 |
|---|---|---|
bmb://spec/full | ✅ | 完整的语言规范(docs/specification.md) |
bmb://spec/quick-reference | ✅ | 备忘单:语法、契约、陷阱、stdlib |
bmb://spec/rust-diff | ✅ | BMB与Rust:哲学、语法、内存模型 |
bmb://context/stdlib | ✅ | stdlib/的上下文包--所有公共导出+合约 |
bmb://examples/{category} | ⏳ | 按类别分类的示例代码 |
bmb://stdlib/{module} | ⏳ | 每个模块的标准库文档 |
提示
| 提示 | 状态 | 描述 |
|---|---|---|
bmb_implement | ✅ | 使用可选合约实现函数 |
bmb_add_contracts | ✅ | 将预/后合同添加到现有代码中 |
bmb_optimize | ✅ | 优化代码的速度或大小 |
______________________________________________________________________
安装(Python——当前实现)
# From source (recommended during M2)
cd ecosystem/bmb-mcp
pip install -e .
# Run the server
bmb-chatter需求
- Python 3.10+
- BMB编译器--设置
BMB_BINARY,添加bmb到PATH,或运行cargo build --release在工作空间中 - Z3求解器(用于
bmb_verify,一旦该工具着陆)
______________________________________________________________________
用法
使用克劳德桌面
添加 claude_desktop_config.json:
{
"mcpServers": {
"bmb": {
"command": "npx",
"args": ["@bmb/chatter"]
}
}
}独立服务器
# Start server
chatter serve
# With custom BMB path
BMB_PATH=/usr/local/bin/bmb chatter serve
# With debug logging
chatter serve --debug______________________________________________________________________
示例会话
用户:在BMB中实现二分查找
AI的内部工作流程:
1. bmb_spec_lookup(topic="contracts")
→ Learn pre/post/invariant syntax
2. bmb_example(category="algorithms", name="binary_search")
→ Reference implementation
3. [Generate code]
4. bmb_check(code)
→ Error: "Array access without bounds check"
→ Suggestion: "Add `pre idx bool {
let mut i = 1;
while i arr[i] {
return false;
}
i = i + 1;
}
return true;
}
fn binary_search(arr: &[i32], target: i32) -> usize?
pre is_sorted(arr)
post ret.is_none() implies forall i: 0..arr.len(). arr[i] != target
post ret.is_some() implies arr[ret.unwrap()] == target
{
let mut lo: usize = 0;
let mut hi: usize = arr.len();
while lo main.bmb:3:5Chatter输出:
{
"success": false,
"errors": [{
"code": "E0421",
"message": "Array index out of bounds cannot be proven safe",
"location": { "line": 3, "column": 5 },
"suggestion": "Add `pre idx ` | `T?` | `bmb_check` |
|Bitwise和| `a & b` | `a band b` | `bmb_check` |
|Bitwise或| `a \| b` | `a bor b` | `bmb_check` |
|隐式返回| `{ x }` | `{ return x; }` | `bmb_check` |
|合同缺失| `arr[idx]` | `pre idx Banter for AI. Bare-metal for humans.
Chatter makes BMB speakable.