Skip to content

fix(opencode): honor MCP enabled false in opencode.json - #3052

Open
Buyan Khurelbaatar (buyan-kh) wants to merge 1 commit into
microsoft:mainfrom
buyan-kh:cursor/opencode-enabled-false-965f
Open

Buyan Khurelbaatar (buyan-kh) wants to merge 1 commit into
microsoft:mainfrom
buyan-kh:cursor/opencode-enabled-false-965f

Conversation

@buyan-kh

Copy link
Copy Markdown

enabled: false in apm.yml was stripped as a passthrough alias and the OpenCode adapter always wrote true. Model the flag and write it through.

Description

Brief description of changes and motivation.

Issue and approved scope

Issue: # (required; use the canonical issue or a bounded child issue)

Human scope-approval comment: (link, state the trivial-documentation
standing-preapproval case, or indicate private security coordination without
disclosing report details)

Does this PR complete the issue, or what remains?

Type of change

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

Testing

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

Spec conformance (OpenAPM v0.1)

If this PR changes behaviour that an OpenAPM v0.1 req-XXX covers,
confirm the three-step ritual in the
development guide:

  • Spec edit: docs/src/content/docs/specs/openapm-v0.1.md updated
    (new/changed <a id="req-XXX"></a> anchor + prose + Appendix C
    row).
  • Manifest edit: docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.yml
    updated.
  • Test edit: a @pytest.mark.req("req-XXX") test under
    tests/spec_conformance/ added or extended.
  • CONFORMANCE.{md,json} regenerated via
    uv run --extra dev python -m tests.spec_conformance.gen_statement
    and committed.
  • N/A -- this PR does not change OpenAPM-observable behaviour.

Copilot AI left a comment

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.

Copilot review overview

🟡 Changes recommended

There are a couple of small but concrete maintainability/convention issues in the newly added code that should be cleaned up before approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 Low severity

Open (2)
What changed in this PR

This PR fixes OpenCode MCP config generation so an explicit enabled: false in apm.yml is preserved and written through to opencode.json (instead of being dropped/forced to true). It does so by modeling enabled on MCPDependency, carrying it through the MCP overlay/cache layer, and teaching the OpenCode adapter to apply it.

Changes:

  • Model enabled: bool | None on MCPDependency and validate/round-trip it via from_dict()/to_dict().
  • Propagate per-dependency enabled state into the MCP server info cache (_apm_enabled) and have the OpenCode adapter honor it when writing opencode.json.
  • Add unit + integration tests, plus manifest-schema docs and a changelog entry for the behavior change.
File Description
src/​apm_cli/​models/​dependency/​mcp.py Adds modeled enabled field, parsing/validation, and serialization.
src/​apm_cli/​integration/​mcp_integrator.py Persists per-dependency enabled into server info cache as _apm_enabled.
src/​apm_cli/​adapters/​client/​opencode.py Applies _apm_enabled when rendering OpenCode config and adds _coerce_enabled helper.
tests/​unit/​test_mcp_from_dict_unknown_keys.py Verifies enabled is modeled (not treated as passthrough extra) and rejects non-bools.
tests/​unit/​test_mcp_overlays.py Ensures overlays embed/omit _apm_enabled correctly.
tests/​unit/​test_opencode_mcp.py Adds coverage for per-entry enabled precedence and update_config behavior.
tests/​integration/​test_mcp_install_flow.py End-to-end install test ensuring enabled is written correctly to opencode.json.
docs/​src/​content/​docs/​reference/​manifest-schema.md Documents dependencies.mcp[].enabled semantics and passthrough-reserved behavior.
CHANGELOG.md Adds a Fixed entry describing the OpenCode enabled behavior correction.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +172 to +177
@staticmethod
def _coerce_enabled(value, default: bool) -> bool:
"""Return *value* when it is a boolean, otherwise *default*."""
if isinstance(value, bool):
return value
return default
Comment on lines 47 to 53
# Harness aliases for modeled fields share the same passthrough boundary. Keeping
# them beside the manifest vocabulary lets parsing report rejected keys truthfully
# before every adapter consumes the filtered ``extra`` mapping.
# ``enabled`` is also the modeled optional boolean below. It stays in this set so
# an explicit ``extra:`` block cannot override that field.
_HARNESS_EXTRA_ALIASES = frozenset({"enabled", "environment", "http_headers", "id"})
_EXTRA_DENYLIST = _RESERVED_EXTRA_KEYS | _HARNESS_EXTRA_ALIASES
enabled: false in apm.yml was stripped as a passthrough alias and the
OpenCode adapter always wrote true. Model the flag and write it through.

Signed-off-by: Buyan Khurelbaatar <buyan-kh@users.noreply.github.com>
@cursor
cursor Bot force-pushed the cursor/opencode-enabled-false-965f branch from 9c16e4e to 5d1475a Compare September 21, 2026 23:13
@cursor
cursor Bot deleted the cursor/opencode-enabled-false-965f branch September 21, 2026 23:13
@cursor
cursor Bot restored the cursor/opencode-enabled-false-965f branch September 21, 2026 23:14
@microsoft-github-policy-service

Copy link
Copy Markdown

