From a2fbed9186170cd567344b0c6cca45a2152eeac2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Mar 2026 21:47:40 +0000 Subject: [PATCH 1/5] Initial plan From 5d6ac01294683c58ec7ce24fe6ae649116aa9200 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Mar 2026 21:55:02 +0000 Subject: [PATCH 2/5] feat: add check-toolnames workflow and Toolnames checkup label bootstrap Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com> --- .github/workflows/check-toolnames.yml | 159 ++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 .github/workflows/check-toolnames.yml diff --git a/.github/workflows/check-toolnames.yml b/.github/workflows/check-toolnames.yml new file mode 100644 index 00000000..bd2913f5 --- /dev/null +++ b/.github/workflows/check-toolnames.yml @@ -0,0 +1,159 @@ +name: Check Toolnames in Issue + +on: + issues: + types: [labeled] + workflow_dispatch: # Run manually to create the 'Toolnames checkup' label + +permissions: + contents: read + +jobs: + # Creates the 'Toolnames checkup' label in the repository. + # Run this job manually via workflow_dispatch the first time to bootstrap the label. + setup-label: + runs-on: ubuntu-latest + if: github.event_name == 'workflow_dispatch' + permissions: + issues: write + steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@a90bcbc6539c36a85cdfeb73f7e2f433735f215b # v2.15.0 + with: + egress-policy: audit + + - name: Create 'Toolnames checkup' label + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + echo "=== Creating 'Toolnames checkup' label ===" + if gh label create "Toolnames checkup" \ + --repo "${{ github.repository }}" \ + --color "e4e669" \ + --description "Triggers a workflow to check if the tool names in this issue are already mapped in src/toolNames.json" \ + 2>&1; then + echo "✅ Label created successfully" + else + echo "â„šī¸ Label may already exist (this is fine)" + fi + + # Checks each tool name in the issue body against src/toolNames.json on main + # and posts a comment with the status of each one. + check-toolnames: + runs-on: ubuntu-latest + if: github.event_name == 'issues' && github.event.label.name == 'Toolnames checkup' + permissions: + issues: write + contents: read + steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@a90bcbc6539c36a85cdfeb73f7e2f433735f215b # v2.15.0 + with: + egress-policy: audit + + - name: Checkout main branch + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + ref: main + + - name: Check toolnames and post comment + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE_BODY: ${{ github.event.issue.body }} + ISSUE_NUMBER: ${{ github.event.issue.number }} + REPO: ${{ github.repository }} + RUN_ID: ${{ github.run_id }} + SERVER_URL: ${{ github.server_url }} + run: | + echo "=== Checking toolnames and building comment ===" + + python3 - << 'PYEOF' + import json + import os + import re + import sys + + issue_body = os.environ.get("ISSUE_BODY", "") + issue_number = os.environ.get("ISSUE_NUMBER", "") + repo = os.environ.get("REPO", "") + run_id = os.environ.get("RUN_ID", "") + server_url = os.environ.get("SERVER_URL", "https://github.com") + + COMMENT_FILE = "/tmp/toolnames-comment.md" + MAX_BODY_LEN = 100_000 # guard against extremely large issue bodies + + # Truncate untrusted input to prevent resource exhaustion + if len(issue_body) > MAX_BODY_LEN: + issue_body = issue_body[:MAX_BODY_LEN] + print("Warning: issue body was truncated to 100 KB", file=sys.stderr) + + # Extract backtick-wrapped strings and filter to plausible tool-name shapes + # (no path separators or spaces; reasonable length). This avoids matching + # inline-code snippets like `src/toolNames.json` or prose code examples. + raw_matches = re.findall(r'`([^`\n]+)`', issue_body) + tools = sorted(set( + m for m in raw_matches + if "/" not in m and " " not in m and len(m) <= 128 + )) + print(f"Found {len(tools)} candidate tool name(s): {tools}", file=sys.stderr) + + if not tools: + print("No candidate tool names found in issue body. Skipping.", file=sys.stderr) + with open(COMMENT_FILE, "w") as f: + f.write("## 🔍 Toolnames Checkup\n\n_No candidate tool names (backtick-wrapped identifiers without path separators) were found in the issue body._\n") + else: + with open("src/toolNames.json", "r") as f: + known_tools = json.load(f) + + already_added = [] + needs_adding = [] + + for tool in tools: + if tool in known_tools: + already_added.append((tool, known_tools[tool])) + else: + needs_adding.append(tool) + + lines = ["## 🔍 Toolnames Checkup", ""] + lines.append("Checked the tool names in this issue against `src/toolNames.json` on the `main` branch:") + lines.append("") + + if already_added: + lines.append("### ✅ Already mapped") + lines.append("") + lines.append("| Tool Name | Friendly Name |") + lines.append("| --- | --- |") + for tool, friendly in already_added: + lines.append(f"| `{tool}` | {friendly} |") + lines.append("") + + if needs_adding: + lines.append("### ❌ Not yet in `toolNames.json`") + lines.append("") + lines.append("| Tool Name |") + lines.append("| --- |") + for tool in needs_adding: + lines.append(f"| `{tool}` |") + lines.append("") + + if already_added and not needs_adding: + lines.append("> **All tool names in this issue are already mapped.** This issue may be a duplicate — consider closing it.") + elif needs_adding: + lines.append(f"> **{len(needs_adding)} tool name(s) still need to be added.** Please use the `tool-names` custom agent or update `src/toolNames.json` manually.") + + lines.append("") + lines.append(f"_Workflow run: {server_url}/{repo}/actions/runs/{run_id}_") + + comment_body = "\n".join(lines) + with open(COMMENT_FILE, "w") as f: + f.write(comment_body) + print("=== Comment preview ===", file=sys.stderr) + print(comment_body, file=sys.stderr) + PYEOF + + echo "=== Posting comment to issue #${ISSUE_NUMBER} ===" + gh issue comment "$ISSUE_NUMBER" \ + --repo "$REPO" \ + --body-file /tmp/toolnames-comment.md + + echo "✅ Comment posted successfully" From f2f00c98d4b33fb7ccfeae0e1ed88b5821e6d461 Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Wed, 11 Mar 2026 23:08:06 +0100 Subject: [PATCH 3/5] Update .github/workflows/check-toolnames.yml --- .github/workflows/check-toolnames.yml | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/.github/workflows/check-toolnames.yml b/.github/workflows/check-toolnames.yml index bd2913f5..1320e2f3 100644 --- a/.github/workflows/check-toolnames.yml +++ b/.github/workflows/check-toolnames.yml @@ -22,20 +22,7 @@ jobs: with: egress-policy: audit - - name: Create 'Toolnames checkup' label - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - echo "=== Creating 'Toolnames checkup' label ===" - if gh label create "Toolnames checkup" \ - --repo "${{ github.repository }}" \ - --color "e4e669" \ - --description "Triggers a workflow to check if the tool names in this issue are already mapped in src/toolNames.json" \ - 2>&1; then - echo "✅ Label created successfully" - else - echo "â„šī¸ Label may already exist (this is fine)" - fi + # Checks each tool name in the issue body against src/toolNames.json on main # and posts a comment with the status of each one. From aae7f62dba71a6d666071e0a68f160a9091eca29 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Mar 2026 22:11:21 +0000 Subject: [PATCH 4/5] fix: remove setup-label job (label exists), add Toolnames checkup label to issue URL Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com> --- .github/workflows/check-toolnames.yml | 18 +----------------- src/webview/usage/main.ts | 2 +- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/.github/workflows/check-toolnames.yml b/.github/workflows/check-toolnames.yml index 1320e2f3..905ac1ac 100644 --- a/.github/workflows/check-toolnames.yml +++ b/.github/workflows/check-toolnames.yml @@ -3,32 +3,16 @@ name: Check Toolnames in Issue on: issues: types: [labeled] - workflow_dispatch: # Run manually to create the 'Toolnames checkup' label permissions: contents: read jobs: - # Creates the 'Toolnames checkup' label in the repository. - # Run this job manually via workflow_dispatch the first time to bootstrap the label. - setup-label: - runs-on: ubuntu-latest - if: github.event_name == 'workflow_dispatch' - permissions: - issues: write - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@a90bcbc6539c36a85cdfeb73f7e2f433735f215b # v2.15.0 - with: - egress-policy: audit - - - # Checks each tool name in the issue body against src/toolNames.json on main # and posts a comment with the status of each one. check-toolnames: runs-on: ubuntu-latest - if: github.event_name == 'issues' && github.event.label.name == 'Toolnames checkup' + if: github.event.label.name == 'Toolnames checkup' permissions: issues: write contents: read diff --git a/src/webview/usage/main.ts b/src/webview/usage/main.ts index 3339329b..3b51b3af 100644 --- a/src/webview/usage/main.ts +++ b/src/webview/usage/main.ts @@ -171,7 +171,7 @@ function createMcpToolIssueUrl(unknownTools: string[]): string { `${toolList}\n\n` + `Please add friendly names for these tools to improve the user experience.` ); - const labels = encodeURIComponent('MCP Toolnames'); + const labels = encodeURIComponent('MCP Toolnames,Toolnames checkup'); return `${repoUrl}/issues/new?title=${title}&body=${body}&labels=${labels}`; } From 299c69cfb17e51d372dbe90b14e70fda9d55ba4d Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Wed, 11 Mar 2026 23:18:36 +0100 Subject: [PATCH 5/5] Only have the initial label present to prevent auto running with write issues access --- src/webview/usage/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webview/usage/main.ts b/src/webview/usage/main.ts index 3b51b3af..3339329b 100644 --- a/src/webview/usage/main.ts +++ b/src/webview/usage/main.ts @@ -171,7 +171,7 @@ function createMcpToolIssueUrl(unknownTools: string[]): string { `${toolList}\n\n` + `Please add friendly names for these tools to improve the user experience.` ); - const labels = encodeURIComponent('MCP Toolnames,Toolnames checkup'); + const labels = encodeURIComponent('MCP Toolnames'); return `${repoUrl}/issues/new?title=${title}&body=${body}&labels=${labels}`; }