Skip to content

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

Closed
reyanthony062001-ops wants to merge 1 commit into
JSONbored:mainfrom
reyanthony062001-ops:fix-6757
Closed

feat(mcp): MCP tool + maintain CLI for contributor-issue-draft generation#6976
reyanthony062001-ops wants to merge 1 commit into
JSONbored:mainfrom
reyanthony062001-ops:fix-6757

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.

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.71%. Comparing base (ad8536e) to head (bba5c83).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6976   +/-   ##
=======================================
  Coverage   93.71%   93.71%           
=======================================
  Files         687      687           
  Lines       68404    68415   +11     
  Branches    18730    18732    +2     
=======================================
+ Hits        64105    64117   +12     
  Misses       3302     3302           
+ Partials      997      996    -1     
Flag Coverage Δ
shard-1 43.94% <100.00%> (+0.19%) ⬆️
shard-2 36.91% <27.27%> (-0.01%) ⬇️
shard-3 32.89% <27.27%> (-0.01%) ⬇️
shard-4 34.25% <27.27%> (+<0.01%) ⬆️
shard-5 31.89% <27.27%> (-0.01%) ⬇️
shard-6 45.74% <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

Warning

⏸️ LoopOver review result - manual review recommended

Review updated: 2026-07-17 17:16:45 UTC

6 files · 1 AI reviewer · no blockers · CI green · dirty

⏸️ Suggested Action - Manual Review

Review summary
This adds an MCP tool and CLI subcommand mirroring the existing REST route for generating contributor issue drafts, reusing the route's schema bounds and re-applying the create-safety guard (create requires explicit dryRun:false) independently in the MCP handler. The output scrub correctly strips drafts[] from the MCP tool's structured content, and the CLI plain-text path sanitizes draft titles/status for terminal output. Test coverage is solid: dry-run defaults, the create-without-dryRun-false rejection, MCP access-control denial, and CLI body-forwarding assertions for both the dry-run and --create paths.

Nits — 5 non-blocking
  • src/mcp/server.ts: the create-safety check `if (input.create && input.dryRun !== false)` duplicates the route's guard rather than importing/calling a shared validator, so future changes to the route's guard logic could silently diverge between the two surfaces.
  • packages/loopover-mcp/bin/loopover-mcp.js: `--limit` is parsed with `Number(options.limit)` and only forwarded if finite, so a non-numeric `--limit foo` silently falls back to the server default instead of erroring — consider validating and failing fast.
  • src/mcp/server.ts:648: the `20`/`5` bounds are inline literals mirroring the route's schema; a shared constant or comment cross-referencing the route file would make the byte-for-byte claim easier to verify at a glance.
  • Extract the `explicit_create_requires_dry_run_false` check into a small shared helper used by both the route and the MCP handler so the guard can't drift, per the PR's own stated risk.
  • Consider validating `--limit` as an integer in the CLI and erroring on invalid input rather than silently dropping it from the request body.

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 ⚠️ 3 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
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: not available
  • 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 #6747, issue #6757)
  • Related work: Titles/paths share 6 meaningful terms. (issue #6746, issue #6757)
  • Additional title-only matches omitted; title-only overlap does not block.
Contributor next steps
  • Start here: Review top overlaps.
  • Then work through the remaining 2 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 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

LoopOver is closing this pull request on the maintainer's behalf (conflicts with the base branch — resolve and open a fresh PR). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed.

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