Token导航 LogoToken导航TokenDH.com
Skinny Jeans logo
运维云端未说明官方级别未说明来源级核验

Skinny Jeans

MCP Server

skinny-jeans是一个MCP服务器,为Claude Code提供透明文件服务,通过TOON编码和内容优化减少文件读取时的令牌消耗。

工具数

5

提示词数

0

GitHub Stars

1

资源数

0
TypeScriptClaude令牌优化Claude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

jordan112

提供方

jordan112

最后核验

2026/5/17 20:21

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

紧身牛仔裤👖

把你的背景塞进紧身牛仔裤里。

一个透明地向以下对象提供文件的MCP服务器 克劳德代码 JSON文件缩小了约40-60%。Markdown下降了约15-30%。代码失去了注释膨胀。每次文件读取都会自动消耗更少的令牌。

为什么

在Claude代码中读取的每个文件都会消耗API配额中的令牌。Markdown很冗长(封面、徽章、空行)。JSON在每个对象中重复字段名。代码中的注释对人类有帮助,但对已经理解代码的LLM来说是噪音。

紧身牛仔裤作为MCP服务器,位于Claude和文件系统之间,实时压缩内容:

Claude Code  ──>  skinny-jeans (MCP)  ──>  reads file from disk
                        │
                        ├── .json/.jsonl  →  TOON encoding     ~40-60% savings
                        ├── .md/.mdx      →  markdown minify   ~15-30% savings
                        ├── .ts/.js/.py   →  comment stripping ~10-20% savings
                        └── other text    →  whitespace cleanup ~5% savings

运作原理

紧身牛仔裤使用 卡通 JSON的(面向令牌的对象表示法)——一种专为LLM消费而构建的格式,可减少约40%的令牌 *更好* LLM理解准确率(73.9%对JSON的69.7%)。

之前(JSON,~96个令牌):

{
  "hikes": [
    {"id": 1, "name": "Blue Lake Trail", "distanceKm": 7.5, "difficulty": "moderate"},
    {"id": 2, "name": "Ridge Overlook", "distanceKm": 9.2, "difficulty": "hard"},
    {"id": 3, "name": "Meadow Loop", "distanceKm": 3.1, "difficulty": "easy"}
  ]
}

之后(TOON,约51个代币——减少47%):

hikes[3]{id	name	distanceKm	difficulty}:
  1	Blue Lake Trail	7.5	moderate
  2	Ridge Overlook	9.2	hard
  3	Meadow Loop	3.1	easy

快速开始

安装

npm install skinny-jeans

使用克劳德代码注册

claude mcp add --scope user --transport stdio skinny-jeans -- node /path/to/node_modules/skinny-jeans/dist/index.js

或者克隆并从源代码构建:

git clone https://github.com/jordan112/skinny-jeans.git
cd skinny-jeans
npm install && npm run build
claude mcp add --scope user --transport stdio skinny-jeans -- node $(pwd)/dist/index.js

添加到CLAUDE.md

将此添加到您的项目 CLAUDE.md (或复制其中一份):

# Token Optimization (skinny-jeans)

Prefer `toon_read_file` over built-in Read for files > 50 lines.
Use `toon_read_json` for any JSON/data file.
Use `toon_list_files` instead of ls/Bash for directory listings.
Use `toon_estimate_tokens` before reading large files.

验证它是否正常工作

启动Claude Code会话并运行 /mcp --你应该看看 skinny-jeans 列出了5种工具。

MCP工具

工具目的
toon_read_file(path)读取任何优化形式的文件。自动检测类型,应用正确的转换,报告节省。
toon_read_json(path)JSON/JSONL到TOON,带有编码选项(分隔符、键折叠)。
`toon_estimate_tokens(path\text)`在不读取完整文件的情况下估计令牌计数。
toon_list_files(path)压缩目录列表为缩进树(没有详细的元数据)。
toon_batch_estimate(paths)跨文件/目录的批量令牌节省报告。

toon_read_file

主要工具。读取任何文件并自动应用正确的优化:

