Skip to content

Commit 55cf37a

Browse files
committed
Replace MCP tool calls with gh CLI commands for coding agent
The coding agent doesn't have mcp_github_* prefixed tools available. Switch to gh CLI commands run in the terminal, which are universally available on GitHub-hosted runners. Also add gh auth status check in copilot-setup-steps.
1 parent 2c0cd0f commit 55cf37a

3 files changed

Lines changed: 24 additions & 22 deletions

File tree

.github/prompts/agentic-merge-upstream.prompt.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -327,24 +327,24 @@ Run the finish script which updates `.lastmerge`, runs a final build, and pushes
327327

328328
### PR Handling: Coding Agent vs. Manual Workflow
329329

330-
**If running as a Copilot coding agent** (triggered via GitHub issue assignment by the weekly sync workflow), a pull request has **already been created automatically** for you. Do NOT create a new one. Just push your commits to the current branch — the existing PR will be updated. Add the `upstream-sync` label to the existing PR using the GitHub MCP tool:
330+
**If running as a Copilot coding agent** (triggered via GitHub issue assignment by the weekly sync workflow), a pull request has **already been created automatically** for you. Do NOT create a new one. Just push your commits to the current branch — the existing PR will be updated. Add the `upstream-sync` label to the existing PR by running this command in a terminal:
331331

332-
```
333-
mcp_github_add_issue_labels(owner: "copilot-community-sdk", repo: "copilot-sdk-java", issue_number: <PR_NUMBER>, labels: ["upstream-sync"])
332+
```bash
333+
gh pr edit --add-label "upstream-sync"
334334
```
335335

336-
> **No-changes scenario (coding agent only):** If after analyzing the upstream diff there are no relevant changes to port to the Java SDK, you **MUST** close the auto-created pull request and the triggering issue using these exact MCP tool calls:
336+
> **No-changes scenario (coding agent only):** If after analyzing the upstream diff there are no relevant changes to port to the Java SDK, you **MUST** close the auto-created pull request and the triggering issue by running these commands in a terminal:
337337
>
338-
> 1. Close the PR: `mcp_github_update_pull_request(owner: "copilot-community-sdk", repo: "copilot-sdk-java", pullNumber: <PR_NUMBER>, state: "closed")`
339-
> 2. Comment on the issue: `mcp_github_add_issue_comment(owner: "copilot-community-sdk", repo: "copilot-sdk-java", issue_number: <ISSUE_NUMBER>, body: "No relevant upstream changes to port. Closing as not planned.")`
340-
> 3. Close the issue: `mcp_github_update_issue(owner: "copilot-community-sdk", repo: "copilot-sdk-java", issue_number: <ISSUE_NUMBER>, state: "closed", state_reason: "not_planned")`
338+
> 1. Close the PR: `gh pr close $(gh pr view --json number --jq .number) --comment "No relevant upstream changes to port to the Java SDK."`
339+
> 2. Close the issue: `gh issue close ISSUE_NUMBER --reason "not planned" --comment "No relevant upstream changes to port to the Java SDK. Closing as not planned."` (replace ISSUE_NUMBER with the actual issue number)
341340
>
342-
> **Do NOT skip these steps.** All three tool calls are required when there are no changes to port.
341+
> **CRITICAL: You MUST run these `gh` CLI commands in a terminal. Do NOT skip these steps.** Both commands are required when there are no changes to port.
343342
344-
**If running manually** (e.g., from VS Code via the reusable prompt), create the Pull Request using the GitHub MCP tool (`mcp_github_create_pull_request`). Use `owner: copilot-community-sdk`, `repo: copilot-sdk-java`, `head: $BRANCH_NAME`, `base: main`. Then add the label:
343+
**If running manually** (e.g., from VS Code via the reusable prompt), create the Pull Request using `gh` CLI or the GitHub MCP tool. Then add the label:
345344

346-
```
347-
mcp_github_add_issue_labels(owner: "copilot-community-sdk", repo: "copilot-sdk-java", issue_number: <PR_NUMBER>, labels: ["upstream-sync"])
345+
```bash
346+
gh pr create --base main --title "Merge upstream SDK changes (YYYY-MM-DD)" --body-file /dev/stdin <<< "$PR_BODY"
347+
gh pr edit --add-label "upstream-sync"
348348
```
349349

350350
The PR body should include:

.github/prompts/coding-agent-merge-instructions.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,20 @@ Commit changes incrementally. Update .lastmerge when done.
1010
IMPORTANT: A pull request has already been created automatically for you — do NOT create a new
1111
one. Push your commits to the current branch, and the existing PR will be updated.
1212

13-
Add the 'upstream-sync' label to the existing PR using the GitHub MCP tool:
13+
Add the 'upstream-sync' label to the existing PR by running this command in a terminal:
1414

15-
mcp_github_add_issue_labels(owner: "copilot-community-sdk", repo: "copilot-sdk-java", issue_number: <PR_NUMBER>, labels: ["upstream-sync"])
15+
gh pr edit --add-label "upstream-sync"
1616

1717
If after analyzing the upstream diff there are no relevant changes to port to the Java SDK,
18-
you MUST close the pull request and the issue. Use these exact GitHub MCP tool calls:
18+
you MUST close the pull request and the issue. Run the following commands in a terminal:
1919

2020
1. Close the auto-created pull request:
2121

22-
mcp_github_update_pull_request(owner: "copilot-community-sdk", repo: "copilot-sdk-java", pullNumber: <PR_NUMBER>, state: "closed")
22+
gh pr close $(gh pr view --json number --jq .number) --comment "No relevant upstream changes to port to the Java SDK."
2323

24-
2. Add a comment to the issue explaining no changes were needed:
24+
2. Close the triggering issue as 'not planned' (replace ISSUE_NUMBER with the actual issue number from the issue that was assigned to you):
2525

26-
mcp_github_add_issue_comment(owner: "copilot-community-sdk", repo: "copilot-sdk-java", issue_number: <ISSUE_NUMBER>, body: "No relevant upstream changes to port to the Java SDK. Closing as not planned.")
26+
gh issue close ISSUE_NUMBER --reason "not planned" --comment "No relevant upstream changes to port to the Java SDK. Closing as not planned."
2727

28-
3. Close the issue as 'not planned':
29-
30-
mcp_github_update_issue(owner: "copilot-community-sdk", repo: "copilot-sdk-java", issue_number: <ISSUE_NUMBER>, state: "closed", state_reason: "not_planned")
31-
32-
Do NOT skip these steps. All three tool calls are required.
28+
CRITICAL: You MUST run these gh CLI commands in a terminal. Do NOT skip these steps.
29+
Both the PR close and issue close commands are required when there are no changes to port.

.github/workflows/copilot-setup-steps.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,8 @@ jobs:
3434

3535
- name: Download dependencies
3636
run: mvn dependency:go-offline -B
37+
38+
- name: Verify gh CLI is authenticated
39+
run: gh auth status
40+
env:
41+
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)