feat: Add HTTP-Streaming support for MCP with backward compatibility #6020
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
| name: Claude Assistant | |
| on: | |
| issue_comment: | |
| types: [created] | |
| pull_request_review_comment: | |
| types: [created] | |
| issues: | |
| types: [opened, assigned, labeled] | |
| pull_request_review: | |
| types: [submitted] | |
| jobs: | |
| claude-response: | |
| # Prevent certain bots from triggering this action (but allow github-actions[bot] for auto-comments) | |
| if: | | |
| github.actor != 'dependabot[bot]' && | |
| github.actor != 'cursor[bot]' && | |
| github.actor != 'renovate[bot]' && | |
| !(contains(github.actor, '[bot]') && github.actor != 'github-actions[bot]') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| issues: write | |
| actions: read | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: anthropics/claude-code-action@beta | |
| with: | |
| claude_code_oauth_token: ${{ secrets.CLAUDE_ACCESS_TOKEN }} | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| trigger_phrase: "@claude" | |
| allowed_tools: | | |
| Bash(git:*) | |
| Bash(python:*) | |
| Bash(pip:*) | |
| Bash(conda:*) | |
| Bash(pytest:*) | |
| Bash(gh:*) | |
| Bash(python -m pytest:*) | |
| Bash(python -m pip:*) | |
| Bash(poetry:*) | |
| View | |
| GlobTool | |
| GrepTool | |
| BatchTool | |
| Edit | |
| Replace | |
| mcp__github__get_issue | |
| mcp__github__get_issue_comments | |
| mcp__github__update_issue | |
| timeout_minutes: 30 | |
| post-review-comment: | |
| needs: claude-response | |
| if: success() && needs.claude-response.result == 'success' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| issues: write | |
| steps: | |
| - name: Check for existing review comment | |
| id: check-comment | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GH_TOKEN }} | |
| script: | | |
| const reviewText = '@claude review if the changes made in the above branch are as per the requirements and make changes to the above branch if issues still exist.'; | |
| let comments = []; | |
| let issueNumber; | |
| try { | |
| // Determine issue/PR number based on event type | |
| if (context.eventName === 'pull_request_review_comment' || context.eventName === 'pull_request_review') { | |
| issueNumber = context.payload.pull_request?.number || context.issue.number; | |
| } else if (context.eventName === 'issue_comment' && context.payload.issue.pull_request) { | |
| // This is a comment on a PR (not an issue) | |
| issueNumber = context.payload.issue.number; | |
| } else { | |
| // This is a regular issue | |
| issueNumber = context.issue.number; | |
| } | |
| comments = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issueNumber | |
| }); | |
| // Look for Claude's completed review comments | |
| const claudeReviewComments = comments.data.filter(comment => | |
| (comment.user.login === 'claude[bot]' || comment.body.includes('✅') || comment.body.includes('## Summary')) && | |
| !comment.body.includes('⏳') && | |
| !comment.body.includes('🔄') && | |
| !comment.body.includes('Loading...') | |
| ); | |
| // Check if our review request comment already exists | |
| const existingReviewRequest = comments.data.find(comment => | |
| comment.body.includes(reviewText) | |
| ); | |
| // Post if Claude has completed a review AND we haven't posted the review request yet | |
| const shouldPost = claudeReviewComments.length > 0 && !existingReviewRequest; | |
| core.setOutput('should-post', shouldPost); | |
| console.log(`Claude review completed: ${claudeReviewComments.length > 0}`); | |
| console.log(`Review request exists: ${!!existingReviewRequest}`); | |
| console.log(`Should post comment: ${shouldPost}`); | |
| } catch (error) { | |
| console.log('Error checking comments:', error); | |
| core.setOutput('should-post', false); // If we can't check, don't post | |
| } | |
| - name: Wait 30 seconds before posting comment | |
| if: steps.check-comment.outputs.should-post == 'true' | |
| run: sleep 30 | |
| - name: Post review comment | |
| if: steps.check-comment.outputs.should-post == 'true' | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GH_TOKEN }} | |
| script: | | |
| let issueNumber; | |
| let isPR = false; | |
| // Determine issue/PR number and type based on event type | |
| if (context.eventName === 'pull_request_review_comment' || context.eventName === 'pull_request_review') { | |
| issueNumber = context.payload.pull_request?.number || context.issue.number; | |
| isPR = true; | |
| } else if (context.eventName === 'issue_comment' && context.payload.issue.pull_request) { | |
| // This is a comment on a PR (not an issue) | |
| issueNumber = context.payload.issue.number; | |
| isPR = true; | |
| } else { | |
| // This is a regular issue - don't post review comment | |
| issueNumber = context.issue.number; | |
| isPR = false; | |
| } | |
| // Only post review comment on PRs, not regular issues | |
| if (isPR) { | |
| console.log(`Posting review comment on PR #${issueNumber}`); | |
| await github.rest.issues.createComment({ | |
| issue_number: issueNumber, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: '@claude review if the changes made in the above branch are as per the requirements and make changes to the above branch if issues still exist. MAINLY IT SHOULD NOT IMPACT ON THE CURRENT SPEED OF EXECUTION of existing features, not increasing the overhead.' | |
| }); | |
| } else { | |
| console.log(`Skipping review comment for regular issue #${issueNumber}`); | |
| } |