Refactor MCP config generation into SDK helper#1179
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR extracts MCP (Model Context Protocol) configuration helpers into a shared SDK module, re-exports them from @bradygaster/squad-sdk/config, and updates the CLI to consume the shared helpers.
Changes:
- Added
mcp-config.tsto centralize MCP server spec generation and frontmatter/config rendering helpers. - Refactored SDK
init.tsand CLIupgrade.tsto import MCP helpers from the shared module instead of duplicating logic. - Added export verification + behavior tests and bumped package versions to align CLI ↔ SDK.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/package-exports.test.ts | Adds export checks and behavior tests for MCP helper functions exposed via the config barrel. |
| packages/squad-sdk/src/config/mcp-config.ts | Introduces centralized MCP server spec + config/frontmatter helper implementations. |
| packages/squad-sdk/src/config/init.ts | Removes inlined MCP helper implementations and uses the shared mcp-config module. |
| packages/squad-sdk/src/config/index.ts | Re-exports the new MCP config module from the SDK config barrel. |
| packages/squad-sdk/package.json | Bumps SDK version to 0.9.7-preview. |
| packages/squad-cli/src/cli/core/upgrade.ts | Replaces duplicated MCP helper code with imports from @bradygaster/squad-sdk/config. |
| packages/squad-cli/package.json | Updates CLI dependency constraint to require the new SDK version. |
| export function injectMcpFrontmatter(content: string, servers: McpServerSpec[]): string { | ||
| const closingStart = content.indexOf('\n---', 4); | ||
| if (!content.startsWith('---') || closingStart === -1) { | ||
| return content; | ||
| } | ||
|
|
||
| return content.slice(0, closingStart) | ||
| + '\n' | ||
| + buildMcpFrontmatterBlock(servers) | ||
| + content.slice(closingStart); | ||
| } | ||
|
|
||
| export function hasMcpFrontmatter(content: string): boolean { | ||
| const frontmatterEnd = content.indexOf('\n---', 4); | ||
| if (!content.startsWith('---') || frontmatterEnd === -1) { | ||
| return false; | ||
| } | ||
| return content.slice(0, frontmatterEnd).includes('mcp-servers:'); | ||
| } |
| expect(injected).toContain('mcp-servers:\n squad_state:'); | ||
| expect(injected).toContain('\n---\n\nBody mentions mcp-servers: only here.\n'); | ||
| }); | ||
|
|
|
👋 Friendly nudge — this PR has had no activity for 12 days. What needs attention:
If this PR is abandoned, please close it. If it's blocked on something external, leave a comment so the team knows. |
|
Hey @weinong — could you rebase this onto current |
44c2d6b to
ef9f418
Compare
🏗️ Architectural Review
Automated architectural review — informational only. |
🟡 Impact Analysis — PR #1179Risk tier: 🟡 MEDIUM 📊 Summary
🎯 Risk Factors
📦 Modules Affectedroot (1 file)
squad-cli (1 file)
squad-sdk (3 files)
tests (1 file)
|
🛫 PR Readiness Check
PR Scope: 📦🔧 Mixed (product + infrastructure)
|
| Status | Check | Details |
|---|---|---|
| ✅ | Single commit | 1 commit — clean history |
| ✅ | Not in draft | Ready for review |
| ✅ | Branch up to date | Up to date with dev |
| ❌ | Copilot review | No Copilot review yet — it may still be processing |
| ✅ | Changeset present | Changeset file found |
| ✅ | Scope clean | No .squad/ or docs/proposals/ files |
| ✅ | No merge conflicts | No merge conflicts |
| ❌ | Copilot threads resolved | 1 unresolved Copilot thread(s) — fix and resolve before merging |
| ❌ | CI passing | 6 check(s) still running |
Files Changed (6 files, +203 −187)
| File | +/− |
|---|---|
.changeset/fix-mcp-config-helpers.md |
+6 −0 |
packages/squad-cli/src/cli/core/upgrade.ts |
+3 −92 |
packages/squad-sdk/src/config/index.ts |
+1 −0 |
packages/squad-sdk/src/config/init.ts |
+1 −95 |
packages/squad-sdk/src/config/mcp-config.ts |
+115 −0 |
test/package-exports.test.ts |
+77 −0 |
Total: +203 −187
This check runs automatically on every push. Fix any ❌ items and push again.
See CONTRIBUTING.md and PR Requirements for details.
ef9f418 to
6050f16
Compare
|
Rebased onto current |
Summary
@bradygaster/squad-sdk/configTests
npm test -- test/package-exports.test.ts test/cli/init.test.ts test/cli/upgrade.test.tsnpm run lintFollow-up to #1166