Skip to content

Browsing directories in the workspace picker or /cd starts a location runtime and its MCP servers for every directory listed #46826

Closed

Description

@heimoshuiyu

Description

Every location-scoped fs endpoint runs through LocationMiddleware, so the
first read against a directory constructs the full location runtime
(config discovery, plugins, watchers) and starts one process set per MCP
server in that directory's config chain. Directory navigation uses those
endpoints.

Measured: opening the workspace picker on a directory with 68 subdirectories,
each inheriting two local MCP servers from the parent config, spawned 68
runtimes and 136 MCP processes (~21 GB RSS). Runtimes persist until the
location-activity sweep.

Plugins

None required; GET /api/fs/list?location[directory]=<abs> reproduces it on
its own.

OpenCode version

v2, local build from d57e210 (2026-09-02)

Steps to reproduce

  1. Put a local MCP server in ~/workspace/.opencode/opencode.json.

  2. In the TUI, type /cd ~/workspace/. Listing workspace's children
    materializes a runtime for ~/workspace itself and starts its MCP
    processes.

  3. Type deeper: /cd ~/workspace/<subdir>/. That subdirectory gets its own
    runtime and a second set of the same MCP processes. Each deeper level the
    path reaches adds another.

  4. The app picker does the same in bulk: opening it on ~/workspace creates
    one runtime and MCP process set per subdirectory immediately.

Screenshot and/or share link

Process table from the measured run can be attached if useful.

Operating System

Ubuntu 24.04 (Linux server)

Terminal

n/a (app + HTTP API)

Activity

  1. github-actions commented on Sep 2, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    • core: cached locations multiply MCP subprocesses #37844: Same root cause — each acquired Location eagerly starts its full MCP subprocess set, leading to multiplied processes and excessive RSS. That issue tracks the general case (multiple Locations open across TUIs); this issue surfaces the same problem specifically through directory navigation/browsing.
    • Web/Desktop directory picker persists every subdirectory of $HOME as a project (v2) #46679: Same trigger path — the directory picker issues GET /api/fs/list calls that pass through LocationMiddleware, booting a Location per directory. That issue focuses on the side-effect of persisting directories as projects; this issue focuses on the MCP process explosion from the same underlying mechanism.

    If these cover the same problem, it may be worth consolidating. If this issue captures a distinct aspect (e.g. the fs/list endpoint specifically, or the /cd command path), please clarify so it can be tracked separately.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions