fix(img-forge): expose aspect_ratio, image_size, model params; gate model-derived tiers#48
Merged
Conversation
…e model-derived tiers (#47) Closes #47. - tool-registry: add aspect_ratio (10 ratios), image_size (512/1K/2K/4K), and model (gemini-3.1-flash-image-preview / gemini-3-pro-image-preview) to image_generate input schema - cost-attribution: add MODEL_QUALITY_TIER map and export resolveImageQualityTier; model wins over quality_tier for billing (gemini-3.1-flash → ultra, gemini-3-pro → ultra_plus) - gateway: enforceTierRestriction uses resolveImageQualityTier, closing the bypass where free-tier callers could set model without quality_tier - docs: README, api-reference, architecture, user-guide all updated with new params, model→tier mapping, and billing precedence rule - tests: 10 new cases covering model-derived cost, collision policy, unknown-model fallback, and free-tier model bypass protection Note: notifications/tools/list_changed deferred — catalog rebuilds per-request so reconnecting clients pick up the new schema automatically. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…low test - tool-registry: add default: '1:1' and default: '1K' to aspect_ratio and image_size so MCP clients can read defaults from schema - gateway: drop inline comment on qualityTier in enforceTierRestriction (resolveImageQualityTier JSDoc carries this) - test: add positive case — pro-tier + model=gemini-3-pro-image-preview should be allowed (catches over-gating regressions) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Closes #47.
Summary
tool-registry.ts): addsaspect_ratio(10 ratios),image_size(512/1K/2K/4K), andmodel(gemini-3.1-flash-image-preview/gemini-3-pro-image-preview) to theimage_generateinput schema so MCP clients discover the new fieldscost-attribution.ts): addsMODEL_QUALITY_TIERmap and exportsresolveImageQualityTier; whenmodelis set it determines the effective tier for quota — model wins overquality_tier(gemini-3.1-flash →ultra, gemini-3-pro →ultra_plus)gateway.ts):enforceTierRestrictioncallsresolveImageQualityTier, closing the bypass where a free-tier caller could setmodelwithoutquality_tierand skip the Pro+ gateproxyToolCallalready forwardsargsunchanged via JSON-RPC; the new fields pass through to img-forge automaticallydocs/api-reference.md,docs/architecture.md,docs/user-guide.mdupdated with new params, model→tier mapping, and billing precedence ruleDeferred
notifications/tools/list_changed— the catalog rebuilds per-request viabuildAggregatedCatalog, so reconnecting clients pick up the new schema automatically. Live-session notification is a separate transport concern and not part of this fix.Test plan
npm run test— 187 tests pass (10 new cases added)npm run typecheck— cleantools/listat gateway includesaspect_ratio,image_size,modelonimage_generatequality_tier: "ultra_plus",aspect_ratio: "2:3",image_size: "2K",model: "gemini-3-pro-image-preview"reaches img-forge unchanged and succeedsmodel: "gemini-3-pro-image-preview"is rejected withrequires a Pro plan or higherultra_plustier cost whenmodel=gemini-3-pro-image-preview🤖 Generated with Claude Code