Skip to content

harden: validate MCP shrink_media inputs (file source, positive target)#175

Open
seonghobae wants to merge 1 commit into
mainfrom
feat/mcp-input-validation
Open

harden: validate MCP shrink_media inputs (file source, positive target)#175
seonghobae wants to merge 1 commit into
mainfrom
feat/mcp-input-validation

Conversation

@seonghobae

Copy link
Copy Markdown
Contributor

Why

The MCP shrink_media tool checked only that the source path exists. Two invalid inputs fell through to the engine and surfaced as an opaque "Conversion failed with error: ..." string rather than a clear message at the trust boundary:

  • a directory source (passes exists()), and
  • target_bytes <= 0.

What

  • Reject a source that is not a regular file.
  • Reject target_bytes <= 0 up front.

Both return a clear "Error: ..." string, consistent with the existing source-not-found handling and the web app's input validation.

(No upper bound on target_bytes here — unlike the web upload path, this is a local tool where a large target is a legitimate request; an arbitrary cap would reject valid use.)

Tests (+2)

Directory source rejected; non-positive target rejected.

Verified: mcp_driver.py 100% coverage, interrogate 100%, full suite 115 tests, no new failures (5 macOS-only os.listxattr errors are pre-existing / Linux-green).

Independence

Off base main; touches only mcp_driver.py. Independent of #163#167 and #174.

🤖 Generated with Claude Code

The MCP tool checked only that the source path exists. A directory source, or
target_bytes <= 0, fell through to the engine and surfaced as an opaque
"Conversion failed with error: ..." string instead of a clear, actionable
message at the trust boundary.

- Reject a source that is not a regular file (e.g. a directory).
- Reject target_bytes <= 0 up front.

Both return a clear "Error: ..." string, consistent with the existing
source-not-found handling and the web app's input validation.

Tests (+2): directory source rejected, non-positive target rejected.
mcp_driver.py stays at 100% coverage; interrogate 100%; full suite 115 tests,
no new failures (5 macOS-only xattr errors pre-existing / Linux-green).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CJRVbDrp1vGYkJgNHMGPpG
@seonghobae seonghobae enabled auto-merge (squash) July 6, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant