Skip to content

cli: mcp/plugin/debug subcommands reject --standalone and spawn a detached service #53878

Closed

Description

@Starefossen

mcp list/auth/logout, plugin list/inventory and debug agents/config do not take --standalone/--server. They always start opencode serve --service (ppid 1), which keeps running after the command exits.

Version: 2.0.24, macOS arm64

Repro (temp HOME/XDG):

  1. echo '{"port":47391,"password":"pw"}' > $XDG_CONFIG_HOME/opencode/service.json
  2. opencode mcp list --standalone → prints usage
  3. opencode mcp list → a detached serve --service now listens on :47391

Expected: the commands accept --standalone/--server like run and session do. Actual: the flag is rejected and a background service is left running.

Source: packages/cli/src/commands/handlers/mcp/list.ts:12 (and the other handlers) call ServerConnection.resolve() without args.

Fix: add ...ServerParams to these specs and pass the args to resolve(args).

Activity

  1. opencode-agent commented on Oct 8, 2026

    @opencode-agent
    Contributor

    Thanks for the clear report. I reproduced this on 2.0.24 (on Linux):

    • opencode mcp list --standalone prints usage with Unrecognized flag: --standalone in command opencode mcp list. mcp auth, mcp logout, plugin list, debug agents and debug config reject it the same way. opencode session list --standalone accepts it.
    • With a service.json pinning port 47391, a plain opencode mcp list leaves a detached opencode serve --service (ppid 1) listening on :47391 after the command exits.

    On the latest v2 commit (93afa91) the flag is still rejected, and these handlers still call ServerConnection.resolve() with no arguments, as you pointed out.

  2. argszero commented on Oct 9, 2026

    @argszero
    Contributor

    I'd like to work on this.

    Confirmed the mechanism on v2. These subcommands resolve their server through ServerConnection.resolve() with no arguments:

    • packages/cli/src/commands/handlers/mcp/list.ts:12, mcp/auth.ts:24, mcp/logout.ts:15
    • packages/cli/src/commands/handlers/plugin/list.ts:19
    • packages/cli/src/commands/handlers/debug/agents.ts:12, debug/config.ts:13

    and their specs in packages/cli/src/commands/commands.ts declare no params, so --standalone / --server are rejected as unrecognized flags and every run falls through to the managed service — starting a detached opencode serve --service that outlives the command. The commands that already work (auth, models, reload, session …) declare ...ServerParams and pass the parsed values into resolve.

    Planned fix:

    • add ...ServerParams to the affected subcommand specs (mcp list/auth/logout, plugin list, debug agents/config), matching how auth and models do it;
    • thread the flags into resolve({ server: Option.getOrUndefined(input.server), standalone: input.standalone }) in each handler;
    • check whether plugin check / plugin update need the same treatment, since they reach the same argument-less resolve() through inspect() in plugin/inventory.ts:19 (that helper is also called by the updater, which has its own service context, so I'll only change the command paths);
    • add a CLI test asserting the flags are accepted and reach resolve.

    Scope stays on these commands; I won't touch the subcommands that already forward the flags.

  3. argszero commented on Oct 9, 2026

    @argszero
    Contributor

    Opened #54166 with the fix.

    All eight commands now declare the shared ...ServerParams and thread
    { server: Option.getOrUndefined(input.server), standalone: input.standalone } into
    ServerConnection.resolve, matching what auth …, models, reload and session … already do:

    • mcp list, mcp auth, mcp logout, plugin list, plugin check, plugin update,
      debug agents, debug config
    • plugin/inventory.ts's inspect() is shared by plugin check and plugin update, so it now takes (args, selected?) and forwards the args; services/updater.ts does not call it, so nothing outside the command surface moved.

    Verified with a new packages/cli/test/server-params.test.ts: a --help case over all eight paths asserting both flags are advertised, and a functional case driving mcp list --server <url> against a local Bun.serve that asserts exit 0, /api/mcp reached, and no service-local.json written. On the unmodified tree that case fails with the reported Unrecognized flag: --server in command opencode mcp list; it passes with the change. The ten neighbouring CLI suites are 65 pass / 0 fail, tsgo -b --force is clean and oxlint reports nothing.

  4. szafranski commented on Oct 20, 2026

    @szafranski

    On macOS with @opencode/cli 2.1.1, opencode plugin check --help and opencode plugin update --help still offer neither --standalone nor --server as flags.

    My use case is a maintenance script that runs plugin check <package> followed by plugin update <package>. I rarely use OpenCode otherwise, so I would like to update plugins without leaving a shared service running.

    #54166 appears to cover this. @argszero, I saw your note about closing it because of the open PR limit. Could it be reopened for review?

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions