Skip to content

feat(mcp): per-dependency targets scoping for dependencies.mcp entries #2606

Description

@lkshrk

Problem

Global MCP installs have exactly one reconciliation domain: every apm install -g --only mcp reconciles the whole MCP surface across every target it has previously touched. --target is per-invocation only, so:

  • Sequential per-target invocations delete each other's servers (pass 1 --target claude with server A, pass 2 --target codex with server B → A is removed as stale).
  • Per-server-per-agent scoping is inexpressible at global scope. A fleet where server X should reach only Claude Code and server Y only Codex cannot be modeled — a union-target invocation deploys every server (including auth headers) to every target.

Verified on apm-cli 0.28.0.

Current behavior

The documented per-dependency targets field works for package (apm:) dependencies, but on dependencies.mcp entries the key is not part of the model — it is swept into the harness-specific extra passthrough (with an unknown-key warning) and flattened verbatim into the deployed config (e.g. it appears as a bogus targets property inside the ~/.claude.json server object), with no scoping effect.

Request

Honor targets: on dependencies.mcp entries with the same semantics as package dependencies: effective reach = install targets ∩ per-dependency targets, omitted = all install targets, and reconciliation/stale-pruning computed per target from the intersection rather than the whole surface.

Related

Context: building fleet tooling that generates ~/.apm/apm.yml per host from a shared config; per-agent MCP scoping is currently the one thing forcing servers to stay outside APM.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/mcp-configMCP server configuration depth, transports, variable resolution.area/mcp-trustTransitive MCP trust prompts, consent contract, transport security.priority/highShips in current or next milestonestatus/triagedInitial agentic triage complete; pending maintainer ratification (silence = approval).theme/governanceGoverned by policy. apm-policy, audit, enforcement, enterprise rollout.theme/securitySecure by default. Content scanning, lockfile integrity, MCP trust boundaries.type/featureNew capability, new flag, new primitive.

    Type

    No type

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions