Skip to content

feat(mcp): MCP tool + maintain CLI for contributor-issue-draft generation - #7019

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
reyanthony062001-ops:fix-6757-v2
Jul 17, 2026
Merged

feat(mcp): MCP tool + maintain CLI for contributor-issue-draft generation#7019
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
reyanthony062001-ops:fix-6757-v2

Conversation

@reyanthony062001-ops

Copy link
Copy Markdown
Contributor

What

POST /v1/repos/:owner/:repo/contributor-issue-drafts/generate was web-dashboard-only — no MCP tool and no CLI could reach it. This adds both mirrors the issue asks for:

  • loopover_generate_contributor_issue_drafts in src/mcp/server.ts, requireRepoManageAccess-gated.
  • maintain generate-issue-drafts [--create] [--limit N] --repo owner/repo CLI in packages/loopover-mcp/bin/loopover-mcp.js.

Create-safety, preserved identically on both surfaces

The whole risk here is silently opening issues, so both mirrors reproduce the route's guard exactly:

  • Dry-run by default. The MCP dryRun/create/limit schema mirrors the route's contributorIssueDraftGenerateSchema byte-for-byte (same defaults, same 1–20 bound). The CLI sends {create:false, dryRun:true} for a bare invocation.
  • create alone never writes. The MCP handler re-applies the route's explicit_create_requires_dry_run_false guard: a caller must pass both create:true and dryRun:false. The CLI's --create maps to exactly that {create:true, dryRun:false} shape — the only shape the route accepts for a real write.
  • The service itself still overlays the global agent kill-switch (a paused/frozen agent can't create even with {create:true, dryRun:false}), and the write path requires repo write access.
  • The MCP tool returns only the counts + posture (proposed/created/skipped*), never the per-draft title/body — the same public-safe scrub getAgentAuditFeed uses. The CLI's plain-text path sanitizes the generated draft titles for the terminal (fix(mcp): ANSI/control-char terminal sanitization is applied to exactly one output path, not the others that also print third-party text #6261).

requireRepoManageAccess is checked first, before the guard or the service.

Testing

  • test/unit/mcp-generate-contributor-issue-drafts.test.ts (new, 5 cases): dry-run preview returns counts and omits drafts[]; create:true without dryRun:false is rejected (explicit_create_requires_dry_run_false); a static MCP-token caller is denied without MCP_ACTUATION_REPO_ALLOWLIST; an operator session is admitted and attributed; and the tool's structuredContent equals a direct service call for identical input (surface parity).
  • test/unit/mcp-cli-maintain.test.ts (2 cases): a bare command forwards {create:false, dryRun:true} and strips an ANSI escape from a draft title; --create --limit 3 forwards {create:true, dryRun:false, limit:3} and renders the created issue link.
  • The CLI harness gains a request-reflecting fixture so the test asserts the exact body each surface sends. The PowerShell-completion assertion is extended for the new subcommand.

Patch coverage measured, not assumed: every changed line and branch in src/mcp/server.ts is covered — 0 uncovered statements, 0 uncovered branches (packages/loopover-mcp/bin/** is outside vitest.config.ts's coverage scope, so the CLI is exercised for correctness rather than the gate).

Green locally at this base (ad8536e): typecheck, build --workspace @loopover/engine, build:mcp, test:mcp-pack, command-reference:check, docs:drift-check, manifest:drift-check, and the full blast radius of 40 test files (311 tests) touching the changed symbols.

Resubmit of #6976 (auto-closed on a mechanical base-branch conflict; CI was 16/16 green). Rebased onto current main with the conflict resolved.

Closes #6757

… maintain CLI

The POST /v1/repos/:owner/:repo/contributor-issue-drafts/generate route was
web-dashboard-only: no MCP tool and no CLI could reach it.

Add loopover_generate_contributor_issue_drafts to src/mcp/server.ts
(requireRepoManageAccess-gated) and a `maintain generate-issue-drafts` CLI
subcommand. Both preserve the route's create-safety EXACTLY: dry-run by default,
and the write path is entered only when the caller passes BOTH create:true and
dryRun:false, so neither surface can silently open issues. The MCP tool re-applies
the route's explicit_create_requires_dry_run_false guard and returns only the
counts + posture, never the per-draft title/body text.

Closes JSONbored#6757
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.73%. Comparing base (99b461d) to head (3f35772).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7019   +/-   ##
=======================================
  Coverage   93.72%   93.73%           
=======================================
  Files         690      690           
  Lines       68560    68571   +11     
  Branches    18743    18745    +2     
=======================================
+ Hits        64261    64273   +12     
  Misses       3302     3302           
+ Partials      997      996    -1     
Flag Coverage Δ
shard-1 43.83% <100.00%> (+0.19%) ⬆️
shard-2 36.90% <27.27%> (-0.01%) ⬇️
shard-3 33.14% <27.27%> (-0.01%) ⬇️
shard-4 34.23% <27.27%> (-0.01%) ⬇️
shard-5 31.89% <27.27%> (-0.01%) ⬇️
shard-6 45.80% <27.27%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/mcp/server.ts 96.41% <100.00%> (+0.14%) ⬆️

@loopover-orb loopover-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 17, 2026
@loopover-orb

loopover-orb Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-17 18:25:29 UTC

6 files · 1 AI reviewer · no blockers · readiness 77/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR adds an MCP tool and CLI mirror for the existing contributor-issue-drafts/generate REST route, reproducing the route's create-safety guard (explicit_create_requires_dry_run_false) in the MCP handler and forwarding the same shape from the CLI. The MCP tool correctly scrubs draft title/body from its output, returning only counts/posture, and the CLI sanitizes drafts for terminal output per #6261. Logic is straightforward delegation to the existing service with parity tests confirming numeric output matches direct service calls.

Nits — 5 non-blocking
  • src/mcp/server.ts: the `20`/`5` limit bounds are copied inline from the route schema rather than importing a shared constant, risking future drift if one side changes without the other.
  • packages/loopover-mcp/bin/loopover-mcp.js generate-issue-drafts: `--limit` is parsed with `Number(options.limit)` and only included if `Number.isFinite`, so a non-numeric `--limit` silently omits the param instead of erroring — verify this matches other CLI subcommands' handling of bad numeric flags.
  • test/unit/mcp-generate-contributor-issue-drafts.test.ts: good coverage of the safety guard and allowlist denial, but there's no test asserting the MCP tool caller identity (`requestedBy`) is actually threaded into the service call for the token-based path.
  • Extract the `1`/`20` limit bounds and `5` default into a shared constant imported by both the REST route and `generateContributorIssueDraftsShape` to guarantee they can't drift apart (src/mcp/server.ts:641-649).
  • Consider a small doc comment or shared type re-export so the MCP output schema and the CLI's expected JSON shape don't need to be kept in sync by hand across three files.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #6757
Related work ⚠️ 2 scoped overlaps Top overlaps are listed below; lower-confidence bulk is hidden.
Change scope ❌ 8/20 High review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 41 registered-repo PR(s), 27 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor reyanthony062001-ops; Gittensor profile; 41 PR(s), 0 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The PR adds the requested loopover_generate_contributor_issue_drafts MCP tool (requireRepoManageAccess-gated, mirroring dryRun/create schema and re-applying the explicit_create_requires_dry_run_false guard) and a `maintain generate-issue-drafts [--create]` CLI subcommand, plus a dedicated unit test file explicitly asserting the create-without-dryRun:false rejection and dry-run defaults.

Review context
  • Author: reyanthony062001-ops
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Cuda, HTML, JavaScript, Python, TypeScript
  • Official Gittensor activity: 41 PR(s), 0 issue(s).
  • Related work: Titles/paths share 6 meaningful terms. (issue #6744, issue #6757)
  • Related work: Titles/paths share 6 meaningful terms. (issue #6746, issue #6757)
Contributor next steps
  • Start here: Review top overlaps.
  • Then work through the remaining 3 steps in the Signals table above.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit bd4c172 into JSONbored:main Jul 17, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP tool + CLI mirror for contributor-issue-drafts/generate

1 participant