feat(mcp-server): explain task_claim_file rejections with a reason-specific message#545
Merged
NagyVikt merged 1 commit intoMay 14, 2026
Conversation
…ecific message
`task_claim_file` and the `TaskThread.claimFile` / `normalizeOptionalClaimPath`
paths used to throw `INVALID_CLAIM_PATH: claim path is not claimable` with no
hint at the reason. Telemetry showed agents bouncing off the same surface for
the same input — e.g. `colony/packages/core/test` (a directory) — because the
message gave them nothing to act on.
The rejection branch now classifies the failure and renders a specific
message per reason: directory ("claim individual files inside it
instead"), pseudo (/dev/null etc), outside_repo, empty, plus the legacy
generic fallback. Existing `INVALID_CLAIM_PATH` error code is preserved.
New `@colony/storage` exports:
* `classifyClaimPathRejection(context)` — pure classifier paralleling
`normalizeRepoFilePath`. Returns the reason or `null`.
* `claimPathRejectionMessage(reason, file_path)` — single source of truth
for the user-facing message so the MCP `task_claim_file` handler and
`TaskThread.claimFile` stay in sync.
* New storage method `classifyTaskFilePathRejection(task_id, file_path,
cwd?)` plumbs the task → repo_root lookup that `normalizeTaskFilePath`
already does, so callers only pay for the classifier on the error
branch.
Tests:
* `packages/storage/test/claim-path.test.ts` covers all five reasons
(existing directory, trailing-slash directory, pseudo, empty,
outside_repo) plus message rendering for each.
* `apps/mcp-server/test/task-threads.test.ts` updates the existing pseudo-
path test to assert the new message and adds a directory case asserting
the recovery hint.
Storage: 149/149 PASS. mcp-server: 273/273 PASS. Lint clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Automated by gx branch finish (PR flow).