toon_read_file({ path: "data.json" })
→ [skinny-jeans: 47% smaller, ~51 tokens (was ~96)]
→ TOON-encoded content

toon_read_file({ path: "README.md" })
→ [skinny-jeans: 22% smaller, ~145 tokens (was ~186)]
→ Minified markdown (no badges, frontmatter, excess blanks)

toon_read_file({ path: "app.ts" })
→ [skinny-jeans: 15% smaller, ~171 tokens (was ~201)]
→ Code with comments stripped

参数:

  • path (string,必填)--文件路径
  • maxTokens (number,可选)--在此令牌计数处截断输出
  • raw (布尔值,可选)--跳过优化,返回原始内容

toon_read_json

专门用于JSON,具有编码选项:

  • delimiter"tab" (默认), "comma",或 "pipe" 对于表格行
  • keyFolding"safe" (默认)崩溃 {"a": {"b": 1}} 进入 a.b: 1

toon_estimate_tokens

在提交完整阅读之前快速检查:

toon_estimate_tokens({ path: "big-dataset.json" })
→ File: big-dataset.json
→ Size: 245891 bytes, 4521 lines
→ Estimated tokens: ~52340
→ Category: json
→ Expected savings with skinny-jeans: 40-60%

toon_batch_估计

分析整个项目:

toon_batch_estimate({ paths: ["src/", "data/"] })
→ Token Savings Report (47 files)
→ json: 12 files, ~45200 tokens → save ~20340 tokens (45%)
→ code: 28 files, ~31000 tokens → save ~4650 tokens (15%)
→ markdown: 7 files, ~8900 tokens → save ~1780 tokens (20%)
→ Total: ~85100 tokens
→ Estimated savings: ~26770 tokens (31%)

命令行界面

紧身牛仔裤也可以作为一个独立的CLI:

# Read a file with optimization
skinny-jeans read data.json

# Estimate tokens for a file
skinny-jeans estimate large-file.ts

# Batch savings report
skinny-jeans batch src/ data/ docs/

变换

JSON/JSONL→ TOON

使用 @卡通格式/卡通 编码器。对象数组变成具有共享标题的表格行。嵌套的键被折叠成虚线路径。制表符的标记效果优于逗号。

Markdown缩小

逐行剥离状态机:YAML frontmatter、HTML注释、徽章图像、尾随 # 标题、多余的空行、尾随空格。保留:代码块(从未接触过)、表、链接、块引号。

代码注释剥离

删除整行 ///* */ 评论(C风格语言)和 # 注释(Python、Ruby、shell)。保留内联注释(它们携带上下文)和包含注释式语法的字符串文字。

通用压缩

其他文本文件的回退:将3行以上连续的空白行折叠为1行,去掉尾随的空白。

预期代币节省

文件类型典型节省
JSON(表格/数组数据)40-60%
JSON(嵌套配置)20%-35%
Markdown(带徽章的自述文件)15-30%
Types/JavaScript10-20%
Python10-25%
其他文本5-10%

发展

git clone https://github.com/jordan112/skinny-jeans.git
cd skinny-jeans
npm install
npm run build
npm test

本地运行

# Test the MCP server directly
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' | node dist/index.js

# Register for development
claude mcp add --scope user --transport stdio skinny-jeans -- node $(pwd)/dist/index.js

它如何与Claude Code集成

紧身牛仔裤是 MCP服务器 它通过stdio进行通信。当在Claude Code注册时,它的工具会与Claude的内置工具一起出现。这 CLAUDE.md 该文件指示Claude更喜欢使用紧身牛仔裤工具进行文件读取,因此优化过程是透明的。

这是Claude Code中透明令牌优化的唯一可行方法——钩子可以在工具使用前/后运行命令,但不能修改工具输出。

许可证

麻省理工学院

目录标签

目录标签

TypeScriptClaude令牌优化文件压缩本地部署MCP服务器JSON优化代码注释剥离

支持客户端

Claude

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

token

工具数量(toolCount,工具数)

5

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明token部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP