Skip to content

fix: propagate headers through OpenCode MCP adapter#622

Merged
sergio-sisternes-epam merged 2 commits intomicrosoft:mainfrom
alopezsanchez:fix/opencode-mcp-headers
Apr 9, 2026
Merged

fix: propagate headers through OpenCode MCP adapter#622
sergio-sisternes-epam merged 2 commits intomicrosoft:mainfrom
alopezsanchez:fix/opencode-mcp-headers

Conversation

@alopezsanchez
Copy link
Copy Markdown
Contributor

Description

_to_opencode_format was not mapping remote server headers from the Copilot-format config into OpenCode's schema. When a remote MCP server declared headers (e.g. Authorization), they were silently dropped from opencode.json.

It also adds a comprehensive test suite to the Opencode MCP adapter.

Fixes #621

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Copilot AI review requested due to automatic review settings April 8, 2026 08:22
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

Fixes OpenCode MCP config generation so remote server headers from Copilot-format configs are preserved when writing opencode.json, and adds a dedicated unit test suite to prevent regressions.

Changes:

  • Propagate headers for remote MCP entries in OpenCodeClientAdapter._to_opencode_format().
  • Add comprehensive unit tests covering OpenCode MCP config read/write, conversion, and stale cleanup behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/apm_cli/adapters/client/opencode.py Copies remote headers into OpenCode schema during Copilot->OpenCode config conversion.
tests/unit/test_opencode_mcp.py Adds unit tests for OpenCode adapter behavior, including remote headers and MCPIntegrator.remove_stale() cleanup.

@sergio-sisternes-epam
Copy link
Copy Markdown
Collaborator

Thanks for this, @alopezsanchez! Great catch on the dropped headers, and the test coverage you added is really appreciated.

Two small suggestions:

  1. Defensive copy on env — You copy headers with dict(headers) to prevent mutation, but env is assigned by reference on L156. Worth applying the same dict(env) pattern for consistency.

  2. CHANGELOG entry — Could you add a line under ## [Unreleased]### Fixed for the header propagation fix?

Neither is a blocker — happy to merge once addressed. Nice work!

@alopezsanchez
Copy link
Copy Markdown
Contributor Author

Thanks for this, @alopezsanchez! Great catch on the dropped headers, and the test coverage you added is really appreciated.

Two small suggestions:

  1. Defensive copy on env — You copy headers with dict(headers) to prevent mutation, but env is assigned by reference on L156. Worth applying the same dict(env) pattern for consistency.
  2. CHANGELOG entry — Could you add a line under ## [Unreleased]### Fixed for the header propagation fix?

Neither is a blocker — happy to merge once addressed. Nice work!

Sure thing! Will do 👍🏻

@sergio-sisternes-epam sergio-sisternes-epam self-assigned this Apr 8, 2026
@sergio-sisternes-epam sergio-sisternes-epam added this to the 0.8.12 milestone Apr 8, 2026
@alopezsanchez alopezsanchez force-pushed the fix/opencode-mcp-headers branch from 49a07ed to 61e882c Compare April 9, 2026 07:49
`_to_opencode_format` was not mapping remote server headers from the Copilot-format
config into OpenCode's schema. When a remote MCP server declared headers (e.g. Authorization),
they were silently dropped from opencode.json.

It also adds a comprehensive test suite to the OpenCode MCP adapter.
@alopezsanchez alopezsanchez force-pushed the fix/opencode-mcp-headers branch from 61e882c to 54a88a3 Compare April 9, 2026 07:50
@alopezsanchez
Copy link
Copy Markdown
Contributor Author

@sergio-sisternes-epam done!

@sergio-sisternes-epam
Copy link
Copy Markdown
Collaborator

@danielmeppiel this will need your "Merge pull request" capabilities :)

@sergio-sisternes-epam sergio-sisternes-epam merged commit b56920e into microsoft:main Apr 9, 2026
6 checks passed
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.

[BUG] MCP dependencies don't populate headers to opencode.json

4 participants