Skip to content

fix(mcp): report a banned license as a business failure - #1838

Merged
marcossevilla merged 5 commits into
mainfrom
unicoder/issue-1823
Nov 30, 2026
Merged

marcossevilla merged 5 commits into
mainfrom
unicoder/issue-1823

Conversation

@unicoderbot

@unicoderbot unicoderbot Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Summary

The MCP license check used to report a banned license as invalid caller input. very_good packages check licenses exits with ExitCode.config (78) when it bans a dependency. ToolFailureType.fromExitCode mapped that code to validation / invalid_input, so agents were told to fix their arguments. In fact the check ran correctly and found a policy violation.

This PR classifies that case as a business failure with a new license_banned reason. The banned packages are now part of the payload, so an agent can act without parsing the report.

Closes #1823

Changes

  • LicenseCheckRecorder side channel
    • New zone-scoped recorder, exported from the check commands barrel. The licenses command records its banned dependencies into it before returning ExitCode.config.
    • ToolRun.capture now wraps the command in a LicenseCheckRecorder zone, alongside the existing TestRunRecorder.
  • Failure classification in ToolRun
    • When the recorder holds banned dependencies, the failure type becomes business and the reason becomes ToolFailureReason.licenseBanned (license_banned).
    • Otherwise, exit code 78 still maps to validation / invalid_input as before.
  • New licenses payload on StructuredToolError
    • Contains banned (the total count) and bannedDependencies (each package with the licenses that banned it), capped at the first maxPayloadItems (20) entries.
    • Added to the tool output schema.
  • Recovery advice for license_banned
    • Read licenses.bannedDependencies.
    • Replace each banned dependency.
    • Change allowed, forbidden or skip_packages only with the user's agreement.
  • Docs
    • Updated the packages_check_licenses tool description.
    • Added license_banned to the failure reason table in site/docs/commands/mcp.md.
    • Added a new "License results" section with an example payload.

Tests

  • The licenses command records banned dependencies for both allowed and forbidden, and records nothing when every license is allowed.
  • ToolRun gives each run its own recorder and returns business / license_banned with the licenses payload when dependencies are banned.
  • ToolRun falls back to validation / invalid_input when nothing was recorded.
  • StructuredToolError puts licenses in the right key order, omits it when absent, and caps it at 20 entries.
  • ToolFailureReason wire values include license_banned.

Closes #1823

Co-authored-by: marcossevilla <marcossevilla@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cognitive Complexity Analysis

Net Delta: +7 | Added: 4 | Increased: 2 | Improved: 0 | Removed: 0 | Violations: 0

Status Declaration Location Delta Score
🟡 ToolRun._recordedReason lib/src/mcp/runner/tool_run.dart:L131-149 +2 5 -> 7
🟡 ToolRun._failure lib/src/mcp/runner/tool_run.dart:L160-206 +1 3 -> 4
🔵 LicenseCheckRecorder.recordBannedDependencies lib/src/commands/packages/commands/check/commands/license_check_recorder.dart:L46-54 +1 new -> 1
🔵 LicensePayload.maybeOf lib/src/mcp/runner/models/license_payload.dart:L35-38 +1 new -> 1
🔵 LicensePayload.of lib/src/mcp/runner/models/license_payload.dart:L25-33 +1 new -> 1
🔵 ToolRun._recordedFailureType lib/src/mcp/runner/tool_run.dart:L82-91 +1 new -> 1

@unicoderbot

unicoderbot Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

I tried to auto-update this PR with main but ran into conflicts. The branch is unchanged — please merge it manually.

@marcossevilla

Copy link
Copy Markdown
Member

/unicoder fix CI failures

@unicoderbot

unicoderbot Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor Author

On it, I'll address the review comments and push the changes.

  • Preparing environment
    • Cloning repository
    • Setting up dev environment
  • Reviewing feedback
  • Working on changes
  • Pushing updates

I've pushed changes to address the feedback.

Co-authored-by: marcossevilla <marcossevilla@users.noreply.github.com>
@marcossevilla

Copy link
Copy Markdown
Member

/unicoder /merge

@unicoderbot

unicoderbot Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor Author

On it, I'll merge the target branch into this PR and resolve any conflicts.

  • Preparing environment
    • Cloning repository
    • Setting up dev environment
  • Fetching target branch
  • Merging target into PR
  • Updating PR branch

I merged main into this PR and resolved the conflicts.

Co-authored-by: marcossevilla <marcossevilla@users.noreply.github.com>
@marcossevilla
marcossevilla merged commit 0cc8c52 into main Nov 30, 2026
27 checks passed
@marcossevilla
marcossevilla deleted the unicoder/issue-1823 branch November 30, 2026 12:08
This was referenced Nov 30, 2026
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.

fix(mcp): a banned license is reported as invalid input

1 participant