Skip to content

[FEATURE] Support stdio MCP servers in inline dependency declarations #122

Closed

Description

Is your feature request related to a problem? Please describe.

Inline MCP dependency declarations in apm.yml currently only support HTTP-based servers (type http/sse) that use a url field. There is no support for stdio type MCP servers that use command, args, and env fields.

This means packages cannot declare dependencies on tools like @playwright/mcp or @azure/mcp which run as local subprocesses via stdio transport. The _install_inline_mcp_deps() function in cli.py requires a url field and skips any entry missing it, making stdio entries silently ignored.

Describe the solution you'd like

  1. apm.yml format: Support an additional inline MCP shape for stdio servers:

    dependencies:
      mcp:
        - name: microsoft-playwright
          type: stdio
          command: npx
          args: ["@playwright/mcp@latest"]
          env: {}
  2. _install_inline_mcp_deps(): Branch on type — if stdio, build {"type": "stdio", "command": ..., "args": ..., "env": ...} instead of requiring url. Only validate command is present (not url).

  3. Writers (_write_inline_mcp_vscode, _write_inline_mcp_copilot): Already type-agnostic — they write the server_config dict as-is. No changes needed.

  4. Deduplication: _deduplicate_mcp_deps() already deduplicates dicts by name — no changes needed.

  5. Tests: Add test cases for stdio parsing, config writing, and dedup alongside existing HTTP tests.

Describe alternatives you've considered

  • Registry-only approach: Users declare stdio MCP servers via registry strings (e.g. npx @playwright/mcp@latest), but this doesn't support custom args or env configuration and conflates the registry model with local execution.
  • Separate stdio section: A new dependencies.mcp_stdio key, but this fragments the MCP config and complicates transitive collection.

Additional context

The change is small — primarily a type check branch in _install_inline_mcp_deps() (~10 lines). The downstream writers and dedup logic are already generic enough to handle it. Related to the transitive MCP dependencies feature on branch feat/transitive-mcp-dependencies.

Example use case: distributing a skill-playwright package that declares Playwright MCP as a stdio dependency, automatically configured across all consuming projects.

