使用说明
toon mcp服务器
MCP服务器,用于LLM上下文窗口中的令牌高效数据编码。
第2版 用途 LEAN格式 (LLM高效自适应表示法)作为主要编码 香椿 可在统计数据中进行比较。
为什么?
JSON在语法上浪费了标记——大括号、方括号、重复的键名、引号。LEAN通过在制表符分隔的表中声明一次字段名、使用点展平键、缩进而不是大括号以及单字符文字(T/F/_),平均节省了约49%的令牌。
工具
lean_encode--JSON值->LEANlean_decode--LEAN->JSON值lean_stats--比较令牌计数:JSON、LEAN和TOONlean_format_response--选择较小的格式(LEAN或紧凑JSON),添加元数据
所有工具在根目录接受任何JSON值。输入已通过Zod验证。
设置
npm install && npm run build
克劳德桌面(claude_desktop_config.json):
{
"mcpServers": {
"toon": {
"command": "node",
"args": ["/absolute/path/to/toon-mcp-server/dist/index.js"]
}
}
}
克劳德代码:
claude mcp add toon -- node /absolute/path/to/toon-mcp-server/dist/index.js
局限性
钥匙 必须匹配 [\w][\w-]*。没有点、空格、斜线、冒号。 encode() 扔坏钥匙。
字符串 正确往返,包括空字符串、标量相似项("null", "42")空白、反斜杠、换行。两种逃生惯例:
- 标量上下文(键:值):反斜杠转义(
\\,\",\n) - 单元格上下文(表格行):RFC 4180加倍(
"") +\n
空根对象 编码为 {}.
文件
index.ts MCP server, 4 tools
lean.ts LEAN encoder/decoder + token estimation
toon.ts TOON encoder/decoder (used in stats comparison)
test.mjs tests
dist/ compiled output
许可证
麻省理工学院
