fix(validate): only recommend 512x512 icon size when the icon isn't already 512x512#248
Open
adityasingh2400 wants to merge 1 commit into
Conversation
mcpb validate always printed the 512x512 size recommendation for any valid PNG icon, because the icon check verified the PNG signature but never read the actual image dimensions. A correctly-sized 512x512 icon still got told to be 512x512. Read the width and height from the PNG IHDR chunk and only emit the recommendation when the icon is not already 512x512. The warning now also reports the icon's actual dimensions so authors know what to fix. Fixes modelcontextprotocol#218
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.
Problem
mcpb validateprints the "Recommended size is 512×512 pixels" message for every valid PNG icon, even when the icon is already 512×512. This is #218, which a maintainer confirmed: the icon check verifies the PNG signature bytes but never reads the image dimensions, so the recommendation is unconditional.Before:
(printed regardless of the icon's real size, including for a correct 512×512 icon)
Fix
Read the width and height from the PNG IHDR chunk and only emit the recommendation when the icon is not already 512×512. The warning now also reports the icon's actual dimensions so authors know what to change:
A correctly-sized 512×512 icon produces no icon warning at all.
The IHDR chunk is required by the PNG spec to be the first chunk immediately after the 8-byte signature, so width/height live at fixed offsets (16 and 20).
getPNGDimensionsreturnsnullif the buffer is too short or those bytes are not an IHDR chunk, in which case the recommendation is simply skipped rather than guessed.Testing
yarn test— all 8 suites, 126 tests pass.yarn lint— clean.test/icon-validation.test.ts: the existing local-icon fixture is 1×1, so it now asserts the recommendation appears with the real dimensions; added a 512×512 fixture asserting no recommendation is shown.Icon is 256×256 pixels.Fixes #218