Repository navigation
feat: optimize_image tool (local compression, no API key), 0.4.0 - #17
Merged
Merged
Conversation
Compress/resize/convert a LOCAL image file with sharp (optional dependency, loaded lazily; a structured sharp_unavailable error if it can't load). Same pipeline as `pixelvault optimize` in pixelvault-cli: orientation applied before metadata is stripped, never writes a bigger file, idempotent, atomic writes, refuses to overwrite unrelated files or write through symlinks. Local stdio server only: the hosted MCP cannot read the user's disk. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tde8opdomzAwwCkmME3ePL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
New
optimize_imagetool for the local stdio MCP: compress, resize and convert a local image file on the user's machine. No API key, nothing uploaded. Mirrorspixelvault optimizein pixelvault-cli 0.14.0 (spec:docs/specs/optimize-command.mdin pixelvault-dev/pixelvault). Local server only: the hosted MCP can't read the user's disk (it already hastransform_imageand the upload'soptimized_url).Inputs:
path,format(keep|webp|avif|jpg|png),max_width/max_height,quality,keep_metadata,output_path|in_place,dry_run. Returns{input, output, status, reason, input_bytes, output_bytes, saved_percent, width, height}.Safety
Default writes
<name>.optimized.<ext>beside the original (original untouched); refuses to overwrite an existing file other than*.optimized.*; refuses symlinks (in place and as destination); atomic temp-file + rename writes; decode limits (100 MP / 100 MB); corrupt files return a structured error; never writes a bigger file; idempotent re-runs. EXIF orientation is applied before metadata is stripped.Dependencies
sharpis anoptionalDependency(external in tsup, loaded lazily). If it can't load,optimize_imagereturnssharp_unavailablewith the reason and every other tool still works. The core (src/optimize-core.ts) is a copy of the CLI'ssrc/lib/optimize.ts; keep them in sync (a shared package is a possible follow-up).Testing
8 tests against real sharp (writes beside, webp+resize, idempotent second run, dry-run, in-place keeps
.jpeg, no-overwrite, symlinks, input validation) plus the existing 13 pass;tsc --noEmitclean. Also ran the built server with a real MCP stdio client: tool listed, 4.1 MB PNG -> 72 KB WebP at 1600 px, missing file returns a structurednot_found.Release
0.4.0 is bumped but not published. This package's publish previously failed with an
NPM_TOKENE404 (0.2.0/0.3.0 are not on npm), so that needs sorting before tagging.🤖 Generated with Claude Code
https://claude.ai/code/session_01Tde8opdomzAwwCkmME3ePL