Activity

  1. added
    needs-triage
    on Mar 2, 2026
  2. danielmeppiel commented on Mar 2, 2026

    @danielmeppiel
    Collaborator

    Thanks for the suggestion and for thinking through the alternatives!

    I'm closing this as won't-fix after researching the MCP ecosystem in depth. Here's why:

    The MCP Registry already supports stdio servers natively.

    The MCP Registry (v0.1 API, schema frozen since Oct 2025) models stdio servers with full metadata: transport.type: "stdio", runtimeHint (npx/uvx/docker), runtimeArguments, environmentVariables, and package identifiers. For example, io.github.mleoca/ucn is a stdio server registered with its npm package and transport type.

    Regarding the "registry-only approach" alternative you considered — the registry schema does support custom args and env configuration. It models what a server expects (which env vars, which args, transport type). What it doesn't provide is project-specific values (your actual API_KEY, your --workspace ./src). That's a config overlay concern — but it's a fundamentally different feature from what this issue proposes.

    What this means for APM:

    1. APM's current bug ([BUG] MCP dependencies from transitive packages are not propagated to the consumer project #121) is real — transitive MCP deps declared as registry strings are silently dropped. That needs to be fixed first.
    2. Once [BUG] MCP dependencies from transitive packages are not propagated to the consumer project #121 is fixed, APM will resolve MCP server names → registry → full config (including stdio) automatically. No inline format needed.
    3. Inline dict declarations ({name: ..., command: ..., args: [...]}) would duplicate what the registry already provides, create a parallel config format to maintain, and bypass the registry's versioning/validation.

    If a future need arises for project-specific overrides on top of registry metadata (env var values, arg overrides), that would be a separate, cleaner feature — not inline server definitions replacing registry lookups.

    APM's position: Stay registry-first. The registry is the source of truth for server metadata. The investment goes into deeper registry integration rather than inventing a parallel inline format.

  3. lirantal commented on Apr 20, 2026

    @lirantal

    Daniel Meppiel (@danielmeppiel) would like to re-visit this with a question - from your statement of:

    APM's position: Stay registry-first.

    Does it mean that I can't just declare an ad-hoc MCP server and must count on the MCP server being published to the registry?

    Meaning, given that an MCP server is a one-off project on GitHub that I'd then install in my AI agent through something like:

    {
      "mcpServers": {
        "nodejs-api-docs": {
          "command": "npx",
          "args": ["-y", "mcp-server-nodejs-api-docs"]
        }
      }
    }
    

    Is there no existing way to declare that for apm currently?

  4. lirantal commented on Apr 20, 2026

    @lirantal

    Oh the above was confusing because the following apm.yaml seems to work just fine....

      mcp:
        - name: nodejs-api-docs
          registry: false
          transport: stdio
          command: "npx mcp-server-nodejs-api-docs"

    I feel like we need a good docs section covering this kind of config Daniel Meppiel (@danielmeppiel) because I couldn't find it

    also, is it possible to somehow use the apm CLI to end up with that config or does an MCP server setup like this require manual edit to the yaml config?

  5. danielmeppiel commented on Apr 21, 2026

    @danielmeppiel
    Collaborator

    Reopening this -- the original close was technically right (the feature exists) but the framing was misleading and missed three real DX gaps your conversation surfaced. Thanks for pushing on it, Liran Tal (@lirantal).

    Yes, this works today -- here is the canonical snippet

    # apm.yml
    dependencies:
      mcp:
        - name: nodejs-api-docs
          registry: false
          transport: stdio
          command: npx
          args: ["-y", "mcp-server-nodejs-api-docs"]

    Run apm install and APM writes the entry to .vscode/mcp.json / .cursor/mcp.json / etc. for the targets you have configured.

    Two things to note:

    • registry: false opts out of the registry resolution, which is what you want for a self-defined server.
    • command is the binary, args is the list. Do not put the whole shell line in command: -- APM does not split on whitespace. (We are about to make that mistake loud rather than silent -- see issue 1 below.)

    Three issues filed off this conversation

    This is what was actually missing -- not capability, but discoverability, ergonomics, and validation:

    1. feat(validation): warn or error on shell-string command in MCP stdio entries #806 -- feat(validation): warn or error on shell-string command in MCP stdio entries. Today command: "npx mcp-server-foo" is silently accepted; we will surface it at parse time with a fix-it message.
    2. feat(cli): extend 'apm install --mcp' for declarative MCP server addition #807 -- feat(cli): extend 'apm install --mcp' for declarative MCP server addition. So you can do apm install --mcp nodejs-api-docs -- npx -y mcp-server-nodejs-api-docs instead of hand-editing apm.yml. Mirrors npm install semantics.
    3. docs: consolidate MCP coverage into a single canonical guide #808 -- docs: consolidate MCP coverage into a single canonical guide. Right now MCP coverage is spread across 24 doc pages with the declaration syntax duplicated three times and no dedicated MCP Servers guide -- which is the structural reason you bounced. We will add guides/mcp-servers.md with a "Quick start: add a one-off MCP server" section right at the top (this snippet, basically) and shrink the duplicates.

    I am sequencing them validation -> CLI -> docs so the new guide can reference shipped behavior, not "coming soon" placeholders.

    To answer your original question directly

    Are MCP servers required to be in the registry?

    No. Set registry: false and provide transport + command/args (or url for http/sse/streamable-http). This will be much easier to find once #808 ships -- and once #807 ships you will not need to touch apm.yml at all for the common case.

  6. danielmeppiel commented on Apr 21, 2026

    @danielmeppiel
    Collaborator

    W3 (CLI gap) shipped: PR #810

    apm install --mcp NAME ... is now the canonical way to add an MCP server declaratively. The lirantal use case from this thread:

    apm install --mcp fetch -- npx -y @modelcontextprotocol/server-fetch

    Mirrors how packages already work. Also accessible as apm mcp install for discoverability.

    Roadmap status:

    Cc Liran Tal (@lirantal) — your feedback drove the whole tranche. Both PRs are independently mergeable.

  7. danielmeppiel commented on Apr 21, 2026

    @danielmeppiel
    Collaborator

    Roadmap update — final tranche shipped (W2 in review).

    Following the panel + doc-architect plan, three workstreams shipped from your original confusion report:

    # What PR
    W4 Validator warns on shell-string command in MCP stdio entries #809
    W3 apm install --mcp <id> -- <argv...> declarative add (mirrors npm install) #810
    W2 New consolidated docs/guides/mcp-servers.md + drift fixes #811 (draft, depends on #810)

    W2 leads with the exact stdio shape you brought to the original report, so future visitors land on a one-line answer instead of scrolling Copilot/IDE primers. The won't-fix close on this issue stands -- no capability gap -- but the discoverability gap your feedback exposed is now closed end-to-end.

    Thanks again for the signal.

  8. danielmeppiel commented on Apr 21, 2026

    @danielmeppiel
    Collaborator

    Update: W2 (docs) folded into W3 PR #810. Single PR now ships both the apm install --mcp code and the consolidated MCP guide that documents it. Roadmap stands; #811 closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions