Colors-LE
io.github.nolindnaidoo由 GitHub 账号 nolindnaidoo 发布v2.5.0更新于 Oct 24, 2026
Extract colors from stylesheets and code, with their notation and position.
概览
本地 MCP 服务器,从助手传入的样式表、标记或代码文本中提取所有颜色,并给出写法与行列位置。
- 可以做什么
- 从传入文本中提取颜色:十六进制、rgb()/rgba()、hsl()/hsla()、hwb()、lab()/lch()、oklab()/oklch()、color() 以及 CSS 命名颜色
- 给出每种颜色的写法与从 1 开始的行号和列号,可选去重并限制返回条数
- 支持 CSS、SCSS、LESS、Stylus、HTML、JS/TS、SVG/XML、JSON、YAML、TOML、Markdown 与纯文本,其他类型按原始文本扫描
- 只返回结构化数据,助手可据此自行排序、转换、聚类或检查对比度
- 适用场景
- 适合助手在已读取的样式表和代码中审查配色、检查设计系统、发现近似重复颜色或核对对比度,而无需另跑命令行工具的场景。
- 运行要求
- 通过 npx(包名 colors-le-mcp)或全局 npm 安装在本地以 stdio 运行。无需 API 密钥、环境变量或额外配置;文件内容由助手作为参数传入。
安装
在 SourceWeft 中
- 打开 控制台中的 Colors-LE,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
Colors-LE: Zero Hassle Color Extraction
Pull every color out of the current file in one keystroke
CSS, SCSS, LESS, Stylus, HTML, JavaScript, TypeScript, SVG, XML, JSON, YAML, TOML, Markdown, and any text
[Install from VS Code Marketplace] [Open VSX downloads] [colors-le-mcp on npm] [colors-le on npm] [colors-le on crates.io] [LE Tools]
Useful? A star or rating is how other developers find it — ★ GitHub · ★ Open VSX · ★ Marketplace
What it does
Open a file, run Colors-LE: Extract Colors, and every color in the document lands in a new editor — deduplicate, sort, convert, filter, analyze, or validate it from there. Works in VS Code and in VS Code–based editors like Cursor and VSCodium (installable from Open VSX).
- Palette auditing — every hex, rgb()/rgba(), hsl()/hsla(), hwb(), lab()/lch(), oklab()/oklch(), color(), and named color in stylesheets, markup, and code
- Design-system review — analyze distribution, cluster similar colors, spot near-duplicates
- Accessibility checks — contrast ratios against WCAG AA/AAA via the Validate command
Install
Use it from an AI agent
The same engine runs as an MCP server, so an agent can call it directly instead of you running a command.
[An agent in Claude Code calling the colors-le MCP server]
Returns every color with its notation and 1-based line and column, capped at 500 by default with meta.truncated so a large stylesheet cannot flood the agent's context window.
The server takes content and returns data — it reads no files and makes no network requests of its own. Published as colors-le-mcp on npm and as io.github.nolindnaidoo/colors-le in the MCP registry.
Configuring it by hand — any host with an MCP config file
Most hosts read a JSON config. Add one entry:
-y skips the install prompt on first run. Pin a version if you would rather not track releases — [email protected].
Prefer not to go through npx on every launch? Install it once and point at the binary instead:
It speaks MCP over stdio and needs no environment variables, no API key and no configuration of its own. To check it before wiring it into anything:
That prints the tool list and exits — if you see extract_colors, the server works.
Supported formats
No document is refused. A language with no reader of its own is read as raw text, and metadata.fileType says which of the two answered.
Recognized syntax: #rgb, #rgba, #rrggbb, #rrggbbaa, comma-form rgb()/rgba()/hsl()/hsla(), CSS Color 4 modern syntax — space-separated rgb()/hsl() with / alpha, hwb(), lab(), lch(), oklab(), oklch() and color() in the nine predefined spaces, with angles in deg, rad, grad or turn and none (calls may span multiple lines), and the CSS named colors including rebeccapurple and transparent. Positions are real 1-based line/column of each literal. Comments never produce colors, and comment markers inside strings don't start comments.
Known limitations (documented, not bugs): relative colours (rgb(from red r g b)), calc() and var() inside a colour call are not read; a colour outside sRGB is clipped when converted; a hex inside any JS string matches, including URL fragments; Stylus values without : or = only yield hex/functional literals, not named colors; in the raw-text scan a value segment runs to the end of the line, so two tokens on one line cost the named one.
Across a folder or a workspace
Extract reads the document you have open. A scan reads many files from disk and gives one report: the project's palette.
- The whole workspace: run
Colors-LE: Extract Colors from Workspacefrom the command palette. - One folder: right-click it in the Explorer and choose
Extract Colors from Folder, or runColors-LE: Extract Colors from Folderand pick one.
Each color is listed once however it is spelled, the most widely used first, with the spellings, how often it is written and where:
The same color is one row. #f00, #FF0000, red and rgb(255, 0, 0) are one color written four ways, and the table says so. Alpha keeps colors apart: a half-transparent red is another color. A value that is not a color in sRGB on its own, such as a var(), is compared as written.
That is with colors-le.showPositions on. It is off by default, and then each line is the file and how many times the color is in it: styles/a.css (3). The copy on the clipboard follows colors-le.clipboardIncludesPositions, as it does for Extract.
What a scan reads. Files come from disk, so an unsaved edit is not seen. A file over the safety size, or one that is not UTF-8 text, is left unread. It stops at 5,000 files or 10,000 listed occurrences. The report ends with a line for each thing it left out, so a short report is never mistaken for a clean project.
What it skips, and how to change that. Three switches are on by default, and each can be turned off on its own in Settings:
Two lists adjust the result without turning a switch off. To skip more, add a pattern to scanExcludes. To read something a switch would skip, add it to scanAlwaysInclude:
Colors-LE: Open Settings opens all of these in the Settings editor.
The built-in list
Folders, wherever they appear:
.git, .hg, .svn, node_modules, bower_components, jspm_packages, .pnpm-store, .yarn, vendor, site-packages, Pods, Carthage, dist, build, out, target, _build, _site, dist-newstyle, zig-out, storybook-static, cdk.out, DerivedData, CMakeFiles, .next, .nuxt, .output, .svelte-kit, .angular, .astro, .docusaurus, .vuepress, .expo, .turbo, .parcel-cache, .cache, .sass-cache, .jekyll-cache, .dart_tool, .pub-cache, .gradle, .kotlin, .cxx, .externalNativeBuild, captures, ephemeral, .symlinks, .swiftpm, .build, .bundle, .stack-work, .zig-cache, .godot, elm-stuff, .vercel, .netlify, .serverless, .aws-sam, .terraform, .venv, venv, __pycache__, .tox, .nox, .mypy_cache, .pytest_cache, .ruff_cache, .ipynb_checkpoints, .eggs, coverage, htmlcov, .nyc_output, .vscode-test, .idea, .vs, xcuserdata, *.egg-info
Files, wherever they appear:
*.min.js, *.min.css, *.map, *.snap, *.lock, package-lock.json, pnpm-lock.yaml, npm-shrinkwrap.json, go.sum, *.pbxproj, *.iml, local.properties, output-metadata.json, .flutter-plugins, .flutter-plugins-dependencies, .packages, Generated.xcconfig, flutter_export_environment.sh, GeneratedPluginRegistrant.*, fastlane/report.xml, fastlane/test_output/**, doc/api/**
Not on the list, because they are ordinary folders in many projects: bin, obj, tmp, logs, public, generated. A project that generates those ignores them in git, and the scan reads .gitignore.
The settings that shape a scan are under Settings.
The CLI
The same extraction from a terminal or a CI step, installed from npm
with npm install -g colors-le (or run with npx colors-le) or from
crates.io with cargo install colors-le. Both install the same command,
documented in crate/, and are held to the same
output byte for byte.
Convert, analyze and validate are interactive and stay in the editor.
Install it from npm (colors-le) or from crates.io (colors-le). Both install the same colors-le command.
[colors-le on npm] [colors-le on crates.io]
Exit codes: 0 clean, 1 none found or a colour outside the palette, 2 the question was malformed.
Matched by colour, not by spelling. A palette written in hex still
catches a violation written in rgb(), because #FFF, #ffffff and
rgb(255, 255, 255) are one entry. Alpha is part of the identity, and a
named colour is only equal to itself — white and #ffffff are the same
pixel and not the same decision.
Commands
No command is bound to a key by default. Give any of them one under Keyboard Shortcuts in the editor.
Settings
Languages
Twelve languages besides English:
German · Spanish · French · Indonesian · Italian · Japanese · Korean · Portuguese (Brazil) · Russian · Ukrainian · Vietnamese · Chinese (Simplified)
Both halves are covered — the manifest (command titles, setting names and descriptions) and everything shown while the extension runs (notifications, the status bar, quick-picks and prompts). The extension follows VS Code's display language, so it matches whatever the editor is already set to; no setting of its own.
Privacy & security
- No network access. The extension never sends data anywhere. The
telemetryEnabledsetting only writes events to a local Output Channel you can inspect (Colors-LE Telemetry). - The MCP server holds the same line. It takes content as an argument and returns data: no filesystem access, no network calls, no telemetry. Your agent already has file-read tools, so duplicating them inside the server would add a path-traversal surface for no capability.
check:mcp-bundlefails the build if the server ever imports something that could reach either. - Error notifications redact home directories and credential-shaped fragments.
- One rating prompt, at most twice. On the 3rd successful use the extension asks once whether you would rate it, and once more on the 20th if you chose Later or dismissed it. Don't Ask Again ends it. Setting
notificationsLeveltoimportantorsilentyourself turns it off. The counts are kept in VS Code's extension storage and nothing is sent anywhere; Rate opens the listing you installed from — the VS Code Marketplace or Open VSX — in your browser.
Documentation
Performance
Median of 7 runs after warmup, on Apple M5 Pro, 24 GB RAM, Node 24.3.0. Inputs are generated
by scripts/benchmark.ts rather than checked in, so the sizes above are
exactly what was measured. Reproduce with bun run benchmark.
These are machine-specific and are not asserted in CI — a benchmark that gates a build only tells you how busy the runner was.
Testing
593 test cases across 41 files, plus an integration suite that runs
in a real VS Code extension host and an end-to-end test that installs the
built .vsix into a clean profile.
Generated from a real run — coverage/coverage-summary.json and
coverage/test-results.json — by scripts/coverage-readme.js, and
bun run coverage:readme:check says whether it has drifted since. Reproduce
with bun run test:coverage, and the case count is the one vitest prints.
More from the LE family
Sixteen single-purpose tools for the work in front of every model. Each ships a Rust CLI and an MCP server. One page: letools.dev
Get it out
- String-LE — Extract every string in a codebase, so a person can read them
- Numbers-LE — Extract every hardcoded number in a codebase, so a person can check them
- Units-LE — Extract every quantity with its unit, normalized, and refuse the ambiguous ones by name
- Dates-LE — Extract every date and timestamp, and the exact instant each one resolves to
- IDs-LE — Extract every UUID, ULID, NanoID, ObjectId and Snowflake, and decode the time inside
- IPs-LE — Extract every IP address, CIDR block and MAC, normalized and classified by scope
- URLs-LE — Extract every URL in a codebase, with its protocol and exact position
- Paths-LE — Extract every file path in a codebase, and say whether it still points at anything
- Colors-LE — Extract every color in a codebase, and say which ones are not in your palette
Check it
- Regex-LE — Find every regex in a codebase, and report which can be driven into catastrophic backtracking
- Versions-LE — Find where one dependency is constrained differently across a repository's manifests
- i18n-LE — Identify the i18n library a project uses, then audit its catalogs by that library's rules
- Scrape-LE — Check whether a page is scrapeable before the scraper is written, and say when it cannot tell
Guard it
- Secrets-LE — Find hardcoded credentials in a codebase, and never print one into the report
- EnvSync-LE — Compare the dotenv files in a tree, and say which keys are missing from which
- Unicode-LE — Find the Unicode that hides meaning — bidi controls, invisibles, homoglyphs, mixed scripts
Each stands on its own: no shared crate, no published core. Where two of them agree, it is because the same answer was right twice.
Contact — nolindnaidoo.com · GitHub · LinkedIn
Also by nolindnaidoo
Rust — pixelcoords and pixelactions are one loop: pixelcoords answers where, pixelactions acts there. Their own tools, their own voice — not part of the LE family.
- pixelcoords — Freeze your screen, mark regions, get pixel-exact coordinates and crops pixelcoords.dev · crates.io · docs.rs
- pixelactions — Consume human-verified coordinates, perform the interaction, confirm it landed pixelactions.dev · crates.io · docs.rs
License
MIT © nolindnaidoo
来源:README.md,提交 13c6e90
工具
0版本历史
6- v2.5.0最新Oct 8, 2026
- v2.4.3Oct 5, 2026
- v2.4.2Oct 3, 2026
- v2.4.0Sep 30, 2026
- v2.3.1Sep 30, 2026
- v2.3.0Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分