Skip to content

fix(mcp): replace stale Context7 config entries#369

Open
LCubero wants to merge 1 commit into
Gentleman-Programming:mainfrom
LCubero:fix/mcp-context7-replace-legacy-fields
Open

fix(mcp): replace stale Context7 config entries#369
LCubero wants to merge 1 commit into
Gentleman-Programming:mainfrom
LCubero:fix/mcp-context7-replace-legacy-fields

Conversation

@LCubero
Copy link
Copy Markdown
Contributor

@LCubero LCubero commented Apr 24, 2026

🔗 Linked Issue

Closes #57


🏷️ PR Type

What kind of change does this PR introduce?

  • type:bug — Bug fix (non-breaking change that fixes an issue)
  • type:feature — New feature (non-breaking change that adds functionality)
  • type:docs — Documentation only
  • type:refactor — Code refactoring (no functional changes)
  • type:chore — Build, CI, or tooling changes
  • type:breaking-change — Breaking change (fix or feature that changes existing behavior)

📝 Summary

  • Replaces managed Context7 MCP entries atomically so stale local fields cannot survive deep merges.
  • Fixes OpenCode/KiloCode upgrade paths where legacy mcp.context7 fields like command, args, or env break strict schema validation.
  • Adds regression coverage for idempotent migration and sibling MCP entry preservation.

📂 Changes

File / Area What Changed
internal/components/mcp/context7.go Wraps managed Context7 overlay entries in __replace__, including OpenCode/KiloCode strict-schema config.
internal/components/mcp/inject_test.go Adds structured regression tests for OpenCode/KiloCode stale field replacement, idempotency, and managed Context7 entries.

🧪 Test Plan

Unit Tests

go test ./internal/components/mcp ./internal/components/filemerge ./internal/components/engram
go test ./...

E2E Tests

cd e2e && ./docker-test.sh
  • Unit tests pass (go test ./...)
  • E2E tests pass (cd e2e && ./docker-test.sh)
  • Manually tested locally

Additional local verification used Fedora Podman as a Docker-compatible shim:

docker(){ podman "$@"; }; export -f docker; cd e2e && ./docker-test.sh

Result: Ubuntu, Arch, and Fedora E2E platforms passed (PASSED 3/3).


🤖 Automated Checks

The following checks run automatically on this PR:

Check Status Description
Check Issue Reference PR body must contain Closes/Fixes/Resolves #N
Check Issue Has status:approved Linked issue must have been approved before work began
Check PR Has type:* Label Exactly one type:* label must be applied
Unit Tests go test ./... must pass
E2E Tests cd e2e && ./docker-test.sh must pass

✅ Contributor Checklist

  • PR is linked to an issue with status:approved
  • Maintainer needs to add the type:bug label
  • Unit tests pass (go test ./...)
  • E2E tests pass (cd e2e && ./docker-test.sh)
  • I have updated documentation if necessary
  • My commits follow Conventional Commits format
  • My commits do not include Co-Authored-By trailers

💬 Notes for Reviewers

This keeps the existing deep-merge behavior globally and uses the repository's existing __replace__ sentinel only for managed Context7 server entries. That preserves unrelated user MCP entries while preventing stale fields from contaminating OpenCode/KiloCode's strict mcp.context7 schema.

Because this PR is opened from a fork, I cannot add labels to the upstream PR. Maintainer action needed: please add type:bug.

@LCubero LCubero closed this Apr 24, 2026
@LCubero LCubero deleted the fix/mcp-context7-replace-legacy-fields branch April 24, 2026 01:59
@LCubero LCubero restored the fix/mcp-context7-replace-legacy-fields branch April 24, 2026 02:03
@LCubero LCubero reopened this Apr 24, 2026
@LCubero
Copy link
Copy Markdown
Contributor Author

LCubero commented Apr 24, 2026

Reopened after local revision. Keeping this as draft while waiting for a maintainer to add the required type:bug label.

@LCubero LCubero marked this pull request as ready for review May 2, 2026 19:43
@Alan-TheGentleman Alan-TheGentleman added the type:bug Bug fix label May 4, 2026
@LCubero LCubero force-pushed the fix/mcp-context7-replace-legacy-fields branch from 98f84f2 to b4ab76d Compare May 6, 2026 17:26
Copy link
Copy Markdown
Contributor

@Alan-TheGentleman Alan-TheGentleman left a comment

Choose a reason for hiding this comment

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

The fix looks scoped, but the branch currently has merge conflicts.

Please rebase on current main and refresh CI. Once it is mergeable again, this can go back into the quick-win review queue.

@LCubero LCubero force-pushed the fix/mcp-context7-replace-legacy-fields branch from b4ab76d to 71d7ab0 Compare May 10, 2026 16:37
@LCubero
Copy link
Copy Markdown
Contributor Author

LCubero commented May 10, 2026

Hey Alan, rebase done on current main (71d7ab0). The 3 conflicts in inject_test.go were additive: this PR's tests and the new OpenClaw test from main now coexist. CI is refreshing.

Unrelated heads-up while I had the file open. openClawContext7OverlayJSON in context7.go is the only Context7 overlay that does not use the __replace__ wrapper, so it has the same shape of stale-field bug as #57 if a user already has a legacy mcp.servers.context7 entry. Left it alone since it is out of scope here.

@LCubero LCubero requested a review from Alan-TheGentleman May 10, 2026 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: OpenCode MCP merge injects fields rejected by OpenCode's strict schema

2 participants