Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/mcp_issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ body:
- gh-tooling / label and project tools (label_list, project_list, project_view)
- gh-tooling / api_read
- gh-tooling-write / PR write tools (pr_create, pr_edit, pr_ready, pr_merge, pr_close, pr_reopen)
- gh-tooling-write / review tools (pr_review_submit, pr_comment, pr_review_reply)
- gh-tooling-write / review tools (pr_review_submit, pr_comment, pr_review_reply, comment_edit)
- gh-tooling-write / issue write tools (issue_create, issue_edit, issue_close, issue_reopen, issue_comment)
- gh-tooling-write / labels, assignees, sub-issues
- gh-tooling-write / project writes (project_item_add, project_status_set)
Expand Down
65 changes: 65 additions & 0 deletions plugin-tests/github-mcp/check_api_tools.bats
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,71 @@ setup_write_blocking() {
assert_output --partial "pr_review_reply"
}

@test "write api: blocks PATCH issues/comments/ID → suggests comment_edit" {
setup_write_blocking
run_api_hook "$WRITE_TOOL" "repos/shopware/shopware/issues/comments/456" "PATCH"
assert_failure 2
assert_output --partial "comment_edit"
refute_output --partial "issue_edit"
}

@test "write api: the PATCH issues/comments/ID block takes the url from issue_view or pr_view comments, not pr_comments" {
setup_write_blocking
run_api_hook "$WRITE_TOOL" "repos/shopware/shopware/issues/comments/456" "PATCH"
assert_failure 2
assert_output --partial "issue_view or pr_view with fields=comments"
refute_output --partial "pr_comments"
}

@test "write api: blocks PATCH pulls/comments/ID → suggests comment_edit" {
setup_write_blocking
run_api_hook "$WRITE_TOOL" "repos/shopware/shopware/pulls/comments/456" "PATCH"
assert_failure 2
assert_output --partial "comment_edit"
assert_output --partial "pr_comments"
}

@test "write api: blocks PUT pulls/N/reviews/ID → suggests comment_edit" {
setup_write_blocking
run_api_hook "$WRITE_TOOL" "repos/shopware/shopware/pulls/123/reviews/456" "PUT"
assert_failure 2
assert_output --partial "comment_edit"
refute_output --partial "pr_review_submit"
}

@test "write api: a comment path only in the query string of another PATCH endpoint is not redirected to comment_edit" {
setup_write_blocking
run_api_hook "$WRITE_TOOL" "repos/shopware/shopware/labels/bug?next=repos/shopware/shopware/issues/comments/456" "PATCH"
assert_success
}

@test "write api: a review path only in the query string of another PUT endpoint is not redirected to comment_edit" {
setup_write_blocking
run_api_hook "$WRITE_TOOL" "repos/shopware/shopware/pulls/123/requested_reviewers?next=repos/shopware/shopware/pulls/123/reviews/456" "PUT"
assert_success
}

@test "write api: POST pulls/N/reviews still suggests pr_review_submit, not comment_edit" {
setup_write_blocking
run_api_hook "$WRITE_TOOL" "repos/shopware/shopware/pulls/123/reviews" "POST"
assert_failure 2
assert_output --partial "pr_review_submit"
refute_output --partial "comment_edit"
}

@test "write api: DELETE issues/comments/ID is not redirected to comment_edit" {
setup_write_blocking
run_api_hook "$WRITE_TOOL" "repos/shopware/shopware/issues/comments/456" "DELETE"
assert_success
}

@test "Codex write api: PATCH issues/comments/ID suggests comment_edit" {
setup_codex_config "gh-tooling" '{"block_api_tool_write": true}'
run_api_hook "$CODEX_WRITE_TOOL" "repos/shopware/shopware/issues/comments/456" "PATCH"
assert_failure 2
assert_output --partial "comment_edit"
}

@test "write api: allows unknown write endpoint" {
setup_write_blocking
run_api_hook "$WRITE_TOOL" "repos/shopware/shopware/releases" "POST"
Expand Down
28 changes: 28 additions & 0 deletions plugin-tests/github-mcp/gh_tools.bats
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,34 @@ bats_test_function \
"gh api repos/shopware/shopware/pulls/14642/reviews" \
"pr_reviews"

# comment_edit redirects: the method flag before or after the endpoint, and the
# reviews/ID PUT must not fall through to pr_reviews.
gh_api_edit_blocks() {
gh_api_hook_blocks "$1" "comment_edit"
refute_output --partial "pr_reviews"
}

bats_test_function \
--description "blocks gh api -X PATCH .../issues/comments/ID → suggests comment_edit" \
-- gh_api_edit_blocks \
"gh api -X PATCH repos/shopware/shopware/issues/comments/2001 -f body=x"

bats_test_function \
--description "blocks gh api .../pulls/comments/ID --method PATCH → suggests comment_edit" \
-- gh_api_edit_blocks \
"gh api repos/shopware/shopware/pulls/comments/1234567 --method PATCH -f body=x"

bats_test_function \
--description "blocks gh api -X PUT .../pulls/N/reviews/ID → suggests comment_edit, not pr_reviews" \
-- gh_api_edit_blocks \
"gh api -X PUT repos/shopware/shopware/pulls/14642/reviews/777 -f body=x"

bats_test_function \
--description "blocks gh api .../pulls/N/reviews/ID -X GET → suggests pr_reviews" \
-- gh_api_hook_blocks \
"gh api repos/shopware/shopware/pulls/14642/reviews/777 -X GET" \
"pr_reviews"

bats_test_function \
--description "blocks gh api .../pulls/N/files → suggests pr_files" \
-- gh_api_hook_blocks \
Expand Down
18 changes: 18 additions & 0 deletions plugin-tests/github-mcp/tool_schemas.bats
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,24 @@ load_validator_for() {
assert_output --partial "Unknown parameter(s): body_file"
}

@test "comment_edit refuses fallback, which would report a failed edit as a success" {
load_validator_for "$WRITE_TOOLS"

run validate_tool_arguments "comment_edit" '{"url": "o/r/issues/1#issuecomment-2", "body": "x", "fallback": "ok"}'

assert_failure
assert_output --partial "Unknown parameter(s): fallback"
}

@test "comment_edit refuses an allow_other_author that is not a boolean" {
load_validator_for "$WRITE_TOOLS"

run validate_tool_arguments "comment_edit" '{"url": "o/r/issues/1#issuecomment-2", "body": "x", "allow_other_author": "true"}'

assert_failure
assert_output --partial "allow_other_author expected boolean, got string"
}

@test "a paging limit sent as a string is refused, naming the parameter" {
# The counterpart to the identifier union: limit and max_lines are
# integer-only on purpose, so the string form must fail rather than reach
Expand Down
Loading
Loading