Buyan Khurelbaatar (@buyan-kh) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"
Contributor License Agreement

Contribution License Agreement

This Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
and conveys certain license rights to Microsoft Corporation and its affiliates (“Microsoft”) for Your
contributions to Microsoft open source projects. This Agreement is effective as of the latest signature
date below.

  1. Definitions.
    “Code” means the computer software code, whether in human-readable or machine-executable form,
    that is delivered by You to Microsoft under this Agreement.
    “Project” means any of the projects owned or managed by Microsoft and offered under a license
    approved by the Open Source Initiative (www.opensource.org).
    “Submit” is the act of uploading, submitting, transmitting, or distributing code or other content to any
    Project, including but not limited to communication on electronic mailing lists, source code control
    systems, and issue tracking systems that are managed by, or on behalf of, the Project for the purpose of
    discussing and improving that Project, but excluding communication that is conspicuously marked or
    otherwise designated in writing by You as “Not a Submission.”
    “Submission” means the Code and any other copyrightable material Submitted by You, including any
    associated comments and documentation.
  2. Your Submission. You must agree to the terms of this Agreement before making a Submission to any
    Project. This Agreement covers any and all Submissions that You, now or in the future (except as
    described in Section 4 below), Submit to any Project.
  3. Originality of Work. You represent that each of Your Submissions is entirely Your original work.
    Should You wish to Submit materials that are not Your original work, You may Submit them separately
    to the Project if You (a) retain all copyright and license information that was in the materials as You
    received them, (b) in the description accompanying Your Submission, include the phrase “Submission
    containing materials of a third party:” followed by the names of the third party and any licenses or other
    restrictions of which You are aware, and (c) follow any other instructions in the Project’s written
    guidelines concerning Submissions.
  4. Your Employer. References to “employer” in this Agreement include Your employer or anyone else
    for whom You are acting in making Your Submission, e.g. as a contractor, vendor, or agent. If Your
    Submission is made in the course of Your work for an employer or Your employer has intellectual
    property rights in Your Submission by contract or applicable law, You must secure permission from Your
    employer to make the Submission before signing this Agreement. In that case, the term “You” in this
    Agreement will refer to You and the employer collectively. If You change employers in the future and
    desire to Submit additional Submissions for the new employer, then You agree to sign a new Agreement
    and secure permission from the new employer before Submitting those Submissions.
  5. Licenses.
  • Copyright License. You grant Microsoft, and those who receive the Submission directly or
    indirectly from Microsoft, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license in the
    Submission to reproduce, prepare derivative works of, publicly display, publicly perform, and distribute
    the Submission and such derivative works, and to sublicense any or all of the foregoing rights to third
    parties.
  • Patent License. You grant Microsoft, and those who receive the Submission directly or
    indirectly from Microsoft, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license under
    Your patent claims that are necessarily infringed by the Submission or the combination of the
    Submission with the Project to which it was Submitted to make, have made, use, offer to sell, sell and
    import or otherwise dispose of the Submission alone or with the Project.
  • Other Rights Reserved. Each party reserves all rights not expressly granted in this Agreement.
    No additional licenses or rights whatsoever (including, without limitation, any implied licenses) are
    granted by implication, exhaustion, estoppel or otherwise.
  1. Representations and Warranties. You represent that You are legally entitled to grant the above
    licenses. You represent that each of Your Submissions is entirely Your original work (except as You may
    have disclosed under Section 3). You represent that You have secured permission from Your employer to
    make the Submission in cases where Your Submission is made in the course of Your work for Your
    employer or Your employer has intellectual property rights in Your Submission by contract or applicable
    law. If You are signing this Agreement on behalf of Your employer, You represent and warrant that You
    have the necessary authority to bind the listed employer to the obligations contained in this Agreement.
    You are not expected to provide support for Your Submission, unless You choose to do so. UNLESS
    REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, AND EXCEPT FOR THE WARRANTIES
    EXPRESSLY STATED IN SECTIONS 3, 4, AND 6, THE SUBMISSION PROVIDED UNDER THIS AGREEMENT IS
    PROVIDED WITHOUT WARRANTY OF ANY KIND, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY OF
    NONINFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
  2. Notice to Microsoft. You agree to notify Microsoft in writing of any facts or circumstances of which
    You later become aware that would make Your representations in this Agreement inaccurate in any
    respect.
  3. Information about Submissions. You agree that contributions to Projects and information about
    contributions may be maintained indefinitely and disclosed publicly, including Your name and other
    information that You submit with Your Submission.
  4. Governing Law/Jurisdiction. This Agreement is governed by the laws of the State of Washington, and
    the parties consent to exclusive jurisdiction and venue in the federal courts sitting in King County,
    Washington, unless no federal subject matter jurisdiction exists, in which case the parties consent to
    exclusive jurisdiction and venue in the Superior Court of King County, Washington. The parties waive all
    defenses of lack of personal jurisdiction and forum non-conveniens.
  5. Entire Agreement/Assignment. This Agreement is the entire agreement between the parties, and
    supersedes any and all prior agreements, understandings or communications, written or oral, between
    the parties relating to the subject matter hereof. This Agreement may be assigned by Microsoft.

This branch has not been deployed

No deployments
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.

2 participants