Skip to content

Remove nested Markdown headers from mcp-clis prompt section#35922

Merged
dsyme merged 3 commits into
mainfrom
copilot/fix-mcp-servers-headers
May 30, 2026
Merged

Remove nested Markdown headers from mcp-clis prompt section#35922
dsyme merged 3 commits into
mainfrom
copilot/fix-mcp-servers-headers

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 30, 2026

The mcp-clis prompt content was emitting H2/H3 Markdown headings even though it is already wrapped in <mcp-clis>...</mcp-clis>. This caused unintended header rendering semantics inside a structured prompt block.

  • Prompt content normalization

    • Updated /actions/setup/md/mcp_cli_tools_prompt.md to remove nested Markdown headers.
    • Replaced heading-style lines with plain labels (How to use:, Passing multiple or complex arguments (preferred):, Notes:).
    • Removed the top-level section header (## MCP Servers Mounted as Shell CLI Commands) from inside the block.
  • Regression coverage

    • Added a focused test in /pkg/workflow/mcp_cli_mount_test.go to assert the mounted prompt file no longer contains ##/### headings while preserving expected section text.
<mcp-clis>
How to use:
...
Passing multiple or complex arguments (preferred):
...
Notes:
...
</mcp-clis>

Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix headers emitted in mcp-clis section Remove nested Markdown headers from mcp-clis prompt section May 30, 2026
Copilot finished work on behalf of dsyme May 30, 2026 14:00
Copilot AI requested a review from dsyme May 30, 2026 14:00
@dsyme dsyme marked this pull request as ready for review May 30, 2026 14:10
Copilot AI review requested due to automatic review settings May 30, 2026 14:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request normalizes the mcp-clis prompt content by removing nested Markdown headings inside the <mcp-clis>...</mcp-clis> block to avoid unintended header semantics, and adds a regression test to prevent reintroducing ##/###-style headings.

Changes:

  • Removed H2/H3 Markdown headings from actions/setup/md/mcp_cli_tools_prompt.md and replaced them with plain label lines (e.g., How to use:).
  • Added a unit test asserting the mounted MCP CLI prompt file does not contain Markdown heading syntax while preserving expected label text.
Show a summary per file
File Description
actions/setup/md/mcp_cli_tools_prompt.md Removes nested ##/### headings from the <mcp-clis> prompt content and replaces them with non-heading labels.
pkg/workflow/mcp_cli_mount_test.go Adds a regression test that reads the prompt file and checks for absence of Markdown heading markers.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 1

Comment thread pkg/workflow/mcp_cli_mount_test.go
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 30, 2026

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #35922 does not have the 'implementation' label and has only 24 new lines (≤100) in business logic directories. has_implementation_label=false, requires_adr_by_default_volume=false, has_custom_config=false.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 30, 2026

🧪 Test Quality Sentinel completed test quality analysis.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 30, 2026

PR Code Quality Reviewer completed the code quality review.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 30, 2026

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actions github-actions Bot mentioned this pull request May 30, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Correct, focused change. Two minor test-coverage gaps noted inline — both non-blocking.

Review summary

What the PR does

Removes ##/### Markdown headings from inside the <mcp-clis> prompt block and replaces them with plain-text labels. Adds a regression test that reads the actual file and asserts no headings are present.

Findings

  • Missing label-presence assertions (line 228): assert.Contains only checks "How to use:"; the two other converted labels are not verified.
  • Blockquote regex depth (line 224): (>\s*)? matches only one level of > nesting; (>\s*)* would be more correct.

Both are low-severity test completeness gaps that are easy to fix. The prompt change itself is correct and unambiguous.

🔎 Code quality review by PR Code Quality Reviewer · sonnet46 1M

prompt := string(content)
assert.NotContains(t, prompt, "\n## ")
assert.NotContains(t, prompt, "\n### ")
assert.Contains(t, prompt, "How to use:")
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.

Incomplete label-presence assertions: only "How to use:" is verified; the other two converted labels are not checked.

💡 Suggested fix

If ### Notes or ### Passing Multiple or Complex Arguments (Preferred) ever regressed back to Markdown headings, the NotRegexp assertion would catch the ### — but there would be no check that the plain-text replacement (Notes: / Passing multiple or complex arguments (preferred):) is actually present. Add the two missing assertions to make the intent explicit:

assert.Contains(t, prompt, "How to use:")
assert.Contains(t, prompt, "Passing multiple or complex arguments (preferred):")
assert.Contains(t, prompt, "Notes:")

Without these, a future edit could replace those labels with something else entirely and the test would still pass.

require.NoError(t, err)
content, err := os.ReadFile(filepath.Clean(filepath.Join(wd, "../../actions/setup/md", section.Content)))
require.NoError(t, err)

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.

Regex covers only one > blockquote level: (>\s*)? matches at most one leading >, so headings inside nested blockquotes would pass the assertion silently.

💡 Suggested fix

Low risk for the current file, but the pattern can be tightened at negligible cost:

assert.NotRegexp(t, `(?m)^(>\s*)*##\s+`, prompt, "prompt must not contain H2 Markdown headings")
assert.NotRegexp(t, `(?m)^(>\s*)*###\s+`, prompt, "prompt must not contain H3 Markdown headings")

(>\s*)* handles arbitrary nesting depth, and because ## already implies ### would also be caught by the H2 pattern, you could optionally collapse to a single check: (?m)^(>\s*)*#{2,}\s+.

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Skills-Based Review 🧠

Applied /diagnose and /tdd — approving with one minor suggestion.

📋 Key Themes & Highlights

Key Themes

  • Correct targeted fix: H2/H3 headings inside <mcp-clis> carried unintended rendering semantics in structured prompt blocks. Replacing them with plain colon-terminated labels is the right normalisation.
  • Regression test present: The test reads the file from disk and asserts both the heading-free invariant and that the expected label text survives — good habit for prompt-content bugs.

Positive Highlights

  • ✅ Tight scope — only the affected prompt file and one test, no collateral changes
  • ✅ Test uses NotRegexp with multiline anchors to catch headings even inside blockquote context (> ##)
  • ✅ PR description clearly explains root cause and lists each changed label

Minor suggestion

Only How to use: is asserted present; adding the other two replaced labels (Passing multiple or complex arguments (preferred): and Notes:) would make the test a complete specification of the new format. See inline comment.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 1M

prompt := string(content)
assert.NotContains(t, prompt, "\n## ")
assert.NotContains(t, prompt, "\n### ")
assert.Contains(t, prompt, "How to use:")
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.

[/tdd] The test verifies How to use: is present after the heading strip, but the other two replaced labels (Passing multiple or complex arguments (preferred): and Notes:) are not asserted.

💡 Suggested additions

Adding the two missing assertions keeps the test spec-complete and prevents the other labels from being accidentally dropped in a future edit:

assert.Contains(t, prompt, "How to use:")
assert.Contains(t, prompt, "Passing multiple or complex arguments (preferred):")
assert.Contains(t, prompt, "Notes:")

Not blocking — the heading-removal invariant is the core concern — but completing the trio makes the test a full specification of the new label format.

@github-actions
Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel Report

Test Quality Score: 80/100 — Excellent

Analyzed 1 test: 1 design test (behavioral contract), 0 implementation tests, 0 guideline violations.

📊 Metrics & Test Classification (1 test analyzed)
Metric Value
New/modified tests analyzed 1
✅ Design tests (behavioral contracts) 1 (100%)
⚠️ Implementation tests (low value) 0 (0%)
Tests with error/edge cases 1 (100%)
Duplicate test clusters 0
Test inflation detected ⚠️ Yes (24 test lines / 3 markdown production lines = 8:1) — justified given the nature of the change
🚨 Coding-guideline violations 0

Test Classification Details

Test File Classification Issues Detected
TestBuildMCPCLIPromptSection_PromptFileUsesNonHeadingLabels pkg/workflow/mcp_cli_mount_test.go ✅ Design Minor: assert.Contains missing descriptive message

Language Support

Tests analyzed:

  • 🐹 Go (*_test.go): 1 test — unit (//go:build !integration)
  • 🟨 JavaScript (*.test.cjs, *.test.js): 0 tests
⚠️ Minor Issues — Non-blocking (1 note)

i️ Missing assertion message on assert.Contains (pkg/workflow/mcp_cli_mount_test.go)

Classification: Minor guideline note (non-blocking)
Issue: assert.Contains(t, prompt, "How to use:") has no descriptive message argument.
Suggested improvement: Add a message, e.g. assert.Contains(t, prompt, "How to use:", "prompt must contain plain 'How to use:' label").

The two assert.NotRegexp calls correctly include descriptive messages — this is a single missed one.

Verdict

Check passed. 0% of new tests are implementation tests (threshold: 30%). The new test directly verifies the behavioral contract: the mounted MCP CLI prompt file must not contain Markdown ##/### headers and must preserve the How to use: plain-text label. High-value regression guard for the PR's key change.

📖 Understanding Test Classifications

Design Tests (High Value) verify what the system does:

  • Assert on observable outputs, return values, or state changes
  • Cover error paths and boundary conditions
  • Would catch a behavioral regression if deleted
  • Remain valid even after internal refactoring

Implementation Tests (Low Value) verify how the system does it:

  • Assert on internal function calls (mocking internals)
  • Only test the happy path with typical inputs
  • Break during legitimate refactoring even when behavior is correct
  • Give false assurance: they pass even when the system is wrong

Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators.

References: §26685907796

🧪 Test quality analysis by Test Quality Sentinel · sonnet46 1.1M ·

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

✅ Test Quality Sentinel: 80/100. Test quality is excellent — 0% of new tests are implementation tests (threshold: 30%). The single new test is a high-value behavioral contract test verifying the prompt file contains no Markdown headers.

@dsyme dsyme merged commit d465d39 into main May 30, 2026
32 checks passed
@dsyme dsyme deleted the copilot/fix-mcp-servers-headers branch May 30, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"MCP Servers Mounted as Shell CLI Commands" wrongly emitted as header

3 participants