Add extra passthrough for harness-specific MCP keys (#1670)#1765
Open
sergio-sisternes-epam wants to merge 2 commits into
Open
Add extra passthrough for harness-specific MCP keys (#1670)#1765sergio-sisternes-epam wants to merge 2 commits into
sergio-sisternes-epam wants to merge 2 commits into
Conversation
MCPDependency now captures unknown keys from apm.yml into an 'extra' dict instead of silently dropping them. The extra fields round-trip through to_dict() and flow through _build_self_defined_info() into every client adapter's _format_server_config(), where _merge_extra() writes them into the generated target manifest without shadowing known keys. This enables harness-specific configuration such as Claude Code's oauth block for remote-MCP OAuth client config to be declared once in apm.yml and appear in the generated .mcp.json. Closes #1670 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a forward-compatible “extra passthrough” mechanism for MCP dependencies: unknown keys found in apm.yml MCP dependency objects are preserved on the model and then merged into the generated target manifests so harness-specific config (e.g., an oauth block) is not lost.
Changes:
- Extend
MCPDependencyto capture unknown keys intoextraand round-trip them viato_dict(). - Plumb
_extrathrough MCP integration and merge it into per-harness adapter configs. - Add/adjust unit tests and update docs to describe the passthrough behavior with examples.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/apm_cli/models/dependency/mcp.py |
Adds extra field and merges unknown keys into extra, then into to_dict() output. |
src/apm_cli/integration/mcp_integrator.py |
Adds _extra passthrough for adapter consumption (currently only in self-defined path; see comments). |
src/apm_cli/adapters/client/base.py |
Introduces _merge_extra() helper used by adapters to merge passthrough keys. |
src/apm_cli/adapters/client/copilot.py |
Calls _merge_extra() before returning formatted config. |
src/apm_cli/adapters/client/codex.py |
Calls _merge_extra() on some return paths (remote-only path still misses it; see comments). |
src/apm_cli/adapters/client/cursor.py |
Calls _merge_extra() before returning formatted config. |
src/apm_cli/adapters/client/gemini.py |
Calls _merge_extra() before returning formatted config. |
src/apm_cli/adapters/client/kiro.py |
Calls _merge_extra() before returning formatted config. |
src/apm_cli/adapters/client/vscode.py |
Calls _merge_extra() before returning formatted config. |
tests/unit/test_mcp_from_dict_unknown_keys.py |
Updates/adds tests for unknown-key preservation, round-tripping, and merge behavior. |
docs/src/content/docs/reference/manifest-schema.md |
Documents extra passthrough semantics and adds an example. |
docs/src/content/docs/consumer/install-mcp-servers.md |
Adds an example using a harness-specific extra key (oauth). |
packages/apm-guide/.apm/skills/apm-usage/dependencies.md |
Updates dependency docs with an extra-key example for MCP. |
…remote path - Add 'extra' to _KNOWN_DICT_KEYS so an explicit 'extra:' YAML block merges into dep.extra without nesting - Propagate dep.extra via _apply_overlay for registry-resolved deps - Add _merge_extra call in codex remote-only return path - Add 7 new tests covering all three fixes Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
MCPDependencynow captures unknown keys fromapm.ymlinto a genericextradict and round-trips them into generated target manifests, enabling harness-specific configuration (e.g. Claude Code'soauthblock) to survive the install pipeline.Problem
When a user declares harness-specific keys (like
oauthfor Claude Code remote-MCP OAuth) in anapm.ymlMCP dependency entry, those keys are silently dropped during parsing becauseMCPDependency.from_dict()only recognises a fixed set of known fields. The warning was already landed, but the keys were still discarded -- they never appeared in the generated.mcp.json.Approach
A generic
extra: dict[str, Any] | Nonefield onMCPDependencycaptures all unknown keys and passes them through the full data flow:Shadow prevention: extra keys never override known fields or adapter-set keys. In both
to_dict()and_merge_extra(), known keys take precedence.Changes
src/apm_cli/models/dependency/mcp.pyextrafield, updatedfrom_dict(),to_dict(),__repr__src/apm_cli/integration/mcp_integrator.py_extrapassthrough in_build_self_defined_info()src/apm_cli/adapters/client/base.py_merge_extra()static methodsrc/apm_cli/adapters/client/{copilot,codex,cursor,gemini,kiro,vscode}.py_merge_extra()calls at all return pointstests/unit/test_mcp_from_dict_unknown_keys.pydocs/src/content/docs/reference/manifest-schema.mddocs/src/content/docs/consumer/install-mcp-servers.mdoauthextra keypackages/apm-guide/.apm/skills/apm-usage/dependencies.mdoauthextra keyValidation
Out of scope
apm packcredential stripping forextrakeys (follow-up)claude:,vscode:) -- genericextrais simpler and sufficientCloses #1670